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
tradej/pykickstart-old
tests/commands/zerombr.py
1
1629
# # Martin Gracik <mgracik@redhat.com> # # Copyright 2009 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU # General Public License v.2. This program is distributed in the hope that it # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the # implied warranties 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. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated # with the express permission of Red Hat, Inc. # import unittest from tests.baseclass import * class FC3_TestCase(CommandTest): command = "zerombr" def runTest(self): # pass self.assert_parse("zerombr", "zerombr\n") # ignoring arguments self.assert_parse("zerombr arg", "zerombr\n") class F9_TestCase(FC3_TestCase): command = "zerombr" def runTest(self): # pass self.assert_parse("zerombr", "zerombr\n") # fail # zerombr does not take any arguments self.assert_parse_error("zerombr arg", KickstartParseError) self.assert_parse_error("zerombr --bad-flag", KickstartParseError) if __name__ == "__main__": unittest.main()
gpl-2.0
[ 3, 199, 3, 603, 26788, 10268, 559, 75, 665, 77, 926, 559, 75, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 1898, 8937, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 2811, 12, 199, 3, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 314, 1664, 199, 3, 1696, 1684, 844, 373, 14, 18, 14, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 199, 3, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 199, 3, 2478, 3712, 1417, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 199, 3, 21032, 10375, 626, 787, 30147, 972, 315, 314, 1350, 1233, 503, 3794, 787, 440, 199, 3, 5420, 370, 314, 1664, 1696, 1684, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 199, 3, 543, 314, 4056, 4983, 402, 9572, 13002, 12, 3277, 14, 199, 3, 199, 199, 646, 2882, 199, 504, 2295, 14, 1095, 533, 492, 627, 199, 199, 533, 20934, 19, 63, 1746, 8, 3110, 774, 304, 272, 1414, 275, 298, 2282, 676, 3289, 2, 339, 347, 29779, 8, 277, 304, 267, 327, 986, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 401, 298, 2282, 676, 3289, 60, 78, 531, 267, 327, 17289, 2368, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 1680, 401, 298, 2282, 676, 3289, 60, 78, 531, 199, 199, 533, 481, 25, 63, 1746, 8, 4161, 19, 63, 1746, 304, 272, 1414, 275, 298, 2282, 676, 3289, 2, 339, 347, 29779, 8, 277, 304, 267, 327, 986, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 401, 298, 2282, 676, 3289, 60, 78, 531, 398, 327, 2449, 267, 327, 8043, 676, 3289, 1630, 440, 5452, 1263, 2368, 267, 291, 14, 479, 63, 1122, 63, 705, 480, 2282, 676, 3289, 1680, 401, 1804, 18938, 9123, 9, 267, 291, 14, 479, 63, 1122, 63, 705, 480, 2282, 676, 3289, 1553, 4087, 13, 4173, 401, 1804, 18938, 9123, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 603, 26788, 10268, 559, 75, 665, 77, 926, 559, 75, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 1898, 8937, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 2811, 12, 199, 3, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 314, 1664, 199, 3, 1696, 1684, 844, 373, 14, 18, 14, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 199, 3, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 199, 3, 2478, 3712, 1417, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 199, 3, 21032, 10375, 626, 787, 30147, 972, 315, 314, 1350, 1233, 503, 3794, 787, 440, 199, 3, 5420, 370, 314, 1664, 1696, 1684, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 199, 3, 543, 314, 4056, 4983, 402, 9572, 13002, 12, 3277, 14, 199, 3, 199, 199, 646, 2882, 199, 504, 2295, 14, 1095, 533, 492, 627, 199, 199, 533, 20934, 19, 63, 1746, 8, 3110, 774, 304, 272, 1414, 275, 298, 2282, 676, 3289, 2, 339, 347, 29779, 8, 277, 304, 267, 327, 986, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 401, 298, 2282, 676, 3289, 60, 78, 531, 267, 327, 17289, 2368, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 1680, 401, 298, 2282, 676, 3289, 60, 78, 531, 199, 199, 533, 481, 25, 63, 1746, 8, 4161, 19, 63, 1746, 304, 272, 1414, 275, 298, 2282, 676, 3289, 2, 339, 347, 29779, 8, 277, 304, 267, 327, 986, 267, 291, 14, 479, 63, 1122, 480, 2282, 676, 3289, 401, 298, 2282, 676, 3289, 60, 78, 531, 398, 327, 2449, 267, 327, 8043, 676, 3289, 1630, 440, 5452, 1263, 2368, 267, 291, 14, 479, 63, 1122, 63, 705, 480, 2282, 676, 3289, 1680, 401, 1804, 18938, 9123, 9, 267, 291, 14, 479, 63, 1122, 63, 705, 480, 2282, 676, 3289, 1553, 4087, 13, 4173, 401, 1804, 18938, 9123, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
stevenmizuno/QGIS
python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
5
5674
# -*- coding: utf-8 -*- """ *************************************************************************** SagaAlgorithmProvider.py --------------------- Date : August 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'August 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' import os from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtCore import QCoreApplication from qgis.core import (Qgis, QgsProcessingProvider, QgsProcessingUtils, QgsApplication, QgsMessageLog) from processing.core.ProcessingConfig import ProcessingConfig, Setting from processing.tools.system import isWindows, isMac from .SagaAlgorithm import SagaAlgorithm from .SplitRGBBands import SplitRGBBands from . import SagaUtils pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) class SagaAlgorithmProvider(QgsProcessingProvider): def __init__(self): super().__init__() self.algs = [] def load(self): ProcessingConfig.settingIcons[self.name()] = self.icon() ProcessingConfig.addSetting(Setting("SAGA", 'ACTIVATE_SAGA', self.tr('Activate'), True)) ProcessingConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION, self.tr('Enable SAGA Import/Export optimizations'), False)) ProcessingConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_LOG_COMMANDS, self.tr('Log execution commands'), True)) ProcessingConfig.addSetting(Setting("SAGA", SagaUtils.SAGA_LOG_CONSOLE, self.tr('Log console output'), True)) ProcessingConfig.readSettings() self.refreshAlgorithms() return True def unload(self): ProcessingConfig.removeSetting('ACTIVATE_SAGA') ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE) ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS) def isActive(self): return ProcessingConfig.getSetting('ACTIVATE_SAGA') def setActive(self, active): ProcessingConfig.setSettingValue('ACTIVATE_SAGA', active) def loadAlgorithms(self): version = SagaUtils.getInstalledVersion(True) if version is None: QgsMessageLog.logMessage(self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'), self.tr('Processing'), Qgis.Critical) return if not version.startswith('2.3.'): QgsMessageLog.logMessage(self.tr('Problem with SAGA installation: unsupported SAGA version found.'), self.tr('Processing'), Qgis.Critical) return self.algs = [] folder = SagaUtils.sagaDescriptionPath() for descriptionFile in os.listdir(folder): if descriptionFile.endswith('txt'): try: alg = SagaAlgorithm(os.path.join(folder, descriptionFile)) if alg.name().strip() != '': self.algs.append(alg) else: QgsMessageLog.logMessage(self.tr('Could not open SAGA algorithm: {}'.format(descriptionFile)), self.tr('Processing'), Qgis.Critical) except Exception as e: QgsMessageLog.logMessage(self.tr('Could not open SAGA algorithm: {}\n{}'.format(descriptionFile, str(e))), self.tr('Processing'), Qgis.Critical) self.algs.append(SplitRGBBands()) for a in self.algs: self.addAlgorithm(a) def name(self): return 'SAGA' def longName(self): version = SagaUtils.getInstalledVersion() return 'SAGA ({})'.format(version) if version is not None else 'SAGA' def id(self): return 'saga' def defaultVectorFileExtension(self, hasGeometry=True): return 'shp' def defaultRasterFileExtension(self): return 'sdat' def supportedOutputTableExtensions(self): return ['dbf'] def supportsNonFileBasedOutput(self): """ SAGA Provider doesn't support non file based outputs """ return False def icon(self): return QgsApplication.getThemeIcon("/providerSaga.svg") def tr(self, string, context=''): if context == '': context = 'SagaAlgorithmProvider' return QCoreApplication.translate(context, string)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 428, 643, 65, 11570, 6663, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 747, 199, 504, 15640, 14, 24107, 14, 10604, 492, 1413, 8954, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 29263, 199, 504, 15640, 14, 1018, 492, 334, 49, 5668, 12, 2432, 17214, 6663, 12, 2432, 17214, 7535, 12, 2432, 4888, 5039, 12, 2432, 4888, 2209, 2445, 9, 199, 504, 6661, 14, 1018, 14, 9589, 2028, 492, 20157, 2028, 12, 13510, 199, 504, 6661, 14, 2537, 14, 2253, 492, 365, 8647, 12, 365, 3399, 199, 199, 504, 1275, 51, 643, 65, 11570, 492, 428, 643, 65, 11570, 199, 504, 1275, 8862, 14058, 5342, 5915, 492, 11740, 14058, 5342, 5915, 199, 504, 1275, 492, 428, 643, 65, 7535, 199, 199, 2718, 2042, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 272, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 59, 16, 467, 747, 14, 21386, 430, 421, 199, 533, 428, 643, 65, 11570, 6663, 8, 28559, 6663, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 11027, 826, 4533, 267, 291, 14, 31128, 275, 942, 339, 347, 2248, 8, 277, 304, 267, 20157, 2028, 14, 6031, 41, 8704, 59, 277, 14, 354, 5106, 275, 291, 14, 4677, 342, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 283, 20425, 1951, 63, 51, 1254, 33, 297, 4490, 291, 14, 454, 360, 30120, 659, 715, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 17576, 63, 18341, 63, 5123, 1469, 22800, 12, 4490, 291, 14, 454, 360, 6476, 428, 1254, 33, 3161, 15, 11399, 5323, 12270, 659, 756, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 28442, 12, 4490, 291, 14, 454, 360, 2445, 6451, 3718, 659, 715, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 31774, 12, 4490, 291, 14, 454, 360, 2445, 8559, 1072, 659, 715, 430, 267, 20157, 2028, 14, 739, 5268, 342, 267, 291, 14, 6635, 2439, 12719, 342, 267, 372, 715, 339, 347, 625, 912, 8, 277, 304, 267, 20157, 2028, 14, 2168, 7776, 360, 20425, 1951, 63, 51, 1254, 33, 358, 267, 20157, 2028, 14, 2168, 7776, 8, 51, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 31774, 9, 267, 20157, 2028, 14, 2168, 7776, 8, 51, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 28442, 9, 339, 347, 365, 7472, 8, 277, 304, 267, 372, 20157, 2028, 14, 30008, 360, 20425, 1951, 63, 51, 1254, 33, 358, 339, 347, 663, 7472, 8, 277, 12, 4702, 304, 267, 20157, 2028, 14, 409, 7776, 1110, 360, 20425, 1951, 63, 51, 1254, 33, 297, 4702, 9, 339, 347, 2248, 2439, 12719, 8, 277, 304, 267, 1015, 275, 428, 643, 65, 7535, 14, 362, 21268, 3353, 8, 549, 9, 267, 340, 1015, 365, 488, 26, 288, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 16467, 543, 428, 1254, 33, 12096, 26, 428, 1254, 33, 1990, 440, 1911, 503, 365, 440, 6657, 4903, 659, 3660, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 288, 372, 398, 340, 440, 1015, 14, 2460, 360, 18, 14, 19, 30194, 288, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 16467, 543, 428, 1254, 33, 12096, 26, 16313, 428, 1254, 33, 1015, 1911, 8038, 3660, 291, 14, 454, 360, 9589, 659, 3660, 1413, 5668, 14, 27677, 9, 288, 372, 398, 291, 14, 31128, 275, 942, 267, 4922, 275, 428, 643, 65, 7535, 14, 83, 643, 65, 5831, 2042, 342, 267, 367, 1369, 1173, 315, 747, 14, 7374, 8, 3741, 304, 288, 340, 1369, 1173, 14, 4130, 360, 2424, 735, 355, 862, 26, 490, 15760, 275, 428, 643, 65, 11570, 8, 736, 14, 515, 14, 904, 8, 3741, 12, 1369, 1173, 430, 490, 340, 15760, 14, 354, 1252, 1913, 342, 1137, 8061, 717, 291, 14, 31128, 14, 740, 8, 6731, 9, 490, 587, 26, 717, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 6531, 440, 1551, 428, 1254, 33, 5563, 26, 9499, 908, 8, 1802, 1173, 1826, 1740, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 355, 871, 2186, 465, 325, 26, 490, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 6531, 440, 1551, 428, 1254, 33, 5563, 26, 22902, 78, 11123, 908, 8, 1802, 1173, 12, 620, 8, 69, 11508, 6163, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 398, 291, 14, 31128, 14, 740, 8, 8862, 14058, 5342, 5915, 1012, 267, 367, 282, 315, 291, 14, 31128, 26, 288, 291, 14, 525, 11570, 8, 65, 9, 339, 347, 536, 8, 277, 304, 267, 372, 283, 51, 1254 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 428, 643, 65, 11570, 6663, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 747, 199, 504, 15640, 14, 24107, 14, 10604, 492, 1413, 8954, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 29263, 199, 504, 15640, 14, 1018, 492, 334, 49, 5668, 12, 2432, 17214, 6663, 12, 2432, 17214, 7535, 12, 2432, 4888, 5039, 12, 2432, 4888, 2209, 2445, 9, 199, 504, 6661, 14, 1018, 14, 9589, 2028, 492, 20157, 2028, 12, 13510, 199, 504, 6661, 14, 2537, 14, 2253, 492, 365, 8647, 12, 365, 3399, 199, 199, 504, 1275, 51, 643, 65, 11570, 492, 428, 643, 65, 11570, 199, 504, 1275, 8862, 14058, 5342, 5915, 492, 11740, 14058, 5342, 5915, 199, 504, 1275, 492, 428, 643, 65, 7535, 199, 199, 2718, 2042, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 272, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 59, 16, 467, 747, 14, 21386, 430, 421, 199, 533, 428, 643, 65, 11570, 6663, 8, 28559, 6663, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 11027, 826, 4533, 267, 291, 14, 31128, 275, 942, 339, 347, 2248, 8, 277, 304, 267, 20157, 2028, 14, 6031, 41, 8704, 59, 277, 14, 354, 5106, 275, 291, 14, 4677, 342, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 283, 20425, 1951, 63, 51, 1254, 33, 297, 4490, 291, 14, 454, 360, 30120, 659, 715, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 17576, 63, 18341, 63, 5123, 1469, 22800, 12, 4490, 291, 14, 454, 360, 6476, 428, 1254, 33, 3161, 15, 11399, 5323, 12270, 659, 756, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 28442, 12, 4490, 291, 14, 454, 360, 2445, 6451, 3718, 659, 715, 430, 267, 20157, 2028, 14, 525, 7776, 8, 7776, 480, 51, 1254, 33, 401, 4490, 428, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 31774, 12, 4490, 291, 14, 454, 360, 2445, 8559, 1072, 659, 715, 430, 267, 20157, 2028, 14, 739, 5268, 342, 267, 291, 14, 6635, 2439, 12719, 342, 267, 372, 715, 339, 347, 625, 912, 8, 277, 304, 267, 20157, 2028, 14, 2168, 7776, 360, 20425, 1951, 63, 51, 1254, 33, 358, 267, 20157, 2028, 14, 2168, 7776, 8, 51, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 31774, 9, 267, 20157, 2028, 14, 2168, 7776, 8, 51, 643, 65, 7535, 14, 51, 1254, 33, 63, 4947, 63, 28442, 9, 339, 347, 365, 7472, 8, 277, 304, 267, 372, 20157, 2028, 14, 30008, 360, 20425, 1951, 63, 51, 1254, 33, 358, 339, 347, 663, 7472, 8, 277, 12, 4702, 304, 267, 20157, 2028, 14, 409, 7776, 1110, 360, 20425, 1951, 63, 51, 1254, 33, 297, 4702, 9, 339, 347, 2248, 2439, 12719, 8, 277, 304, 267, 1015, 275, 428, 643, 65, 7535, 14, 362, 21268, 3353, 8, 549, 9, 267, 340, 1015, 365, 488, 26, 288, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 16467, 543, 428, 1254, 33, 12096, 26, 428, 1254, 33, 1990, 440, 1911, 503, 365, 440, 6657, 4903, 659, 3660, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 288, 372, 398, 340, 440, 1015, 14, 2460, 360, 18, 14, 19, 30194, 288, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 16467, 543, 428, 1254, 33, 12096, 26, 16313, 428, 1254, 33, 1015, 1911, 8038, 3660, 291, 14, 454, 360, 9589, 659, 3660, 1413, 5668, 14, 27677, 9, 288, 372, 398, 291, 14, 31128, 275, 942, 267, 4922, 275, 428, 643, 65, 7535, 14, 83, 643, 65, 5831, 2042, 342, 267, 367, 1369, 1173, 315, 747, 14, 7374, 8, 3741, 304, 288, 340, 1369, 1173, 14, 4130, 360, 2424, 735, 355, 862, 26, 490, 15760, 275, 428, 643, 65, 11570, 8, 736, 14, 515, 14, 904, 8, 3741, 12, 1369, 1173, 430, 490, 340, 15760, 14, 354, 1252, 1913, 342, 1137, 8061, 717, 291, 14, 31128, 14, 740, 8, 6731, 9, 490, 587, 26, 717, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 6531, 440, 1551, 428, 1254, 33, 5563, 26, 9499, 908, 8, 1802, 1173, 1826, 1740, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 355, 871, 2186, 465, 325, 26, 490, 4888, 2209, 2445, 14, 793, 2209, 8, 277, 14, 454, 360, 6531, 440, 1551, 428, 1254, 33, 5563, 26, 22902, 78, 11123, 908, 8, 1802, 1173, 12, 620, 8, 69, 11508, 6163, 291, 14, 454, 360, 9589, 659, 1413, 5668, 14, 27677, 9, 398, 291, 14, 31128, 14, 740, 8, 8862, 14058, 5342, 5915, 1012, 267, 367, 282, 315, 291, 14, 31128, 26, 288, 291, 14, 525, 11570, 8, 65, 9, 339, 347, 536, 8, 277, 304, 267, 372, 283, 51, 1254, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
FEniCS/dolfin
demo/undocumented/adaptive-poisson/python/demo_adaptive-poisson.py
1
2889
"""This demo program solves Poisson's equation - div grad u(x, y) = f(x, y) on the unit square with source f given by f(x, y) = exp(-100(x^2 + y^2)) and homogeneous Dirichlet boundary conditions. Note that we use a simplified error indicator, ignoring edge (jump) terms and the size of the interpolation constant. """ # Copyright (C) 2008 Rolv Erlend Bredesen # # This file is part of DOLFIN. # # DOLFIN 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. # # DOLFIN 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 DOLFIN. If not, see <http://www.gnu.org/licenses/>. # # Modified by Anders Logg 2008-2011 from __future__ import print_function from dolfin import * from numpy import array, sqrt from math import pow from six.moves import xrange as range TOL = 5e-4 # Error tolerance REFINE_RATIO = 0.50 # Refine 50 % of the cells in each iteration MAX_ITER = 20 # Maximal number of iterations # Create initial mesh mesh = UnitSquareMesh(4, 4) source_str = "exp(-100.0*(pow(x[0], 2) + pow(x[1], 2)))" source = eval("lambda x: " + source_str) # Adaptive algorithm for level in range(MAX_ITER): # Define variational problem V = FunctionSpace(mesh, "CG", 1) v = TestFunction(V) u = TrialFunction(V) f = Expression(source_str, degree=2) a = dot(grad(v), grad(u))*dx L = v*f*dx # Define boundary condition u0 = Constant(0.0) bc = DirichletBC(V, u0, DomainBoundary()) # Compute solution u = Function(V) solve(a == L, u, bc) # Compute error indicators h = array([c.h() for c in cells(mesh)]) K = array([c.volume() for c in cells(mesh)]) R = array([abs(source([c.midpoint().x(), c.midpoint().y()])) for c in cells(mesh)]) gamma = h*R*sqrt(K) # Compute error estimate E = sum([g*g for g in gamma]) E = sqrt(MPI.sum(mesh.mpi_comm(), E)) print("Level %d: E = %g (TOL = %g)" % (level, E, TOL)) # Check convergence if E < TOL: info("Success, solution converged after %d iterations" % level) break # Mark cells for refinement cell_markers = MeshFunction("bool", mesh, mesh.topology().dim()) gamma_0 = sorted(gamma, reverse=True)[int(len(gamma)*REFINE_RATIO)] gamma_0 = MPI.max(mesh.mpi_comm(), gamma_0) for c in cells(mesh): cell_markers[c] = gamma[c.index()] > gamma_0 # Refine mesh mesh = refine(mesh, cell_markers) # Plot mesh plot(mesh)
lgpl-3.0
[ 624, 2765, 14779, 2240, 8597, 2310, 4376, 18571, 1159, 18649, 339, 446, 9073, 7659, 399, 8, 88, 12, 612, 9, 275, 289, 8, 88, 12, 612, 9, 199, 199, 265, 314, 4137, 12386, 543, 1350, 289, 1627, 701, 339, 289, 8, 88, 12, 612, 9, 275, 1437, 2801, 1960, 8, 88, 62, 18, 435, 612, 62, 18, 430, 199, 199, 460, 2636, 23748, 3757, 19683, 8424, 3704, 14, 199, 199, 7443, 626, 781, 675, 282, 26867, 1125, 16385, 12, 17289, 199, 5173, 334, 11126, 9, 2895, 436, 314, 1568, 402, 314, 14046, 4413, 14, 199, 624, 199, 199, 3, 1898, 334, 35, 9, 9079, 820, 393, 86, 221, 539, 12944, 699, 21919, 2464, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28701, 17383, 14, 199, 3, 199, 3, 28701, 17383, 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, 28701, 17383, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 28701, 17383, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 22016, 701, 1626, 7735, 5297, 71, 9079, 13, 8128, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 886, 276, 262, 492, 627, 199, 504, 2680, 492, 1625, 12, 7452, 199, 504, 3473, 492, 13131, 199, 504, 3816, 14, 4912, 492, 4945, 465, 1425, 199, 199, 52, 2228, 275, 959, 69, 13, 20, 3698, 327, 4520, 13464, 199, 8279, 3565, 63, 26566, 275, 378, 14, 1400, 221, 327, 15397, 1132, 5238, 450, 402, 314, 10106, 315, 1924, 8494, 199, 4283, 63, 11084, 275, 3388, 263, 327, 8228, 7265, 1329, 402, 10615, 199, 199, 3, 2790, 2536, 9364, 199, 6480, 275, 12008, 23373, 12241, 8, 20, 12, 841, 9, 199, 1365, 63, 495, 275, 298, 1474, 2801, 1960, 14, 16, 5830, 8278, 8, 88, 59, 16, 467, 499, 9, 435, 13131, 8, 88, 59, 17, 467, 499, 1724, 2, 199, 1365, 275, 3468, 480, 2734, 671, 26, 298, 435, 1350, 63, 495, 9, 199, 199, 3, 4431, 22430, 5563, 199, 509, 2166, 315, 1425, 8, 4283, 63, 11084, 304, 339, 327, 13930, 4172, 6279, 5160, 272, 812, 275, 6801, 7643, 8, 6480, 12, 298, 4064, 401, 413, 9, 272, 373, 275, 1379, 3481, 8, 54, 9, 272, 399, 275, 377, 1383, 3481, 8, 54, 9, 272, 289, 275, 22013, 8, 1365, 63, 495, 12, 13666, 29, 18, 9, 272, 282, 275, 6308, 8, 6017, 8, 86, 395, 7659, 8, 85, 19198, 8373, 272, 491, 275, 373, 10, 70, 10, 8373, 339, 327, 13930, 8424, 5558, 272, 399, 16, 275, 19991, 8, 16, 14, 16, 9, 272, 16604, 275, 3757, 19683, 6265, 8, 54, 12, 399, 16, 12, 14061, 19831, 1012, 339, 327, 8354, 8744, 272, 399, 275, 6801, 8, 54, 9, 272, 14241, 8, 65, 508, 491, 12, 399, 12, 16604, 9, 339, 327, 8354, 1125, 7262, 2750, 272, 394, 275, 1625, 779, 67, 14, 72, 342, 367, 286, 315, 10106, 8, 6480, 3948, 272, 1804, 275, 1625, 779, 67, 14, 2405, 342, 367, 286, 315, 10106, 8, 6480, 3948, 272, 820, 275, 1625, 779, 2101, 8, 1365, 779, 67, 14, 8523, 1403, 1252, 88, 1062, 286, 14, 8523, 1403, 1252, 89, 342, 2459, 367, 286, 315, 10106, 8, 6480, 3948, 272, 10169, 275, 394, 10, 50, 10, 5079, 8, 43, 9, 339, 327, 8354, 1125, 14497, 272, 662, 275, 3089, 779, 71, 10, 71, 367, 486, 315, 10169, 566, 272, 662, 275, 7452, 8, 28983, 14, 1838, 8, 6480, 14, 13213, 63, 1404, 1062, 662, 430, 272, 870, 480, 4670, 450, 68, 26, 662, 275, 450, 71, 334, 52, 2228, 275, 450, 71, 2924, 450, 334, 1896, 12, 662, 12, 377, 2228, 430, 339, 327, 2670, 21346, 272, 340, 662, 665, 377, 2228, 26, 267, 2256, 480, 8300, 12, 8744, 3818, 3046, 2410, 450, 68, 10615, 2, 450, 2166, 9, 267, 2059, 339, 327, 7173, 10106, 367, 2984, 1132, 434, 272, 4917, 63, 16835, 275, 603, 10613, 3481, 480, 2245, 401, 9364, 12, 9364, 14, 10775, 1252, 3572, 1012, 272, 10169, 63, 16, 275, 3355, 8, 7325, 12, 3837, 29, 549, 2788, 442, 8, 552, 8, 7325, 3342, 8279, 3565, 63, 26566, 1874, 272, 10169, 63, 16, 275, 26024, 14, 988, 8, 6480, 14, 13213, 63, 1404, 1062, 10169, 63, 16, 9, 272, 367, 286, 315, 10106, 8, 6480, 304, 267, 4917, 63, 16835, 59, 67, 61, 275, 10169, 59, 67, 14, 1080, 5106, 690, 10169, 63, 16, 339, 327, 15397, 1132, 9364, 272, 9364, 275, 2984, 1132, 8, 6480, 12, 4917, 63, 16835, 9, 339, 327, 14794, 9364, 272, 5137, 8, 6480, 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 ]
[ 2765, 14779, 2240, 8597, 2310, 4376, 18571, 1159, 18649, 339, 446, 9073, 7659, 399, 8, 88, 12, 612, 9, 275, 289, 8, 88, 12, 612, 9, 199, 199, 265, 314, 4137, 12386, 543, 1350, 289, 1627, 701, 339, 289, 8, 88, 12, 612, 9, 275, 1437, 2801, 1960, 8, 88, 62, 18, 435, 612, 62, 18, 430, 199, 199, 460, 2636, 23748, 3757, 19683, 8424, 3704, 14, 199, 199, 7443, 626, 781, 675, 282, 26867, 1125, 16385, 12, 17289, 199, 5173, 334, 11126, 9, 2895, 436, 314, 1568, 402, 314, 14046, 4413, 14, 199, 624, 199, 199, 3, 1898, 334, 35, 9, 9079, 820, 393, 86, 221, 539, 12944, 699, 21919, 2464, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28701, 17383, 14, 199, 3, 199, 3, 28701, 17383, 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, 28701, 17383, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 28701, 17383, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 22016, 701, 1626, 7735, 5297, 71, 9079, 13, 8128, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 886, 276, 262, 492, 627, 199, 504, 2680, 492, 1625, 12, 7452, 199, 504, 3473, 492, 13131, 199, 504, 3816, 14, 4912, 492, 4945, 465, 1425, 199, 199, 52, 2228, 275, 959, 69, 13, 20, 3698, 327, 4520, 13464, 199, 8279, 3565, 63, 26566, 275, 378, 14, 1400, 221, 327, 15397, 1132, 5238, 450, 402, 314, 10106, 315, 1924, 8494, 199, 4283, 63, 11084, 275, 3388, 263, 327, 8228, 7265, 1329, 402, 10615, 199, 199, 3, 2790, 2536, 9364, 199, 6480, 275, 12008, 23373, 12241, 8, 20, 12, 841, 9, 199, 1365, 63, 495, 275, 298, 1474, 2801, 1960, 14, 16, 5830, 8278, 8, 88, 59, 16, 467, 499, 9, 435, 13131, 8, 88, 59, 17, 467, 499, 1724, 2, 199, 1365, 275, 3468, 480, 2734, 671, 26, 298, 435, 1350, 63, 495, 9, 199, 199, 3, 4431, 22430, 5563, 199, 509, 2166, 315, 1425, 8, 4283, 63, 11084, 304, 339, 327, 13930, 4172, 6279, 5160, 272, 812, 275, 6801, 7643, 8, 6480, 12, 298, 4064, 401, 413, 9, 272, 373, 275, 1379, 3481, 8, 54, 9, 272, 399, 275, 377, 1383, 3481, 8, 54, 9, 272, 289, 275, 22013, 8, 1365, 63, 495, 12, 13666, 29, 18, 9, 272, 282, 275, 6308, 8, 6017, 8, 86, 395, 7659, 8, 85, 19198, 8373, 272, 491, 275, 373, 10, 70, 10, 8373, 339, 327, 13930, 8424, 5558, 272, 399, 16, 275, 19991, 8, 16, 14, 16, 9, 272, 16604, 275, 3757, 19683, 6265, 8, 54, 12, 399, 16, 12, 14061, 19831, 1012, 339, 327, 8354, 8744, 272, 399, 275, 6801, 8, 54, 9, 272, 14241, 8, 65, 508, 491, 12, 399, 12, 16604, 9, 339, 327, 8354, 1125, 7262, 2750, 272, 394, 275, 1625, 779, 67, 14, 72, 342, 367, 286, 315, 10106, 8, 6480, 3948, 272, 1804, 275, 1625, 779, 67, 14, 2405, 342, 367, 286, 315, 10106, 8, 6480, 3948, 272, 820, 275, 1625, 779, 2101, 8, 1365, 779, 67, 14, 8523, 1403, 1252, 88, 1062, 286, 14, 8523, 1403, 1252, 89, 342, 2459, 367, 286, 315, 10106, 8, 6480, 3948, 272, 10169, 275, 394, 10, 50, 10, 5079, 8, 43, 9, 339, 327, 8354, 1125, 14497, 272, 662, 275, 3089, 779, 71, 10, 71, 367, 486, 315, 10169, 566, 272, 662, 275, 7452, 8, 28983, 14, 1838, 8, 6480, 14, 13213, 63, 1404, 1062, 662, 430, 272, 870, 480, 4670, 450, 68, 26, 662, 275, 450, 71, 334, 52, 2228, 275, 450, 71, 2924, 450, 334, 1896, 12, 662, 12, 377, 2228, 430, 339, 327, 2670, 21346, 272, 340, 662, 665, 377, 2228, 26, 267, 2256, 480, 8300, 12, 8744, 3818, 3046, 2410, 450, 68, 10615, 2, 450, 2166, 9, 267, 2059, 339, 327, 7173, 10106, 367, 2984, 1132, 434, 272, 4917, 63, 16835, 275, 603, 10613, 3481, 480, 2245, 401, 9364, 12, 9364, 14, 10775, 1252, 3572, 1012, 272, 10169, 63, 16, 275, 3355, 8, 7325, 12, 3837, 29, 549, 2788, 442, 8, 552, 8, 7325, 3342, 8279, 3565, 63, 26566, 1874, 272, 10169, 63, 16, 275, 26024, 14, 988, 8, 6480, 14, 13213, 63, 1404, 1062, 10169, 63, 16, 9, 272, 367, 286, 315, 10106, 8, 6480, 304, 267, 4917, 63, 16835, 59, 67, 61, 275, 10169, 59, 67, 14, 1080, 5106, 690, 10169, 63, 16, 339, 327, 15397, 1132, 9364, 272, 9364, 275, 2984, 1132, 8, 6480, 12, 4917, 63, 16835, 9, 339, 327, 14794, 9364, 272, 5137, 8, 6480, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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*- # # This file is part of Invenio. # Copyright (C) 2013, 2014, 2015 CERN. # # Invenio is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. import six from invenio_records.api import Record from .models import DepositionDraft def record_to_draft(record, draft=None, form_class=None, pre_process=None, post_process=None, producer='json_for_form'): """ Load a record into a draft """ if draft is None: draft = DepositionDraft(None, form_class=form_class) draft.values = record.produce('json_for_form') if pre_process: draft = pre_process(draft) if draft.has_form(): form = draft.get_form() form.post_process() draft.update(form) # Custom post process function if post_process: draft = post_process(draft) return draft def drafts_to_record(drafts, post_process=None): """ Export recjson from drafts """ values = DepositionDraft.merge_data(drafts) if post_process: values = post_process(values) return make_record(values) def deposition_record(record, form_classes, pre_process_load=None, post_process_load=None, process_export=None): """ Generate recjson representation of a record for this given deposition. """ return drafts_to_record( [ record_to_draft( record, form_class=cls, pre_process=pre_process_load, post_process=post_process_load, ) for cls in form_classes ], post_process=process_export ) def make_record(values, is_dump=None): """ Export recjson from drafts """ if is_dump is not None: import warnings warnings.warn( "Usage of `is_dump` parameter is deprecated and has no effect.", category=UserWarning ) return Record(data=values)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 421, 199, 646, 3816, 199, 504, 13640, 63, 6502, 14, 1246, 492, 12651, 199, 199, 504, 1275, 992, 492, 1487, 3124, 18332, 421, 199, 318, 2777, 63, 475, 63, 7185, 8, 3059, 12, 11872, 29, 403, 12, 1824, 63, 533, 29, 403, 12, 876, 63, 1412, 29, 403, 12, 490, 2963, 63, 1412, 29, 403, 12, 17339, 534, 1001, 63, 509, 63, 964, 735, 272, 408, 272, 7190, 282, 2777, 1901, 282, 11872, 272, 408, 272, 340, 11872, 365, 488, 26, 267, 11872, 275, 1487, 3124, 18332, 8, 403, 12, 1824, 63, 533, 29, 964, 63, 533, 9, 339, 11872, 14, 1459, 275, 2777, 14, 7832, 360, 1001, 63, 509, 63, 964, 358, 339, 340, 876, 63, 1412, 26, 267, 11872, 275, 876, 63, 1412, 8, 7185, 9, 339, 340, 11872, 14, 1989, 63, 964, 837, 267, 1824, 275, 11872, 14, 362, 63, 964, 342, 267, 1824, 14, 1932, 63, 1412, 342, 267, 11872, 14, 873, 8, 964, 9, 339, 327, 8388, 2963, 2112, 805, 272, 340, 2963, 63, 1412, 26, 267, 11872, 275, 2963, 63, 1412, 8, 7185, 9, 339, 372, 11872, 421, 199, 318, 11872, 83, 63, 475, 63, 3059, 8, 7185, 83, 12, 2963, 63, 1412, 29, 403, 304, 272, 408, 272, 20220, 6488, 1001, 687, 11872, 83, 272, 408, 272, 1338, 275, 1487, 3124, 18332, 14, 5628, 63, 576, 8, 7185, 83, 9, 339, 340, 2963, 63, 1412, 26, 267, 1338, 275, 2963, 63, 1412, 8, 1459, 9, 339, 372, 1852, 63, 3059, 8, 1459, 9, 421, 199, 318, 477, 3124, 63, 3059, 8, 3059, 12, 1824, 63, 2888, 12, 876, 63, 1412, 63, 912, 29, 403, 12, 1993, 2963, 63, 1412, 63, 912, 29, 403, 12, 2112, 63, 3790, 29, 403, 304, 272, 408, 272, 7958, 6488, 1001, 6025, 402, 282, 2777, 367, 642, 1627, 477, 3124, 14, 272, 408, 272, 372, 11872, 83, 63, 475, 63, 3059, 8, 267, 359, 288, 2777, 63, 475, 63, 7185, 8, 355, 2777, 12, 355, 1824, 63, 533, 29, 1886, 12, 355, 876, 63, 1412, 29, 657, 63, 1412, 63, 912, 12, 355, 2963, 63, 1412, 29, 1932, 63, 1412, 63, 912, 12, 288, 776, 288, 367, 843, 315, 1824, 63, 2888, 267, 2156, 267, 2963, 63, 1412, 29, 1412, 63, 3790, 272, 776, 421, 199, 318, 1852, 63, 3059, 8, 1459, 12, 365, 63, 2724, 29, 403, 304, 272, 408, 272, 20220, 6488, 1001, 687, 11872, 83, 272, 408, 272, 340, 365, 63, 2724, 365, 440, 488, 26, 267, 492, 3598, 267, 3598, 14, 4050, 8, 288, 298, 7692, 402, 658, 374, 63, 2724, 64, 2725, 365, 5906, 436, 965, 949, 7763, 4765, 288, 4637, 29, 32114, 267, 776, 272, 372, 12651, 8, 576, 29, 1459, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 421, 199, 646, 3816, 199, 504, 13640, 63, 6502, 14, 1246, 492, 12651, 199, 199, 504, 1275, 992, 492, 1487, 3124, 18332, 421, 199, 318, 2777, 63, 475, 63, 7185, 8, 3059, 12, 11872, 29, 403, 12, 1824, 63, 533, 29, 403, 12, 876, 63, 1412, 29, 403, 12, 490, 2963, 63, 1412, 29, 403, 12, 17339, 534, 1001, 63, 509, 63, 964, 735, 272, 408, 272, 7190, 282, 2777, 1901, 282, 11872, 272, 408, 272, 340, 11872, 365, 488, 26, 267, 11872, 275, 1487, 3124, 18332, 8, 403, 12, 1824, 63, 533, 29, 964, 63, 533, 9, 339, 11872, 14, 1459, 275, 2777, 14, 7832, 360, 1001, 63, 509, 63, 964, 358, 339, 340, 876, 63, 1412, 26, 267, 11872, 275, 876, 63, 1412, 8, 7185, 9, 339, 340, 11872, 14, 1989, 63, 964, 837, 267, 1824, 275, 11872, 14, 362, 63, 964, 342, 267, 1824, 14, 1932, 63, 1412, 342, 267, 11872, 14, 873, 8, 964, 9, 339, 327, 8388, 2963, 2112, 805, 272, 340, 2963, 63, 1412, 26, 267, 11872, 275, 2963, 63, 1412, 8, 7185, 9, 339, 372, 11872, 421, 199, 318, 11872, 83, 63, 475, 63, 3059, 8, 7185, 83, 12, 2963, 63, 1412, 29, 403, 304, 272, 408, 272, 20220, 6488, 1001, 687, 11872, 83, 272, 408, 272, 1338, 275, 1487, 3124, 18332, 14, 5628, 63, 576, 8, 7185, 83, 9, 339, 340, 2963, 63, 1412, 26, 267, 1338, 275, 2963, 63, 1412, 8, 1459, 9, 339, 372, 1852, 63, 3059, 8, 1459, 9, 421, 199, 318, 477, 3124, 63, 3059, 8, 3059, 12, 1824, 63, 2888, 12, 876, 63, 1412, 63, 912, 29, 403, 12, 1993, 2963, 63, 1412, 63, 912, 29, 403, 12, 2112, 63, 3790, 29, 403, 304, 272, 408, 272, 7958, 6488, 1001, 6025, 402, 282, 2777, 367, 642, 1627, 477, 3124, 14, 272, 408, 272, 372, 11872, 83, 63, 475, 63, 3059, 8, 267, 359, 288, 2777, 63, 475, 63, 7185, 8, 355, 2777, 12, 355, 1824, 63, 533, 29, 1886, 12, 355, 876, 63, 1412, 29, 657, 63, 1412, 63, 912, 12, 355, 2963, 63, 1412, 29, 1932, 63, 1412, 63, 912, 12, 288, 776, 288, 367, 843, 315, 1824, 63, 2888, 267, 2156, 267, 2963, 63, 1412, 29, 1412, 63, 3790, 272, 776, 421, 199, 318, 1852, 63, 3059, 8, 1459, 12, 365, 63, 2724, 29, 403, 304, 272, 408, 272, 20220, 6488, 1001, 687, 11872, 83, 272, 408, 272, 340, 365, 63, 2724, 365, 440, 488, 26, 267, 492, 3598, 267, 3598, 14, 4050, 8, 288, 298, 7692, 402, 658, 374, 63, 2724, 64, 2725, 365, 5906, 436, 965, 949, 7763, 4765, 288, 4637, 29, 32114, 267, 776, 272, 372, 12651, 8, 576, 29, 1459, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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.common import InfoExtractor from ..utils import ( compat_urlparse, get_meta_content, ) class UstreamIE(InfoExtractor): _VALID_URL = r'https?://www\.ustream\.tv/recorded/(?P<videoID>\d+)' IE_NAME = 'ustream' _TEST = { 'url': 'http://www.ustream.tv/recorded/20274954', 'file': '20274954.flv', 'md5': '088f151799e8f572f84eb62f17d73e5c', 'info_dict': { "uploader": "Young Americans for Liberty", "title": "Young Americans for Liberty February 7, 2012 2:28 AM", }, } def _real_extract(self, url): m = re.match(self._VALID_URL, url) video_id = m.group('videoID') video_url = 'http://tcdn.ustream.tv/video/%s' % video_id webpage = self._download_webpage(url, video_id) self.report_extraction(video_id) video_title = self._html_search_regex(r'data-title="(?P<title>.+)"', webpage, 'title') uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>', webpage, 'uploader', fatal=False, flags=re.DOTALL) thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"', webpage, 'thumbnail', fatal=False) return { 'id': video_id, 'url': video_url, 'ext': 'flv', 'title': video_title, 'uploader': uploader, 'thumbnail': thumbnail, } class UstreamChannelIE(InfoExtractor): _VALID_URL = r'https?://www\.ustream\.tv/channel/(?P<slug>.+)' IE_NAME = 'ustream:channel' def _real_extract(self, url): m = re.match(self._VALID_URL, url) slug = m.group('slug') webpage = self._download_webpage(url, slug) channel_id = get_meta_content('ustream:channel_id', webpage) BASE = 'http://www.ustream.tv' next_url = '/ajax/socialstream/videos/%s/1.json' % channel_id video_ids = [] while next_url: reply = json.loads(self._download_webpage(compat_urlparse.urljoin(BASE, next_url), channel_id)) video_ids.extend(re.findall(r'data-content-id="(\d.*)"', reply['data'])) next_url = reply['nextUrl'] urls = ['http://www.ustream.tv/recorded/' + vid for vid in video_ids] url_entries = [self.url_result(eurl, 'Ustream') for eurl in urls] return self.playlist_result(url_entries, channel_id)
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 8434, 63, 10290, 12, 272, 664, 63, 2024, 63, 1317, 12, 199, 9, 421, 199, 533, 738, 1745, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 833, 1091, 4537, 6993, 15, 264, 15402, 9448, 48, 28, 3722, 998, 3072, 68, 29600, 272, 15292, 63, 2339, 275, 283, 833, 1091, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 15, 264, 15402, 15, 4999, 15971, 1477, 297, 267, 283, 493, 356, 283, 4999, 15971, 1477, 14, 22753, 297, 267, 283, 1064, 21, 356, 283, 27930, 70, 1046, 1196, 1020, 69, 24, 70, 17802, 70, 1349, 2871, 2789, 70, 1196, 68, 2898, 69, 21, 67, 297, 267, 283, 815, 63, 807, 356, 469, 288, 298, 13671, 582, 298, 32154, 10335, 437, 278, 1567, 796, 367, 24157, 605, 369, 401, 288, 298, 1213, 582, 298, 32154, 10335, 437, 278, 1567, 796, 367, 24157, 605, 369, 21141, 26709, 1520, 12, 6029, 499, 26, 1651, 24343, 401, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 333, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 333, 14, 923, 360, 3722, 998, 358, 398, 3991, 63, 633, 275, 283, 1014, 921, 84, 23982, 14, 833, 1091, 14, 6993, 15, 3722, 3149, 83, 7, 450, 3991, 63, 344, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 291, 14, 3070, 63, 24020, 8, 3722, 63, 344, 9, 398, 3991, 63, 1213, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 5121, 419, 13, 1213, 628, 2229, 48, 28, 1213, 31411, 32691, 288, 9248, 12, 283, 1213, 358, 398, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 5121, 419, 13, 1317, 13, 466, 628, 2775, 1674, 15279, 30, 2229, 48, 28, 13671, 27124, 15939, 65, 4206, 288, 9248, 12, 283, 13671, 297, 14294, 29, 797, 12, 3285, 29, 264, 14, 16504, 9, 398, 10062, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 7601, 1073, 4668, 628, 1569, 63, 2164, 2, 4369, 628, 2229, 48, 28, 16534, 27124, 32691, 288, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 3991, 63, 1213, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 8311, 356, 10062, 12, 267, 789, 421, 199, 533, 738, 1745, 5358, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 833, 1091, 4537, 6993, 15, 2775, 9448, 48, 28, 5464, 31411, 3171, 272, 15292, 63, 2339, 275, 283, 833, 1091, 26, 2775, 7, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 333, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 8889, 275, 333, 14, 923, 360, 5464, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 8889, 9, 267, 3623, 63, 344, 275, 664, 63, 2024, 63, 1317, 360, 833, 1091, 26, 2775, 63, 344, 297, 9248, 9, 398, 19721, 275, 283, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 7, 267, 2163, 63, 633, 275, 1994, 12774, 15, 13574, 1745, 15, 11418, 3149, 83, 15, 17, 14, 1001, 7, 450, 3623, 63, 344, 267, 3991, 63, 1580, 275, 942, 267, 1830, 2163, 63, 633, 26, 288, 9351, 275, 2022, 14, 3640, 8, 277, 423, 4249, 63, 12022, 8, 5819, 63, 10290, 14, 17755, 8, 5825, 12, 2163, 63, 633, 395, 3623, 63, 344, 430, 288, 3991, 63, 1580, 14, 2880, 8, 264, 14, 6452, 8, 82, 5121, 419, 13, 1317, 13, 344, 628, 2961, 68, 2795, 32691, 9351, 459, 576, 5156, 288, 2163, 63, 633, 275, 9351, 459, 2184, 6417, 418, 398, 8187, 275, 788, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 15, 264, 15402, 4805, 435, 27767, 367, 27767, 315, 3991, 63, 1580, 61, 267, 1166, 63, 3189, 275, 359, 277, 14, 633, 63, 1099, 8, 69, 633, 12, 283, 53, 1745, 358, 367, 325, 633, 315, 8187, 61, 267, 372, 291, 14, 10411, 63, 1099, 8, 633, 63, 3189, 12, 3623, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 8434, 63, 10290, 12, 272, 664, 63, 2024, 63, 1317, 12, 199, 9, 421, 199, 533, 738, 1745, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 833, 1091, 4537, 6993, 15, 264, 15402, 9448, 48, 28, 3722, 998, 3072, 68, 29600, 272, 15292, 63, 2339, 275, 283, 833, 1091, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 15, 264, 15402, 15, 4999, 15971, 1477, 297, 267, 283, 493, 356, 283, 4999, 15971, 1477, 14, 22753, 297, 267, 283, 1064, 21, 356, 283, 27930, 70, 1046, 1196, 1020, 69, 24, 70, 17802, 70, 1349, 2871, 2789, 70, 1196, 68, 2898, 69, 21, 67, 297, 267, 283, 815, 63, 807, 356, 469, 288, 298, 13671, 582, 298, 32154, 10335, 437, 278, 1567, 796, 367, 24157, 605, 369, 401, 288, 298, 1213, 582, 298, 32154, 10335, 437, 278, 1567, 796, 367, 24157, 605, 369, 21141, 26709, 1520, 12, 6029, 499, 26, 1651, 24343, 401, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 333, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 333, 14, 923, 360, 3722, 998, 358, 398, 3991, 63, 633, 275, 283, 1014, 921, 84, 23982, 14, 833, 1091, 14, 6993, 15, 3722, 3149, 83, 7, 450, 3991, 63, 344, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 291, 14, 3070, 63, 24020, 8, 3722, 63, 344, 9, 398, 3991, 63, 1213, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 5121, 419, 13, 1213, 628, 2229, 48, 28, 1213, 31411, 32691, 288, 9248, 12, 283, 1213, 358, 398, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 5121, 419, 13, 1317, 13, 466, 628, 2775, 1674, 15279, 30, 2229, 48, 28, 13671, 27124, 15939, 65, 4206, 288, 9248, 12, 283, 13671, 297, 14294, 29, 797, 12, 3285, 29, 264, 14, 16504, 9, 398, 10062, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 7601, 1073, 4668, 628, 1569, 63, 2164, 2, 4369, 628, 2229, 48, 28, 16534, 27124, 32691, 288, 9248, 12, 283, 8311, 297, 14294, 29, 797, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 3991, 63, 1213, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 8311, 356, 10062, 12, 267, 789, 421, 199, 533, 738, 1745, 5358, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 833, 1091, 4537, 6993, 15, 2775, 9448, 48, 28, 5464, 31411, 3171, 272, 15292, 63, 2339, 275, 283, 833, 1091, 26, 2775, 7, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 333, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 8889, 275, 333, 14, 923, 360, 5464, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 8889, 9, 267, 3623, 63, 344, 275, 664, 63, 2024, 63, 1317, 360, 833, 1091, 26, 2775, 63, 344, 297, 9248, 9, 398, 19721, 275, 283, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 7, 267, 2163, 63, 633, 275, 1994, 12774, 15, 13574, 1745, 15, 11418, 3149, 83, 15, 17, 14, 1001, 7, 450, 3623, 63, 344, 267, 3991, 63, 1580, 275, 942, 267, 1830, 2163, 63, 633, 26, 288, 9351, 275, 2022, 14, 3640, 8, 277, 423, 4249, 63, 12022, 8, 5819, 63, 10290, 14, 17755, 8, 5825, 12, 2163, 63, 633, 395, 3623, 63, 344, 430, 288, 3991, 63, 1580, 14, 2880, 8, 264, 14, 6452, 8, 82, 5121, 419, 13, 1317, 13, 344, 628, 2961, 68, 2795, 32691, 9351, 459, 576, 5156, 288, 2163, 63, 633, 275, 9351, 459, 2184, 6417, 418, 398, 8187, 275, 788, 1014, 921, 1544, 14, 833, 1091, 14, 6993, 15, 264, 15402, 4805, 435, 27767, 367, 27767, 315, 3991, 63, 1580, 61, 267, 1166, 63, 3189, 275, 359, 277, 14, 633, 63, 1099, 8, 69, 633, 12, 283, 53, 1745, 358, 367, 325, 633, 315, 8187, 61, 267, 372, 291, 14, 10411, 63, 1099, 8, 633, 63, 3189, 12, 3623, 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, 0 ]
[ 1, 1, 1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/ASM_xf
PythonD/lib/python2.4/lib-tk/tkFont.py
4
6241
# # Tkinter # $Id: tkFont.py,v 1.9 2004/08/20 06:19:23 loewis Exp $ # # font wrapper # # written by Fredrik Lundh <fredrik@pythonware.com>, February 1998 # # FIXME: should add 'displayof' option where relevant (actual, families, # measure, and metrics) # # Copyright (c) Secret Labs AB 1998. # # info@pythonware.com # http://www.pythonware.com # __version__ = "0.9" import Tkinter # weight/slant NORMAL = "normal" ROMAN = "roman" BOLD = "bold" ITALIC = "italic" def nametofont(name): """Given the name of a tk named font, returns a Font representation. """ return Font(name=name, exists=True) class Font: """Represents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. Raises _tkinter.TclError if the assertion is false. the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica size -- font size in points weight -- font thickness: NORMAL, BOLD slant -- font slant: ROMAN, ITALIC underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) """ def _set(self, kw): options = [] for k, v in kw.items(): options.append("-"+k) options.append(str(v)) return tuple(options) def _get(self, args): options = [] for k in args: options.append("-"+k) return tuple(options) def _mkdict(self, args): options = {} for i in range(0, len(args), 2): options[args[i][1:]] = args[i+1] return options def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: root = Tkinter._default_root if font: # get actual settings corresponding to the given font font = root.tk.splitlist(root.tk.call("font", "actual", font)) else: font = self._set(options) if not name: name = "font" + str(id(self)) self.name = name if exists: self.delete_font = False # confirm font exists if self.name not in root.tk.call("font", "names"): raise Tkinter._tkinter.TclError, "named font %s does not already exist" % (self.name,) # if font config info supplied, apply it if font: root.tk.call("font", "configure", self.name, *font) else: # create new font (raises TclError if the font exists) root.tk.call("font", "create", self.name, *font) self.delete_font = True # backlinks! self._root = root self._split = root.tk.splitlist self._call = root.tk.call def __str__(self): return self.name def __eq__(self, other): return self.name == other.name and isinstance(other, Font) def __getitem__(self, key): return self.cget(key) def __setitem__(self, key, value): self.configure(**{key: value}) def __del__(self): try: if self.delete_font: self._call("font", "delete", self.name) except (AttributeError, Tkinter.TclError): pass def copy(self): "Return a distinct copy of the current font" return Font(self._root, **self.actual()) def actual(self, option=None): "Return actual font attributes" if option: return self._call("font", "actual", self.name, "-"+option) else: return self._mkdict( self._split(self._call("font", "actual", self.name)) ) def cget(self, option): "Get font attribute" return self._call("font", "config", self.name, "-"+option) def config(self, **options): "Modify font attributes" if options: self._call("font", "config", self.name, *self._set(options)) else: return self._mkdict( self._split(self._call("font", "config", self.name)) ) configure = config def measure(self, text): "Return text width" return int(self._call("font", "measure", self.name, text)) def metrics(self, *options): """Return font metrics. For best performance, create a dummy widget using this font before calling this method.""" if options: return int( self._call("font", "metrics", self.name, self._get(options)) ) else: res = self._split(self._call("font", "metrics", self.name)) options = {} for i in range(0, len(res), 2): options[res[i][1:]] = int(res[i+1]) return options def families(root=None): "Get font families (as a tuple)" if not root: root = Tkinter._default_root return root.tk.splitlist(root.tk.call("font", "families")) def names(root=None): "Get names of defined fonts (as a tuple)" if not root: root = Tkinter._default_root return root.tk.splitlist(root.tk.call("font", "names")) # -------------------------------------------------------------------- # test stuff if __name__ == "__main__": root = Tkinter.Tk() # create a font f = Font(family="times", size=30, weight=NORMAL) print f.actual() print f.actual("family") print f.actual("weight") print f.config() print f.cget("family") print f.cget("weight") print names() print f.measure("hello"), f.metrics("linespace") print f.metrics() f = Font(font=("Courier", 20, "bold")) print f.measure("hello"), f.metrics("linespace") w = Tkinter.Label(root, text="Hello, world", font=f) w.pack() w = Tkinter.Button(root, text="Quit!", command=root.destroy) w.pack() fb = Font(font=w["font"]).copy() fb.config(weight=BOLD) w.config(font=fb) Tkinter.mainloop()
gpl-2.0
[ 3, 199, 3, 16826, 199, 3, 2672, 1304, 26, 10157, 6986, 14, 647, 12, 86, 413, 14, 25, 8353, 15, 2036, 15, 1165, 24293, 26, 1167, 26, 1789, 560, 546, 374, 7910, 2672, 199, 3, 199, 3, 5023, 4975, 199, 3, 199, 3, 5313, 701, 481, 581, 25844, 491, 725, 72, 665, 22980, 25844, 32, 1548, 1068, 14, 957, 6244, 21141, 26709, 19960, 199, 3, 199, 3, 7600, 26, 1077, 1050, 283, 2918, 1618, 7, 945, 2382, 12082, 334, 6514, 12, 21450, 20111, 12, 199, 3, 263, 9775, 12, 436, 7186, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 19960, 14, 199, 3, 199, 3, 2256, 32, 1548, 1068, 14, 957, 199, 3, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 199, 3, 199, 199, 363, 1023, 363, 275, 298, 16, 14, 25, 2, 199, 199, 646, 16826, 199, 199, 3, 5401, 15, 2482, 867, 199, 10765, 275, 298, 3302, 2, 199, 3810, 879, 275, 298, 20971, 2, 199, 30144, 257, 275, 298, 9771, 2, 199, 649, 748, 948, 275, 298, 21843, 2, 199, 199, 318, 536, 475, 4246, 8, 354, 304, 272, 408, 13735, 314, 536, 402, 282, 10157, 4310, 5023, 12, 2529, 282, 26159, 6025, 14, 272, 408, 272, 372, 26159, 8, 354, 29, 354, 12, 3495, 29, 549, 9, 199, 199, 533, 26159, 26, 339, 408, 18089, 282, 4310, 5023, 14, 339, 20297, 1511, 787, 26, 339, 5023, 1553, 5023, 16628, 334, 354, 12, 2656, 5023, 12, 503, 334, 6606, 12, 1568, 12, 3449, 7216, 2960, 9, 272, 536, 1553, 536, 370, 675, 367, 642, 5023, 2897, 334, 4322, 370, 282, 3747, 536, 9, 272, 3495, 1553, 1630, 282, 4310, 5023, 701, 642, 536, 2575, 2187, 31, 2126, 10560, 282, 892, 4310, 5023, 340, 756, 12, 4501, 370, 314, 3411, 5023, 340, 715, 14, 2126, 6218, 485, 12223, 14, 29175, 547, 340, 314, 14412, 365, 3055, 14, 10817, 314, 2569, 787, 5525, 340, 5023, 365, 2013, 26, 339, 9614, 1553, 5023, 283, 6606, 297, 325, 14, 71, 14, 445, 567, 4446, 12, 4703, 83, 12, 869, 25911, 272, 1568, 1553, 5023, 1568, 315, 4501, 272, 5401, 1553, 5023, 294, 17437, 26, 653, 9623, 12, 699, 5104, 272, 5340, 867, 1553, 5023, 5340, 867, 26, 9769, 6588, 12, 473, 52, 748, 948, 272, 25735, 1553, 5023, 1334, 30176, 26, 3055, 334, 16, 395, 2549, 334, 17, 9, 272, 1806, 26845, 1553, 5023, 4024, 415, 548, 26, 3055, 334, 16, 395, 2549, 334, 17, 9, 339, 408, 339, 347, 485, 409, 8, 277, 12, 4775, 304, 267, 1511, 275, 942, 267, 367, 1022, 12, 373, 315, 4775, 14, 1744, 837, 288, 1511, 14, 740, 6096, 7709, 75, 9, 288, 1511, 14, 740, 8, 495, 8, 86, 430, 267, 372, 2008, 8, 1419, 9, 339, 347, 485, 362, 8, 277, 12, 1249, 304, 267, 1511, 275, 942, 267, 367, 1022, 315, 1249, 26, 288, 1511, 14, 740, 6096, 7709, 75, 9, 267, 372, 2008, 8, 1419, 9, 339, 347, 485, 3880, 807, 8, 277, 12, 1249, 304, 267, 1511, 275, 1052, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 589, 395, 499, 304, 288, 1511, 59, 589, 59, 73, 1527, 17, 21316, 275, 1249, 59, 73, 11, 17, 61, 267, 372, 1511, 339, 347, 636, 826, 721, 277, 12, 1738, 29, 403, 12, 5023, 29, 403, 12, 536, 29, 403, 12, 3495, 29, 797, 12, 1011, 1419, 304, 267, 340, 440, 1738, 26, 288, 1738, 275, 16826, 423, 885, 63, 1231, 267, 340, 5023, 26, 288, 327, 664, 3503, 2202, 5226, 370, 314, 1627, 5023, 288, 5023, 275, 1738, 14, 2663, 14, 1294, 513, 8, 1231, 14, 2663, 14, 1250, 480, 4246, 401, 298, 6514, 401, 5023, 430, 267, 587, 26, 288, 5023, 275, 291, 423, 409, 8, 1419, 9, 267, 340, 440, 536, 26, 288, 536, 275, 298, 4246, 2, 435, 620, 8, 344, 8, 277, 430, 267, 291, 14, 354, 275, 536, 398, 340, 3495, 26, 288, 291, 14, 1807, 63, 4246, 275, 756, 288, 327, 12679, 5023, 3495, 288, 340, 291, 14, 354, 440, 315, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 1247, 2349, 355, 746, 16826, 423, 12223, 14, 29175, 547, 12, 298, 4579, 5023, 450, 83, 1630, 440, 2575, 2187, 2, 450, 334, 277, 14, 354, 4258, 288, 327, 340, 5023, 1101, 2256, 6841, 12, 4838, 652, 288, 340, 5023, 26, 355, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 6472, 401, 291, 14, 354, 12, 627, 4246, 9, 267, 587, 26, 288, 327, 1218, 892, 5023, 334, 3536, 29251, 547, 340, 314, 5023, 3495, 9, 288, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 981, 401, 291, 14, 354, 12, 627, 4246, 9, 288, 291, 14, 1807, 63, 4246, 275, 715, 267, 327, 1771, 4614, 1, 267, 291, 423, 1231, 221, 275, 1738, 267, 291, 423, 1294, 275, 1738, 14, 2663, 14, 1294, 513, 267, 291, 423, 1250, 221, 275, 1738, 14, 2663, 14, 1250, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 508, 1163, 14, 354, 436, 1228, 8, 1848, 12, 26159, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 67, 362, 8, 498, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 291, 14, 6472, 25679, 498, 26, 574, 1552, 339, 347, 636, 2264, 721, 277, 304, 267, 862, 26, 288, 340, 291, 14, 1807, 63, 4246, 26, 355, 291, 423, 1250, 480, 4246, 401, 298, 1807, 401, 291, 14, 354, 9, 267, 871, 334, 10227, 12, 16826, 14, 29175, 547, 304, 288, 986, 339, 347, 1331, 8, 277, 304, 267, 298, 1767, 282, 15392, 1331, 402, 314, 1453, 5023, 2, 267, 372, 26159, 8, 277, 423, 1231, 12, 1011, 277, 14, 6514, 1012, 339, 347, 3503, 8, 277, 12, 945, 29, 403, 304, 267, 298, 1767, 3503, 5023, 3004, 2, 267, 340, 945, 26, 288, 372, 291, 423, 1250, 480, 4246, 401, 298, 6514, 401, 291, 14, 354, 12, 3905, 7709, 1422, 9, 267, 587, 26, 288, 372, 291, 423, 3880, 807, 8, 355, 291, 423 ]
[ 199, 3, 16826, 199, 3, 2672, 1304, 26, 10157, 6986, 14, 647, 12, 86, 413, 14, 25, 8353, 15, 2036, 15, 1165, 24293, 26, 1167, 26, 1789, 560, 546, 374, 7910, 2672, 199, 3, 199, 3, 5023, 4975, 199, 3, 199, 3, 5313, 701, 481, 581, 25844, 491, 725, 72, 665, 22980, 25844, 32, 1548, 1068, 14, 957, 6244, 21141, 26709, 19960, 199, 3, 199, 3, 7600, 26, 1077, 1050, 283, 2918, 1618, 7, 945, 2382, 12082, 334, 6514, 12, 21450, 20111, 12, 199, 3, 263, 9775, 12, 436, 7186, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 19960, 14, 199, 3, 199, 3, 2256, 32, 1548, 1068, 14, 957, 199, 3, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 199, 3, 199, 199, 363, 1023, 363, 275, 298, 16, 14, 25, 2, 199, 199, 646, 16826, 199, 199, 3, 5401, 15, 2482, 867, 199, 10765, 275, 298, 3302, 2, 199, 3810, 879, 275, 298, 20971, 2, 199, 30144, 257, 275, 298, 9771, 2, 199, 649, 748, 948, 275, 298, 21843, 2, 199, 199, 318, 536, 475, 4246, 8, 354, 304, 272, 408, 13735, 314, 536, 402, 282, 10157, 4310, 5023, 12, 2529, 282, 26159, 6025, 14, 272, 408, 272, 372, 26159, 8, 354, 29, 354, 12, 3495, 29, 549, 9, 199, 199, 533, 26159, 26, 339, 408, 18089, 282, 4310, 5023, 14, 339, 20297, 1511, 787, 26, 339, 5023, 1553, 5023, 16628, 334, 354, 12, 2656, 5023, 12, 503, 334, 6606, 12, 1568, 12, 3449, 7216, 2960, 9, 272, 536, 1553, 536, 370, 675, 367, 642, 5023, 2897, 334, 4322, 370, 282, 3747, 536, 9, 272, 3495, 1553, 1630, 282, 4310, 5023, 701, 642, 536, 2575, 2187, 31, 2126, 10560, 282, 892, 4310, 5023, 340, 756, 12, 4501, 370, 314, 3411, 5023, 340, 715, 14, 2126, 6218, 485, 12223, 14, 29175, 547, 340, 314, 14412, 365, 3055, 14, 10817, 314, 2569, 787, 5525, 340, 5023, 365, 2013, 26, 339, 9614, 1553, 5023, 283, 6606, 297, 325, 14, 71, 14, 445, 567, 4446, 12, 4703, 83, 12, 869, 25911, 272, 1568, 1553, 5023, 1568, 315, 4501, 272, 5401, 1553, 5023, 294, 17437, 26, 653, 9623, 12, 699, 5104, 272, 5340, 867, 1553, 5023, 5340, 867, 26, 9769, 6588, 12, 473, 52, 748, 948, 272, 25735, 1553, 5023, 1334, 30176, 26, 3055, 334, 16, 395, 2549, 334, 17, 9, 272, 1806, 26845, 1553, 5023, 4024, 415, 548, 26, 3055, 334, 16, 395, 2549, 334, 17, 9, 339, 408, 339, 347, 485, 409, 8, 277, 12, 4775, 304, 267, 1511, 275, 942, 267, 367, 1022, 12, 373, 315, 4775, 14, 1744, 837, 288, 1511, 14, 740, 6096, 7709, 75, 9, 288, 1511, 14, 740, 8, 495, 8, 86, 430, 267, 372, 2008, 8, 1419, 9, 339, 347, 485, 362, 8, 277, 12, 1249, 304, 267, 1511, 275, 942, 267, 367, 1022, 315, 1249, 26, 288, 1511, 14, 740, 6096, 7709, 75, 9, 267, 372, 2008, 8, 1419, 9, 339, 347, 485, 3880, 807, 8, 277, 12, 1249, 304, 267, 1511, 275, 1052, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 589, 395, 499, 304, 288, 1511, 59, 589, 59, 73, 1527, 17, 21316, 275, 1249, 59, 73, 11, 17, 61, 267, 372, 1511, 339, 347, 636, 826, 721, 277, 12, 1738, 29, 403, 12, 5023, 29, 403, 12, 536, 29, 403, 12, 3495, 29, 797, 12, 1011, 1419, 304, 267, 340, 440, 1738, 26, 288, 1738, 275, 16826, 423, 885, 63, 1231, 267, 340, 5023, 26, 288, 327, 664, 3503, 2202, 5226, 370, 314, 1627, 5023, 288, 5023, 275, 1738, 14, 2663, 14, 1294, 513, 8, 1231, 14, 2663, 14, 1250, 480, 4246, 401, 298, 6514, 401, 5023, 430, 267, 587, 26, 288, 5023, 275, 291, 423, 409, 8, 1419, 9, 267, 340, 440, 536, 26, 288, 536, 275, 298, 4246, 2, 435, 620, 8, 344, 8, 277, 430, 267, 291, 14, 354, 275, 536, 398, 340, 3495, 26, 288, 291, 14, 1807, 63, 4246, 275, 756, 288, 327, 12679, 5023, 3495, 288, 340, 291, 14, 354, 440, 315, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 1247, 2349, 355, 746, 16826, 423, 12223, 14, 29175, 547, 12, 298, 4579, 5023, 450, 83, 1630, 440, 2575, 2187, 2, 450, 334, 277, 14, 354, 4258, 288, 327, 340, 5023, 1101, 2256, 6841, 12, 4838, 652, 288, 340, 5023, 26, 355, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 6472, 401, 291, 14, 354, 12, 627, 4246, 9, 267, 587, 26, 288, 327, 1218, 892, 5023, 334, 3536, 29251, 547, 340, 314, 5023, 3495, 9, 288, 1738, 14, 2663, 14, 1250, 480, 4246, 401, 298, 981, 401, 291, 14, 354, 12, 627, 4246, 9, 288, 291, 14, 1807, 63, 4246, 275, 715, 267, 327, 1771, 4614, 1, 267, 291, 423, 1231, 221, 275, 1738, 267, 291, 423, 1294, 275, 1738, 14, 2663, 14, 1294, 513, 267, 291, 423, 1250, 221, 275, 1738, 14, 2663, 14, 1250, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 508, 1163, 14, 354, 436, 1228, 8, 1848, 12, 26159, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 67, 362, 8, 498, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 291, 14, 6472, 25679, 498, 26, 574, 1552, 339, 347, 636, 2264, 721, 277, 304, 267, 862, 26, 288, 340, 291, 14, 1807, 63, 4246, 26, 355, 291, 423, 1250, 480, 4246, 401, 298, 1807, 401, 291, 14, 354, 9, 267, 871, 334, 10227, 12, 16826, 14, 29175, 547, 304, 288, 986, 339, 347, 1331, 8, 277, 304, 267, 298, 1767, 282, 15392, 1331, 402, 314, 1453, 5023, 2, 267, 372, 26159, 8, 277, 423, 1231, 12, 1011, 277, 14, 6514, 1012, 339, 347, 3503, 8, 277, 12, 945, 29, 403, 304, 267, 298, 1767, 3503, 5023, 3004, 2, 267, 340, 945, 26, 288, 372, 291, 423, 1250, 480, 4246, 401, 298, 6514, 401, 291, 14, 354, 12, 3905, 7709, 1422, 9, 267, 587, 26, 288, 372, 291, 423, 3880, 807, 8, 355, 291, 423, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
CubicERP/geraldo
site/newsite/django_1_0/django/core/management/validation.py
9
12200
import sys from django.core.management.color import color_style from django.utils.itercompat import is_iterable class ModelErrorCollection: def __init__(self, outfile=sys.stdout): self.errors = [] self.outfile = outfile self.style = color_style() def add(self, context, error): self.errors.append((context, error)) self.outfile.write(self.style.ERROR("%s: %s\n" % (context, error))) def get_validation_errors(outfile, app=None): """ Validates all models that are part of the specified app. If no app name is provided, validates all models of all installed apps. Writes errors, if any, to outfile. Returns number of errors. """ from django.conf import settings from django.db import models, connection from django.db.models.loading import get_app_errors from django.db.models.fields.related import RelatedObject e = ModelErrorCollection(outfile) for (app_name, error) in get_app_errors().items(): e.add(app_name, error) for cls in models.get_models(app): opts = cls._meta # Do field-specific validation. for f in opts.local_fields: if f.name == 'id' and not f.primary_key and opts.pk.name == 'id': e.add(opts, '"%s": You can\'t use "id" as a field name, because each model automatically gets an "id" field if none of the fields have primary_key=True. You need to either remove/rename your "id" field or add primary_key=True to a field.' % f.name) if f.name.endswith('_'): e.add(opts, '"%s": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name) if isinstance(f, models.CharField) and f.max_length in (None, 0): e.add(opts, '"%s": CharFields require a "max_length" attribute.' % f.name) if isinstance(f, models.DecimalField): if f.decimal_places is None: e.add(opts, '"%s": DecimalFields require a "decimal_places" attribute.' % f.name) if f.max_digits is None: e.add(opts, '"%s": DecimalFields require a "max_digits" attribute.' % f.name) if isinstance(f, models.FileField) and not f.upload_to: e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name) if isinstance(f, models.ImageField): try: from PIL import Image except ImportError: e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name) if f.choices: if isinstance(f.choices, basestring) or not is_iterable(f.choices): e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name) else: for c in f.choices: if not type(c) in (tuple, list) or len(c) != 2: e.add(opts, '"%s": "choices" should be a sequence of two-tuples.' % f.name) if f.db_index not in (None, True, False): e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name) # Check that max_length <= 255 if using older MySQL versions. if settings.DATABASE_ENGINE == 'mysql': db_version = connection.get_server_version() if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.max_length > 255: e.add(opts, '"%s": %s cannot have a "max_length" greater than 255 when you are using a version of MySQL prior to 5.0.3 (you are using %s).' % (f.name, f.__class__.__name__, '.'.join([str(n) for n in db_version[:3]]))) # Check to see if the related field will clash with any existing # fields, m2m fields, m2m related objects or related objects if f.rel: if f.rel.to not in models.get_models(): e.add(opts, "'%s' has relation with model %s, which has not been installed" % (f.name, f.rel.to)) # it is a string and we could not find the model it refers to # so skip the next section if isinstance(f.rel.to, (str, unicode)): continue rel_opts = f.rel.to._meta rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() rel_query_name = f.related_query_name() for r in rel_opts.fields: if r.name == rel_name: e.add(opts, "Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.local_many_to_many: if r.name == rel_name: e.add(opts, "Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.get_all_related_many_to_many_objects(): if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) for r in rel_opts.get_all_related_objects(): if r.field is not f: if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) for i, f in enumerate(opts.local_many_to_many): # Check to see if the related m2m field will clash with any # existing fields, m2m fields, m2m related objects or related # objects if f.rel.to not in models.get_models(): e.add(opts, "'%s' has m2m relation with model %s, which has not been installed" % (f.name, f.rel.to)) # it is a string and we could not find the model it refers to # so skip the next section if isinstance(f.rel.to, (str, unicode)): continue rel_opts = f.rel.to._meta rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() rel_query_name = f.related_query_name() # If rel_name is none, there is no reverse accessor (this only # occurs for symmetrical m2m relations to self). If this is the # case, there are no clashes to check for this field, as there are # no reverse descriptors for this field. if rel_name is not None: for r in rel_opts.fields: if r.name == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.local_many_to_many: if r.name == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.get_all_related_many_to_many_objects(): if r.field is not f: if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) for r in rel_opts.get_all_related_objects(): if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) # Check ordering attribute. if opts.ordering: for field_name in opts.ordering: if field_name == '?': continue if field_name.startswith('-'): field_name = field_name[1:] if opts.order_with_respect_to and field_name == '_order': continue # Skip ordering in the format field1__field2 (FIXME: checking # this format would be nice, but it's a little fiddly). if '_' in field_name: continue try: opts.get_field(field_name, many_to_many=False) except models.FieldDoesNotExist: e.add(opts, '"ordering" refers to "%s", a field that doesn\'t exist.' % field_name) # Check unique_together. for ut in opts.unique_together: for field_name in ut: try: f = opts.get_field(field_name, many_to_many=True) except models.FieldDoesNotExist: e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name) else: if isinstance(f.rel, models.ManyToManyRel): e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name) if f not in opts.local_fields: e.add(opts, '"unique_together" refers to %s. This is not in the same model as the unique_together statement.' % f.name) return len(e.errors)
lgpl-3.0
[ 646, 984, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 3164, 63, 2487, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 199, 533, 5822, 547, 7768, 26, 272, 347, 636, 826, 721, 277, 12, 4386, 29, 1274, 14, 2703, 304, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 4984, 275, 4386, 267, 291, 14, 2487, 275, 3164, 63, 2487, 342, 339, 347, 1050, 8, 277, 12, 1067, 12, 1125, 304, 267, 291, 14, 2550, 14, 740, 1332, 1100, 12, 1125, 430, 267, 291, 14, 4984, 14, 952, 8, 277, 14, 2487, 14, 3170, 3647, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1100, 12, 1125, 1724, 199, 199, 318, 664, 63, 6136, 63, 2550, 8, 4984, 12, 1145, 29, 403, 304, 272, 408, 272, 4821, 2335, 1006, 1709, 626, 787, 1777, 402, 314, 2013, 1145, 14, 982, 949, 1145, 536, 365, 2741, 12, 272, 29280, 1006, 1709, 402, 1006, 4903, 8686, 14, 30753, 2552, 12, 340, 1263, 12, 370, 4386, 14, 272, 1803, 1329, 402, 2552, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 1639, 14, 697, 492, 1709, 12, 1950, 272, 687, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 571, 63, 2550, 272, 687, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 492, 20116, 1692, 339, 325, 275, 5822, 547, 7768, 8, 4984, 9, 339, 367, 334, 571, 63, 354, 12, 1125, 9, 315, 664, 63, 571, 63, 2550, 1252, 1744, 837, 267, 325, 14, 525, 8, 571, 63, 354, 12, 1125, 9, 339, 367, 843, 315, 1709, 14, 362, 63, 992, 8, 571, 304, 267, 3999, 275, 843, 423, 2024, 398, 327, 4226, 901, 13, 6100, 6411, 14, 267, 367, 289, 315, 3999, 14, 1832, 63, 955, 26, 288, 340, 289, 14, 354, 508, 283, 344, 7, 436, 440, 289, 14, 3327, 63, 498, 436, 3999, 14, 2051, 14, 354, 508, 283, 344, 356, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 2047, 883, 3985, 84, 675, 298, 344, 2, 465, 282, 901, 536, 12, 2952, 1924, 1402, 5847, 7545, 376, 298, 344, 2, 901, 340, 7179, 402, 314, 1504, 1172, 5062, 63, 498, 29, 549, 14, 2047, 1929, 370, 1902, 2813, 15, 8165, 2195, 298, 344, 2, 901, 503, 1050, 5062, 63, 498, 29, 549, 370, 282, 901, 3530, 450, 289, 14, 354, 9, 288, 340, 289, 14, 354, 14, 4130, 30018, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 5024, 1561, 3913, 1284, 543, 23998, 12, 2952, 642, 3955, 12690, 370, 26711, 7594, 4766, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 2183, 9, 436, 289, 14, 988, 63, 1267, 315, 334, 403, 12, 378, 304, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6659, 7304, 4409, 282, 298, 988, 63, 1267, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 15975, 304, 355, 340, 289, 14, 6355, 63, 10696, 365, 488, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6345, 7304, 4409, 282, 298, 6355, 63, 10696, 2, 2225, 3530, 450, 289, 14, 354, 9, 355, 340, 289, 14, 988, 63, 7022, 365, 488, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6345, 7304, 4409, 282, 298, 988, 63, 7022, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 23252, 9, 436, 440, 289, 14, 5064, 63, 475, 26, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 3814, 7304, 4409, 376, 298, 5064, 63, 475, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 21910, 304, 355, 862, 26, 490, 687, 14937, 492, 6047, 355, 871, 3545, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 4005, 675, 6047, 7304, 12, 1265, 1929, 370, 3907, 314, 2018, 473, 391, 1540, 11243, 14, 2372, 652, 737, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 15, 13336, 15, 80, 382, 15, 1275, 7, 450, 289, 14, 354, 9, 288, 340, 289, 14, 4577, 26, 355, 340, 1228, 8, 70, 14, 4577, 12, 7116, 9, 503, 440, 365, 63, 8147, 8, 70, 14, 4577, 304, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 4577, 2, 1077, 506, 6076, 334, 69, 14, 71, 2020, 282, 2008, 503, 769, 28823, 450, 289, 14, 354, 9, 355, 587, 26, 490, 367, 286, 315, 289, 14, 4577, 26, 717, 340, 440, 730, 8, 67, 9, 315, 334, 2960, 12, 769, 9, 503, 822, 8, 67, 9, 1137, 499, 26, 1169, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 4577, 2, 1077, 506, 282, 3414, 402, 2877, 13, 11760, 3530, 450, 289, 14, 354, 9, 288, 340, 289, 14, 697, 63, 1080, 440, 315, 334, 403, 12, 715, 12, 756, 304, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 697, 63, 1080, 2, 1077, 506, 1902, 488, 12, 715, 503, 756, 3530, 450, 289, 14, 354, 9, 953, 327, 2670, 626, 1390, 63, 1267, 2695, 5450, 340, 1808, 12731, 11200, 5459, 14, 288, 340, 2202, 14, 17873, 63, 15956, 508, 283, 8644, 356, 355, 1592, 63, 1023, 275, 1950, 14, 362, 63, 1000, 63, 1023, 342, 355, 340, 1592, 63, 1023, 665, 334, 21, 12, 378, 12, 650, 9, 436, 1228, 8, 70, 12, 334, 992, 14, 2183, 12, 1709, 14, 25732, 20727, 3901, 12, 1709, 14, 17315, 430, 436, 289, 14, 988, 63, 1267, 690, 5450, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 450, 83, 3913, 1172, 282, 298, 988, 63, 1267, 2, 8932, 2419, 5450, 1380, 1265, 787, 1808, 282, 1015, 402, 11200, 6791, 370, 959, 14, 16, 14, 19, 334, 13297, 787, 1808, 450, 83, 28823, 450, 334, 70, 14, 354, 12, 289, 855, 533, 4914, 354, 3108, 15671, 904, 779, 495, 8, 78, 9, 367, 302, 315, 1592, 63, 1023, 1491, 19, 2677, 1724, 953, 327, 2670, 370, 1937, 340, 314, 4048, 901, 911, 30109, 543, 1263, 3411, 288, 327, 1504, 12, 333, 18, 77, 1504, 12, 333, 18, 77, 4048 ]
[ 984, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 3164, 63, 2487, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 199, 533, 5822, 547, 7768, 26, 272, 347, 636, 826, 721, 277, 12, 4386, 29, 1274, 14, 2703, 304, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 4984, 275, 4386, 267, 291, 14, 2487, 275, 3164, 63, 2487, 342, 339, 347, 1050, 8, 277, 12, 1067, 12, 1125, 304, 267, 291, 14, 2550, 14, 740, 1332, 1100, 12, 1125, 430, 267, 291, 14, 4984, 14, 952, 8, 277, 14, 2487, 14, 3170, 3647, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1100, 12, 1125, 1724, 199, 199, 318, 664, 63, 6136, 63, 2550, 8, 4984, 12, 1145, 29, 403, 304, 272, 408, 272, 4821, 2335, 1006, 1709, 626, 787, 1777, 402, 314, 2013, 1145, 14, 982, 949, 1145, 536, 365, 2741, 12, 272, 29280, 1006, 1709, 402, 1006, 4903, 8686, 14, 30753, 2552, 12, 340, 1263, 12, 370, 4386, 14, 272, 1803, 1329, 402, 2552, 14, 272, 408, 272, 687, 1639, 14, 2190, 492, 2202, 272, 687, 1639, 14, 697, 492, 1709, 12, 1950, 272, 687, 1639, 14, 697, 14, 992, 14, 8786, 492, 664, 63, 571, 63, 2550, 272, 687, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 492, 20116, 1692, 339, 325, 275, 5822, 547, 7768, 8, 4984, 9, 339, 367, 334, 571, 63, 354, 12, 1125, 9, 315, 664, 63, 571, 63, 2550, 1252, 1744, 837, 267, 325, 14, 525, 8, 571, 63, 354, 12, 1125, 9, 339, 367, 843, 315, 1709, 14, 362, 63, 992, 8, 571, 304, 267, 3999, 275, 843, 423, 2024, 398, 327, 4226, 901, 13, 6100, 6411, 14, 267, 367, 289, 315, 3999, 14, 1832, 63, 955, 26, 288, 340, 289, 14, 354, 508, 283, 344, 7, 436, 440, 289, 14, 3327, 63, 498, 436, 3999, 14, 2051, 14, 354, 508, 283, 344, 356, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 2047, 883, 3985, 84, 675, 298, 344, 2, 465, 282, 901, 536, 12, 2952, 1924, 1402, 5847, 7545, 376, 298, 344, 2, 901, 340, 7179, 402, 314, 1504, 1172, 5062, 63, 498, 29, 549, 14, 2047, 1929, 370, 1902, 2813, 15, 8165, 2195, 298, 344, 2, 901, 503, 1050, 5062, 63, 498, 29, 549, 370, 282, 901, 3530, 450, 289, 14, 354, 9, 288, 340, 289, 14, 354, 14, 4130, 30018, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 5024, 1561, 3913, 1284, 543, 23998, 12, 2952, 642, 3955, 12690, 370, 26711, 7594, 4766, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 2183, 9, 436, 289, 14, 988, 63, 1267, 315, 334, 403, 12, 378, 304, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6659, 7304, 4409, 282, 298, 988, 63, 1267, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 15975, 304, 355, 340, 289, 14, 6355, 63, 10696, 365, 488, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6345, 7304, 4409, 282, 298, 6355, 63, 10696, 2, 2225, 3530, 450, 289, 14, 354, 9, 355, 340, 289, 14, 988, 63, 7022, 365, 488, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 6345, 7304, 4409, 282, 298, 988, 63, 7022, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 23252, 9, 436, 440, 289, 14, 5064, 63, 475, 26, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 3814, 7304, 4409, 376, 298, 5064, 63, 475, 2, 2225, 3530, 450, 289, 14, 354, 9, 288, 340, 1228, 8, 70, 12, 1709, 14, 21910, 304, 355, 862, 26, 490, 687, 14937, 492, 6047, 355, 871, 3545, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 4005, 675, 6047, 7304, 12, 1265, 1929, 370, 3907, 314, 2018, 473, 391, 1540, 11243, 14, 2372, 652, 737, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 15, 13336, 15, 80, 382, 15, 1275, 7, 450, 289, 14, 354, 9, 288, 340, 289, 14, 4577, 26, 355, 340, 1228, 8, 70, 14, 4577, 12, 7116, 9, 503, 440, 365, 63, 8147, 8, 70, 14, 4577, 304, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 4577, 2, 1077, 506, 6076, 334, 69, 14, 71, 2020, 282, 2008, 503, 769, 28823, 450, 289, 14, 354, 9, 355, 587, 26, 490, 367, 286, 315, 289, 14, 4577, 26, 717, 340, 440, 730, 8, 67, 9, 315, 334, 2960, 12, 769, 9, 503, 822, 8, 67, 9, 1137, 499, 26, 1169, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 4577, 2, 1077, 506, 282, 3414, 402, 2877, 13, 11760, 3530, 450, 289, 14, 354, 9, 288, 340, 289, 14, 697, 63, 1080, 440, 315, 334, 403, 12, 715, 12, 756, 304, 355, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 298, 697, 63, 1080, 2, 1077, 506, 1902, 488, 12, 715, 503, 756, 3530, 450, 289, 14, 354, 9, 953, 327, 2670, 626, 1390, 63, 1267, 2695, 5450, 340, 1808, 12731, 11200, 5459, 14, 288, 340, 2202, 14, 17873, 63, 15956, 508, 283, 8644, 356, 355, 1592, 63, 1023, 275, 1950, 14, 362, 63, 1000, 63, 1023, 342, 355, 340, 1592, 63, 1023, 665, 334, 21, 12, 378, 12, 650, 9, 436, 1228, 8, 70, 12, 334, 992, 14, 2183, 12, 1709, 14, 25732, 20727, 3901, 12, 1709, 14, 17315, 430, 436, 289, 14, 988, 63, 1267, 690, 5450, 26, 490, 325, 14, 525, 8, 3291, 12, 18253, 83, 582, 450, 83, 3913, 1172, 282, 298, 988, 63, 1267, 2, 8932, 2419, 5450, 1380, 1265, 787, 1808, 282, 1015, 402, 11200, 6791, 370, 959, 14, 16, 14, 19, 334, 13297, 787, 1808, 450, 83, 28823, 450, 334, 70, 14, 354, 12, 289, 855, 533, 4914, 354, 3108, 15671, 904, 779, 495, 8, 78, 9, 367, 302, 315, 1592, 63, 1023, 1491, 19, 2677, 1724, 953, 327, 2670, 370, 1937, 340, 314, 4048, 901, 911, 30109, 543, 1263, 3411, 288, 327, 1504, 12, 333, 18, 77, 1504, 12, 333, 18, 77, 4048, 0 ]
[ 1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
sahutd/youtube-dl
youtube_dl/extractor/golem.py
186
2181
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urlparse, ) from ..utils import ( determine_ext, ) class GolemIE(InfoExtractor): _VALID_URL = r'^https?://video\.golem\.de/.+?/(?P<id>.+?)/' _TEST = { 'url': 'http://video.golem.de/handy/14095/iphone-6-und-6-plus-test.html', 'md5': 'c1a2c0a3c863319651c7c992c5ee29bf', 'info_dict': { 'id': '14095', 'format_id': 'high', 'ext': 'mp4', 'title': 'iPhone 6 und 6 Plus - Test', 'duration': 300.44, 'filesize': 65309548, } } _PREFIX = 'http://video.golem.de' def _real_extract(self, url): video_id = self._match_id(url) config = self._download_xml( 'https://video.golem.de/xml/{0}.xml'.format(video_id), video_id) info = { 'id': video_id, 'title': config.findtext('./title', 'golem'), 'duration': self._float(config.findtext('./playtime'), 'duration'), } formats = [] for e in config: url = e.findtext('./url') if not url: continue formats.append({ 'format_id': e.tag, 'url': compat_urlparse.urljoin(self._PREFIX, url), 'height': self._int(e.get('height'), 'height'), 'width': self._int(e.get('width'), 'width'), 'filesize': self._int(e.findtext('filesize'), 'filesize'), 'ext': determine_ext(e.findtext('./filename')), }) self._sort_formats(formats) info['formats'] = formats thumbnails = [] for e in config.findall('.//teaser'): url = e.findtext('./url') if not url: continue thumbnails.append({ 'url': compat_urlparse.urljoin(self._PREFIX, url), 'width': self._int(e.get('width'), 'thumbnail width'), 'height': self._int(e.get('height'), 'thumbnail height'), }) info['thumbnails'] = thumbnails return info
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 199, 9, 421, 199, 533, 3971, 3701, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 4289, 2859, 14144, 3722, 4537, 1939, 3701, 4537, 271, 15, 11198, 9448, 48, 28, 344, 29587, 2447, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 1939, 3701, 14, 271, 15, 6868, 89, 15, 1079, 19113, 15, 28303, 13, 22, 13, 725, 13, 22, 13, 6666, 13, 396, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 67, 17, 65, 18, 67, 16, 65, 19, 67, 1184, 1153, 1167, 25459, 67, 23, 67, 16544, 67, 21, 1024, 1398, 4361, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1079, 19113, 297, 288, 283, 908, 63, 344, 356, 283, 6260, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 73, 15199, 1227, 625, 68, 1227, 7497, 527, 446, 1379, 297, 288, 283, 5553, 356, 9601, 14, 1602, 12, 288, 283, 19233, 356, 11738, 10556, 17054, 12, 267, 789, 272, 789, 339, 485, 6351, 275, 283, 1014, 921, 3722, 14, 1939, 3701, 14, 271, 7, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 1101, 275, 291, 423, 4249, 63, 1652, 8, 288, 283, 2859, 921, 3722, 14, 1939, 3701, 14, 271, 15, 1652, 5321, 16, 5565, 1652, 1370, 908, 8, 3722, 63, 344, 395, 3991, 63, 344, 9, 398, 2256, 275, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 1101, 14, 30401, 17371, 1213, 297, 283, 1939, 3701, 659, 288, 283, 5553, 356, 291, 423, 1609, 8, 888, 14, 30401, 17371, 2802, 521, 659, 283, 5553, 659, 267, 789, 398, 6752, 275, 942, 267, 367, 325, 315, 1101, 26, 288, 1166, 275, 325, 14, 30401, 17371, 633, 358, 288, 340, 440, 1166, 26, 355, 1980, 953, 6752, 14, 740, 2561, 355, 283, 908, 63, 344, 356, 325, 14, 1450, 12, 355, 283, 633, 356, 8434, 63, 10290, 14, 17755, 8, 277, 423, 6351, 12, 1166, 395, 355, 283, 3333, 356, 291, 423, 442, 8, 69, 14, 362, 360, 3333, 659, 283, 3333, 659, 355, 283, 2063, 356, 291, 423, 442, 8, 69, 14, 362, 360, 2063, 659, 283, 2063, 659, 355, 283, 19233, 356, 291, 423, 442, 8, 69, 14, 30401, 360, 19233, 659, 283, 19233, 659, 355, 283, 832, 356, 6705, 63, 832, 8, 69, 14, 30401, 17371, 1501, 3855, 288, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 267, 2256, 459, 6321, 418, 275, 6752, 398, 10062, 83, 275, 942, 267, 367, 325, 315, 1101, 14, 6452, 29995, 266, 65, 332, 735, 288, 1166, 275, 325, 14, 30401, 17371, 633, 358, 288, 340, 440, 1166, 26, 355, 1980, 288, 10062, 83, 14, 740, 2561, 355, 283, 633, 356, 8434, 63, 10290, 14, 17755, 8, 277, 423, 6351, 12, 1166, 395, 355, 283, 2063, 356, 291, 423, 442, 8, 69, 14, 362, 360, 2063, 659, 283, 8311, 3462, 659, 355, 283, 3333, 356, 291, 423, 442, 8, 69, 14, 362, 360, 3333, 659, 283, 8311, 4569, 659, 288, 3828, 267, 2256, 459, 8311, 83, 418, 275, 10062, 83, 398, 372, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 199, 9, 421, 199, 533, 3971, 3701, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 4289, 2859, 14144, 3722, 4537, 1939, 3701, 4537, 271, 15, 11198, 9448, 48, 28, 344, 29587, 2447, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 1939, 3701, 14, 271, 15, 6868, 89, 15, 1079, 19113, 15, 28303, 13, 22, 13, 725, 13, 22, 13, 6666, 13, 396, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 67, 17, 65, 18, 67, 16, 65, 19, 67, 1184, 1153, 1167, 25459, 67, 23, 67, 16544, 67, 21, 1024, 1398, 4361, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1079, 19113, 297, 288, 283, 908, 63, 344, 356, 283, 6260, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 73, 15199, 1227, 625, 68, 1227, 7497, 527, 446, 1379, 297, 288, 283, 5553, 356, 9601, 14, 1602, 12, 288, 283, 19233, 356, 11738, 10556, 17054, 12, 267, 789, 272, 789, 339, 485, 6351, 275, 283, 1014, 921, 3722, 14, 1939, 3701, 14, 271, 7, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 1101, 275, 291, 423, 4249, 63, 1652, 8, 288, 283, 2859, 921, 3722, 14, 1939, 3701, 14, 271, 15, 1652, 5321, 16, 5565, 1652, 1370, 908, 8, 3722, 63, 344, 395, 3991, 63, 344, 9, 398, 2256, 275, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 1101, 14, 30401, 17371, 1213, 297, 283, 1939, 3701, 659, 288, 283, 5553, 356, 291, 423, 1609, 8, 888, 14, 30401, 17371, 2802, 521, 659, 283, 5553, 659, 267, 789, 398, 6752, 275, 942, 267, 367, 325, 315, 1101, 26, 288, 1166, 275, 325, 14, 30401, 17371, 633, 358, 288, 340, 440, 1166, 26, 355, 1980, 953, 6752, 14, 740, 2561, 355, 283, 908, 63, 344, 356, 325, 14, 1450, 12, 355, 283, 633, 356, 8434, 63, 10290, 14, 17755, 8, 277, 423, 6351, 12, 1166, 395, 355, 283, 3333, 356, 291, 423, 442, 8, 69, 14, 362, 360, 3333, 659, 283, 3333, 659, 355, 283, 2063, 356, 291, 423, 442, 8, 69, 14, 362, 360, 2063, 659, 283, 2063, 659, 355, 283, 19233, 356, 291, 423, 442, 8, 69, 14, 30401, 360, 19233, 659, 283, 19233, 659, 355, 283, 832, 356, 6705, 63, 832, 8, 69, 14, 30401, 17371, 1501, 3855, 288, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 267, 2256, 459, 6321, 418, 275, 6752, 398, 10062, 83, 275, 942, 267, 367, 325, 315, 1101, 14, 6452, 29995, 266, 65, 332, 735, 288, 1166, 275, 325, 14, 30401, 17371, 633, 358, 288, 340, 440, 1166, 26, 355, 1980, 288, 10062, 83, 14, 740, 2561, 355, 283, 633, 356, 8434, 63, 10290, 14, 17755, 8, 277, 423, 6351, 12, 1166, 395, 355, 283, 2063, 356, 291, 423, 442, 8, 69, 14, 362, 360, 2063, 659, 283, 8311, 3462, 659, 355, 283, 3333, 356, 291, 423, 442, 8, 69, 14, 362, 360, 3333, 659, 283, 8311, 4569, 659, 288, 3828, 267, 2256, 459, 8311, 83, 418, 275, 10062, 83, 398, 372, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1,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service.py
6
13775
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # Copyright 2011 Justin Santa Barbara # 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. """Generic Node base class for all workers that run on hosts.""" import errno import os import random import signal import sys import time import eventlet from eventlet import event import logging as std_logging from oslo.config import cfg from heat.openstack.common import eventlet_backdoor from heat.openstack.common.gettextutils import _ # noqa from heat.openstack.common import importutils from heat.openstack.common import log as logging from heat.openstack.common import threadgroup rpc = importutils.try_import('heat.openstack.common.rpc') CONF = cfg.CONF LOG = logging.getLogger(__name__) class Launcher(object): """Launch one or more services and wait for them to complete.""" def __init__(self): """Initialize the service launcher. :returns: None """ self.services = Services() self.backdoor_port = eventlet_backdoor.initialize_if_enabled() def launch_service(self, service): """Load and start the given service. :param service: The service you would like to start. :returns: None """ service.backdoor_port = self.backdoor_port self.services.add(service) def stop(self): """Stop all services which are currently running. :returns: None """ self.services.stop() def wait(self): """Waits until all services have been stopped, and then returns. :returns: None """ self.services.wait() def restart(self): """Reload config files and restart service. :returns: None """ cfg.CONF.reload_config_files() self.services.restart() class SignalExit(SystemExit): def __init__(self, signo, exccode=1): super(SignalExit, self).__init__(exccode) self.signo = signo class ServiceLauncher(Launcher): def _handle_signal(self, signo, frame): # Allow the process to be killed again and die from natural causes signal.signal(signal.SIGTERM, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGHUP, signal.SIG_DFL) raise SignalExit(signo) def handle_signal(self): signal.signal(signal.SIGTERM, self._handle_signal) signal.signal(signal.SIGINT, self._handle_signal) signal.signal(signal.SIGHUP, self._handle_signal) def _wait_for_exit_or_signal(self): status = None signo = 0 LOG.debug(_('Full set of CONF:')) CONF.log_opt_values(LOG, std_logging.DEBUG) try: super(ServiceLauncher, self).wait() except SignalExit as exc: signame = {signal.SIGTERM: 'SIGTERM', signal.SIGINT: 'SIGINT', signal.SIGHUP: 'SIGHUP'}[exc.signo] LOG.info(_('Caught %s, exiting'), signame) status = exc.code signo = exc.signo except SystemExit as exc: status = exc.code finally: self.stop() if rpc: try: rpc.cleanup() except Exception: # We're shutting down, so it doesn't matter at this point. LOG.exception(_('Exception during rpc cleanup.')) return status, signo def wait(self): while True: self.handle_signal() status, signo = self._wait_for_exit_or_signal() if signo != signal.SIGHUP: return status self.restart() class ServiceWrapper(object): def __init__(self, service, workers): self.service = service self.workers = workers self.children = set() self.forktimes = [] class ProcessLauncher(object): def __init__(self): self.children = {} self.sigcaught = None self.running = True rfd, self.writepipe = os.pipe() self.readpipe = eventlet.greenio.GreenPipe(rfd, 'r') self.handle_signal() def handle_signal(self): signal.signal(signal.SIGTERM, self._handle_signal) signal.signal(signal.SIGINT, self._handle_signal) signal.signal(signal.SIGHUP, self._handle_signal) def _handle_signal(self, signo, frame): self.sigcaught = signo self.running = False # Allow the process to be killed again and die from natural causes signal.signal(signal.SIGTERM, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGHUP, signal.SIG_DFL) def _pipe_watcher(self): # This will block until the write end is closed when the parent # dies unexpectedly self.readpipe.read() LOG.info(_('Parent process has died unexpectedly, exiting')) sys.exit(1) def _child_process_handle_signal(self): # Setup child signal handlers differently def _sigterm(*args): signal.signal(signal.SIGTERM, signal.SIG_DFL) raise SignalExit(signal.SIGTERM) def _sighup(*args): signal.signal(signal.SIGHUP, signal.SIG_DFL) raise SignalExit(signal.SIGHUP) signal.signal(signal.SIGTERM, _sigterm) signal.signal(signal.SIGHUP, _sighup) # Block SIGINT and let the parent send us a SIGTERM signal.signal(signal.SIGINT, signal.SIG_IGN) def _child_wait_for_exit_or_signal(self, launcher): status = None signo = 0 try: launcher.wait() except SignalExit as exc: signame = {signal.SIGTERM: 'SIGTERM', signal.SIGINT: 'SIGINT', signal.SIGHUP: 'SIGHUP'}[exc.signo] LOG.info(_('Caught %s, exiting'), signame) status = exc.code signo = exc.signo except SystemExit as exc: status = exc.code except BaseException: LOG.exception(_('Unhandled exception')) status = 2 finally: launcher.stop() return status, signo def _child_process(self, service): self._child_process_handle_signal() # Reopen the eventlet hub to make sure we don't share an epoll # fd with parent and/or siblings, which would be bad eventlet.hubs.use_hub() # Close write to ensure only parent has it open os.close(self.writepipe) # Create greenthread to watch for parent to close pipe eventlet.spawn_n(self._pipe_watcher) # Reseed random number generator random.seed() launcher = Launcher() launcher.launch_service(service) return launcher def _start_child(self, wrap): if len(wrap.forktimes) > wrap.workers: # Limit ourselves to one process a second (over the period of # number of workers * 1 second). This will allow workers to # start up quickly but ensure we don't fork off children that # die instantly too quickly. if time.time() - wrap.forktimes[0] < wrap.workers: LOG.info(_('Forking too fast, sleeping')) time.sleep(1) wrap.forktimes.pop(0) wrap.forktimes.append(time.time()) pid = os.fork() if pid == 0: # NOTE(johannes): All exceptions are caught to ensure this # doesn't fallback into the loop spawning children. It would # be bad for a child to spawn more children. launcher = self._child_process(wrap.service) while True: self._child_process_handle_signal() status, signo = self._child_wait_for_exit_or_signal(launcher) if signo != signal.SIGHUP: break launcher.restart() os._exit(status) LOG.info(_('Started child %d'), pid) wrap.children.add(pid) self.children[pid] = wrap return pid def launch_service(self, service, workers=1): wrap = ServiceWrapper(service, workers) LOG.info(_('Starting %d workers'), wrap.workers) while self.running and len(wrap.children) < wrap.workers: self._start_child(wrap) def _wait_child(self): try: # Don't block if no child processes have exited pid, status = os.waitpid(0, os.WNOHANG) if not pid: return None except OSError as exc: if exc.errno not in (errno.EINTR, errno.ECHILD): raise return None if os.WIFSIGNALED(status): sig = os.WTERMSIG(status) LOG.info(_('Child %(pid)d killed by signal %(sig)d'), dict(pid=pid, sig=sig)) else: code = os.WEXITSTATUS(status) LOG.info(_('Child %(pid)s exited with status %(code)d'), dict(pid=pid, code=code)) if pid not in self.children: LOG.warning(_('pid %d not in child list'), pid) return None wrap = self.children.pop(pid) wrap.children.remove(pid) return wrap def _respawn_children(self): while self.running: wrap = self._wait_child() if not wrap: # Yield to other threads if no children have exited # Sleep for a short time to avoid excessive CPU usage # (see bug #1095346) eventlet.greenthread.sleep(.01) continue while self.running and len(wrap.children) < wrap.workers: self._start_child(wrap) def wait(self): """Loop waiting on children to die and respawning as necessary.""" LOG.debug(_('Full set of CONF:')) CONF.log_opt_values(LOG, std_logging.DEBUG) while True: self.handle_signal() self._respawn_children() if self.sigcaught: signame = {signal.SIGTERM: 'SIGTERM', signal.SIGINT: 'SIGINT', signal.SIGHUP: 'SIGHUP'}[self.sigcaught] LOG.info(_('Caught %s, stopping children'), signame) if self.sigcaught != signal.SIGHUP: break for pid in self.children: os.kill(pid, signal.SIGHUP) self.running = True self.sigcaught = None for pid in self.children: try: os.kill(pid, signal.SIGTERM) except OSError as exc: if exc.errno != errno.ESRCH: raise # Wait for children to die if self.children: LOG.info(_('Waiting on %d children to exit'), len(self.children)) while self.children: self._wait_child() class Service(object): """Service object for binaries running on hosts.""" def __init__(self, threads=1000): self.tg = threadgroup.ThreadGroup(threads) # signal that the service is done shutting itself down: self._done = event.Event() def reset(self): # NOTE(Fengqian): docs for Event.reset() recommend against using it self._done = event.Event() def start(self): pass def stop(self): self.tg.stop() self.tg.wait() # Signal that service cleanup is done: if not self._done.ready(): self._done.send() def wait(self): self._done.wait() class Services(object): def __init__(self): self.services = [] self.tg = threadgroup.ThreadGroup() self.done = event.Event() def add(self, service): self.services.append(service) self.tg.add_thread(self.run_service, service, self.done) def stop(self): # wait for graceful shutdown of services: for service in self.services: service.stop() service.wait() # Each service has performed cleanup, now signal that the run_service # wrapper threads can now die: if not self.done.ready(): self.done.send() # reap threads: self.tg.stop() def wait(self): self.tg.wait() def restart(self): self.stop() self.done = event.Event() for restart_service in self.services: restart_service.reset() self.tg.add_thread(self.run_service, restart_service, self.done) @staticmethod def run_service(service, done): """Service start wrapper. :param service: service to run :param done: event to wait on until a shutdown is triggered :returns: None """ service.start() done.wait() def launch(service, workers=None): if workers: launcher = ProcessLauncher() launcher.launch_service(service, workers=workers) else: launcher = ServiceLauncher() launcher.launch_service(service) return launcher
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 1898, 7760, 13870, 262, 29359, 502, 12377, 1700, 65, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 9417, 5013, 1300, 1021, 367, 1006, 14123, 626, 1255, 641, 7057, 1041, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 2196, 199, 646, 4673, 199, 646, 984, 199, 646, 900, 199, 199, 646, 21819, 199, 504, 21819, 492, 1566, 199, 646, 2050, 465, 2418, 63, 4806, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 20408, 14, 8512, 14, 2330, 492, 21819, 63, 894, 20842, 199, 504, 20408, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 221, 327, 8151, 199, 504, 20408, 14, 8512, 14, 2330, 492, 492, 1208, 199, 504, 20408, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 20408, 14, 8512, 14, 2330, 492, 2462, 923, 421, 199, 4354, 275, 492, 1208, 14, 893, 63, 646, 360, 16614, 14, 8512, 14, 2330, 14, 4354, 358, 199, 3103, 275, 4810, 14, 3103, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 23615, 281, 8, 785, 304, 272, 408, 18543, 1373, 503, 1655, 8500, 436, 3618, 367, 3062, 370, 4890, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 408, 9345, 314, 2435, 28757, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 275, 21813, 342, 267, 291, 14, 894, 20842, 63, 719, 275, 21819, 63, 894, 20842, 14, 8489, 63, 692, 63, 3827, 342, 339, 347, 10623, 63, 1364, 8, 277, 12, 2435, 304, 267, 408, 6200, 436, 1343, 314, 1627, 2435, 14, 398, 520, 635, 2435, 26, 710, 2435, 1265, 3955, 2839, 370, 1343, 14, 267, 520, 5808, 26, 488, 398, 408, 267, 2435, 14, 894, 20842, 63, 719, 275, 291, 14, 894, 20842, 63, 719, 267, 291, 14, 5950, 14, 525, 8, 1364, 9, 339, 347, 3631, 8, 277, 304, 267, 408, 6293, 1006, 8500, 1314, 787, 5544, 3879, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 14, 2379, 342, 339, 347, 3618, 8, 277, 304, 267, 408, 24804, 1405, 5133, 1006, 8500, 1172, 2757, 15248, 12, 436, 2066, 2529, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 14, 2573, 342, 339, 347, 11004, 8, 277, 304, 267, 408, 30590, 1101, 1584, 436, 11004, 2435, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 4810, 14, 3103, 14, 9233, 63, 888, 63, 1725, 342, 267, 291, 14, 5950, 14, 10506, 342, 421, 199, 533, 18288, 6699, 8, 24738, 304, 272, 347, 636, 826, 721, 277, 12, 5259, 889, 12, 3178, 600, 29, 17, 304, 267, 1613, 8, 11274, 6699, 12, 291, 2843, 826, 721, 2804, 600, 9, 267, 291, 14, 1037, 79, 275, 5259, 889, 421, 199, 533, 7591, 18543, 281, 8, 18543, 281, 304, 272, 347, 485, 2479, 63, 4653, 8, 277, 12, 5259, 889, 12, 2787, 304, 267, 327, 9812, 314, 2112, 370, 506, 26659, 4020, 436, 18833, 687, 19981, 14486, 267, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 4673, 14, 7864, 63, 36, 3143, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 14, 7864, 63, 36, 3143, 9, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 40, 2160, 12, 4673, 14, 7864, 63, 36, 3143, 9, 398, 746, 18288, 6699, 8, 1037, 79, 9, 339, 347, 2429, 63, 4653, 8, 277, 304, 267, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 291, 423, 2479, 63, 4653, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 291, 423, 2479, 63, 4653, 9, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 40, 2160, 12, 291, 423, 2479, 63, 4653, 9, 339, 347, 485, 2573, 63, 509, 63, 2224, 63, 269, 63, 4653, 8, 277, 304, 267, 2004, 275, 488, 267, 5259, 889, 275, 378, 398, 5051, 14, 1757, 6723, 9042, 663, 402, 6392, 26, 1333, 267, 6392, 14, 793, 63, 2992, 63, 1459, 8, 4947, 12, 2418, 63, 4806, 14, 5287, 9, 398, 862, 26, 288, 1613, 8, 3167, 18543, 281, 12, 291, 680, 2573, 342, 267, 871, 18288, 6699, 465, 3178, 26, 288, 5259, 354, 275, 469, 4653, 14, 29190, 26, 283, 29190, 297, 2432, 4673, 14, 21223, 26, 283, 21223, 297, 2432, 4673, 14, 7864, 40, 2160, 26, 283, 7864, 40, 2160, 936, 59, 2804, 14, 1037, 79, 61, 288, 5051, 14, 815, 6723, 3630, 10846, 450, 83, 12, 24234, 659, 5259, 354, 9, 288, 2004, 275, 3178, 14, 600, 288, 5259, 889, 275, 3178, 14, 1037, 79, 267, 871, 14838, 465, 3178, 26, 288, 2004, 275, 3178, 14, 600, 267, 3753, 26, 288, 291, 14, 2379, 342, 288, 340, 8985, 26, 355, 862, 26, 490, 8985, 14, 7661, 342, 355, 871, 2186, 26, 490, 327, 2136, 3984, 24761, 1337, 3224, 12, 880, 652, 3181, 1133, 17247, 737, 642, 2376, 14, 490, 5051, 14, 1971, 6723, 1726, 5309, 8985, 9058, 12459, 398, 372, 2004, 12, 5259, 889, 339, 347, 3618, 8, 277, 304, 267, 1830, 715, 26, 288, 291, 14, 2479, 63, 4653, 342, 288, 2004, 12, 5259, 889, 275, 291, 423, 2573, 63, 509, 63, 2224, 63, 269, 63, 4653, 342, 288 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 1898, 7760, 13870, 262, 29359, 502, 12377, 1700, 65, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 9417, 5013, 1300, 1021, 367, 1006, 14123, 626, 1255, 641, 7057, 1041, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 2196, 199, 646, 4673, 199, 646, 984, 199, 646, 900, 199, 199, 646, 21819, 199, 504, 21819, 492, 1566, 199, 646, 2050, 465, 2418, 63, 4806, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 20408, 14, 8512, 14, 2330, 492, 21819, 63, 894, 20842, 199, 504, 20408, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 221, 327, 8151, 199, 504, 20408, 14, 8512, 14, 2330, 492, 492, 1208, 199, 504, 20408, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 20408, 14, 8512, 14, 2330, 492, 2462, 923, 421, 199, 4354, 275, 492, 1208, 14, 893, 63, 646, 360, 16614, 14, 8512, 14, 2330, 14, 4354, 358, 199, 3103, 275, 4810, 14, 3103, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 23615, 281, 8, 785, 304, 272, 408, 18543, 1373, 503, 1655, 8500, 436, 3618, 367, 3062, 370, 4890, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 408, 9345, 314, 2435, 28757, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 275, 21813, 342, 267, 291, 14, 894, 20842, 63, 719, 275, 21819, 63, 894, 20842, 14, 8489, 63, 692, 63, 3827, 342, 339, 347, 10623, 63, 1364, 8, 277, 12, 2435, 304, 267, 408, 6200, 436, 1343, 314, 1627, 2435, 14, 398, 520, 635, 2435, 26, 710, 2435, 1265, 3955, 2839, 370, 1343, 14, 267, 520, 5808, 26, 488, 398, 408, 267, 2435, 14, 894, 20842, 63, 719, 275, 291, 14, 894, 20842, 63, 719, 267, 291, 14, 5950, 14, 525, 8, 1364, 9, 339, 347, 3631, 8, 277, 304, 267, 408, 6293, 1006, 8500, 1314, 787, 5544, 3879, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 14, 2379, 342, 339, 347, 3618, 8, 277, 304, 267, 408, 24804, 1405, 5133, 1006, 8500, 1172, 2757, 15248, 12, 436, 2066, 2529, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 291, 14, 5950, 14, 2573, 342, 339, 347, 11004, 8, 277, 304, 267, 408, 30590, 1101, 1584, 436, 11004, 2435, 14, 398, 520, 5808, 26, 488, 398, 408, 267, 4810, 14, 3103, 14, 9233, 63, 888, 63, 1725, 342, 267, 291, 14, 5950, 14, 10506, 342, 421, 199, 533, 18288, 6699, 8, 24738, 304, 272, 347, 636, 826, 721, 277, 12, 5259, 889, 12, 3178, 600, 29, 17, 304, 267, 1613, 8, 11274, 6699, 12, 291, 2843, 826, 721, 2804, 600, 9, 267, 291, 14, 1037, 79, 275, 5259, 889, 421, 199, 533, 7591, 18543, 281, 8, 18543, 281, 304, 272, 347, 485, 2479, 63, 4653, 8, 277, 12, 5259, 889, 12, 2787, 304, 267, 327, 9812, 314, 2112, 370, 506, 26659, 4020, 436, 18833, 687, 19981, 14486, 267, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 4673, 14, 7864, 63, 36, 3143, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 14, 7864, 63, 36, 3143, 9, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 40, 2160, 12, 4673, 14, 7864, 63, 36, 3143, 9, 398, 746, 18288, 6699, 8, 1037, 79, 9, 339, 347, 2429, 63, 4653, 8, 277, 304, 267, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 291, 423, 2479, 63, 4653, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 291, 423, 2479, 63, 4653, 9, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 40, 2160, 12, 291, 423, 2479, 63, 4653, 9, 339, 347, 485, 2573, 63, 509, 63, 2224, 63, 269, 63, 4653, 8, 277, 304, 267, 2004, 275, 488, 267, 5259, 889, 275, 378, 398, 5051, 14, 1757, 6723, 9042, 663, 402, 6392, 26, 1333, 267, 6392, 14, 793, 63, 2992, 63, 1459, 8, 4947, 12, 2418, 63, 4806, 14, 5287, 9, 398, 862, 26, 288, 1613, 8, 3167, 18543, 281, 12, 291, 680, 2573, 342, 267, 871, 18288, 6699, 465, 3178, 26, 288, 5259, 354, 275, 469, 4653, 14, 29190, 26, 283, 29190, 297, 2432, 4673, 14, 21223, 26, 283, 21223, 297, 2432, 4673, 14, 7864, 40, 2160, 26, 283, 7864, 40, 2160, 936, 59, 2804, 14, 1037, 79, 61, 288, 5051, 14, 815, 6723, 3630, 10846, 450, 83, 12, 24234, 659, 5259, 354, 9, 288, 2004, 275, 3178, 14, 600, 288, 5259, 889, 275, 3178, 14, 1037, 79, 267, 871, 14838, 465, 3178, 26, 288, 2004, 275, 3178, 14, 600, 267, 3753, 26, 288, 291, 14, 2379, 342, 288, 340, 8985, 26, 355, 862, 26, 490, 8985, 14, 7661, 342, 355, 871, 2186, 26, 490, 327, 2136, 3984, 24761, 1337, 3224, 12, 880, 652, 3181, 1133, 17247, 737, 642, 2376, 14, 490, 5051, 14, 1971, 6723, 1726, 5309, 8985, 9058, 12459, 398, 372, 2004, 12, 5259, 889, 339, 347, 3618, 8, 277, 304, 267, 1830, 715, 26, 288, 291, 14, 2479, 63, 4653, 342, 288, 2004, 12, 5259, 889, 275, 291, 423, 2573, 63, 509, 63, 2224, 63, 269, 63, 4653, 342, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
follow99/django
django/contrib/admin/filters.py
188
16608
""" This encapsulates the logic for displaying filters in the Django admin. Filters are specified in models with the "list_filter" option. Each filter subclass knows how to display a filter for a field that passes a certain test -- e.g. being a DateField or ForeignKey. """ import datetime from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.admin.utils import ( get_model_from_relation, prepare_lookup_value, reverse_field_path, ) from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.utils import timezone from django.utils.encoding import force_text, smart_text from django.utils.translation import ugettext_lazy as _ class ListFilter(object): title = None # Human-readable title to appear in the right sidebar. template = 'admin/filter.html' def __init__(self, request, params, model, model_admin): # This dictionary will eventually contain the request's query string # parameters actually used by this filter. self.used_parameters = {} if self.title is None: raise ImproperlyConfigured( "The list filter '%s' does not specify " "a 'title'." % self.__class__.__name__) def has_output(self): """ Returns True if some choices would be output for this filter. """ raise NotImplementedError('subclasses of ListFilter must provide a has_output() method') def choices(self, cl): """ Returns choices ready to be output in the template. """ raise NotImplementedError('subclasses of ListFilter must provide a choices() method') def queryset(self, request, queryset): """ Returns the filtered queryset. """ raise NotImplementedError('subclasses of ListFilter must provide a queryset() method') def expected_parameters(self): """ Returns the list of parameter names that are expected from the request's query string and that will be used by this filter. """ raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method') class SimpleListFilter(ListFilter): # The parameter that should be used in the query string for that filter. parameter_name = None def __init__(self, request, params, model, model_admin): super(SimpleListFilter, self).__init__( request, params, model, model_admin) if self.parameter_name is None: raise ImproperlyConfigured( "The list filter '%s' does not specify " "a 'parameter_name'." % self.__class__.__name__) if self.parameter_name in params: value = params.pop(self.parameter_name) self.used_parameters[self.parameter_name] = value lookup_choices = self.lookups(request, model_admin) if lookup_choices is None: lookup_choices = () self.lookup_choices = list(lookup_choices) def has_output(self): return len(self.lookup_choices) > 0 def value(self): """ Returns the value (in string format) provided in the request's query string for this filter, if any. If the value wasn't provided then returns None. """ return self.used_parameters.get(self.parameter_name) def lookups(self, request, model_admin): """ Must be overridden to return a list of tuples (value, verbose value) """ raise NotImplementedError( 'The SimpleListFilter.lookups() method must be overridden to ' 'return a list of tuples (value, verbose value)') def expected_parameters(self): return [self.parameter_name] def choices(self, cl): yield { 'selected': self.value() is None, 'query_string': cl.get_query_string({}, [self.parameter_name]), 'display': _('All'), } for lookup, title in self.lookup_choices: yield { 'selected': self.value() == force_text(lookup), 'query_string': cl.get_query_string({ self.parameter_name: lookup, }, []), 'display': title, } class FieldListFilter(ListFilter): _field_list_filters = [] _take_priority_index = 0 def __init__(self, field, request, params, model, model_admin, field_path): self.field = field self.field_path = field_path self.title = getattr(field, 'verbose_name', field_path) super(FieldListFilter, self).__init__( request, params, model, model_admin) for p in self.expected_parameters(): if p in params: value = params.pop(p) self.used_parameters[p] = prepare_lookup_value(p, value) def has_output(self): return True def queryset(self, request, queryset): try: return queryset.filter(**self.used_parameters) except ValidationError as e: raise IncorrectLookupParameters(e) @classmethod def register(cls, test, list_filter_class, take_priority=False): if take_priority: # This is to allow overriding the default filters for certain types # of fields with some custom filters. The first found in the list # is used in priority. cls._field_list_filters.insert( cls._take_priority_index, (test, list_filter_class)) cls._take_priority_index += 1 else: cls._field_list_filters.append((test, list_filter_class)) @classmethod def create(cls, field, request, params, model, model_admin, field_path): for test, list_filter_class in cls._field_list_filters: if not test(field): continue return list_filter_class(field, request, params, model, model_admin, field_path=field_path) class RelatedFieldListFilter(FieldListFilter): def __init__(self, field, request, params, model, model_admin, field_path): other_model = get_model_from_relation(field) self.lookup_kwarg = '%s__%s__exact' % (field_path, field.target_field.name) self.lookup_kwarg_isnull = '%s__isnull' % field_path self.lookup_val = request.GET.get(self.lookup_kwarg) self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull) self.lookup_choices = self.field_choices(field, request, model_admin) super(RelatedFieldListFilter, self).__init__( field, request, params, model, model_admin, field_path) if hasattr(field, 'verbose_name'): self.lookup_title = field.verbose_name else: self.lookup_title = other_model._meta.verbose_name self.title = self.lookup_title self.empty_value_display = model_admin.get_empty_value_display() @property def include_empty_choice(self): """ Return True if a "(None)" choice should be included, which filters out everything except empty relationships. """ return self.field.null or (self.field.is_relation and self.field.many_to_many) def has_output(self): if self.include_empty_choice: extra = 1 else: extra = 0 return len(self.lookup_choices) + extra > 1 def expected_parameters(self): return [self.lookup_kwarg, self.lookup_kwarg_isnull] def field_choices(self, field, request, model_admin): return field.get_choices(include_blank=False) def choices(self, cl): yield { 'selected': self.lookup_val is None and not self.lookup_val_isnull, 'query_string': cl.get_query_string({}, [self.lookup_kwarg, self.lookup_kwarg_isnull]), 'display': _('All'), } for pk_val, val in self.lookup_choices: yield { 'selected': self.lookup_val == smart_text(pk_val), 'query_string': cl.get_query_string({ self.lookup_kwarg: pk_val, }, [self.lookup_kwarg_isnull]), 'display': val, } if self.include_empty_choice: yield { 'selected': bool(self.lookup_val_isnull), 'query_string': cl.get_query_string({ self.lookup_kwarg_isnull: 'True', }, [self.lookup_kwarg]), 'display': self.empty_value_display, } FieldListFilter.register(lambda f: f.remote_field, RelatedFieldListFilter) class BooleanFieldListFilter(FieldListFilter): def __init__(self, field, request, params, model, model_admin, field_path): self.lookup_kwarg = '%s__exact' % field_path self.lookup_kwarg2 = '%s__isnull' % field_path self.lookup_val = request.GET.get(self.lookup_kwarg) self.lookup_val2 = request.GET.get(self.lookup_kwarg2) super(BooleanFieldListFilter, self).__init__(field, request, params, model, model_admin, field_path) def expected_parameters(self): return [self.lookup_kwarg, self.lookup_kwarg2] def choices(self, cl): for lookup, title in ( (None, _('All')), ('1', _('Yes')), ('0', _('No'))): yield { 'selected': self.lookup_val == lookup and not self.lookup_val2, 'query_string': cl.get_query_string({ self.lookup_kwarg: lookup, }, [self.lookup_kwarg2]), 'display': title, } if isinstance(self.field, models.NullBooleanField): yield { 'selected': self.lookup_val2 == 'True', 'query_string': cl.get_query_string({ self.lookup_kwarg2: 'True', }, [self.lookup_kwarg]), 'display': _('Unknown'), } FieldListFilter.register(lambda f: isinstance(f, (models.BooleanField, models.NullBooleanField)), BooleanFieldListFilter) class ChoicesFieldListFilter(FieldListFilter): def __init__(self, field, request, params, model, model_admin, field_path): self.lookup_kwarg = '%s__exact' % field_path self.lookup_val = request.GET.get(self.lookup_kwarg) super(ChoicesFieldListFilter, self).__init__( field, request, params, model, model_admin, field_path) def expected_parameters(self): return [self.lookup_kwarg] def choices(self, cl): yield { 'selected': self.lookup_val is None, 'query_string': cl.get_query_string({}, [self.lookup_kwarg]), 'display': _('All') } for lookup, title in self.field.flatchoices: yield { 'selected': smart_text(lookup) == self.lookup_val, 'query_string': cl.get_query_string({ self.lookup_kwarg: lookup}), 'display': title, } FieldListFilter.register(lambda f: bool(f.choices), ChoicesFieldListFilter) class DateFieldListFilter(FieldListFilter): def __init__(self, field, request, params, model, model_admin, field_path): self.field_generic = '%s__' % field_path self.date_params = {k: v for k, v in params.items() if k.startswith(self.field_generic)} now = timezone.now() # When time zone support is enabled, convert "now" to the user's time # zone so Django's definition of "Today" matches what the user expects. if timezone.is_aware(now): now = timezone.localtime(now) if isinstance(field, models.DateTimeField): today = now.replace(hour=0, minute=0, second=0, microsecond=0) else: # field is a models.DateField today = now.date() tomorrow = today + datetime.timedelta(days=1) if today.month == 12: next_month = today.replace(year=today.year + 1, month=1, day=1) else: next_month = today.replace(month=today.month + 1, day=1) next_year = today.replace(year=today.year + 1, month=1, day=1) self.lookup_kwarg_since = '%s__gte' % field_path self.lookup_kwarg_until = '%s__lt' % field_path self.links = ( (_('Any date'), {}), (_('Today'), { self.lookup_kwarg_since: str(today), self.lookup_kwarg_until: str(tomorrow), }), (_('Past 7 days'), { self.lookup_kwarg_since: str(today - datetime.timedelta(days=7)), self.lookup_kwarg_until: str(tomorrow), }), (_('This month'), { self.lookup_kwarg_since: str(today.replace(day=1)), self.lookup_kwarg_until: str(next_month), }), (_('This year'), { self.lookup_kwarg_since: str(today.replace(month=1, day=1)), self.lookup_kwarg_until: str(next_year), }), ) super(DateFieldListFilter, self).__init__( field, request, params, model, model_admin, field_path) def expected_parameters(self): return [self.lookup_kwarg_since, self.lookup_kwarg_until] def choices(self, cl): for title, param_dict in self.links: yield { 'selected': self.date_params == param_dict, 'query_string': cl.get_query_string( param_dict, [self.field_generic]), 'display': title, } FieldListFilter.register( lambda f: isinstance(f, models.DateField), DateFieldListFilter) # This should be registered last, because it's a last resort. For example, # if a field is eligible to use the BooleanFieldListFilter, that'd be much # more appropriate, and the AllValuesFieldListFilter won't get used for it. class AllValuesFieldListFilter(FieldListFilter): def __init__(self, field, request, params, model, model_admin, field_path): self.lookup_kwarg = field_path self.lookup_kwarg_isnull = '%s__isnull' % field_path self.lookup_val = request.GET.get(self.lookup_kwarg) self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull) self.empty_value_display = model_admin.get_empty_value_display() parent_model, reverse_path = reverse_field_path(model, field_path) # Obey parent ModelAdmin queryset when deciding which options to show if model == parent_model: queryset = model_admin.get_queryset(request) else: queryset = parent_model._default_manager.all() self.lookup_choices = (queryset .distinct() .order_by(field.name) .values_list(field.name, flat=True)) super(AllValuesFieldListFilter, self).__init__( field, request, params, model, model_admin, field_path) def expected_parameters(self): return [self.lookup_kwarg, self.lookup_kwarg_isnull] def choices(self, cl): yield { 'selected': (self.lookup_val is None and self.lookup_val_isnull is None), 'query_string': cl.get_query_string({}, [self.lookup_kwarg, self.lookup_kwarg_isnull]), 'display': _('All'), } include_none = False for val in self.lookup_choices: if val is None: include_none = True continue val = smart_text(val) yield { 'selected': self.lookup_val == val, 'query_string': cl.get_query_string({ self.lookup_kwarg: val, }, [self.lookup_kwarg_isnull]), 'display': val, } if include_none: yield { 'selected': bool(self.lookup_val_isnull), 'query_string': cl.get_query_string({ self.lookup_kwarg_isnull: 'True', }, [self.lookup_kwarg]), 'display': self.empty_value_display, } FieldListFilter.register(lambda f: True, AllValuesFieldListFilter) class RelatedOnlyFieldListFilter(RelatedFieldListFilter): def field_choices(self, field, request, model_admin): limit_choices_to = {'pk__in': set(model_admin.get_queryset(request).values_list(field.name, flat=True))} return field.get_choices(include_blank=False, limit_choices_to=limit_choices_to)
bsd-3-clause
[ 624, 199, 2765, 22667, 15409, 314, 9661, 367, 20589, 4766, 315, 314, 5634, 4628, 14, 199, 18053, 787, 2013, 315, 1709, 543, 314, 298, 513, 63, 1541, 2, 945, 14, 199, 199, 22321, 2457, 5516, 19428, 4212, 370, 2929, 282, 2457, 367, 282, 901, 626, 14933, 282, 199, 20226, 511, 1553, 325, 14, 71, 14, 3769, 282, 30997, 503, 12718, 14, 199, 624, 199, 646, 2197, 199, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 1010, 4525, 7521, 5976, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 334, 272, 664, 63, 1238, 63, 504, 63, 5690, 12, 9275, 63, 3892, 63, 585, 12, 3837, 63, 698, 63, 515, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 421, 199, 533, 3820, 4131, 8, 785, 304, 272, 2538, 275, 488, 221, 327, 869, 7652, 13, 11875, 2538, 370, 7468, 315, 314, 2451, 18437, 14, 272, 1978, 275, 283, 2113, 15, 1541, 14, 1360, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 304, 267, 327, 961, 2600, 911, 21356, 1395, 314, 1056, 1159, 1827, 1059, 267, 327, 2633, 5965, 1202, 701, 642, 2457, 14, 267, 291, 14, 2972, 63, 3214, 275, 1052, 267, 340, 291, 14, 1213, 365, 488, 26, 288, 746, 11897, 8, 355, 298, 1918, 769, 2457, 1543, 83, 7, 1630, 440, 4165, 298, 355, 298, 65, 283, 1213, 16669, 450, 291, 855, 533, 4914, 354, 3368, 339, 347, 965, 63, 1199, 8, 277, 304, 267, 408, 267, 1803, 715, 340, 2005, 3415, 3955, 506, 1072, 367, 642, 2457, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 965, 63, 1199, 342, 1083, 358, 339, 347, 3415, 8, 277, 12, 824, 304, 267, 408, 267, 1803, 3415, 10144, 370, 506, 1072, 315, 314, 1978, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 3415, 342, 1083, 358, 339, 347, 7594, 8, 277, 12, 1056, 12, 7594, 304, 267, 408, 267, 1803, 314, 9806, 7594, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 7594, 342, 1083, 358, 339, 347, 1420, 63, 3214, 8, 277, 304, 267, 408, 267, 1803, 314, 769, 402, 2725, 1561, 626, 787, 1420, 687, 314, 267, 1056, 1159, 1827, 1059, 436, 626, 911, 506, 1202, 701, 642, 2457, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 376, 1420, 63, 3214, 342, 1083, 358, 421, 199, 533, 5870, 24703, 8, 24703, 304, 272, 327, 710, 2725, 626, 1077, 506, 1202, 315, 314, 1827, 1059, 367, 626, 2457, 14, 272, 2725, 63, 354, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 304, 267, 1613, 8, 3184, 24703, 12, 291, 2843, 826, 721, 288, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 9, 267, 340, 291, 14, 5329, 63, 354, 365, 488, 26, 288, 746, 11897, 8, 355, 298, 1918, 769, 2457, 1543, 83, 7, 1630, 440, 4165, 298, 355, 298, 65, 283, 5329, 63, 354, 16669, 450, 291, 855, 533, 4914, 354, 3368, 267, 340, 291, 14, 5329, 63, 354, 315, 1862, 26, 288, 574, 275, 1862, 14, 1935, 8, 277, 14, 5329, 63, 354, 9, 288, 291, 14, 2972, 63, 3214, 59, 277, 14, 5329, 63, 354, 61, 275, 574, 267, 4237, 63, 4577, 275, 291, 14, 17438, 8, 1069, 12, 1402, 63, 2113, 9, 267, 340, 4237, 63, 4577, 365, 488, 26, 288, 4237, 63, 4577, 275, 6248, 267, 291, 14, 3892, 63, 4577, 275, 769, 8, 3892, 63, 4577, 9, 339, 347, 965, 63, 1199, 8, 277, 304, 267, 372, 822, 8, 277, 14, 3892, 63, 4577, 9, 690, 378, 339, 347, 574, 8, 277, 304, 267, 408, 267, 1803, 314, 574, 334, 262, 1059, 1475, 9, 2741, 315, 314, 1056, 1159, 267, 1827, 1059, 367, 642, 2457, 12, 340, 1263, 14, 982, 314, 574, 17373, 1133, 2741, 2066, 267, 2529, 488, 14, 267, 408, 267, 372, 291, 14, 2972, 63, 3214, 14, 362, 8, 277, 14, 5329, 63, 354, 9, 339, 347, 16807, 8, 277, 12, 1056, 12, 1402, 63, 2113, 304, 267, 408, 267, 9498, 506, 10087, 370, 372, 282, 769, 402, 6346, 334, 585, 12, 3376, 574, 9, 267, 408, 267, 746, 4279, 8, 288, 283, 1918, 5870, 24703, 14, 17438, 342, 1083, 1471, 506, 10087, 370, 283, 288, 283, 1107, 282, 769, 402, 6346, 334, 585, 12, 3376, 574, 5942, 339, 347, 1420, 63, 3214, 8, 277, 304, 267, 372, 359, 277, 14, 5329, 63, 354, 61, 339, 347, 3415, 8, 277, 12, 824, 304, 267, 1995, 469, 288, 283, 5511, 356, 291, 14, 585, 342, 365, 488, 12, 288, 283, 1131, 63, 875, 356, 824, 14, 362, 63, 1131, 63, 875, 16037, 359, 277, 14, 5329, 63, 354, 2522, 288, 283, 2918, 356, 4018, 2422, 659, 267, 789, 267, 367, 4237, 12, 2538, 315, 291, 14, 3892, 63, 4577, 26, 288, 1995, 469, 355, 283, 5511, 356, 291, 14, 585, 342, 508, 3542, 63, 505, 8, 3892, 395, 355, 283, 1131, 63, 875, 356, 824, 14, 362, 63, 1131, 63, 875, 2561, 490, 291, 14, 5329, 63, 354, 26, 4237, 12, 355, 1660, 14431, 355, 283, 2918, 356, 2538, 12, 288, 789, 421, 199, 533, 5024, 24703, 8, 24703, 304, 272, 485, 698, 63, 513, 63, 4273, 275, 942, 272, 485, 11066, 63, 6693, 63, 1080, 275, 378, 339, 347, 636, 826, 721, 277, 12, 901, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 12, 901, 63, 515, 304, 267, 291, 14, 698, 275, 901, 267, 291, 14, 698, 63, 515, 275, 901, 63, 515, 267, 291, 14, 1213, 275, 2519, 8, 698, 12, 283, 3832, 63, 354, 297, 901, 63, 515, 9, 267, 1613, 8, 792, 24703, 12, 291, 2843, 826, 721, 288, 1056, 12, 1862, 12, 1402, 12, 1402 ]
[ 199, 2765, 22667, 15409, 314, 9661, 367, 20589, 4766, 315, 314, 5634, 4628, 14, 199, 18053, 787, 2013, 315, 1709, 543, 314, 298, 513, 63, 1541, 2, 945, 14, 199, 199, 22321, 2457, 5516, 19428, 4212, 370, 2929, 282, 2457, 367, 282, 901, 626, 14933, 282, 199, 20226, 511, 1553, 325, 14, 71, 14, 3769, 282, 30997, 503, 12718, 14, 199, 624, 199, 646, 2197, 199, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 1010, 4525, 7521, 5976, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 334, 272, 664, 63, 1238, 63, 504, 63, 5690, 12, 9275, 63, 3892, 63, 585, 12, 3837, 63, 698, 63, 515, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 421, 199, 533, 3820, 4131, 8, 785, 304, 272, 2538, 275, 488, 221, 327, 869, 7652, 13, 11875, 2538, 370, 7468, 315, 314, 2451, 18437, 14, 272, 1978, 275, 283, 2113, 15, 1541, 14, 1360, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 304, 267, 327, 961, 2600, 911, 21356, 1395, 314, 1056, 1159, 1827, 1059, 267, 327, 2633, 5965, 1202, 701, 642, 2457, 14, 267, 291, 14, 2972, 63, 3214, 275, 1052, 267, 340, 291, 14, 1213, 365, 488, 26, 288, 746, 11897, 8, 355, 298, 1918, 769, 2457, 1543, 83, 7, 1630, 440, 4165, 298, 355, 298, 65, 283, 1213, 16669, 450, 291, 855, 533, 4914, 354, 3368, 339, 347, 965, 63, 1199, 8, 277, 304, 267, 408, 267, 1803, 715, 340, 2005, 3415, 3955, 506, 1072, 367, 642, 2457, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 965, 63, 1199, 342, 1083, 358, 339, 347, 3415, 8, 277, 12, 824, 304, 267, 408, 267, 1803, 3415, 10144, 370, 506, 1072, 315, 314, 1978, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 3415, 342, 1083, 358, 339, 347, 7594, 8, 277, 12, 1056, 12, 7594, 304, 267, 408, 267, 1803, 314, 9806, 7594, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 282, 7594, 342, 1083, 358, 339, 347, 1420, 63, 3214, 8, 277, 304, 267, 408, 267, 1803, 314, 769, 402, 2725, 1561, 626, 787, 1420, 687, 314, 267, 1056, 1159, 1827, 1059, 436, 626, 911, 506, 1202, 701, 642, 2457, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3820, 4131, 1471, 5647, 376, 1420, 63, 3214, 342, 1083, 358, 421, 199, 533, 5870, 24703, 8, 24703, 304, 272, 327, 710, 2725, 626, 1077, 506, 1202, 315, 314, 1827, 1059, 367, 626, 2457, 14, 272, 2725, 63, 354, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 304, 267, 1613, 8, 3184, 24703, 12, 291, 2843, 826, 721, 288, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 9, 267, 340, 291, 14, 5329, 63, 354, 365, 488, 26, 288, 746, 11897, 8, 355, 298, 1918, 769, 2457, 1543, 83, 7, 1630, 440, 4165, 298, 355, 298, 65, 283, 5329, 63, 354, 16669, 450, 291, 855, 533, 4914, 354, 3368, 267, 340, 291, 14, 5329, 63, 354, 315, 1862, 26, 288, 574, 275, 1862, 14, 1935, 8, 277, 14, 5329, 63, 354, 9, 288, 291, 14, 2972, 63, 3214, 59, 277, 14, 5329, 63, 354, 61, 275, 574, 267, 4237, 63, 4577, 275, 291, 14, 17438, 8, 1069, 12, 1402, 63, 2113, 9, 267, 340, 4237, 63, 4577, 365, 488, 26, 288, 4237, 63, 4577, 275, 6248, 267, 291, 14, 3892, 63, 4577, 275, 769, 8, 3892, 63, 4577, 9, 339, 347, 965, 63, 1199, 8, 277, 304, 267, 372, 822, 8, 277, 14, 3892, 63, 4577, 9, 690, 378, 339, 347, 574, 8, 277, 304, 267, 408, 267, 1803, 314, 574, 334, 262, 1059, 1475, 9, 2741, 315, 314, 1056, 1159, 267, 1827, 1059, 367, 642, 2457, 12, 340, 1263, 14, 982, 314, 574, 17373, 1133, 2741, 2066, 267, 2529, 488, 14, 267, 408, 267, 372, 291, 14, 2972, 63, 3214, 14, 362, 8, 277, 14, 5329, 63, 354, 9, 339, 347, 16807, 8, 277, 12, 1056, 12, 1402, 63, 2113, 304, 267, 408, 267, 9498, 506, 10087, 370, 372, 282, 769, 402, 6346, 334, 585, 12, 3376, 574, 9, 267, 408, 267, 746, 4279, 8, 288, 283, 1918, 5870, 24703, 14, 17438, 342, 1083, 1471, 506, 10087, 370, 283, 288, 283, 1107, 282, 769, 402, 6346, 334, 585, 12, 3376, 574, 5942, 339, 347, 1420, 63, 3214, 8, 277, 304, 267, 372, 359, 277, 14, 5329, 63, 354, 61, 339, 347, 3415, 8, 277, 12, 824, 304, 267, 1995, 469, 288, 283, 5511, 356, 291, 14, 585, 342, 365, 488, 12, 288, 283, 1131, 63, 875, 356, 824, 14, 362, 63, 1131, 63, 875, 16037, 359, 277, 14, 5329, 63, 354, 2522, 288, 283, 2918, 356, 4018, 2422, 659, 267, 789, 267, 367, 4237, 12, 2538, 315, 291, 14, 3892, 63, 4577, 26, 288, 1995, 469, 355, 283, 5511, 356, 291, 14, 585, 342, 508, 3542, 63, 505, 8, 3892, 395, 355, 283, 1131, 63, 875, 356, 824, 14, 362, 63, 1131, 63, 875, 2561, 490, 291, 14, 5329, 63, 354, 26, 4237, 12, 355, 1660, 14431, 355, 283, 2918, 356, 2538, 12, 288, 789, 421, 199, 533, 5024, 24703, 8, 24703, 304, 272, 485, 698, 63, 513, 63, 4273, 275, 942, 272, 485, 11066, 63, 6693, 63, 1080, 275, 378, 339, 347, 636, 826, 721, 277, 12, 901, 12, 1056, 12, 1862, 12, 1402, 12, 1402, 63, 2113, 12, 901, 63, 515, 304, 267, 291, 14, 698, 275, 901, 267, 291, 14, 698, 63, 515, 275, 901, 63, 515, 267, 291, 14, 1213, 275, 2519, 8, 698, 12, 283, 3832, 63, 354, 297, 901, 63, 515, 9, 267, 1613, 8, 792, 24703, 12, 291, 2843, 826, 721, 288, 1056, 12, 1862, 12, 1402, 12, 1402, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
theintencity/flash-videoio
examples/django-apps/project/experts/models.py
1
3541
import datetime from google.appengine.api import users from google.appengine.ext import db class User(db.Model): name = db.StringProperty('Full Name') account = db.UserProperty() phone_number = db.PhoneNumberProperty('Phone Number') address = db.PostalAddressProperty('Postal Address') website = db.StringProperty('Homepage URL') description = db.TextProperty('Brief Biography') rating = db.FloatProperty(default=0.0) rating_count = db.IntegerProperty(default=0) tags = db.StringListProperty('Expertise, one per line', default=None) availability = db.TextProperty('Availability', default='Available by appointment on weekdays in PST timezone') has_chat = db.BooleanProperty('Use Google Chat', default=False) def email(self): result = self.account.nickname() if self.account else '' return (result + '@gmail.com') if result and '@' not in result else result def get_current_user(): account = users.get_current_user() if account: user = db.GqlQuery('SELECT * FROM User WHERE account = :1', account).get() if not user: user = User(name='', account=account) user.put() user.is_active = True user.is_staff = users.is_current_user_admin() else: user = User() user.is_active = False return user class Tag(db.Model): name = db.StringProperty(required=True) count = db.IntegerProperty(default=1) class Event(db.Model): subject = db.StringProperty() description = db.TextProperty() owner = db.StringProperty() visitor = db.StringProperty() start_time = db.DateTimeProperty() end_time = db.DateTimeProperty() created_on = db.DateTimeProperty(auto_now_add=True) class Review(db.Model): event = db.ReferenceProperty(Event, collection_name='event_set') # TODO make required=True for_user = db.ReferenceProperty(User, required=True, collection_name='for_user_set') by_user = db.ReferenceProperty(User, required=True, collection_name='by_user_set') rating = db.IntegerProperty(default=3) description = db.TextProperty() modified_on = db.DateTimeProperty(auto_now=True) class ClientStream(db.Model): clientId = db.StringProperty(required=True) visitor = db.StringProperty() name = db.StringProperty(default='Anonymous') publish = db.StringProperty(required=True) play = db.StringProperty() is_owner = db.BooleanProperty(default=False) owner = db.StringProperty(required=True) modified_on = db.DateTimeProperty(auto_now=True) created_on = db.DateTimeProperty(auto_now_add=True) def __repr__(self): return '<ClientStream clientId=%r visitor=%r name=%r is_owner=%r owner=%r />'%(self.clientId, self.visitor, self.name, self.is_owner, self.owner) def get_object(self, full=True): if full: return {'clientId': self.clientId, 'name': self.name, 'url': self.publish} else: return {'clientId': self.clientId} class OfflineMessage(db.Model): sender = db.StringProperty() senderName = db.StringProperty() receiver = db.StringProperty() text = db.StringProperty(multiline=True) created_on = db.DateTimeProperty(auto_now_add=True) def __repr__(self): return '<OfflineMessage sender=%r senderName=%r receiver=%r text=%r />'%(self.sender, self.senderName, self.receiver, self.text) def get_object(self): return {'senderName': self.senderName, 'text': self.text}
lgpl-3.0
[ 646, 2197, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 199, 533, 2876, 8, 697, 14, 1685, 304, 272, 536, 275, 1592, 14, 31821, 360, 9042, 2812, 358, 272, 2933, 275, 1592, 14, 1899, 3697, 342, 272, 14617, 63, 1955, 275, 1592, 14, 25640, 3697, 360, 15199, 4860, 358, 272, 2287, 275, 1592, 14, 6564, 279, 1476, 3697, 360, 6564, 279, 9906, 358, 272, 10691, 275, 1592, 14, 31821, 360, 12054, 1606, 2851, 358, 272, 1369, 275, 1592, 14, 1872, 3697, 360, 34, 322, 2829, 699, 2308, 9773, 358, 272, 18360, 275, 1592, 14, 5136, 3697, 8, 885, 29, 16, 14, 16, 9, 272, 18360, 63, 835, 275, 1592, 14, 2674, 3697, 8, 885, 29, 16, 9, 272, 3762, 275, 1592, 14, 32216, 3697, 360, 920, 529, 280, 261, 12, 1373, 1126, 1004, 297, 849, 29, 403, 9, 272, 14962, 275, 1592, 14, 1872, 3697, 360, 26462, 297, 849, 534, 11464, 701, 2771, 29594, 641, 8620, 4899, 315, 510, 840, 7137, 358, 272, 965, 63, 10289, 275, 1592, 14, 4082, 3697, 360, 6119, 4475, 2799, 292, 297, 849, 29, 797, 9, 2286, 347, 3031, 8, 277, 304, 267, 754, 275, 291, 14, 2048, 14, 18544, 342, 340, 291, 14, 2048, 587, 2125, 267, 372, 334, 1099, 435, 10267, 6799, 14, 957, 358, 340, 754, 436, 22143, 440, 315, 754, 587, 754, 199, 199, 318, 664, 63, 1818, 63, 751, 837, 272, 2933, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 272, 340, 2933, 26, 267, 922, 275, 1592, 14, 39, 1710, 3227, 360, 4859, 627, 4442, 2876, 6038, 2933, 275, 520, 17, 297, 2933, 680, 362, 342, 267, 340, 440, 922, 26, 288, 922, 275, 2876, 8, 354, 4581, 2933, 29, 2048, 9, 288, 922, 14, 524, 342, 267, 922, 14, 374, 63, 2682, 275, 715, 267, 922, 14, 374, 63, 7018, 275, 4390, 14, 374, 63, 1818, 63, 751, 63, 2113, 342, 272, 587, 26, 267, 922, 275, 2876, 342, 267, 922, 14, 374, 63, 2682, 275, 756, 272, 372, 922, 199, 199, 533, 8053, 8, 697, 14, 1685, 304, 272, 536, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 2338, 275, 1592, 14, 2674, 3697, 8, 885, 29, 17, 9, 1362, 199, 533, 6763, 8, 697, 14, 1685, 304, 272, 5420, 275, 1592, 14, 31821, 342, 272, 1369, 275, 1592, 14, 1872, 3697, 342, 272, 5771, 275, 1592, 14, 31821, 342, 272, 18040, 275, 1592, 14, 31821, 342, 272, 1343, 63, 521, 275, 1592, 14, 3926, 3697, 342, 272, 1284, 63, 521, 275, 1592, 14, 3926, 3697, 342, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 199, 199, 533, 26705, 8, 697, 14, 1685, 304, 272, 1566, 275, 1592, 14, 5083, 3697, 8, 2390, 12, 3245, 63, 354, 534, 1430, 63, 409, 358, 327, 3254, 1852, 1415, 29, 549, 272, 367, 63, 751, 275, 1592, 14, 5083, 3697, 8, 1899, 12, 1415, 29, 549, 12, 3245, 63, 354, 534, 509, 63, 751, 63, 409, 358, 272, 701, 63, 751, 275, 1592, 14, 5083, 3697, 8, 1899, 12, 1415, 29, 549, 12, 3245, 63, 354, 534, 991, 63, 751, 63, 409, 358, 272, 18360, 275, 1592, 14, 2674, 3697, 8, 885, 29, 19, 9, 272, 1369, 275, 1592, 14, 1872, 3697, 342, 272, 6042, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 29, 549, 9, 199, 199, 533, 6810, 3296, 8, 697, 14, 1685, 304, 272, 1890, 1304, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 18040, 275, 1592, 14, 31821, 342, 272, 536, 275, 1592, 14, 31821, 8, 885, 534, 23902, 358, 2286, 2780, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 5232, 275, 1592, 14, 31821, 342, 339, 365, 63, 4597, 275, 1592, 14, 4082, 3697, 8, 885, 29, 797, 9, 272, 5771, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 2286, 6042, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 29, 549, 9, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 2286, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3041, 3296, 1890, 1304, 2458, 82, 18040, 2458, 82, 536, 2458, 82, 365, 63, 4597, 2458, 82, 5771, 2458, 82, 22294, 2840, 277, 14, 1258, 1304, 12, 291, 14, 19863, 12, 291, 14, 354, 12, 291, 14, 374, 63, 4597, 12, 291, 14, 4597, 9, 2286, 347, 664, 63, 785, 8, 277, 12, 2615, 29, 549, 304, 267, 340, 2615, 26, 288, 372, 791, 1258, 1304, 356, 291, 14, 1258, 1304, 12, 283, 354, 356, 291, 14, 354, 12, 283, 633, 356, 291, 14, 4763, 93, 267, 587, 26, 288, 372, 791, 1258, 1304, 356, 291, 14, 1258, 1304, 93, 199, 199, 533, 28856, 604, 2209, 8, 697, 14, 1685, 304, 272, 8904, 275, 1592, 14, 31821, 342, 272, 8904, 985, 275, 1592, 14, 31821, 342, 272, 13035, 275, 1592, 14, 31821, 342, 272, 1318, 275, 1592, 14, 31821, 8, 21108, 29, 549, 9, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 2286, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 5195, 604, 2209, 8904, 2458, 82, 8904, 985, 2458, 82, 13035, 2458, 82, 1318, 2458, 82, 22294, 2840, 277, 14, 8114, 12, 291, 14, 8114, 985, 12, 291, 14, 10244, 12, 291, 14, 505, 9, 272, 347, 664, 63, 785, 8, 277, 304, 267, 372, 791, 8114, 985, 356, 291, 14, 8114, 985, 12, 283, 505, 356, 291, 14, 505, 93, 489, 26339, 1362, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4390, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 199, 533, 2876, 8, 697, 14, 1685, 304, 272, 536, 275, 1592, 14, 31821, 360, 9042, 2812, 358, 272, 2933, 275, 1592, 14, 1899, 3697, 342, 272, 14617, 63, 1955, 275, 1592, 14, 25640, 3697, 360, 15199, 4860, 358, 272, 2287, 275, 1592, 14, 6564, 279, 1476, 3697, 360, 6564, 279, 9906, 358, 272, 10691, 275, 1592, 14, 31821, 360, 12054, 1606, 2851, 358, 272, 1369, 275, 1592, 14, 1872, 3697, 360, 34, 322, 2829, 699, 2308, 9773, 358, 272, 18360, 275, 1592, 14, 5136, 3697, 8, 885, 29, 16, 14, 16, 9, 272, 18360, 63, 835, 275, 1592, 14, 2674, 3697, 8, 885, 29, 16, 9, 272, 3762, 275, 1592, 14, 32216, 3697, 360, 920, 529, 280, 261, 12, 1373, 1126, 1004, 297, 849, 29, 403, 9, 272, 14962, 275, 1592, 14, 1872, 3697, 360, 26462, 297, 849, 534, 11464, 701, 2771, 29594, 641, 8620, 4899, 315, 510, 840, 7137, 358, 272, 965, 63, 10289, 275, 1592, 14, 4082, 3697, 360, 6119, 4475, 2799, 292, 297, 849, 29, 797, 9, 2286, 347, 3031, 8, 277, 304, 267, 754, 275, 291, 14, 2048, 14, 18544, 342, 340, 291, 14, 2048, 587, 2125, 267, 372, 334, 1099, 435, 10267, 6799, 14, 957, 358, 340, 754, 436, 22143, 440, 315, 754, 587, 754, 199, 199, 318, 664, 63, 1818, 63, 751, 837, 272, 2933, 275, 4390, 14, 362, 63, 1818, 63, 751, 342, 272, 340, 2933, 26, 267, 922, 275, 1592, 14, 39, 1710, 3227, 360, 4859, 627, 4442, 2876, 6038, 2933, 275, 520, 17, 297, 2933, 680, 362, 342, 267, 340, 440, 922, 26, 288, 922, 275, 2876, 8, 354, 4581, 2933, 29, 2048, 9, 288, 922, 14, 524, 342, 267, 922, 14, 374, 63, 2682, 275, 715, 267, 922, 14, 374, 63, 7018, 275, 4390, 14, 374, 63, 1818, 63, 751, 63, 2113, 342, 272, 587, 26, 267, 922, 275, 2876, 342, 267, 922, 14, 374, 63, 2682, 275, 756, 272, 372, 922, 199, 199, 533, 8053, 8, 697, 14, 1685, 304, 272, 536, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 2338, 275, 1592, 14, 2674, 3697, 8, 885, 29, 17, 9, 1362, 199, 533, 6763, 8, 697, 14, 1685, 304, 272, 5420, 275, 1592, 14, 31821, 342, 272, 1369, 275, 1592, 14, 1872, 3697, 342, 272, 5771, 275, 1592, 14, 31821, 342, 272, 18040, 275, 1592, 14, 31821, 342, 272, 1343, 63, 521, 275, 1592, 14, 3926, 3697, 342, 272, 1284, 63, 521, 275, 1592, 14, 3926, 3697, 342, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 199, 199, 533, 26705, 8, 697, 14, 1685, 304, 272, 1566, 275, 1592, 14, 5083, 3697, 8, 2390, 12, 3245, 63, 354, 534, 1430, 63, 409, 358, 327, 3254, 1852, 1415, 29, 549, 272, 367, 63, 751, 275, 1592, 14, 5083, 3697, 8, 1899, 12, 1415, 29, 549, 12, 3245, 63, 354, 534, 509, 63, 751, 63, 409, 358, 272, 701, 63, 751, 275, 1592, 14, 5083, 3697, 8, 1899, 12, 1415, 29, 549, 12, 3245, 63, 354, 534, 991, 63, 751, 63, 409, 358, 272, 18360, 275, 1592, 14, 2674, 3697, 8, 885, 29, 19, 9, 272, 1369, 275, 1592, 14, 1872, 3697, 342, 272, 6042, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 29, 549, 9, 199, 199, 533, 6810, 3296, 8, 697, 14, 1685, 304, 272, 1890, 1304, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 18040, 275, 1592, 14, 31821, 342, 272, 536, 275, 1592, 14, 31821, 8, 885, 534, 23902, 358, 2286, 2780, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 272, 5232, 275, 1592, 14, 31821, 342, 339, 365, 63, 4597, 275, 1592, 14, 4082, 3697, 8, 885, 29, 797, 9, 272, 5771, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 2286, 6042, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 29, 549, 9, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 2286, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3041, 3296, 1890, 1304, 2458, 82, 18040, 2458, 82, 536, 2458, 82, 365, 63, 4597, 2458, 82, 5771, 2458, 82, 22294, 2840, 277, 14, 1258, 1304, 12, 291, 14, 19863, 12, 291, 14, 354, 12, 291, 14, 374, 63, 4597, 12, 291, 14, 4597, 9, 2286, 347, 664, 63, 785, 8, 277, 12, 2615, 29, 549, 304, 267, 340, 2615, 26, 288, 372, 791, 1258, 1304, 356, 291, 14, 1258, 1304, 12, 283, 354, 356, 291, 14, 354, 12, 283, 633, 356, 291, 14, 4763, 93, 267, 587, 26, 288, 372, 791, 1258, 1304, 356, 291, 14, 1258, 1304, 93, 199, 199, 533, 28856, 604, 2209, 8, 697, 14, 1685, 304, 272, 8904, 275, 1592, 14, 31821, 342, 272, 8904, 985, 275, 1592, 14, 31821, 342, 272, 13035, 275, 1592, 14, 31821, 342, 272, 1318, 275, 1592, 14, 31821, 8, 21108, 29, 549, 9, 272, 2737, 63, 265, 275, 1592, 14, 3926, 3697, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 2286, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 5195, 604, 2209, 8904, 2458, 82, 8904, 985, 2458, 82, 13035, 2458, 82, 1318, 2458, 82, 22294, 2840, 277, 14, 8114, 12, 291, 14, 8114, 985, 12, 291, 14, 10244, 12, 291, 14, 505, 9, 272, 347, 664, 63, 785, 8, 277, 304, 267, 372, 791, 8114, 985, 356, 291, 14, 8114, 985, 12, 283, 505, 356, 291, 14, 505, 93, 489, 26339, 1362, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
valaxy/robotframework-selenium2library
demo/package.py
64
1359
#!/usr/bin/env python import os, sys from time import localtime from zipfile import ZipFile, ZIP_DEFLATED THIS_DIR = os.path.dirname(os.path.abspath(__file__)) execfile(os.path.join(THIS_DIR, '..', 'src', 'Selenium2Library', 'version.py')) FILES = { '': ['rundemo.py'], 'login_tests': ['valid_login.txt', 'invalid_login.txt', 'resource.txt'], 'demoapp': ['server.py'], 'demoapp/html': ['index.html', 'welcome.html', 'error.html', 'demo.css'] } def main(): cwd = os.getcwd() try: os.chdir(THIS_DIR) name = 'robotframework-selenium2library-%s-demo' % VERSION zipname = '%s.zip' % name if os.path.exists(zipname): os.remove(zipname) zipfile = ZipFile(zipname, 'w', ZIP_DEFLATED) for dirname in FILES: for filename in FILES[dirname]: path = os.path.join('.', dirname.replace('/', os.sep), filename) print 'Adding: ', os.path.normpath(path) zipfile.write(path, os.path.join(name, path)) zipfile.close() target_path = os.path.join('..', 'dist', zipname) if os.path.exists(target_path): os.remove(target_path) os.rename(zipname, target_path) print 'Created: ', os.path.abspath(target_path) finally: os.chdir(cwd) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 12, 984, 199, 504, 900, 492, 2257, 521, 199, 504, 10392, 492, 26755, 12, 18402, 63, 28506, 199, 199, 24571, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 24571, 63, 3022, 12, 19155, 283, 2164, 297, 283, 31315, 18, 7424, 297, 283, 1023, 14, 647, 1333, 199, 199, 9472, 275, 469, 272, 8061, 788, 1065, 8768, 14, 647, 995, 272, 283, 2886, 63, 2219, 356, 788, 1078, 63, 2886, 14, 2424, 297, 283, 3197, 63, 2886, 14, 2424, 297, 283, 1927, 14, 2424, 995, 272, 283, 8768, 571, 356, 788, 1000, 14, 647, 995, 272, 283, 8768, 571, 15, 1360, 356, 788, 1080, 14, 1360, 297, 283, 28508, 14, 1360, 297, 283, 705, 14, 1360, 297, 283, 8768, 14, 3919, 418, 199, 93, 199, 199, 318, 2446, 837, 272, 8288, 275, 747, 14, 9458, 342, 272, 862, 26, 267, 747, 14, 8563, 8, 24571, 63, 3022, 9, 267, 536, 275, 283, 9751, 4857, 13, 15041, 18, 4342, 3295, 83, 13, 8768, 7, 450, 15945, 267, 3482, 354, 275, 1543, 83, 14, 3065, 7, 450, 536, 267, 340, 747, 14, 515, 14, 2444, 8, 3065, 354, 304, 288, 747, 14, 2168, 8, 3065, 354, 9, 267, 10392, 275, 26755, 8, 3065, 354, 12, 283, 87, 297, 18402, 63, 28506, 9, 267, 367, 9017, 315, 16444, 654, 26, 288, 367, 1788, 315, 16444, 654, 59, 3475, 2189, 355, 931, 275, 747, 14, 515, 14, 904, 14078, 9017, 14, 1814, 10998, 747, 14, 4127, 395, 1788, 9, 355, 870, 283, 20897, 26, 221, 1656, 747, 14, 515, 14, 9267, 8, 515, 9, 355, 10392, 14, 952, 8, 515, 12, 747, 14, 515, 14, 904, 8, 354, 12, 931, 430, 267, 10392, 14, 1600, 342, 267, 1347, 63, 515, 275, 747, 14, 515, 14, 904, 24893, 297, 283, 2686, 297, 3482, 354, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 1375, 63, 515, 304, 288, 747, 14, 2168, 8, 1375, 63, 515, 9, 267, 747, 14, 8165, 8, 3065, 354, 12, 1347, 63, 515, 9, 267, 870, 283, 10502, 26, 1656, 747, 14, 515, 14, 4832, 8, 1375, 63, 515, 9, 272, 3753, 26, 267, 747, 14, 8563, 8, 6525, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 12, 984, 199, 504, 900, 492, 2257, 521, 199, 504, 10392, 492, 26755, 12, 18402, 63, 28506, 199, 199, 24571, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 1628, 493, 8, 736, 14, 515, 14, 904, 8, 24571, 63, 3022, 12, 19155, 283, 2164, 297, 283, 31315, 18, 7424, 297, 283, 1023, 14, 647, 1333, 199, 199, 9472, 275, 469, 272, 8061, 788, 1065, 8768, 14, 647, 995, 272, 283, 2886, 63, 2219, 356, 788, 1078, 63, 2886, 14, 2424, 297, 283, 3197, 63, 2886, 14, 2424, 297, 283, 1927, 14, 2424, 995, 272, 283, 8768, 571, 356, 788, 1000, 14, 647, 995, 272, 283, 8768, 571, 15, 1360, 356, 788, 1080, 14, 1360, 297, 283, 28508, 14, 1360, 297, 283, 705, 14, 1360, 297, 283, 8768, 14, 3919, 418, 199, 93, 199, 199, 318, 2446, 837, 272, 8288, 275, 747, 14, 9458, 342, 272, 862, 26, 267, 747, 14, 8563, 8, 24571, 63, 3022, 9, 267, 536, 275, 283, 9751, 4857, 13, 15041, 18, 4342, 3295, 83, 13, 8768, 7, 450, 15945, 267, 3482, 354, 275, 1543, 83, 14, 3065, 7, 450, 536, 267, 340, 747, 14, 515, 14, 2444, 8, 3065, 354, 304, 288, 747, 14, 2168, 8, 3065, 354, 9, 267, 10392, 275, 26755, 8, 3065, 354, 12, 283, 87, 297, 18402, 63, 28506, 9, 267, 367, 9017, 315, 16444, 654, 26, 288, 367, 1788, 315, 16444, 654, 59, 3475, 2189, 355, 931, 275, 747, 14, 515, 14, 904, 14078, 9017, 14, 1814, 10998, 747, 14, 4127, 395, 1788, 9, 355, 870, 283, 20897, 26, 221, 1656, 747, 14, 515, 14, 9267, 8, 515, 9, 355, 10392, 14, 952, 8, 515, 12, 747, 14, 515, 14, 904, 8, 354, 12, 931, 430, 267, 10392, 14, 1600, 342, 267, 1347, 63, 515, 275, 747, 14, 515, 14, 904, 24893, 297, 283, 2686, 297, 3482, 354, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 1375, 63, 515, 304, 288, 747, 14, 2168, 8, 1375, 63, 515, 9, 267, 747, 14, 8165, 8, 3065, 354, 12, 1347, 63, 515, 9, 267, 870, 283, 10502, 26, 1656, 747, 14, 515, 14, 4832, 8, 1375, 63, 515, 9, 272, 3753, 26, 267, 747, 14, 8563, 8, 6525, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
thesilencelies/SonnetConvs
InceptionModule.py
1
1790
#implimentation of the standard inceptionnet v3 inception module in sonnet import tensorflow as tf import sonnet as snt class InceptionModule(snt.AbstractModule): def __init__(self, output_channels, name="inception_module"): super(InceptionModule, self).__init__(name=name) self._output_channels = output_channels def _build(self, inputs): reshapeFlat = lambda x : tf.contrib.layers.flatten(x) conv1d5 = snt.Conv2D(output_channels=self._output_channels, kernel_shape=1, stride=1,name="inception5input") conv1d3 = snt.Conv2D(output_channels=self._output_channels, kernel_shape=1, stride=1,name="inception3input") conv1dm = snt.Conv2D(output_channels=self._output_channels, kernel_shape=1, stride=1,name="inceptionpoolinput") conv1d1 = snt.Conv2D(output_channels=self._output_channels, kernel_shape=1, stride=1,name="inception1channel") conv3d5a = snt.Conv2D(output_channels=self._output_channels, kernel_shape=3, stride=1,name="inception5stage1") conv3d5b = snt.Conv2D(output_channels=self._output_channels, kernel_shape=3, stride=1,name="inception5stage2") conv3d3 = snt.Conv2D(output_channels=self._output_channels, kernel_shape=3, stride=1,name="inception3channel") maxpool = lambda x : tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') return tf.concat([reshapeFlat(conv3d5b(conv3d5a(conv1d5(inputs)))), reshapeFlat(conv3d3(conv1d3(inputs))), reshapeFlat(maxpool(conv1dm(inputs))), reshapeFlat(conv1d1(inputs))],1) # then connect it.
apache-2.0
[ 3, 3236, 317, 3117, 402, 314, 4465, 315, 814, 846, 373, 19, 315, 814, 859, 315, 27970, 846, 199, 646, 3228, 465, 2833, 199, 646, 27970, 846, 465, 308, 343, 421, 199, 533, 1010, 814, 2377, 8, 83, 343, 14, 8458, 2377, 304, 523, 347, 636, 826, 721, 277, 12, 1072, 63, 6324, 12, 536, 628, 262, 814, 63, 578, 2349, 272, 1613, 8, 607, 814, 2377, 12, 291, 2843, 826, 721, 354, 29, 354, 9, 272, 291, 423, 1199, 63, 6324, 275, 1072, 63, 6324, 819, 347, 485, 1506, 8, 277, 12, 4153, 304, 272, 21460, 17271, 275, 2400, 671, 520, 2833, 14, 2828, 14, 4359, 14, 8487, 8, 88, 9, 339, 8260, 17, 68, 21, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 1210, 531, 339, 8260, 17, 68, 19, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 19, 1210, 531, 339, 8260, 17, 6428, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 2293, 1210, 531, 339, 8260, 17, 68, 17, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 17, 2775, 531, 339, 8260, 19, 68, 21, 65, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 8614, 17, 531, 339, 8260, 19, 68, 21, 66, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 8614, 18, 531, 339, 8260, 19, 68, 19, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 19, 2775, 531, 339, 1390, 2293, 275, 2400, 671, 520, 2833, 14, 4411, 14, 988, 63, 2293, 8, 88, 12, 30180, 1524, 17, 12, 499, 12, 499, 12, 413, 467, 717, 11883, 1524, 17, 12, 499, 12, 499, 12, 413, 467, 6273, 534, 19935, 358, 272, 372, 2833, 14, 9419, 779, 5217, 17271, 8, 5598, 19, 68, 21, 66, 8, 5598, 19, 68, 21, 65, 8, 5598, 17, 68, 21, 8, 3711, 1724, 395, 2151, 21460, 17271, 8, 5598, 19, 68, 19, 8, 5598, 17, 68, 19, 8, 3711, 11508, 2151, 21460, 17271, 8, 988, 2293, 8, 5598, 17, 6428, 8, 3711, 11508, 2151, 21460, 17271, 8, 5598, 17, 68, 17, 8, 3711, 25106, 17, 9, 3515, 327, 2066, 4907, 652, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3236, 317, 3117, 402, 314, 4465, 315, 814, 846, 373, 19, 315, 814, 859, 315, 27970, 846, 199, 646, 3228, 465, 2833, 199, 646, 27970, 846, 465, 308, 343, 421, 199, 533, 1010, 814, 2377, 8, 83, 343, 14, 8458, 2377, 304, 523, 347, 636, 826, 721, 277, 12, 1072, 63, 6324, 12, 536, 628, 262, 814, 63, 578, 2349, 272, 1613, 8, 607, 814, 2377, 12, 291, 2843, 826, 721, 354, 29, 354, 9, 272, 291, 423, 1199, 63, 6324, 275, 1072, 63, 6324, 819, 347, 485, 1506, 8, 277, 12, 4153, 304, 272, 21460, 17271, 275, 2400, 671, 520, 2833, 14, 2828, 14, 4359, 14, 8487, 8, 88, 9, 339, 8260, 17, 68, 21, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 1210, 531, 339, 8260, 17, 68, 19, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 19, 1210, 531, 339, 8260, 17, 6428, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 2293, 1210, 531, 339, 8260, 17, 68, 17, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 17, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 17, 2775, 531, 339, 8260, 19, 68, 21, 65, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 8614, 17, 531, 339, 8260, 19, 68, 21, 66, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 21, 8614, 18, 531, 339, 8260, 19, 68, 19, 275, 308, 343, 14, 11596, 18, 36, 8, 1199, 63, 6324, 29, 277, 423, 1199, 63, 6324, 12, 5114, 63, 1392, 29, 19, 12, 717, 7345, 29, 17, 12, 354, 628, 262, 814, 19, 2775, 531, 339, 1390, 2293, 275, 2400, 671, 520, 2833, 14, 4411, 14, 988, 63, 2293, 8, 88, 12, 30180, 1524, 17, 12, 499, 12, 499, 12, 413, 467, 717, 11883, 1524, 17, 12, 499, 12, 499, 12, 413, 467, 6273, 534, 19935, 358, 272, 372, 2833, 14, 9419, 779, 5217, 17271, 8, 5598, 19, 68, 21, 66, 8, 5598, 19, 68, 21, 65, 8, 5598, 17, 68, 21, 8, 3711, 1724, 395, 2151, 21460, 17271, 8, 5598, 19, 68, 19, 8, 5598, 17, 68, 19, 8, 3711, 11508, 2151, 21460, 17271, 8, 988, 2293, 8, 5598, 17, 6428, 8, 3711, 11508, 2151, 21460, 17271, 8, 5598, 17, 68, 17, 8, 3711, 25106, 17, 9, 3515, 327, 2066, 4907, 652, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
github-account-because-they-want-it/django
django/contrib/gis/forms/fields.py
504
4316
from __future__ import unicode_literals from django import forms from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.utils.translation import ugettext_lazy as _ from .widgets import OpenLayersWidget class GeometryField(forms.Field): """ This is the basic form field for a Geometry. Any textual input that is accepted by GEOSGeometry is accepted by this form. By default, this includes WKT, HEXEWKB, WKB (in a buffer), and GeoJSON. """ widget = OpenLayersWidget geom_type = 'GEOMETRY' default_error_messages = { 'required': _('No geometry value provided.'), 'invalid_geom': _('Invalid geometry value.'), 'invalid_geom_type': _('Invalid geometry type.'), 'transform_error': _('An error occurred when transforming the geometry ' 'to the SRID of the geometry form field.'), } def __init__(self, **kwargs): # Pop out attributes from the database field, or use sensible # defaults (e.g., allow None). self.srid = kwargs.pop('srid', None) self.geom_type = kwargs.pop('geom_type', self.geom_type) super(GeometryField, self).__init__(**kwargs) self.widget.attrs['geom_type'] = self.geom_type def to_python(self, value): """ Transforms the value to a Geometry object. """ if value in self.empty_values: return None if not isinstance(value, GEOSGeometry): try: value = GEOSGeometry(value) except (GEOSException, ValueError, TypeError): raise forms.ValidationError(self.error_messages['invalid_geom'], code='invalid_geom') # Try to set the srid if not value.srid: try: value.srid = self.widget.map_srid except AttributeError: if self.srid: value.srid = self.srid return value def clean(self, value): """ Validates that the input value can be converted to a Geometry object (which is returned). A ValidationError is raised if the value cannot be instantiated as a Geometry. """ geom = super(GeometryField, self).clean(value) if geom is None: return geom # Ensuring that the geometry is of the correct type (indicated # using the OGC string label). if str(geom.geom_type).upper() != self.geom_type and not self.geom_type == 'GEOMETRY': raise forms.ValidationError(self.error_messages['invalid_geom_type'], code='invalid_geom_type') # Transforming the geometry if the SRID was set. if self.srid and self.srid != -1 and self.srid != geom.srid: try: geom.transform(self.srid) except GEOSException: raise forms.ValidationError( self.error_messages['transform_error'], code='transform_error') return geom def has_changed(self, initial, data): """ Compare geographic value of data with its initial value. """ try: data = self.to_python(data) initial = self.to_python(initial) except forms.ValidationError: return True # Only do a geographic comparison if both values are available if initial and data: data.transform(initial.srid) # If the initial value was not added by the browser, the geometry # provided may be slightly different, the first time it is saved. # The comparison is done with a very low tolerance. return not initial.equals_exact(data, tolerance=0.000001) else: # Check for change of state of existence return bool(initial) != bool(data) class GeometryCollectionField(GeometryField): geom_type = 'GEOMETRYCOLLECTION' class PointField(GeometryField): geom_type = 'POINT' class MultiPointField(GeometryField): geom_type = 'MULTIPOINT' class LineStringField(GeometryField): geom_type = 'LINESTRING' class MultiLineStringField(GeometryField): geom_type = 'MULTILINESTRING' class PolygonField(GeometryField): geom_type = 'POLYGON' class MultiPolygonField(GeometryField): geom_type = 'MULTIPOLYGON'
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21390, 21686, 12, 21479, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 1275, 8583, 492, 3232, 16862, 3339, 421, 199, 533, 30490, 8, 3351, 14, 792, 304, 272, 408, 272, 961, 365, 314, 5678, 1824, 901, 367, 282, 10579, 14, 221, 6184, 25884, 1324, 626, 365, 272, 10226, 701, 21479, 365, 10226, 701, 642, 1824, 14, 221, 4885, 849, 12, 272, 642, 6952, 22561, 12, 869, 23017, 28328, 12, 644, 12780, 334, 262, 282, 3335, 395, 436, 8875, 6243, 14, 272, 408, 272, 3938, 275, 3232, 16862, 3339, 272, 9671, 63, 466, 275, 283, 28472, 7, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 2427, 356, 4018, 1944, 3400, 574, 2741, 8038, 267, 283, 3197, 63, 6481, 356, 4018, 3364, 3400, 574, 8038, 267, 283, 3197, 63, 6481, 63, 466, 356, 4018, 3364, 3400, 730, 8038, 267, 283, 4711, 63, 705, 356, 4018, 2493, 1125, 8920, 1380, 5793, 316, 314, 3400, 283, 2490, 283, 475, 314, 22425, 402, 314, 3400, 1824, 901, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 327, 13244, 734, 3004, 687, 314, 3050, 901, 12, 503, 675, 27962, 267, 327, 4243, 334, 69, 14, 71, 2020, 2040, 488, 680, 267, 291, 14, 10498, 275, 2074, 14, 1935, 360, 10498, 297, 488, 9, 267, 291, 14, 6481, 63, 466, 275, 2074, 14, 1935, 360, 6481, 63, 466, 297, 291, 14, 6481, 63, 466, 9, 267, 1613, 8, 6831, 792, 12, 291, 2843, 826, 14155, 958, 9, 267, 291, 14, 3440, 14, 3288, 459, 6481, 63, 466, 418, 275, 291, 14, 6481, 63, 466, 339, 347, 370, 63, 1548, 8, 277, 12, 574, 304, 267, 408, 267, 6266, 3351, 314, 574, 370, 282, 10579, 909, 14, 267, 408, 267, 340, 574, 315, 291, 14, 1667, 63, 1459, 26, 288, 372, 488, 398, 340, 440, 1228, 8, 585, 12, 21479, 304, 288, 862, 26, 355, 574, 275, 21479, 8, 585, 9, 288, 871, 334, 18120, 21686, 12, 1722, 12, 3146, 304, 355, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 63, 6481, 995, 1233, 534, 3197, 63, 6481, 358, 398, 327, 7649, 370, 663, 314, 15627, 267, 340, 440, 574, 14, 10498, 26, 288, 862, 26, 355, 574, 14, 10498, 275, 291, 14, 3440, 14, 1130, 63, 10498, 288, 871, 4281, 26, 355, 340, 291, 14, 10498, 26, 490, 574, 14, 10498, 275, 291, 14, 10498, 267, 372, 574, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 4821, 2335, 626, 314, 1324, 574, 883, 506, 6702, 370, 282, 10579, 267, 909, 334, 6777, 365, 2138, 680, 221, 437, 8505, 365, 4915, 340, 267, 314, 574, 3913, 506, 17544, 465, 282, 10579, 14, 267, 408, 267, 9671, 275, 1613, 8, 6831, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 9671, 365, 488, 26, 288, 372, 9671, 398, 327, 23312, 4039, 626, 314, 3400, 365, 402, 314, 3211, 730, 334, 3558, 3153, 267, 327, 1808, 314, 593, 7484, 1059, 1768, 680, 267, 340, 620, 8, 6481, 14, 6481, 63, 466, 680, 4142, 342, 1137, 291, 14, 6481, 63, 466, 436, 440, 291, 14, 6481, 63, 466, 508, 283, 28472, 356, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 63, 6481, 63, 466, 995, 1233, 534, 3197, 63, 6481, 63, 466, 358, 398, 327, 19463, 316, 314, 3400, 340, 314, 22425, 1990, 663, 14, 267, 340, 291, 14, 10498, 436, 291, 14, 10498, 1137, 446, 17, 436, 291, 14, 10498, 1137, 9671, 14, 10498, 26, 288, 862, 26, 355, 9671, 14, 4711, 8, 277, 14, 10498, 9, 288, 871, 21390, 21686, 26, 355, 746, 4513, 14, 8172, 8, 490, 291, 14, 705, 63, 3431, 459, 4711, 63, 705, 995, 1233, 534, 4711, 63, 705, 358, 398, 372, 9671, 339, 347, 965, 63, 2489, 8, 277, 12, 2536, 12, 666, 304, 267, 408, 18955, 25637, 574, 402, 666, 543, 2399, 2536, 574, 14, 408, 398, 862, 26, 288, 666, 275, 291, 14, 475, 63, 1548, 8, 576, 9, 288, 2536, 275, 291, 14, 475, 63, 1548, 8, 2747, 9, 267, 871, 4513, 14, 8172, 26, 288, 372, 715, 398, 327, 5972, 886, 282, 25637, 9132, 340, 3865, 1338, 787, 2808, 267, 340, 2536, 436, 666, 26, 288, 666, 14, 4711, 8, 2747, 14, 10498, 9, 288, 327, 982, 314, 2536, 574, 1990, 440, 3483, 701, 314, 7042, 12, 314, 3400, 288, 327, 2741, 1443, 506, 18023, 3365, 12, 314, 1642, 900, 652, 365, 6290, 14, 288, 327, 710, 9132, 365, 4224, 543, 282, 7437, 6465, 13464, 14, 288, 372, 440, 2536, 14, 11332, 63, 7327, 8, 576, 12, 13464, 29, 16, 14, 19983, 9, 267, 587, 26, 288, 327, 2670, 367, 1570, 402, 1174, 402, 23780, 288, 372, 2155, 8, 2747, 9, 1137, 2155, 8, 576, 9, 421, 199, 533, 10579, 7768, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 28472, 29374, 7, 421, 199, 533, 7584, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 7217, 7, 421, 199, 533, 6879, 3428, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 21389, 7217, 7, 421, 199, 533, 7030, 14912, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 6143, 29780, 7, 421, 199, 533, 6879, 3049, 14912, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 15635, 568, 29780, 7, 421, 199, 533, 17560, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 23602, 7, 421, 199, 533, 6879, 12367, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 21389, 23602, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21390, 21686, 12, 21479, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 1275, 8583, 492, 3232, 16862, 3339, 421, 199, 533, 30490, 8, 3351, 14, 792, 304, 272, 408, 272, 961, 365, 314, 5678, 1824, 901, 367, 282, 10579, 14, 221, 6184, 25884, 1324, 626, 365, 272, 10226, 701, 21479, 365, 10226, 701, 642, 1824, 14, 221, 4885, 849, 12, 272, 642, 6952, 22561, 12, 869, 23017, 28328, 12, 644, 12780, 334, 262, 282, 3335, 395, 436, 8875, 6243, 14, 272, 408, 272, 3938, 275, 3232, 16862, 3339, 272, 9671, 63, 466, 275, 283, 28472, 7, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 2427, 356, 4018, 1944, 3400, 574, 2741, 8038, 267, 283, 3197, 63, 6481, 356, 4018, 3364, 3400, 574, 8038, 267, 283, 3197, 63, 6481, 63, 466, 356, 4018, 3364, 3400, 730, 8038, 267, 283, 4711, 63, 705, 356, 4018, 2493, 1125, 8920, 1380, 5793, 316, 314, 3400, 283, 2490, 283, 475, 314, 22425, 402, 314, 3400, 1824, 901, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 327, 13244, 734, 3004, 687, 314, 3050, 901, 12, 503, 675, 27962, 267, 327, 4243, 334, 69, 14, 71, 2020, 2040, 488, 680, 267, 291, 14, 10498, 275, 2074, 14, 1935, 360, 10498, 297, 488, 9, 267, 291, 14, 6481, 63, 466, 275, 2074, 14, 1935, 360, 6481, 63, 466, 297, 291, 14, 6481, 63, 466, 9, 267, 1613, 8, 6831, 792, 12, 291, 2843, 826, 14155, 958, 9, 267, 291, 14, 3440, 14, 3288, 459, 6481, 63, 466, 418, 275, 291, 14, 6481, 63, 466, 339, 347, 370, 63, 1548, 8, 277, 12, 574, 304, 267, 408, 267, 6266, 3351, 314, 574, 370, 282, 10579, 909, 14, 267, 408, 267, 340, 574, 315, 291, 14, 1667, 63, 1459, 26, 288, 372, 488, 398, 340, 440, 1228, 8, 585, 12, 21479, 304, 288, 862, 26, 355, 574, 275, 21479, 8, 585, 9, 288, 871, 334, 18120, 21686, 12, 1722, 12, 3146, 304, 355, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 63, 6481, 995, 1233, 534, 3197, 63, 6481, 358, 398, 327, 7649, 370, 663, 314, 15627, 267, 340, 440, 574, 14, 10498, 26, 288, 862, 26, 355, 574, 14, 10498, 275, 291, 14, 3440, 14, 1130, 63, 10498, 288, 871, 4281, 26, 355, 340, 291, 14, 10498, 26, 490, 574, 14, 10498, 275, 291, 14, 10498, 267, 372, 574, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 4821, 2335, 626, 314, 1324, 574, 883, 506, 6702, 370, 282, 10579, 267, 909, 334, 6777, 365, 2138, 680, 221, 437, 8505, 365, 4915, 340, 267, 314, 574, 3913, 506, 17544, 465, 282, 10579, 14, 267, 408, 267, 9671, 275, 1613, 8, 6831, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 9671, 365, 488, 26, 288, 372, 9671, 398, 327, 23312, 4039, 626, 314, 3400, 365, 402, 314, 3211, 730, 334, 3558, 3153, 267, 327, 1808, 314, 593, 7484, 1059, 1768, 680, 267, 340, 620, 8, 6481, 14, 6481, 63, 466, 680, 4142, 342, 1137, 291, 14, 6481, 63, 466, 436, 440, 291, 14, 6481, 63, 466, 508, 283, 28472, 356, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 63, 6481, 63, 466, 995, 1233, 534, 3197, 63, 6481, 63, 466, 358, 398, 327, 19463, 316, 314, 3400, 340, 314, 22425, 1990, 663, 14, 267, 340, 291, 14, 10498, 436, 291, 14, 10498, 1137, 446, 17, 436, 291, 14, 10498, 1137, 9671, 14, 10498, 26, 288, 862, 26, 355, 9671, 14, 4711, 8, 277, 14, 10498, 9, 288, 871, 21390, 21686, 26, 355, 746, 4513, 14, 8172, 8, 490, 291, 14, 705, 63, 3431, 459, 4711, 63, 705, 995, 1233, 534, 4711, 63, 705, 358, 398, 372, 9671, 339, 347, 965, 63, 2489, 8, 277, 12, 2536, 12, 666, 304, 267, 408, 18955, 25637, 574, 402, 666, 543, 2399, 2536, 574, 14, 408, 398, 862, 26, 288, 666, 275, 291, 14, 475, 63, 1548, 8, 576, 9, 288, 2536, 275, 291, 14, 475, 63, 1548, 8, 2747, 9, 267, 871, 4513, 14, 8172, 26, 288, 372, 715, 398, 327, 5972, 886, 282, 25637, 9132, 340, 3865, 1338, 787, 2808, 267, 340, 2536, 436, 666, 26, 288, 666, 14, 4711, 8, 2747, 14, 10498, 9, 288, 327, 982, 314, 2536, 574, 1990, 440, 3483, 701, 314, 7042, 12, 314, 3400, 288, 327, 2741, 1443, 506, 18023, 3365, 12, 314, 1642, 900, 652, 365, 6290, 14, 288, 327, 710, 9132, 365, 4224, 543, 282, 7437, 6465, 13464, 14, 288, 372, 440, 2536, 14, 11332, 63, 7327, 8, 576, 12, 13464, 29, 16, 14, 19983, 9, 267, 587, 26, 288, 327, 2670, 367, 1570, 402, 1174, 402, 23780, 288, 372, 2155, 8, 2747, 9, 1137, 2155, 8, 576, 9, 421, 199, 533, 10579, 7768, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 28472, 29374, 7, 421, 199, 533, 7584, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 7217, 7, 421, 199, 533, 6879, 3428, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 21389, 7217, 7, 421, 199, 533, 7030, 14912, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 6143, 29780, 7, 421, 199, 533, 6879, 3049, 14912, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 15635, 568, 29780, 7, 421, 199, 533, 17560, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 23602, 7, 421, 199, 533, 6879, 12367, 792, 8, 6831, 792, 304, 272, 9671, 63, 466, 275, 283, 21389, 23602, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
spectralDNS/spectralDNS
tests/test_MHD.py
2
1863
import pytest from six.moves import reload_module from mpi4py import MPI from spectralDNS import config, get_solver, solve from TGMHD import initialize, regression_test, pi comm = MPI.COMM_WORLD if comm.Get_size() >= 4: params = ('uniform_slab', 'nonuniform_slab', 'uniform_pencil', 'nonuniform_pencil') else: params = ('uniform', 'nonuniform') @pytest.fixture(params=params) def sol(request): """Check for uniform and non-uniform cube""" pars = request.param.split('_') mesh = pars[0] mpi = 'slab' if len(pars) == 2: mpi = pars[1] _args = ['--decomposition', mpi] if mesh == 'uniform': _args += ['--M', '4', '4', '4', '--L', '2*pi', '2*pi', '2*pi'] else: _args += ['--M', '6', '5', '4', '--L', '6*pi', '4*pi', '2*pi'] _args += ['MHD'] return _args def test_MHD(sol): config.update( { 'nu': 0.000625, # Viscosity 'dt': 0.01, # Time step 'T': 0.1, # End time 'eta': 0.01, 'L': [2*pi, 4*pi, 6*pi], 'M': [4, 5, 6], 'convection': 'Divergence' } ) solver = get_solver(regression_test=regression_test, parse_args=sol) context = solver.get_context() initialize(**context) solve(solver, context) config.params.dealias = '3/2-rule' initialize(**context) solve(solver, context) config.params.dealias = '2/3-rule' config.params.optimization = 'cython' reload_module(solver) initialize(**context) solve(solver, context) config.params.write_result = 1 config.params.checkpoint = 1 config.dt = 0.01 config.params.t = 0.0 config.params.tstep = 0 config.T = 0.04 solver.regression_test = lambda c: None solve(solver, context)
lgpl-3.0
[ 646, 4613, 199, 504, 3816, 14, 4912, 492, 13101, 63, 578, 199, 504, 26806, 20, 647, 492, 26024, 199, 504, 28397, 12323, 492, 1101, 12, 664, 63, 11263, 12, 14241, 199, 504, 377, 22636, 14903, 492, 8265, 12, 10864, 63, 396, 12, 6682, 199, 199, 1404, 275, 26024, 14, 5378, 63, 22125, 199, 199, 692, 1923, 14, 1002, 63, 890, 342, 2356, 841, 26, 272, 1862, 275, 661, 8830, 63, 2482, 371, 297, 283, 2865, 8830, 63, 2482, 371, 297, 1598, 283, 8830, 63, 897, 24707, 297, 283, 2865, 8830, 63, 897, 24707, 358, 199, 2836, 26, 272, 1862, 275, 661, 8830, 297, 283, 2865, 8830, 358, 199, 199, 32, 4462, 14, 5997, 8, 1162, 29, 1162, 9, 199, 318, 8597, 8, 1069, 304, 272, 408, 1799, 367, 14818, 436, 2222, 13, 8830, 15681, 624, 272, 30903, 275, 1056, 14, 635, 14, 1294, 26341, 272, 9364, 275, 30903, 59, 16, 61, 272, 26806, 275, 283, 2482, 371, 7, 272, 340, 822, 8, 21152, 9, 508, 499, 26, 267, 26806, 275, 30903, 59, 17, 61, 272, 485, 589, 275, 14574, 31384, 297, 26806, 61, 272, 340, 9364, 508, 283, 8830, 356, 267, 485, 589, 847, 14574, 45, 297, 283, 20, 297, 283, 20, 297, 283, 20, 297, 2850, 44, 297, 283, 18, 10, 1038, 297, 283, 18, 10, 1038, 297, 283, 18, 10, 1038, 418, 272, 587, 26, 267, 485, 589, 847, 14574, 45, 297, 283, 22, 297, 283, 21, 297, 283, 20, 297, 2850, 44, 297, 283, 22, 10, 1038, 297, 283, 20, 10, 1038, 297, 283, 18, 10, 1038, 418, 272, 485, 589, 847, 788, 45, 14903, 418, 339, 372, 485, 589, 199, 199, 318, 511, 63, 45, 14903, 8, 7873, 304, 272, 1101, 14, 873, 8, 267, 469, 288, 283, 4850, 356, 378, 14, 20965, 821, 12, 3777, 327, 812, 10081, 3677, 288, 283, 3583, 356, 378, 14, 614, 12, 463, 327, 4703, 3650, 288, 283, 52, 356, 378, 14, 17, 12, 7861, 327, 9599, 900, 288, 283, 1841, 356, 378, 14, 614, 12, 288, 283, 44, 356, 359, 18, 10, 1038, 12, 841, 10, 1038, 12, 1227, 10, 1038, 467, 288, 283, 45, 356, 359, 20, 12, 959, 12, 1227, 467, 288, 283, 388, 432, 414, 356, 283, 1341, 23803, 7, 267, 789, 272, 776, 339, 10196, 275, 664, 63, 11263, 8, 12513, 63, 396, 29, 12513, 63, 396, 12, 717, 2198, 63, 589, 29, 7873, 9, 272, 1067, 275, 10196, 14, 362, 63, 1100, 342, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 271, 3620, 275, 283, 19, 15, 18, 13, 2200, 7, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 271, 3620, 275, 283, 18, 15, 19, 13, 2200, 7, 272, 1101, 14, 1162, 14, 31405, 275, 283, 20747, 7, 272, 13101, 63, 578, 8, 11263, 9, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 952, 63, 1099, 275, 413, 272, 1101, 14, 1162, 14, 10109, 275, 413, 272, 1101, 14, 3583, 275, 378, 14, 614, 272, 1101, 14, 1162, 14, 84, 275, 378, 14, 16, 272, 1101, 14, 1162, 14, 1086, 2852, 275, 378, 272, 1101, 14, 52, 275, 378, 14, 966, 272, 10196, 14, 12513, 63, 396, 275, 2400, 286, 26, 488, 272, 14241, 8, 11263, 12, 1067, 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 ]
[ 4613, 199, 504, 3816, 14, 4912, 492, 13101, 63, 578, 199, 504, 26806, 20, 647, 492, 26024, 199, 504, 28397, 12323, 492, 1101, 12, 664, 63, 11263, 12, 14241, 199, 504, 377, 22636, 14903, 492, 8265, 12, 10864, 63, 396, 12, 6682, 199, 199, 1404, 275, 26024, 14, 5378, 63, 22125, 199, 199, 692, 1923, 14, 1002, 63, 890, 342, 2356, 841, 26, 272, 1862, 275, 661, 8830, 63, 2482, 371, 297, 283, 2865, 8830, 63, 2482, 371, 297, 1598, 283, 8830, 63, 897, 24707, 297, 283, 2865, 8830, 63, 897, 24707, 358, 199, 2836, 26, 272, 1862, 275, 661, 8830, 297, 283, 2865, 8830, 358, 199, 199, 32, 4462, 14, 5997, 8, 1162, 29, 1162, 9, 199, 318, 8597, 8, 1069, 304, 272, 408, 1799, 367, 14818, 436, 2222, 13, 8830, 15681, 624, 272, 30903, 275, 1056, 14, 635, 14, 1294, 26341, 272, 9364, 275, 30903, 59, 16, 61, 272, 26806, 275, 283, 2482, 371, 7, 272, 340, 822, 8, 21152, 9, 508, 499, 26, 267, 26806, 275, 30903, 59, 17, 61, 272, 485, 589, 275, 14574, 31384, 297, 26806, 61, 272, 340, 9364, 508, 283, 8830, 356, 267, 485, 589, 847, 14574, 45, 297, 283, 20, 297, 283, 20, 297, 283, 20, 297, 2850, 44, 297, 283, 18, 10, 1038, 297, 283, 18, 10, 1038, 297, 283, 18, 10, 1038, 418, 272, 587, 26, 267, 485, 589, 847, 14574, 45, 297, 283, 22, 297, 283, 21, 297, 283, 20, 297, 2850, 44, 297, 283, 22, 10, 1038, 297, 283, 20, 10, 1038, 297, 283, 18, 10, 1038, 418, 272, 485, 589, 847, 788, 45, 14903, 418, 339, 372, 485, 589, 199, 199, 318, 511, 63, 45, 14903, 8, 7873, 304, 272, 1101, 14, 873, 8, 267, 469, 288, 283, 4850, 356, 378, 14, 20965, 821, 12, 3777, 327, 812, 10081, 3677, 288, 283, 3583, 356, 378, 14, 614, 12, 463, 327, 4703, 3650, 288, 283, 52, 356, 378, 14, 17, 12, 7861, 327, 9599, 900, 288, 283, 1841, 356, 378, 14, 614, 12, 288, 283, 44, 356, 359, 18, 10, 1038, 12, 841, 10, 1038, 12, 1227, 10, 1038, 467, 288, 283, 45, 356, 359, 20, 12, 959, 12, 1227, 467, 288, 283, 388, 432, 414, 356, 283, 1341, 23803, 7, 267, 789, 272, 776, 339, 10196, 275, 664, 63, 11263, 8, 12513, 63, 396, 29, 12513, 63, 396, 12, 717, 2198, 63, 589, 29, 7873, 9, 272, 1067, 275, 10196, 14, 362, 63, 1100, 342, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 271, 3620, 275, 283, 19, 15, 18, 13, 2200, 7, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 271, 3620, 275, 283, 18, 15, 19, 13, 2200, 7, 272, 1101, 14, 1162, 14, 31405, 275, 283, 20747, 7, 272, 13101, 63, 578, 8, 11263, 9, 272, 8265, 3682, 1100, 9, 272, 14241, 8, 11263, 12, 1067, 9, 339, 1101, 14, 1162, 14, 952, 63, 1099, 275, 413, 272, 1101, 14, 1162, 14, 10109, 275, 413, 272, 1101, 14, 3583, 275, 378, 14, 614, 272, 1101, 14, 1162, 14, 84, 275, 378, 14, 16, 272, 1101, 14, 1162, 14, 1086, 2852, 275, 378, 272, 1101, 14, 52, 275, 378, 14, 966, 272, 10196, 14, 12513, 63, 396, 275, 2400, 286, 26, 488, 272, 14241, 8, 11263, 12, 1067, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mail-apps/pootle
pootle/apps/staticpages/models.py
6
4568
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) Pootle contributors. # # This file is a part of the Pootle project. It is distributed under the GPL3 # or later license. See the LICENSE file for a copy of the license and the # AUTHORS file for copyright and authorship information. from django.db import models from django.db.models import Q from django.db.models.aggregates import Max from django.conf import settings from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ from pootle.core.markup import get_markup_filter_name, MarkupField from pootle.core.mixins import DirtyFieldsMixin from .managers import PageManager class AbstractPage(DirtyFieldsMixin, models.Model): active = models.BooleanField( _('Active'), default=False, help_text=_('Whether this page is active or not.'), ) virtual_path = models.CharField( _("Virtual Path"), max_length=100, default='', unique=True, help_text='/pages/', ) # TODO: make title and body localizable fields title = models.CharField(_("Title"), max_length=100) body = MarkupField( # Translators: Content that will be used to display this static page _("Display Content"), blank=True, help_text=_('Allowed markup: %s', get_markup_filter_name()), ) url = models.URLField( _("Redirect to URL"), blank=True, help_text=_('If set, any references to this page will redirect to this' ' URL'), ) modified_on = models.DateTimeField( default=now, editable=False, ) objects = PageManager() class Meta: abstract = True def __unicode__(self): return self.virtual_path def save(self, **kwargs): # Update the `modified_on` timestamp only when specific fields change. if self.has_changes(): self.modified_on = now() super(AbstractPage, self).save(**kwargs) def get_absolute_url(self): if self.url: return self.url return reverse('pootle-staticpages-display', args=[self.virtual_path]) @staticmethod def max_pk(): """Returns the sum of all the highest PKs for each submodel.""" return reduce( lambda x, y: x + y, [int(p.objects.aggregate(Max('pk')).values()[0] or 0) for p in AbstractPage.__subclasses__()], ) def clean(self): """Fail validation if: - URL and body are blank - Current virtual path exists in other page models """ if not self.url and not self.body: # Translators: 'URL' and 'content' refer to form fields. raise ValidationError(_('URL or content must be provided.')) pages = [p.objects.filter( Q(virtual_path=self.virtual_path), ~Q(pk=self.pk), ).exists() for p in AbstractPage.__subclasses__()] if True in pages: raise ValidationError(_(u'Virtual path already in use.')) def has_changes(self): dirty_fields = self.get_dirty_fields() return any(field in dirty_fields for field in ('title', 'body', 'url')) class LegalPage(AbstractPage): display_name = _('Legal Page') def localized_title(self): return _(self.title) def get_edit_url(self): return reverse('pootle-staticpages-edit', args=['legal', self.pk]) class StaticPage(AbstractPage): display_name = _('Regular Page') def get_edit_url(self): page_type = 'static' if self.virtual_path.startswith('announcements/'): page_type = 'announcements' return reverse('pootle-staticpages-edit', args=[page_type, self.pk]) class Agreement(models.Model): """Tracks who agreed a specific legal document and when.""" user = models.ForeignKey(settings.AUTH_USER_MODEL) document = models.ForeignKey(LegalPage) agreed_on = models.DateTimeField( default=now, editable=False, ) class Meta: unique_together = ('user', 'document',) def __unicode__(self): return u'%s (%s@%s)' % (self.document, self.user, self.agreed_on) def save(self, **kwargs): # When updating always explicitly renew agreement date if self.pk: self.agreed_on = now() super(Agreement, self).save(**kwargs)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 4376, 24629, 8417, 14, 199, 3, 199, 3, 961, 570, 365, 282, 1777, 402, 314, 4376, 24629, 2199, 14, 2779, 365, 1854, 1334, 314, 14629, 19, 199, 3, 503, 2945, 4190, 14, 1666, 314, 5113, 570, 367, 282, 1331, 402, 314, 4190, 436, 314, 199, 3, 10610, 570, 367, 4248, 436, 4132, 3319, 2556, 14, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 21622, 492, 8228, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 1115, 24629, 14, 1018, 14, 10131, 492, 664, 63, 10131, 63, 1541, 63, 354, 12, 17504, 792, 199, 504, 1115, 24629, 14, 1018, 14, 30192, 492, 25866, 369, 7304, 4256, 199, 199, 504, 1275, 16259, 492, 10331, 2988, 421, 199, 533, 11836, 3276, 8, 29413, 7304, 4256, 12, 1709, 14, 1685, 304, 339, 4702, 275, 1709, 14, 5036, 8, 267, 4018, 7472, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 12397, 26625, 642, 2034, 365, 4702, 503, 440, 8038, 272, 776, 272, 5791, 63, 515, 275, 1709, 14, 2183, 8, 267, 3824, 8735, 6912, 1288, 267, 1390, 63, 1267, 29, 1960, 12, 267, 849, 4581, 267, 3747, 29, 549, 12, 267, 1720, 63, 505, 8805, 5856, 3678, 272, 776, 272, 327, 3254, 26, 1852, 2538, 436, 2396, 2257, 14065, 1504, 272, 2538, 275, 1709, 14, 2183, 6115, 6888, 1288, 1390, 63, 1267, 29, 1960, 9, 272, 2396, 275, 17504, 792, 8, 267, 327, 26355, 26, 6646, 626, 911, 506, 1202, 370, 2929, 642, 2955, 2034, 267, 3824, 7687, 6646, 1288, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 12397, 16070, 9189, 26, 450, 83, 297, 664, 63, 10131, 63, 1541, 63, 354, 4000, 272, 776, 272, 1166, 275, 1709, 14, 17363, 8, 267, 3824, 7071, 370, 2851, 1288, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 12397, 3917, 663, 12, 1263, 6941, 370, 642, 2034, 911, 4660, 370, 642, 7, 490, 283, 2851, 659, 272, 776, 272, 6042, 63, 265, 275, 1709, 14, 4626, 8, 267, 849, 29, 2131, 12, 267, 14783, 29, 797, 12, 272, 776, 339, 2251, 275, 10331, 2988, 342, 339, 1021, 6288, 26, 267, 9006, 275, 715, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2065, 63, 515, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 327, 6162, 314, 658, 5540, 63, 265, 64, 4913, 1454, 1380, 2488, 1504, 1570, 14, 267, 340, 291, 14, 1989, 63, 6627, 837, 288, 291, 14, 5540, 63, 265, 275, 3063, 342, 398, 1613, 8, 8458, 3276, 12, 291, 680, 2117, 3682, 958, 9, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 340, 291, 14, 633, 26, 288, 372, 291, 14, 633, 398, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 2918, 297, 1249, 1524, 277, 14, 2065, 63, 515, 566, 339, 768, 4639, 272, 347, 1390, 63, 2051, 837, 267, 408, 3407, 314, 3089, 402, 1006, 314, 15356, 18368, 83, 367, 1924, 1007, 1238, 1041, 267, 372, 7114, 8, 288, 2400, 671, 12, 612, 26, 671, 435, 612, 12, 288, 359, 442, 8, 80, 14, 1462, 14, 7516, 8, 4261, 360, 2051, 11103, 1459, 3430, 16, 61, 503, 378, 9, 1467, 367, 299, 315, 11836, 3276, 855, 19094, 4533, 467, 267, 776, 339, 347, 3633, 8, 277, 304, 267, 408, 4874, 6411, 340, 26, 398, 446, 2851, 436, 2396, 787, 4596, 267, 446, 9338, 5791, 931, 3495, 315, 1163, 2034, 1709, 267, 408, 267, 340, 440, 291, 14, 633, 436, 440, 291, 14, 2030, 26, 288, 327, 26355, 26, 283, 2632, 7, 436, 283, 1317, 7, 10618, 370, 1824, 1504, 14, 288, 746, 8505, 6723, 2632, 503, 1564, 1471, 506, 2741, 12459, 398, 6497, 275, 359, 80, 14, 1462, 14, 1541, 8, 2151, 1413, 8, 2065, 63, 515, 29, 277, 14, 2065, 63, 515, 395, 2151, 6146, 49, 8, 2051, 29, 277, 14, 2051, 395, 326, 7092, 2444, 342, 326, 367, 299, 315, 11836, 3276, 855, 19094, 4533, 61, 267, 340, 715, 315, 6497, 26, 288, 746, 8505, 27594, 85, 7, 8735, 931, 2575, 315, 675, 12459, 339, 347, 965, 63, 6627, 8, 277, 304, 267, 14650, 63, 955, 275, 291, 14, 362, 63, 8799, 63, 955, 342, 267, 372, 1263, 8, 698, 315, 14650, 63, 955, 367, 901, 315, 661, 1213, 297, 283, 2030, 297, 283, 633, 1333, 421, 199, 533, 16258, 279, 3276, 8, 8458, 3276, 304, 339, 2929, 63, 354, 275, 4018, 13257, 279, 10331, 358, 339, 347, 25460, 63, 1213, 8, 277, 304, 267, 372, 12561, 277, 14, 1213, 9, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 3773, 297, 1249, 2968, 9666, 297, 291, 14, 2051, 566, 421, 199, 533, 13599, 3276, 8, 8458, 3276, 304, 339, 2929, 63, 354, 275, 4018, 16038, 10331, 358, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 2034, 63, 466, 275, 283, 1986, 7, 267, 340, 291, 14, 2065, 63, 515, 14, 2460, 360, 17803, 1470, 26985, 288, 2034, 63, 466, 275, 283, 17803, 1470, 7, 267, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 3773, 297, 1249, 1524, 1606, 63, 466, 12, 291, 14, 2051, 566, 421, 199, 533, 28629, 8, 992, 14, 1685, 304, 272, 408, 2437, 5618, 3963, 4193, 282, 2488, 18393, 2213, 436, 1380, 1041, 339, 922, 275, 1709, 14, 3190, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 9, 272, 2213, 275, 1709, 14, 3190, 8, 13257, 279, 3276, 9, 272, 4193, 63, 265, 275, 1709, 14, 4626, 8, 267, 849, 29, 2131, 12, 267, 14783, 29, 797, 12, 272, 776, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 751, 297, 283, 3554, 9538, 339, 347, 636, 2975, 721 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 4376, 24629, 8417, 14, 199, 3, 199, 3, 961, 570, 365, 282, 1777, 402, 314, 4376, 24629, 2199, 14, 2779, 365, 1854, 1334, 314, 14629, 19, 199, 3, 503, 2945, 4190, 14, 1666, 314, 5113, 570, 367, 282, 1331, 402, 314, 4190, 436, 314, 199, 3, 10610, 570, 367, 4248, 436, 4132, 3319, 2556, 14, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 21622, 492, 8228, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 1115, 24629, 14, 1018, 14, 10131, 492, 664, 63, 10131, 63, 1541, 63, 354, 12, 17504, 792, 199, 504, 1115, 24629, 14, 1018, 14, 30192, 492, 25866, 369, 7304, 4256, 199, 199, 504, 1275, 16259, 492, 10331, 2988, 421, 199, 533, 11836, 3276, 8, 29413, 7304, 4256, 12, 1709, 14, 1685, 304, 339, 4702, 275, 1709, 14, 5036, 8, 267, 4018, 7472, 659, 267, 849, 29, 797, 12, 267, 1720, 63, 505, 12397, 26625, 642, 2034, 365, 4702, 503, 440, 8038, 272, 776, 272, 5791, 63, 515, 275, 1709, 14, 2183, 8, 267, 3824, 8735, 6912, 1288, 267, 1390, 63, 1267, 29, 1960, 12, 267, 849, 4581, 267, 3747, 29, 549, 12, 267, 1720, 63, 505, 8805, 5856, 3678, 272, 776, 272, 327, 3254, 26, 1852, 2538, 436, 2396, 2257, 14065, 1504, 272, 2538, 275, 1709, 14, 2183, 6115, 6888, 1288, 1390, 63, 1267, 29, 1960, 9, 272, 2396, 275, 17504, 792, 8, 267, 327, 26355, 26, 6646, 626, 911, 506, 1202, 370, 2929, 642, 2955, 2034, 267, 3824, 7687, 6646, 1288, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 12397, 16070, 9189, 26, 450, 83, 297, 664, 63, 10131, 63, 1541, 63, 354, 4000, 272, 776, 272, 1166, 275, 1709, 14, 17363, 8, 267, 3824, 7071, 370, 2851, 1288, 267, 4596, 29, 549, 12, 267, 1720, 63, 505, 12397, 3917, 663, 12, 1263, 6941, 370, 642, 2034, 911, 4660, 370, 642, 7, 490, 283, 2851, 659, 272, 776, 272, 6042, 63, 265, 275, 1709, 14, 4626, 8, 267, 849, 29, 2131, 12, 267, 14783, 29, 797, 12, 272, 776, 339, 2251, 275, 10331, 2988, 342, 339, 1021, 6288, 26, 267, 9006, 275, 715, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2065, 63, 515, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 327, 6162, 314, 658, 5540, 63, 265, 64, 4913, 1454, 1380, 2488, 1504, 1570, 14, 267, 340, 291, 14, 1989, 63, 6627, 837, 288, 291, 14, 5540, 63, 265, 275, 3063, 342, 398, 1613, 8, 8458, 3276, 12, 291, 680, 2117, 3682, 958, 9, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 340, 291, 14, 633, 26, 288, 372, 291, 14, 633, 398, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 2918, 297, 1249, 1524, 277, 14, 2065, 63, 515, 566, 339, 768, 4639, 272, 347, 1390, 63, 2051, 837, 267, 408, 3407, 314, 3089, 402, 1006, 314, 15356, 18368, 83, 367, 1924, 1007, 1238, 1041, 267, 372, 7114, 8, 288, 2400, 671, 12, 612, 26, 671, 435, 612, 12, 288, 359, 442, 8, 80, 14, 1462, 14, 7516, 8, 4261, 360, 2051, 11103, 1459, 3430, 16, 61, 503, 378, 9, 1467, 367, 299, 315, 11836, 3276, 855, 19094, 4533, 467, 267, 776, 339, 347, 3633, 8, 277, 304, 267, 408, 4874, 6411, 340, 26, 398, 446, 2851, 436, 2396, 787, 4596, 267, 446, 9338, 5791, 931, 3495, 315, 1163, 2034, 1709, 267, 408, 267, 340, 440, 291, 14, 633, 436, 440, 291, 14, 2030, 26, 288, 327, 26355, 26, 283, 2632, 7, 436, 283, 1317, 7, 10618, 370, 1824, 1504, 14, 288, 746, 8505, 6723, 2632, 503, 1564, 1471, 506, 2741, 12459, 398, 6497, 275, 359, 80, 14, 1462, 14, 1541, 8, 2151, 1413, 8, 2065, 63, 515, 29, 277, 14, 2065, 63, 515, 395, 2151, 6146, 49, 8, 2051, 29, 277, 14, 2051, 395, 326, 7092, 2444, 342, 326, 367, 299, 315, 11836, 3276, 855, 19094, 4533, 61, 267, 340, 715, 315, 6497, 26, 288, 746, 8505, 27594, 85, 7, 8735, 931, 2575, 315, 675, 12459, 339, 347, 965, 63, 6627, 8, 277, 304, 267, 14650, 63, 955, 275, 291, 14, 362, 63, 8799, 63, 955, 342, 267, 372, 1263, 8, 698, 315, 14650, 63, 955, 367, 901, 315, 661, 1213, 297, 283, 2030, 297, 283, 633, 1333, 421, 199, 533, 16258, 279, 3276, 8, 8458, 3276, 304, 339, 2929, 63, 354, 275, 4018, 13257, 279, 10331, 358, 339, 347, 25460, 63, 1213, 8, 277, 304, 267, 372, 12561, 277, 14, 1213, 9, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 3773, 297, 1249, 2968, 9666, 297, 291, 14, 2051, 566, 421, 199, 533, 13599, 3276, 8, 8458, 3276, 304, 339, 2929, 63, 354, 275, 4018, 16038, 10331, 358, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 2034, 63, 466, 275, 283, 1986, 7, 267, 340, 291, 14, 2065, 63, 515, 14, 2460, 360, 17803, 1470, 26985, 288, 2034, 63, 466, 275, 283, 17803, 1470, 7, 267, 372, 3837, 360, 555, 24629, 13, 1986, 5856, 13, 3773, 297, 1249, 1524, 1606, 63, 466, 12, 291, 14, 2051, 566, 421, 199, 533, 28629, 8, 992, 14, 1685, 304, 272, 408, 2437, 5618, 3963, 4193, 282, 2488, 18393, 2213, 436, 1380, 1041, 339, 922, 275, 1709, 14, 3190, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 9, 272, 2213, 275, 1709, 14, 3190, 8, 13257, 279, 3276, 9, 272, 4193, 63, 265, 275, 1709, 14, 4626, 8, 267, 849, 29, 2131, 12, 267, 14783, 29, 797, 12, 272, 776, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 751, 297, 283, 3554, 9538, 339, 347, 636, 2975, 721, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Azure/azure-sdk-for-python
sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_04_01/aio/operations/_hub_virtual_network_connections_operations.py
1
8982
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class HubVirtualNetworkConnectionsOperations: """HubVirtualNetworkConnectionsOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.mgmt.network.v2019_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config async def get( self, resource_group_name: str, virtual_hub_name: str, connection_name: str, **kwargs ) -> "_models.HubVirtualNetworkConnection": """Retrieves the details of a HubVirtualNetworkConnection. :param resource_group_name: The resource group name of the VirtualHub. :type resource_group_name: str :param virtual_hub_name: The name of the VirtualHub. :type virtual_hub_name: str :param connection_name: The name of the vpn connection. :type connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HubVirtualNetworkConnection, or the result of cls(response) :rtype: ~azure.mgmt.network.v2019_04_01.models.HubVirtualNetworkConnection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.HubVirtualNetworkConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2019-04-01" accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'virtualHubName': self._serialize.url("virtual_hub_name", virtual_hub_name, 'str'), 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HubVirtualNetworkConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/hubVirtualNetworkConnections/{connectionName}'} # type: ignore def list( self, resource_group_name: str, virtual_hub_name: str, **kwargs ) -> AsyncIterable["_models.ListHubVirtualNetworkConnectionsResult"]: """Retrieves the details of all HubVirtualNetworkConnections. :param resource_group_name: The resource group name of the VirtualHub. :type resource_group_name: str :param virtual_hub_name: The name of the VirtualHub. :type virtual_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListHubVirtualNetworkConnectionsResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.network.v2019_04_01.models.ListHubVirtualNetworkConnectionsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListHubVirtualNetworkConnectionsResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2019-04-01" accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'virtualHubName': self._serialize.url("virtual_hub_name", virtual_hub_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): deserialized = self._deserialize('ListHubVirtualNetworkConnectionsResult', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: error = self._deserialize.failsafe_deserialize(_models.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/hubVirtualNetworkConnections'} # type: ignore
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 4190, 2556, 14, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 31904, 14, 199, 3, 24775, 199, 504, 14090, 492, 6184, 12, 15223, 20852, 12, 16975, 12, 7448, 12, 8307, 12, 4879, 12, 2434, 5894, 199, 646, 3598, 199, 199, 504, 13601, 14, 1018, 14, 4146, 63, 31691, 492, 15223, 2081, 16769, 12, 15223, 1296, 199, 504, 13601, 14, 1018, 14, 3924, 492, 6810, 27942, 12, 6183, 547, 12, 7337, 23839, 12, 28783, 12, 2341, 63, 705, 199, 504, 13601, 14, 1018, 14, 7379, 492, 19090, 2364, 199, 504, 13601, 14, 1018, 14, 7379, 14, 5545, 492, 15223, 16287, 12, 20730, 199, 504, 13601, 14, 9752, 14, 1018, 14, 3924, 492, 27155, 547, 3484, 199, 199, 504, 2263, 492, 1709, 465, 485, 992, 199, 199, 52, 275, 2434, 5894, 360, 52, 358, 199, 24342, 804, 275, 4879, 59, 16410, 9046, 17562, 2364, 59, 10441, 12, 15223, 16287, 467, 377, 12, 7448, 59, 495, 12, 6184, 2365, 6184, 2677, 199, 199, 533, 869, 456, 8735, 4491, 22122, 12929, 26, 272, 408, 15338, 8735, 4491, 22122, 12929, 5316, 5331, 14, 339, 2047, 1077, 440, 17321, 642, 1021, 5370, 14, 15345, 12, 1265, 1077, 1218, 282, 6810, 1256, 626, 272, 9034, 2335, 652, 367, 1265, 436, 6554, 397, 652, 465, 376, 2225, 14, 339, 520, 7725, 1709, 26, 24777, 370, 1402, 3992, 1202, 315, 642, 3439, 1572, 14, 272, 520, 466, 1709, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 14982, 63, 966, 63, 614, 14, 992, 272, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 909, 1402, 30237, 14, 272, 408, 339, 1709, 275, 485, 992, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 9, 1035, 488, 26, 267, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 423, 888, 275, 1101, 339, 5316, 347, 664, 8, 267, 291, 12, 267, 2073, 63, 923, 63, 354, 26, 620, 12, 267, 5791, 63, 16560, 63, 354, 26, 620, 12, 267, 1950, 63, 354, 26, 620, 12, 267, 1011, 958, 272, 776, 1035, 2668, 992, 14, 15338, 8735, 4491, 3225, 582, 267, 408, 28112, 314, 2436, 402, 282, 869, 456, 8735, 4491, 3225, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 2073, 1572, 536, 402, 314, 13311, 15338, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 5791, 63, 16560, 63, 354, 26, 710, 536, 402, 314, 13311, 15338, 14, 267, 520, 466, 5791, 63, 16560, 63, 354, 26, 620, 267, 520, 635, 1950, 63, 354, 26, 710, 536, 402, 314, 15978, 1950, 14, 267, 520, 466, 1950, 63, 354, 26, 620, 267, 520, 6691, 4550, 843, 26, 437, 3537, 730, 503, 805, 626, 911, 506, 3032, 314, 4125, 1177, 267, 520, 1107, 26, 869, 456, 8735, 4491, 3225, 12, 503, 314, 754, 402, 843, 8, 1310, 9, 267, 520, 4500, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 14982, 63, 966, 63, 614, 14, 992, 14, 15338, 8735, 4491, 3225, 267, 520, 3536, 26, 6146, 9078, 14, 1018, 14, 3924, 14, 16287, 547, 267, 408, 267, 843, 275, 2074, 14, 1935, 360, 1886, 297, 488, 9, 221, 327, 730, 26, 28793, 804, 18524, 992, 14, 15338, 8735, 4491, 3225, 937, 267, 1125, 63, 1130, 275, 469, 288, 13952, 26, 6810, 27942, 12, 7901, 26, 28783, 12, 21292, 26, 7337, 23839, 267, 789, 267, 1125, 63, 1130, 14, 873, 8, 958, 14, 1935, 360, 705, 63, 1130, 297, 17003, 267, 2986, 63, 1023, 275, 298, 14982, 13, 966, 13, 614, 2, 267, 4729, 275, 298, 3578, 15, 1001, 2, 398, 327, 9215, 2851, 267, 1166, 275, 291, 14, 362, 14, 2343, 459, 633, 418, 221, 327, 730, 26, 3686, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 423, 888, 14, 6645, 63, 344, 401, 291, 423, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 2065, 15338, 985, 356, 291, 423, 3549, 14, 633, 480, 2065, 63, 16560, 63, 354, 401, 5791, 63, 16560, 63, 354, 12, 283, 495, 659, 288, 283, 2105, 985, 356, 291, 423, 3549, 14, 633, 480, 2105, 63, 354, 401, 1950, 63, 354, 12, 283, 495, 659, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 267, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 1246, 63, 1023, 401, 2986, 63, 1023, 12, 283, 495, 358, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 267, 1406, 63, 3214, 459, 8422, 418, 275, 291, 423, 3549, 14, 1291, 480, 5694, 401, 4729, 12, 283, 495, 358, 398, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 267, 7679, 63, 1310, 275, 5517, 291, 423, 1258, 423, 7379, 14, 1065, 8, 1069, 12, 2547, 29, 797, 12, 1011, 958, 9, 267, 1177, 275, 7679, 63, 1310, 14, 1014, 63, 1310, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 1840, 2189, 288, 2341, 63, 705, 8, 1205, 63, 600, 29, 1310, 14, 1205, 63, 600, 12, 1177, 29, 1310, 12, 1125, 63, 1130, 29, 705, 63, 1130, 9, 288, 1125, 275, 291 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 4190, 2556, 14, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 31904, 14, 199, 3, 24775, 199, 504, 14090, 492, 6184, 12, 15223, 20852, 12, 16975, 12, 7448, 12, 8307, 12, 4879, 12, 2434, 5894, 199, 646, 3598, 199, 199, 504, 13601, 14, 1018, 14, 4146, 63, 31691, 492, 15223, 2081, 16769, 12, 15223, 1296, 199, 504, 13601, 14, 1018, 14, 3924, 492, 6810, 27942, 12, 6183, 547, 12, 7337, 23839, 12, 28783, 12, 2341, 63, 705, 199, 504, 13601, 14, 1018, 14, 7379, 492, 19090, 2364, 199, 504, 13601, 14, 1018, 14, 7379, 14, 5545, 492, 15223, 16287, 12, 20730, 199, 504, 13601, 14, 9752, 14, 1018, 14, 3924, 492, 27155, 547, 3484, 199, 199, 504, 2263, 492, 1709, 465, 485, 992, 199, 199, 52, 275, 2434, 5894, 360, 52, 358, 199, 24342, 804, 275, 4879, 59, 16410, 9046, 17562, 2364, 59, 10441, 12, 15223, 16287, 467, 377, 12, 7448, 59, 495, 12, 6184, 2365, 6184, 2677, 199, 199, 533, 869, 456, 8735, 4491, 22122, 12929, 26, 272, 408, 15338, 8735, 4491, 22122, 12929, 5316, 5331, 14, 339, 2047, 1077, 440, 17321, 642, 1021, 5370, 14, 15345, 12, 1265, 1077, 1218, 282, 6810, 1256, 626, 272, 9034, 2335, 652, 367, 1265, 436, 6554, 397, 652, 465, 376, 2225, 14, 339, 520, 7725, 1709, 26, 24777, 370, 1402, 3992, 1202, 315, 642, 3439, 1572, 14, 272, 520, 466, 1709, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 14982, 63, 966, 63, 614, 14, 992, 272, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 909, 1402, 30237, 14, 272, 408, 339, 1709, 275, 485, 992, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 9, 1035, 488, 26, 267, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 423, 888, 275, 1101, 339, 5316, 347, 664, 8, 267, 291, 12, 267, 2073, 63, 923, 63, 354, 26, 620, 12, 267, 5791, 63, 16560, 63, 354, 26, 620, 12, 267, 1950, 63, 354, 26, 620, 12, 267, 1011, 958, 272, 776, 1035, 2668, 992, 14, 15338, 8735, 4491, 3225, 582, 267, 408, 28112, 314, 2436, 402, 282, 869, 456, 8735, 4491, 3225, 14, 398, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 2073, 1572, 536, 402, 314, 13311, 15338, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 5791, 63, 16560, 63, 354, 26, 710, 536, 402, 314, 13311, 15338, 14, 267, 520, 466, 5791, 63, 16560, 63, 354, 26, 620, 267, 520, 635, 1950, 63, 354, 26, 710, 536, 402, 314, 15978, 1950, 14, 267, 520, 466, 1950, 63, 354, 26, 620, 267, 520, 6691, 4550, 843, 26, 437, 3537, 730, 503, 805, 626, 911, 506, 3032, 314, 4125, 1177, 267, 520, 1107, 26, 869, 456, 8735, 4491, 3225, 12, 503, 314, 754, 402, 843, 8, 1310, 9, 267, 520, 4500, 26, 6146, 9078, 14, 9752, 14, 1200, 14, 86, 14982, 63, 966, 63, 614, 14, 992, 14, 15338, 8735, 4491, 3225, 267, 520, 3536, 26, 6146, 9078, 14, 1018, 14, 3924, 14, 16287, 547, 267, 408, 267, 843, 275, 2074, 14, 1935, 360, 1886, 297, 488, 9, 221, 327, 730, 26, 28793, 804, 18524, 992, 14, 15338, 8735, 4491, 3225, 937, 267, 1125, 63, 1130, 275, 469, 288, 13952, 26, 6810, 27942, 12, 7901, 26, 28783, 12, 21292, 26, 7337, 23839, 267, 789, 267, 1125, 63, 1130, 14, 873, 8, 958, 14, 1935, 360, 705, 63, 1130, 297, 17003, 267, 2986, 63, 1023, 275, 298, 14982, 13, 966, 13, 614, 2, 267, 4729, 275, 298, 3578, 15, 1001, 2, 398, 327, 9215, 2851, 267, 1166, 275, 291, 14, 362, 14, 2343, 459, 633, 418, 221, 327, 730, 26, 3686, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 423, 888, 14, 6645, 63, 344, 401, 291, 423, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 2065, 15338, 985, 356, 291, 423, 3549, 14, 633, 480, 2065, 63, 16560, 63, 354, 401, 5791, 63, 16560, 63, 354, 12, 283, 495, 659, 288, 283, 2105, 985, 356, 291, 423, 3549, 14, 633, 480, 2105, 63, 354, 401, 1950, 63, 354, 12, 283, 495, 659, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 267, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 1246, 63, 1023, 401, 2986, 63, 1023, 12, 283, 495, 358, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6184, 61, 267, 1406, 63, 3214, 459, 8422, 418, 275, 291, 423, 3549, 14, 1291, 480, 5694, 401, 4729, 12, 283, 495, 358, 398, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 9, 267, 7679, 63, 1310, 275, 5517, 291, 423, 1258, 423, 7379, 14, 1065, 8, 1069, 12, 2547, 29, 797, 12, 1011, 958, 9, 267, 1177, 275, 7679, 63, 1310, 14, 1014, 63, 1310, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 1840, 2189, 288, 2341, 63, 705, 8, 1205, 63, 600, 29, 1310, 14, 1205, 63, 600, 12, 1177, 29, 1310, 12, 1125, 63, 1130, 29, 705, 63, 1130, 9, 288, 1125, 275, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
drawquest/drawquest-web
website/compressor/js.py
4
1181
from compressor.conf import settings from compressor.base import Compressor, SOURCE_HUNK, SOURCE_FILE from compressor.exceptions import UncompressableFileError class JsCompressor(Compressor): template_name = "compressor/js.html" template_name_inline = "compressor/js_inline.html" def __init__(self, content=None, output_prefix="js", context=None): super(JsCompressor, self).__init__(content, output_prefix, context) self.filters = list(settings.COMPRESS_JS_FILTERS) self.type = output_prefix def split_contents(self): if self.split_content: return self.split_content for elem in self.parser.js_elems(): attribs = self.parser.elem_attribs(elem) if 'src' in attribs: basename = self.get_basename(attribs['src']) filename = self.get_filename(basename) content = (SOURCE_FILE, filename, basename, elem) self.split_content.append(content) else: content = self.parser.elem_content(elem) self.split_content.append((SOURCE_HUNK, content, None, elem)) return self.split_content
bsd-3-clause
[ 504, 11029, 269, 14, 2190, 492, 2202, 199, 504, 11029, 269, 14, 1095, 492, 3599, 11686, 12, 25470, 63, 40, 8019, 12, 25470, 63, 3817, 199, 504, 11029, 269, 14, 3924, 492, 1910, 6447, 461, 25212, 421, 199, 533, 26231, 2404, 11686, 8, 2404, 11686, 304, 272, 1978, 63, 354, 275, 298, 27879, 15, 3596, 14, 1360, 2, 272, 1978, 63, 354, 63, 6460, 275, 298, 27879, 15, 3596, 63, 6460, 14, 1360, 2, 339, 347, 636, 826, 721, 277, 12, 1564, 29, 403, 12, 1072, 63, 1861, 628, 3596, 401, 1067, 29, 403, 304, 267, 1613, 8, 16633, 2404, 11686, 12, 291, 2843, 826, 721, 1317, 12, 1072, 63, 1861, 12, 1067, 9, 267, 291, 14, 4273, 275, 769, 8, 1751, 14, 22827, 1608, 63, 11378, 63, 9905, 51, 9, 267, 291, 14, 466, 275, 1072, 63, 1861, 339, 347, 3715, 63, 4407, 8, 277, 304, 267, 340, 291, 14, 1294, 63, 1317, 26, 288, 372, 291, 14, 1294, 63, 1317, 267, 367, 6193, 315, 291, 14, 2087, 14, 3596, 63, 17482, 837, 288, 737, 19577, 275, 291, 14, 2087, 14, 6086, 63, 30674, 8, 6086, 9, 288, 340, 283, 2164, 7, 315, 737, 19577, 26, 355, 9593, 275, 291, 14, 362, 63, 4846, 8, 30674, 459, 2164, 1105, 355, 1788, 275, 291, 14, 362, 63, 1501, 8, 4846, 9, 355, 1564, 275, 334, 10187, 63, 3817, 12, 1788, 12, 9593, 12, 6193, 9, 355, 291, 14, 1294, 63, 1317, 14, 740, 8, 1317, 9, 288, 587, 26, 355, 1564, 275, 291, 14, 2087, 14, 6086, 63, 1317, 8, 6086, 9, 355, 291, 14, 1294, 63, 1317, 14, 740, 1332, 10187, 63, 40, 8019, 12, 1564, 12, 488, 12, 6193, 430, 267, 372, 291, 14, 1294, 63, 1317, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11029, 269, 14, 2190, 492, 2202, 199, 504, 11029, 269, 14, 1095, 492, 3599, 11686, 12, 25470, 63, 40, 8019, 12, 25470, 63, 3817, 199, 504, 11029, 269, 14, 3924, 492, 1910, 6447, 461, 25212, 421, 199, 533, 26231, 2404, 11686, 8, 2404, 11686, 304, 272, 1978, 63, 354, 275, 298, 27879, 15, 3596, 14, 1360, 2, 272, 1978, 63, 354, 63, 6460, 275, 298, 27879, 15, 3596, 63, 6460, 14, 1360, 2, 339, 347, 636, 826, 721, 277, 12, 1564, 29, 403, 12, 1072, 63, 1861, 628, 3596, 401, 1067, 29, 403, 304, 267, 1613, 8, 16633, 2404, 11686, 12, 291, 2843, 826, 721, 1317, 12, 1072, 63, 1861, 12, 1067, 9, 267, 291, 14, 4273, 275, 769, 8, 1751, 14, 22827, 1608, 63, 11378, 63, 9905, 51, 9, 267, 291, 14, 466, 275, 1072, 63, 1861, 339, 347, 3715, 63, 4407, 8, 277, 304, 267, 340, 291, 14, 1294, 63, 1317, 26, 288, 372, 291, 14, 1294, 63, 1317, 267, 367, 6193, 315, 291, 14, 2087, 14, 3596, 63, 17482, 837, 288, 737, 19577, 275, 291, 14, 2087, 14, 6086, 63, 30674, 8, 6086, 9, 288, 340, 283, 2164, 7, 315, 737, 19577, 26, 355, 9593, 275, 291, 14, 362, 63, 4846, 8, 30674, 459, 2164, 1105, 355, 1788, 275, 291, 14, 362, 63, 1501, 8, 4846, 9, 355, 1564, 275, 334, 10187, 63, 3817, 12, 1788, 12, 9593, 12, 6193, 9, 355, 291, 14, 1294, 63, 1317, 14, 740, 8, 1317, 9, 288, 587, 26, 355, 1564, 275, 291, 14, 2087, 14, 6086, 63, 1317, 8, 6086, 9, 355, 291, 14, 1294, 63, 1317, 14, 740, 1332, 10187, 63, 40, 8019, 12, 1564, 12, 488, 12, 6193, 430, 267, 372, 291, 14, 1294, 63, 1317, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
chris-chris/tensorflow
tensorflow/contrib/tensor_forest/hybrid/python/ops/training_ops.py
134
11225
# 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. # ============================================================================== """Ops for hybrid model training.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import threading from tensorflow.contrib.tensor_forest.hybrid.ops import gen_training_ops from tensorflow.contrib.util import loader from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import resource_loader from tensorflow.python.platform import tf_logging as logging TRAINING_OPS_FILE = '_training_ops.so' _training_ops = None _ops_lock = threading.Lock() # TODO(b/31222613): Some of these ops are probably differentiable, and # there may be latent bugs here. ops.NotDifferentiable('HardRoutingFunction') ops.NotDifferentiable('RoutingGradient') ops.NotDifferentiable('KFeatureDataGradient') ops.NotDifferentiable('KFeatureRoutingGradient') ops.NotDifferentiable('KFeatureWeightGradient') ops.NotDifferentiable('UnpackPath') @ops.RegisterGradient('RoutingFunction') def _RoutingFunctionGradient(op, grad): """The gradient of RoutingFunction. Args: op: The RoutingFunction op. grad: Gradient with respect to the output of the RoutingFunction op. Returns: Gradients with respect to the input of the RoutingFunction op. """ routing_gradient = gen_training_ops.routing_gradient input_data_tensor = op.inputs[0] tree_weights_tensor = op.inputs[1] tree_thresholds_tensor = op.inputs[2] routing_function_tensor = op.outputs[0] # The derivatives below are each defined over one or two of three dimensions: # (batch_size, num_nodes, num_features). We explicitly expand each derivative # to three dimensions to ensure that they're broadcasted correctly. # dl / du is the derivative of the loss with respect to the output of the # routing function, which is provided by tensorflow. # # dl / du has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). dl_du = array_ops.expand_dims(grad, 2) # du / df is the derivative of the output of the routing function with respect # to the decision function at each node. It is computed by # routing_gradient_op.cc. # # du / df has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). du_df = array_ops.expand_dims( routing_gradient( input_data_tensor, tree_weights_tensor, tree_thresholds_tensor, routing_function_tensor, max_nodes=op.get_attr('max_nodes')), 2) # df / dx is the derivative of the decision function with respect to the input # data. f_i(x) = (-t_i * x + b_i), so df_i / dx = -t_i. # # df / dx has dimension (num_nodes, num_features), which we expand to # (1, num_nodes, num_features). df_dx = -array_ops.expand_dims(tree_weights_tensor, 0) # df / dt is the derivative of the decision function with respect to its # parameters. f_i(x) = (-t_i * x + b_i), so df_i / d t_i = -x. # # df / dt has dimension (batch_size, num_features), which we expand to # (batch_size, 1, num_features). df_dt = -array_ops.expand_dims(input_data_tensor, 1) # df / dt is the derivative of the decision function with respect to its # bias parameter. f_i(x) = (-t_i * x + b_i), so df_i / d t_i = 1. # # df / db has dimension (num_nodes), which we expand to # (1, num_nodes, 1). df_db = array_ops.expand_dims( array_ops.expand_dims(array_ops.ones_like(tree_thresholds_tensor), 0), 2) # Compute the derivatives of the loss with respect to the inputs using the # chain rule (backpropagation). dl_dx = math_ops.reduce_mean(dl_du * du_df * df_dx, 1) dl_dt = math_ops.reduce_mean(dl_du * du_df * df_dt, 0) dl_db = math_ops.reduce_mean(array_ops.squeeze(dl_du * du_df * df_db, [2]), 0) input_gradients = [dl_dx, dl_dt, dl_db] return input_gradients @ops.RegisterGradient('StochasticHardRoutingFunction') def _StochasticHardRoutingFunctionGradient(op, routing_grad, unused_path_grad): """The gradient of RoutingFunction. Args: op: The RoutingFunction op. routing_grad: Gradient with respect to the output of the RoutingFunction op. Returns: Gradients with respect to the input of the RoutingFunction op. """ gradient_op = gen_training_ops.stochastic_hard_routing_gradient unpack_path_op = gen_training_ops.unpack_path input_data_tensor = op.inputs[0] tree_weights_tensor = op.inputs[1] tree_thresholds_tensor = op.inputs[2] path_probability_tensor = op.outputs[0] path_tensor = op.outputs[1] # The derivatives below are each defined over one or two of three dimensions: # (batch_size, num_nodes, num_features). We explicitly expand each derivative # to three dimensions to ensure that they're broadcasted correctly. du_df_raw, df_dx_raw, df_dt_raw, df_db_raw = gradient_op( input_data_tensor, tree_weights_tensor, tree_thresholds_tensor, path_probability_tensor, path_tensor, tree_depth=op.get_attr('tree_depth')) # dl / du is the derivative of the loss with respect to the output of the # routing function, which is provided by tensorflow. # # dl / du has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). dl_du = array_ops.expand_dims(unpack_path_op(path_tensor, routing_grad), 2) # du / df is the derivative of the output of the routing function with respect # to the decision function at each node. It is computed by # single_feature_routing_gradient_op.cc. # # du / df has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). du_df = array_ops.expand_dims(du_df_raw, 2) # df / dx is the derivative of the decision function with respect to the input # data. f(x) = (-t * x + b), so df / dx = -t for the selected features and # zero elsewhere. # # df / dx has dimension (num_nodes, num_features), which we expand to # (1, num_nodes, num_features). df_dx = array_ops.expand_dims(df_dx_raw, 0) # df / dt is the derivative of the decision function with respect to its # parameters. f(x) = (-t * x + b), so df / dt = -x[feature]. # # df / dt has dimension (batch_size, num_nodes, num_features). df_dt = -df_dt_raw # df / dt is the derivative of the decision function with respect to its # bias parameter. f(x) = (-t * x + b), so df / dt = 1. # # df / db has dimension (num_nodes), which we expand to # (1, num_nodes, 1). df_db = array_ops.expand_dims(array_ops.expand_dims(df_db_raw, 0), 2) # Compute the derivatives of the loss with respect to the inputs using the # chain rule (backpropagation). dl_dx = math_ops.reduce_mean(dl_du * du_df * df_dx, 1) dl_dt = math_ops.reduce_mean(dl_du * du_df * df_dt, 0) dl_db = math_ops.reduce_mean(array_ops.squeeze(dl_du * du_df * df_db, [2]), 0) input_gradients = [dl_dx, dl_dt, dl_db] return input_gradients @ops.RegisterGradient('KFeatureRoutingFunction') def _KFeatureRoutingFunctionGradient(op, grad): """The gradient of RoutingFunction. Args: op: The RoutingFunction op. grad: Gradient with respect to the output of the RoutingFunction op. Returns: Gradients with respect to the input of the RoutingFunction op. """ gradient_op = gen_training_ops.k_feature_gradient input_data_tensor = op.inputs[0] tree_weights_tensor = op.inputs[1] tree_thresholds_tensor = op.inputs[2] routing_function_tensor = op.outputs[0] # The derivatives below are each defined over one or two of three dimensions: # (batch_size, num_nodes, num_features). We explicitly expand each derivative # to three dimensions to ensure that they're broadcasted correctly. du_df_raw, df_dx_raw, df_dt_raw = gradient_op( input_data_tensor, tree_weights_tensor, tree_thresholds_tensor, routing_function_tensor, layer_num=op.get_attr('layer_num'), random_seed=op.get_attr('random_seed')) # dl / du is the derivative of the loss with respect to the output of the # routing function, which is provided by tensorflow. # # dl / du has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). dl_du = array_ops.expand_dims(grad, 2) # du / df is the derivative of the output of the routing function with respect # to the decision function at each node. It is computed by # single_feature_routing_gradient_op.cc. # # du / df has dimension (batch_size, num_nodes), which we expand to # (batch_size, num_nodes, 1). du_df = array_ops.expand_dims(du_df_raw, 2) # df / dx is the derivative of the decision function with respect to the input # data. f(x) = (-t * x + b), so df / dx = -t for the selected features and # zero elsewhere. # # df / dx has dimension (num_nodes, num_features), which we expand to # (1, num_nodes, num_features). df_dx = array_ops.expand_dims(df_dx_raw, 0) # df / dt is the derivative of the decision function with respect to its # parameters. f(x) = (-t * x + b), so df / dt = -x[feature]. # # df / dt has dimension (batch_size, num_nodes, num_features). df_dt = -df_dt_raw # df / dt is the derivative of the decision function with respect to its # bias parameter. f(x) = (-t * x + b), so df / dt = 1. # # df / db has dimension (num_nodes), which we expand to # (1, num_nodes, 1). df_db = array_ops.expand_dims( array_ops.expand_dims(array_ops.ones_like(tree_thresholds_tensor), 0), 2) # Compute the derivatives of the loss with respect to the inputs using the # chain rule (backpropagation). dl_dx = math_ops.reduce_mean(dl_du * du_df * df_dx, 1) dl_dt = math_ops.reduce_mean(dl_du * du_df * df_dt, 0) dl_db = math_ops.reduce_mean(array_ops.squeeze(dl_du * du_df * df_db, [2]), 0) input_gradients = [dl_dx, dl_dt, dl_db] return input_gradients # Workaround for the fact that importing tensorflow imports contrib # (even if a user isn't using this or any other contrib op), but # there's not yet any guarantee that the shared object exists. # In which case, "import tensorflow" will always crash, even for users that # never use contrib. def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = loader.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
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, 16452, 367, 7188, 14601, 1402, 6093, 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, 5796, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1483, 492, 3805, 63, 7588, 63, 1483, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 199, 18473, 1206, 63, 21665, 63, 3817, 275, 2513, 7588, 63, 1483, 14, 1152, 7, 199, 199, 63, 7588, 63, 1483, 275, 488, 199, 63, 1483, 63, 831, 275, 5796, 14, 6432, 342, 199, 199, 3, 3254, 8, 66, 15, 16683, 11085, 969, 304, 6601, 402, 3520, 4156, 787, 8646, 26796, 461, 12, 436, 199, 3, 2337, 1443, 506, 2465, 343, 18227, 2348, 14, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 16464, 8056, 3481, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 8056, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 1451, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 8056, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 16359, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 26472, 2042, 358, 421, 199, 32, 1483, 14, 24876, 360, 8056, 3481, 358, 199, 318, 485, 8056, 3481, 9942, 8, 411, 12, 7659, 304, 523, 408, 1918, 6709, 402, 30790, 316, 3481, 14, 819, 3033, 26, 272, 1687, 26, 710, 30790, 316, 3481, 1687, 14, 272, 7659, 26, 19603, 543, 14021, 370, 314, 1072, 402, 314, 30790, 316, 3481, 1687, 14, 819, 1803, 26, 272, 19603, 83, 543, 14021, 370, 314, 1324, 402, 314, 30790, 316, 3481, 1687, 14, 523, 408, 523, 14870, 63, 7490, 275, 3805, 63, 7588, 63, 1483, 14, 9492, 63, 7490, 819, 1324, 63, 576, 63, 3128, 275, 1687, 14, 3711, 59, 16, 61, 523, 3123, 63, 4916, 63, 3128, 275, 1687, 14, 3711, 59, 17, 61, 523, 3123, 63, 22611, 63, 3128, 275, 1687, 14, 3711, 59, 18, 61, 819, 14870, 63, 1593, 63, 3128, 275, 1687, 14, 4467, 59, 16, 61, 819, 327, 710, 28059, 5084, 787, 1924, 3247, 1806, 1373, 503, 2877, 402, 7795, 7365, 26, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 1967, 63, 3179, 680, 221, 2136, 7662, 6544, 1924, 18883, 523, 327, 370, 7795, 7365, 370, 4868, 626, 2985, 3984, 330, 5063, 9765, 471, 6657, 14, 819, 327, 15396, 1182, 15776, 365, 314, 18883, 402, 314, 5621, 543, 14021, 370, 314, 1072, 402, 314, 523, 327, 14870, 805, 12, 1314, 365, 2741, 701, 3228, 14, 523, 327, 523, 327, 15396, 1182, 15776, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 2415, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 413, 680, 523, 15396, 63, 2033, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 6017, 12, 499, 9, 819, 327, 15776, 1182, 4051, 365, 314, 18883, 402, 314, 1072, 402, 314, 14870, 805, 543, 14021, 523, 327, 370, 314, 14692, 805, 737, 1924, 1031, 14, 221, 2779, 365, 9235, 701, 523, 327, 14870, 63, 7490, 63, 411, 14, 2055, 14, 523, 327, 523, 327, 15776, 1182, 4051, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 2415, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 413, 680, 523, 15776, 63, 1587, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 489, 14870, 63, 7490, 8, 881, 1324, 63, 576, 63, 3128, 12, 881, 3123, 63, 4916, 63, 3128, 12, 881, 3123, 63, 22611, 63, 3128, 12, 881, 14870, 63, 1593, 63, 3128, 12, 881, 1390, 63, 2415, 29, 411, 14, 362, 63, 962, 360, 988, 63, 2415, 3855, 489, 499, 9, 819, 327, 4051, 1182, 11868, 365, 314, 18883, 402, 314, 14692, 805, 543, 14021, 370, 314, 1324, 523, 327, 666, 14, 221, 289, 63, 73, 8, 88, 9, 275, 5868, 84, 63, 73, 627, 671, 435, 330, 63, 73, 395, 880, 4051, 63, 73, 1182, 11868, 275, 446, 84, 63, 73, 14, 523, 327, 523, 327, 4051, 1182, 11868, 965, 6240, 334, 1507, 63, 2415, 12, 1967, 63, 3179, 395, 1314, 781, 6544, 370, 523, 327, 334, 17, 12, 1967, 63, 2415, 12, 1967, 63, 3179, 680, 523, 4051, 63, 8373, 275, 446, 1144, 63, 1483, 14, 4441, 63, 5380, 8, 2350, 63, 4916, 63, 3128, 12, 378, 9, 819, 327, 4051, 1182, 4487, 365, 314, 18883, 402, 314, 14692, 805, 543, 14021, 370, 2399, 523, 327, 2633, 14, 289, 63, 73, 8, 88, 9, 275, 5868, 84, 63, 73, 627, 671, 435, 330, 63, 73, 395, 880, 4051, 63, 73, 1182, 366, 307, 63, 73, 275, 446, 88, 14, 523, 327, 523, 327, 4051, 1182, 4487, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 3179, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 413, 12, 1967, 63, 3179, 680, 523, 4051, 63, 3583, 275 ]
[ 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, 16452, 367, 7188, 14601, 1402, 6093, 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, 5796, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1483, 492, 3805, 63, 7588, 63, 1483, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 199, 199, 18473, 1206, 63, 21665, 63, 3817, 275, 2513, 7588, 63, 1483, 14, 1152, 7, 199, 199, 63, 7588, 63, 1483, 275, 488, 199, 63, 1483, 63, 831, 275, 5796, 14, 6432, 342, 199, 199, 3, 3254, 8, 66, 15, 16683, 11085, 969, 304, 6601, 402, 3520, 4156, 787, 8646, 26796, 461, 12, 436, 199, 3, 2337, 1443, 506, 2465, 343, 18227, 2348, 14, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 16464, 8056, 3481, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 8056, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 1451, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 8056, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 43, 5968, 16359, 9942, 358, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 26472, 2042, 358, 421, 199, 32, 1483, 14, 24876, 360, 8056, 3481, 358, 199, 318, 485, 8056, 3481, 9942, 8, 411, 12, 7659, 304, 523, 408, 1918, 6709, 402, 30790, 316, 3481, 14, 819, 3033, 26, 272, 1687, 26, 710, 30790, 316, 3481, 1687, 14, 272, 7659, 26, 19603, 543, 14021, 370, 314, 1072, 402, 314, 30790, 316, 3481, 1687, 14, 819, 1803, 26, 272, 19603, 83, 543, 14021, 370, 314, 1324, 402, 314, 30790, 316, 3481, 1687, 14, 523, 408, 523, 14870, 63, 7490, 275, 3805, 63, 7588, 63, 1483, 14, 9492, 63, 7490, 819, 1324, 63, 576, 63, 3128, 275, 1687, 14, 3711, 59, 16, 61, 523, 3123, 63, 4916, 63, 3128, 275, 1687, 14, 3711, 59, 17, 61, 523, 3123, 63, 22611, 63, 3128, 275, 1687, 14, 3711, 59, 18, 61, 819, 14870, 63, 1593, 63, 3128, 275, 1687, 14, 4467, 59, 16, 61, 819, 327, 710, 28059, 5084, 787, 1924, 3247, 1806, 1373, 503, 2877, 402, 7795, 7365, 26, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 1967, 63, 3179, 680, 221, 2136, 7662, 6544, 1924, 18883, 523, 327, 370, 7795, 7365, 370, 4868, 626, 2985, 3984, 330, 5063, 9765, 471, 6657, 14, 819, 327, 15396, 1182, 15776, 365, 314, 18883, 402, 314, 5621, 543, 14021, 370, 314, 1072, 402, 314, 523, 327, 14870, 805, 12, 1314, 365, 2741, 701, 3228, 14, 523, 327, 523, 327, 15396, 1182, 15776, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 2415, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 413, 680, 523, 15396, 63, 2033, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 6017, 12, 499, 9, 819, 327, 15776, 1182, 4051, 365, 314, 18883, 402, 314, 1072, 402, 314, 14870, 805, 543, 14021, 523, 327, 370, 314, 14692, 805, 737, 1924, 1031, 14, 221, 2779, 365, 9235, 701, 523, 327, 14870, 63, 7490, 63, 411, 14, 2055, 14, 523, 327, 523, 327, 15776, 1182, 4051, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 2415, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 1967, 63, 2415, 12, 413, 680, 523, 15776, 63, 1587, 275, 1625, 63, 1483, 14, 4441, 63, 5380, 8, 489, 14870, 63, 7490, 8, 881, 1324, 63, 576, 63, 3128, 12, 881, 3123, 63, 4916, 63, 3128, 12, 881, 3123, 63, 22611, 63, 3128, 12, 881, 14870, 63, 1593, 63, 3128, 12, 881, 1390, 63, 2415, 29, 411, 14, 362, 63, 962, 360, 988, 63, 2415, 3855, 489, 499, 9, 819, 327, 4051, 1182, 11868, 365, 314, 18883, 402, 314, 14692, 805, 543, 14021, 370, 314, 1324, 523, 327, 666, 14, 221, 289, 63, 73, 8, 88, 9, 275, 5868, 84, 63, 73, 627, 671, 435, 330, 63, 73, 395, 880, 4051, 63, 73, 1182, 11868, 275, 446, 84, 63, 73, 14, 523, 327, 523, 327, 4051, 1182, 11868, 965, 6240, 334, 1507, 63, 2415, 12, 1967, 63, 3179, 395, 1314, 781, 6544, 370, 523, 327, 334, 17, 12, 1967, 63, 2415, 12, 1967, 63, 3179, 680, 523, 4051, 63, 8373, 275, 446, 1144, 63, 1483, 14, 4441, 63, 5380, 8, 2350, 63, 4916, 63, 3128, 12, 378, 9, 819, 327, 4051, 1182, 4487, 365, 314, 18883, 402, 314, 14692, 805, 543, 14021, 370, 2399, 523, 327, 2633, 14, 289, 63, 73, 8, 88, 9, 275, 5868, 84, 63, 73, 627, 671, 435, 330, 63, 73, 395, 880, 4051, 63, 73, 1182, 366, 307, 63, 73, 275, 446, 88, 14, 523, 327, 523, 327, 4051, 1182, 4487, 965, 6240, 334, 2912, 63, 890, 12, 1967, 63, 3179, 395, 1314, 781, 6544, 370, 523, 327, 334, 2912, 63, 890, 12, 413, 12, 1967, 63, 3179, 680, 523, 4051, 63, 3583, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jcrugzz/lpvisualization
django/core/mail/backends/smtp.py
202
3878
"""SMTP email backend class.""" import smtplib import socket import threading from django.conf import settings from django.core.mail.backends.base import BaseEmailBackend from django.core.mail.utils import DNS_NAME from django.core.mail.message import sanitize_address class EmailBackend(BaseEmailBackend): """ A wrapper that manages the SMTP network connection. """ def __init__(self, host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, **kwargs): super(EmailBackend, self).__init__(fail_silently=fail_silently) self.host = host or settings.EMAIL_HOST self.port = port or settings.EMAIL_PORT self.username = username or settings.EMAIL_HOST_USER self.password = password or settings.EMAIL_HOST_PASSWORD if use_tls is None: self.use_tls = settings.EMAIL_USE_TLS else: self.use_tls = use_tls self.connection = None self._lock = threading.RLock() def open(self): """ Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False). """ if self.connection: # Nothing to do if the connection is already open. return False try: # If local_hostname is not specified, socket.getfqdn() gets used. # For performance, we use the cached FQDN for local_hostname. self.connection = smtplib.SMTP(self.host, self.port, local_hostname=DNS_NAME.get_fqdn()) if self.use_tls: self.connection.ehlo() self.connection.starttls() self.connection.ehlo() if self.username and self.password: self.connection.login(self.username, self.password) return True except: if not self.fail_silently: raise def close(self): """Closes the connection to the email server.""" try: try: self.connection.quit() except socket.sslerror: # This happens when calling quit() on a TLS connection # sometimes. self.connection.close() except: if self.fail_silently: return raise finally: self.connection = None def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return self._lock.acquire() try: new_conn_created = self.open() if not self.connection: # We failed silently on open(). # Trying to send would be pointless. return num_sent = 0 for message in email_messages: sent = self._send(message) if sent: num_sent += 1 if new_conn_created: self.close() finally: self._lock.release() return num_sent def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False from_email = sanitize_address(email_message.from_email, email_message.encoding) recipients = [sanitize_address(addr, email_message.encoding) for addr in email_message.recipients()] try: self.connection.sendmail(from_email, recipients, email_message.message().as_string()) except: if not self.fail_silently: raise return False return True
bsd-3-clause
[ 624, 20927, 3031, 4865, 1021, 1041, 199, 646, 30475, 199, 646, 2838, 199, 646, 5796, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1198, 14, 7765, 14, 1095, 492, 3523, 7035, 8447, 199, 504, 1639, 14, 1018, 14, 1198, 14, 1208, 492, 10237, 63, 2339, 199, 504, 1639, 14, 1018, 14, 1198, 14, 1188, 492, 21077, 63, 1562, 421, 199, 533, 11426, 8447, 8, 1563, 7035, 8447, 304, 272, 408, 272, 437, 4975, 626, 31965, 314, 19810, 2784, 1950, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 3434, 29, 403, 12, 2505, 29, 403, 12, 326, 675, 63, 9945, 29, 403, 12, 2449, 63, 25163, 29, 797, 12, 1011, 958, 304, 267, 1613, 8, 7035, 8447, 12, 291, 2843, 826, 721, 1633, 63, 25163, 29, 1633, 63, 25163, 9, 267, 291, 14, 1102, 275, 1591, 503, 2202, 14, 10089, 63, 5449, 267, 291, 14, 719, 275, 1844, 503, 2202, 14, 10089, 63, 3657, 267, 291, 14, 2473, 275, 3434, 503, 2202, 14, 10089, 63, 5449, 63, 3791, 267, 291, 14, 2060, 275, 2505, 503, 2202, 14, 10089, 63, 5449, 63, 9032, 267, 340, 675, 63, 9945, 365, 488, 26, 288, 291, 14, 1180, 63, 9945, 275, 2202, 14, 10089, 63, 4701, 63, 10224, 267, 587, 26, 288, 291, 14, 1180, 63, 9945, 275, 675, 63, 9945, 267, 291, 14, 2105, 275, 488, 267, 291, 423, 831, 275, 5796, 14, 30550, 342, 339, 347, 1551, 8, 277, 304, 267, 408, 267, 29652, 781, 1172, 282, 1950, 370, 314, 3031, 1654, 14, 1803, 3775, 503, 267, 440, 282, 892, 1950, 1990, 1415, 334, 549, 503, 756, 680, 267, 408, 267, 340, 291, 14, 2105, 26, 288, 327, 20550, 370, 886, 340, 314, 1950, 365, 2575, 1551, 14, 288, 372, 756, 267, 862, 26, 288, 327, 982, 2257, 63, 4269, 365, 440, 2013, 12, 2838, 14, 362, 18364, 342, 7545, 1202, 14, 288, 327, 2104, 10238, 12, 781, 675, 314, 6328, 481, 49, 10872, 367, 2257, 63, 4269, 14, 288, 291, 14, 2105, 275, 30475, 14, 20927, 8, 277, 14, 1102, 12, 291, 14, 719, 12, 5644, 2257, 63, 4269, 29, 12323, 63, 2339, 14, 362, 63, 18364, 1012, 288, 340, 291, 14, 1180, 63, 9945, 26, 355, 291, 14, 2105, 14, 24528, 320, 342, 355, 291, 14, 2105, 14, 928, 9945, 342, 355, 291, 14, 2105, 14, 24528, 320, 342, 288, 340, 291, 14, 2473, 436, 291, 14, 2060, 26, 355, 291, 14, 2105, 14, 2886, 8, 277, 14, 2473, 12, 291, 14, 2060, 9, 288, 372, 715, 267, 871, 26, 288, 340, 440, 291, 14, 1633, 63, 25163, 26, 355, 746, 339, 347, 4002, 8, 277, 304, 267, 408, 3337, 874, 314, 1950, 370, 314, 3031, 1654, 1041, 267, 862, 26, 288, 862, 26, 355, 291, 14, 2105, 14, 10589, 342, 288, 871, 2838, 14, 385, 1435, 451, 26, 355, 327, 961, 10986, 1380, 6358, 17242, 342, 641, 282, 12213, 1950, 355, 327, 15026, 14, 355, 291, 14, 2105, 14, 1600, 342, 288, 871, 26, 355, 340, 291, 14, 1633, 63, 25163, 26, 490, 372, 355, 746, 267, 3753, 26, 288, 291, 14, 2105, 275, 488, 339, 347, 3222, 63, 3431, 8, 277, 12, 3031, 63, 3431, 304, 267, 408, 267, 428, 3198, 1373, 503, 1655, 11426, 2209, 2251, 436, 2529, 314, 1329, 402, 3031, 267, 3788, 4847, 14, 267, 408, 267, 340, 440, 3031, 63, 3431, 26, 288, 372, 267, 291, 423, 831, 14, 8174, 342, 267, 862, 26, 288, 892, 63, 1631, 63, 3966, 275, 291, 14, 1490, 342, 288, 340, 440, 291, 14, 2105, 26, 355, 327, 2136, 3405, 18030, 641, 1551, 1252, 355, 327, 7649, 316, 370, 3222, 3955, 506, 2376, 2003, 14, 355, 372, 288, 1967, 63, 1150, 275, 378, 288, 367, 1245, 315, 3031, 63, 3431, 26, 355, 4847, 275, 291, 423, 2254, 8, 1188, 9, 355, 340, 4847, 26, 490, 1967, 63, 1150, 847, 413, 288, 340, 892, 63, 1631, 63, 3966, 26, 355, 291, 14, 1600, 342, 267, 3753, 26, 288, 291, 423, 831, 14, 3221, 342, 267, 372, 1967, 63, 1150, 339, 347, 485, 2254, 8, 277, 12, 3031, 63, 1188, 304, 267, 408, 33, 5922, 1083, 626, 1630, 314, 3503, 10209, 1041, 267, 340, 440, 3031, 63, 1188, 14, 18323, 837, 288, 372, 756, 267, 687, 63, 2123, 275, 21077, 63, 1562, 8, 2123, 63, 1188, 14, 504, 63, 2123, 12, 3031, 63, 1188, 14, 2991, 9, 267, 19255, 275, 359, 18177, 63, 1562, 8, 2697, 12, 3031, 63, 1188, 14, 2991, 9, 1993, 367, 5552, 315, 3031, 63, 1188, 14, 18323, 5106, 267, 862, 26, 288, 291, 14, 2105, 14, 2254, 1198, 8, 504, 63, 2123, 12, 19255, 12, 490, 3031, 63, 1188, 14, 1188, 1252, 305, 63, 875, 1012, 267, 871, 26, 288, 340, 440, 291, 14, 1633, 63, 25163, 26, 355, 746, 288, 372, 756, 267, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20927, 3031, 4865, 1021, 1041, 199, 646, 30475, 199, 646, 2838, 199, 646, 5796, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1198, 14, 7765, 14, 1095, 492, 3523, 7035, 8447, 199, 504, 1639, 14, 1018, 14, 1198, 14, 1208, 492, 10237, 63, 2339, 199, 504, 1639, 14, 1018, 14, 1198, 14, 1188, 492, 21077, 63, 1562, 421, 199, 533, 11426, 8447, 8, 1563, 7035, 8447, 304, 272, 408, 272, 437, 4975, 626, 31965, 314, 19810, 2784, 1950, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 3434, 29, 403, 12, 2505, 29, 403, 12, 326, 675, 63, 9945, 29, 403, 12, 2449, 63, 25163, 29, 797, 12, 1011, 958, 304, 267, 1613, 8, 7035, 8447, 12, 291, 2843, 826, 721, 1633, 63, 25163, 29, 1633, 63, 25163, 9, 267, 291, 14, 1102, 275, 1591, 503, 2202, 14, 10089, 63, 5449, 267, 291, 14, 719, 275, 1844, 503, 2202, 14, 10089, 63, 3657, 267, 291, 14, 2473, 275, 3434, 503, 2202, 14, 10089, 63, 5449, 63, 3791, 267, 291, 14, 2060, 275, 2505, 503, 2202, 14, 10089, 63, 5449, 63, 9032, 267, 340, 675, 63, 9945, 365, 488, 26, 288, 291, 14, 1180, 63, 9945, 275, 2202, 14, 10089, 63, 4701, 63, 10224, 267, 587, 26, 288, 291, 14, 1180, 63, 9945, 275, 675, 63, 9945, 267, 291, 14, 2105, 275, 488, 267, 291, 423, 831, 275, 5796, 14, 30550, 342, 339, 347, 1551, 8, 277, 304, 267, 408, 267, 29652, 781, 1172, 282, 1950, 370, 314, 3031, 1654, 14, 1803, 3775, 503, 267, 440, 282, 892, 1950, 1990, 1415, 334, 549, 503, 756, 680, 267, 408, 267, 340, 291, 14, 2105, 26, 288, 327, 20550, 370, 886, 340, 314, 1950, 365, 2575, 1551, 14, 288, 372, 756, 267, 862, 26, 288, 327, 982, 2257, 63, 4269, 365, 440, 2013, 12, 2838, 14, 362, 18364, 342, 7545, 1202, 14, 288, 327, 2104, 10238, 12, 781, 675, 314, 6328, 481, 49, 10872, 367, 2257, 63, 4269, 14, 288, 291, 14, 2105, 275, 30475, 14, 20927, 8, 277, 14, 1102, 12, 291, 14, 719, 12, 5644, 2257, 63, 4269, 29, 12323, 63, 2339, 14, 362, 63, 18364, 1012, 288, 340, 291, 14, 1180, 63, 9945, 26, 355, 291, 14, 2105, 14, 24528, 320, 342, 355, 291, 14, 2105, 14, 928, 9945, 342, 355, 291, 14, 2105, 14, 24528, 320, 342, 288, 340, 291, 14, 2473, 436, 291, 14, 2060, 26, 355, 291, 14, 2105, 14, 2886, 8, 277, 14, 2473, 12, 291, 14, 2060, 9, 288, 372, 715, 267, 871, 26, 288, 340, 440, 291, 14, 1633, 63, 25163, 26, 355, 746, 339, 347, 4002, 8, 277, 304, 267, 408, 3337, 874, 314, 1950, 370, 314, 3031, 1654, 1041, 267, 862, 26, 288, 862, 26, 355, 291, 14, 2105, 14, 10589, 342, 288, 871, 2838, 14, 385, 1435, 451, 26, 355, 327, 961, 10986, 1380, 6358, 17242, 342, 641, 282, 12213, 1950, 355, 327, 15026, 14, 355, 291, 14, 2105, 14, 1600, 342, 288, 871, 26, 355, 340, 291, 14, 1633, 63, 25163, 26, 490, 372, 355, 746, 267, 3753, 26, 288, 291, 14, 2105, 275, 488, 339, 347, 3222, 63, 3431, 8, 277, 12, 3031, 63, 3431, 304, 267, 408, 267, 428, 3198, 1373, 503, 1655, 11426, 2209, 2251, 436, 2529, 314, 1329, 402, 3031, 267, 3788, 4847, 14, 267, 408, 267, 340, 440, 3031, 63, 3431, 26, 288, 372, 267, 291, 423, 831, 14, 8174, 342, 267, 862, 26, 288, 892, 63, 1631, 63, 3966, 275, 291, 14, 1490, 342, 288, 340, 440, 291, 14, 2105, 26, 355, 327, 2136, 3405, 18030, 641, 1551, 1252, 355, 327, 7649, 316, 370, 3222, 3955, 506, 2376, 2003, 14, 355, 372, 288, 1967, 63, 1150, 275, 378, 288, 367, 1245, 315, 3031, 63, 3431, 26, 355, 4847, 275, 291, 423, 2254, 8, 1188, 9, 355, 340, 4847, 26, 490, 1967, 63, 1150, 847, 413, 288, 340, 892, 63, 1631, 63, 3966, 26, 355, 291, 14, 1600, 342, 267, 3753, 26, 288, 291, 423, 831, 14, 3221, 342, 267, 372, 1967, 63, 1150, 339, 347, 485, 2254, 8, 277, 12, 3031, 63, 1188, 304, 267, 408, 33, 5922, 1083, 626, 1630, 314, 3503, 10209, 1041, 267, 340, 440, 3031, 63, 1188, 14, 18323, 837, 288, 372, 756, 267, 687, 63, 2123, 275, 21077, 63, 1562, 8, 2123, 63, 1188, 14, 504, 63, 2123, 12, 3031, 63, 1188, 14, 2991, 9, 267, 19255, 275, 359, 18177, 63, 1562, 8, 2697, 12, 3031, 63, 1188, 14, 2991, 9, 1993, 367, 5552, 315, 3031, 63, 1188, 14, 18323, 5106, 267, 862, 26, 288, 291, 14, 2105, 14, 2254, 1198, 8, 504, 63, 2123, 12, 19255, 12, 490, 3031, 63, 1188, 14, 1188, 1252, 305, 63, 875, 1012, 267, 871, 26, 288, 340, 440, 291, 14, 1633, 63, 25163, 26, 355, 746, 288, 372, 756, 267, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kenshay/ImageScripter
ProgramData/Android/ADB/platform-tools/systrace/catapult/telemetry/telemetry/internal/platform/msr_server_win.py
7
3273
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """A server that serves MSR values over TCP. Takes a port as its sole parameter. The reference client for this server is msr_power_monitor.MsrPowerMonitor. Must be run as Administrator. We use TCP instead of named pipes or another IPC to avoid dealing with the pipe security mechanisms. We take the port as a parameter instead of choosing one, because it's hard to communicate the port number across integrity levels. Requires WinRing0 to be installed in the Python directory. msr_power_monitor.MsrPowerMonitor does this if needed. """ import argparse import ctypes import os import SocketServer import struct import sys try: import win32api # pylint: disable=import-error import win32file # pylint: disable=import-error except ImportError: win32api = None win32file = None WINRING0_STATUS_MESSAGES = ( 'No error', 'Unsupported platform', 'Driver not loaded. You may need to run as Administrator', 'Driver not found', 'Driver unloaded by other process', 'Driver not loaded because of executing on Network Drive', 'Unknown error', ) # The DLL initialization is global, so put it in a global variable. _winring0 = None class WinRing0Error(OSError): pass def _WinRing0Path(): python_is_64_bit = sys.maxsize > 2 ** 32 dll_file_name = 'WinRing0x64.dll' if python_is_64_bit else 'WinRing0.dll' return os.path.join(os.path.dirname(sys.executable), dll_file_name) def _Initialize(): global _winring0 if not _winring0: winring0 = ctypes.WinDLL(_WinRing0Path()) if not winring0.InitializeOls(): winring0_status = winring0.GetDllStatus() raise WinRing0Error(winring0_status, 'Unable to initialize WinRing0: %s' % WINRING0_STATUS_MESSAGES[winring0_status]) _winring0 = winring0 def _Deinitialize(): global _winring0 if _winring0: _winring0.DeinitializeOls() _winring0 = None def _ReadMsr(msr_number): low = ctypes.c_uint() high = ctypes.c_uint() _winring0.Rdmsr(ctypes.c_uint(msr_number), ctypes.byref(low), ctypes.byref(high)) return high.value << 32 | low.value class MsrRequestHandler(SocketServer.StreamRequestHandler): def handle(self): msr_number = struct.unpack('I', self.rfile.read(4))[0] self.wfile.write(struct.pack('Q', _ReadMsr(msr_number))) def main(): parser = argparse.ArgumentParser() parser.add_argument('pipe_name', type=str) args = parser.parse_args() _Initialize() try: SocketServer.TCPServer.allow_reuse_address = True server_address = ('127.0.0.1', 0) server = SocketServer.TCPServer(server_address, MsrRequestHandler) handle = win32file.CreateFile(args.pipe_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, None) _, port = server.server_address win32file.WriteFile(handle, str(port)) win32api.CloseHandle(handle) server.serve_forever() finally: _Deinitialize() if __name__ == '__main__': main()
gpl-3.0
[ 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 33, 1654, 626, 23739, 603, 5943, 1338, 1806, 13488, 14, 17415, 282, 1844, 465, 2399, 30869, 2725, 14, 199, 199, 1918, 3659, 1890, 367, 642, 1654, 365, 333, 5474, 63, 5652, 63, 7157, 14, 45, 5474, 6921, 13189, 14, 199, 199, 13757, 506, 1255, 465, 30660, 14, 2136, 675, 13488, 3140, 402, 4310, 20988, 503, 4573, 3531, 35, 199, 475, 5126, 23654, 543, 314, 5200, 6391, 562, 10832, 706, 14, 2136, 5452, 314, 1844, 465, 282, 199, 5329, 3140, 402, 2468, 26056, 1373, 12, 2952, 652, 1159, 7508, 370, 26808, 314, 1844, 199, 1955, 9371, 4661, 12997, 11106, 14, 199, 199, 18153, 13036, 15420, 16, 370, 506, 4903, 315, 314, 2018, 2082, 14, 199, 706, 82, 63, 5652, 63, 7157, 14, 45, 5474, 6921, 13189, 1630, 642, 340, 4346, 14, 199, 624, 199, 199, 646, 7534, 199, 646, 5577, 199, 646, 747, 199, 646, 17766, 3120, 199, 646, 2702, 199, 646, 984, 199, 893, 26, 523, 492, 4747, 708, 1246, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 523, 492, 4747, 708, 493, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 2590, 3545, 26, 523, 4747, 708, 1246, 275, 488, 523, 4747, 708, 493, 275, 488, 421, 199, 7941, 25127, 16, 63, 6305, 63, 23229, 275, 334, 272, 283, 1944, 1125, 297, 272, 283, 12647, 4298, 297, 272, 283, 6158, 440, 6511, 14, 2047, 1443, 1929, 370, 1255, 465, 30660, 297, 272, 283, 6158, 440, 1911, 297, 272, 283, 6158, 625, 4591, 701, 1163, 2112, 297, 272, 283, 6158, 440, 6511, 2952, 402, 14043, 641, 7220, 577, 6053, 297, 272, 283, 5912, 1125, 297, 199, 9, 421, 199, 3, 710, 577, 4464, 11097, 365, 2288, 12, 880, 5324, 652, 315, 282, 2288, 1750, 14, 199, 63, 2676, 5985, 16, 275, 488, 421, 199, 533, 13036, 15420, 16, 547, 8, 16719, 304, 523, 986, 421, 199, 318, 485, 8886, 15420, 16, 2042, 837, 523, 2366, 63, 374, 63, 772, 63, 2075, 275, 984, 14, 13634, 690, 499, 1011, 4337, 523, 17112, 63, 493, 63, 354, 275, 283, 8886, 15420, 16, 88, 772, 14, 9259, 7, 340, 2366, 63, 374, 63, 772, 63, 2075, 587, 283, 8886, 15420, 16, 14, 9259, 7, 523, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 5904, 395, 17112, 63, 493, 63, 354, 9, 421, 199, 318, 485, 9345, 837, 523, 2288, 485, 2676, 5985, 16, 523, 340, 440, 485, 2676, 5985, 16, 26, 272, 4747, 5985, 16, 275, 5577, 14, 8886, 15982, 1547, 8886, 15420, 16, 2042, 1012, 272, 340, 440, 4747, 5985, 16, 14, 9345, 47, 478, 837, 489, 4747, 5985, 16, 63, 1205, 275, 4747, 5985, 16, 14, 1002, 29479, 3694, 342, 489, 746, 13036, 15420, 16, 547, 8, 2676, 5985, 16, 63, 1205, 12, 2079, 283, 6005, 370, 8265, 13036, 15420, 16, 26, 450, 83, 7, 450, 2079, 20896, 25127, 16, 63, 6305, 63, 23229, 59, 2676, 5985, 16, 63, 1205, 566, 272, 485, 2676, 5985, 16, 275, 4747, 5985, 16, 421, 199, 318, 485, 872, 8489, 837, 523, 2288, 485, 2676, 5985, 16, 523, 340, 485, 2676, 5985, 16, 26, 272, 485, 2676, 5985, 16, 14, 872, 8489, 47, 478, 342, 272, 485, 2676, 5985, 16, 275, 488, 421, 199, 318, 485, 3284, 45, 5474, 8, 706, 82, 63, 1955, 304, 523, 6465, 275, 5577, 14, 67, 63, 1635, 342, 523, 4721, 275, 5577, 14, 67, 63, 1635, 342, 523, 485, 2676, 5985, 16, 14, 50, 68, 706, 82, 8, 9798, 14, 67, 63, 1635, 8, 706, 82, 63, 1955, 395, 2116, 5577, 14, 20447, 8, 674, 395, 5577, 14, 20447, 8, 6260, 430, 523, 372, 4721, 14, 585, 5213, 4337, 1204, 6465, 14, 585, 421, 199, 533, 603, 5474, 11149, 8, 3869, 3120, 14, 3296, 11149, 304, 523, 347, 2429, 8, 277, 304, 272, 333, 5474, 63, 1955, 275, 2702, 14, 5301, 360, 41, 297, 291, 14, 23830, 14, 739, 8, 20, 11515, 16, 61, 272, 291, 14, 18076, 14, 952, 8, 1820, 14, 1389, 360, 49, 297, 485, 3284, 45, 5474, 8, 706, 82, 63, 1955, 1724, 421, 199, 318, 2446, 837, 523, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 360, 4990, 63, 354, 297, 730, 29, 495, 9, 523, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 485, 9345, 342, 523, 862, 26, 272, 17766, 3120, 14, 9735, 3120, 14, 3306, 63, 15712, 63, 1562, 275, 715, 272, 1654, 63, 1562, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 378, 9, 272, 1654, 275, 17766, 3120, 14, 9735, 3120, 8, 1000, 63, 1562, 12, 603, 5474, 11149, 9, 272, 2429, 275, 4747, 708, 493, 14, 2499, 1173, 8, 589, 14, 4990, 63, 354, 12, 3303, 4747, 708, 493, 14, 29395, 63, 10387, 12, 3303, 378, 12, 488, 12, 3303, 4747, 708, 493, 14, 9935, 63, 13301, 1206, 12, 3303, 378, 12, 488, 9, 272, 5501, 1844, 275, 1654, 14, 1000, 63, 1562, 272, 4747, 708, 493, 14, 3534, 1173, 8, 2479, 12, 620, 8, 719, 430, 272, 4747, 708, 1246, 14, 4724, 5940, 8, 2479, 9, 272, 1654, 14, 4909, 63, 21327, 342, 523, 3753, 26, 272, 485, 872, 8489, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 33, 1654, 626, 23739, 603, 5943, 1338, 1806, 13488, 14, 17415, 282, 1844, 465, 2399, 30869, 2725, 14, 199, 199, 1918, 3659, 1890, 367, 642, 1654, 365, 333, 5474, 63, 5652, 63, 7157, 14, 45, 5474, 6921, 13189, 14, 199, 199, 13757, 506, 1255, 465, 30660, 14, 2136, 675, 13488, 3140, 402, 4310, 20988, 503, 4573, 3531, 35, 199, 475, 5126, 23654, 543, 314, 5200, 6391, 562, 10832, 706, 14, 2136, 5452, 314, 1844, 465, 282, 199, 5329, 3140, 402, 2468, 26056, 1373, 12, 2952, 652, 1159, 7508, 370, 26808, 314, 1844, 199, 1955, 9371, 4661, 12997, 11106, 14, 199, 199, 18153, 13036, 15420, 16, 370, 506, 4903, 315, 314, 2018, 2082, 14, 199, 706, 82, 63, 5652, 63, 7157, 14, 45, 5474, 6921, 13189, 1630, 642, 340, 4346, 14, 199, 624, 199, 199, 646, 7534, 199, 646, 5577, 199, 646, 747, 199, 646, 17766, 3120, 199, 646, 2702, 199, 646, 984, 199, 893, 26, 523, 492, 4747, 708, 1246, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 523, 492, 4747, 708, 493, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 2590, 3545, 26, 523, 4747, 708, 1246, 275, 488, 523, 4747, 708, 493, 275, 488, 421, 199, 7941, 25127, 16, 63, 6305, 63, 23229, 275, 334, 272, 283, 1944, 1125, 297, 272, 283, 12647, 4298, 297, 272, 283, 6158, 440, 6511, 14, 2047, 1443, 1929, 370, 1255, 465, 30660, 297, 272, 283, 6158, 440, 1911, 297, 272, 283, 6158, 625, 4591, 701, 1163, 2112, 297, 272, 283, 6158, 440, 6511, 2952, 402, 14043, 641, 7220, 577, 6053, 297, 272, 283, 5912, 1125, 297, 199, 9, 421, 199, 3, 710, 577, 4464, 11097, 365, 2288, 12, 880, 5324, 652, 315, 282, 2288, 1750, 14, 199, 63, 2676, 5985, 16, 275, 488, 421, 199, 533, 13036, 15420, 16, 547, 8, 16719, 304, 523, 986, 421, 199, 318, 485, 8886, 15420, 16, 2042, 837, 523, 2366, 63, 374, 63, 772, 63, 2075, 275, 984, 14, 13634, 690, 499, 1011, 4337, 523, 17112, 63, 493, 63, 354, 275, 283, 8886, 15420, 16, 88, 772, 14, 9259, 7, 340, 2366, 63, 374, 63, 772, 63, 2075, 587, 283, 8886, 15420, 16, 14, 9259, 7, 523, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 5904, 395, 17112, 63, 493, 63, 354, 9, 421, 199, 318, 485, 9345, 837, 523, 2288, 485, 2676, 5985, 16, 523, 340, 440, 485, 2676, 5985, 16, 26, 272, 4747, 5985, 16, 275, 5577, 14, 8886, 15982, 1547, 8886, 15420, 16, 2042, 1012, 272, 340, 440, 4747, 5985, 16, 14, 9345, 47, 478, 837, 489, 4747, 5985, 16, 63, 1205, 275, 4747, 5985, 16, 14, 1002, 29479, 3694, 342, 489, 746, 13036, 15420, 16, 547, 8, 2676, 5985, 16, 63, 1205, 12, 2079, 283, 6005, 370, 8265, 13036, 15420, 16, 26, 450, 83, 7, 450, 2079, 20896, 25127, 16, 63, 6305, 63, 23229, 59, 2676, 5985, 16, 63, 1205, 566, 272, 485, 2676, 5985, 16, 275, 4747, 5985, 16, 421, 199, 318, 485, 872, 8489, 837, 523, 2288, 485, 2676, 5985, 16, 523, 340, 485, 2676, 5985, 16, 26, 272, 485, 2676, 5985, 16, 14, 872, 8489, 47, 478, 342, 272, 485, 2676, 5985, 16, 275, 488, 421, 199, 318, 485, 3284, 45, 5474, 8, 706, 82, 63, 1955, 304, 523, 6465, 275, 5577, 14, 67, 63, 1635, 342, 523, 4721, 275, 5577, 14, 67, 63, 1635, 342, 523, 485, 2676, 5985, 16, 14, 50, 68, 706, 82, 8, 9798, 14, 67, 63, 1635, 8, 706, 82, 63, 1955, 395, 2116, 5577, 14, 20447, 8, 674, 395, 5577, 14, 20447, 8, 6260, 430, 523, 372, 4721, 14, 585, 5213, 4337, 1204, 6465, 14, 585, 421, 199, 533, 603, 5474, 11149, 8, 3869, 3120, 14, 3296, 11149, 304, 523, 347, 2429, 8, 277, 304, 272, 333, 5474, 63, 1955, 275, 2702, 14, 5301, 360, 41, 297, 291, 14, 23830, 14, 739, 8, 20, 11515, 16, 61, 272, 291, 14, 18076, 14, 952, 8, 1820, 14, 1389, 360, 49, 297, 485, 3284, 45, 5474, 8, 706, 82, 63, 1955, 1724, 421, 199, 318, 2446, 837, 523, 1798, 275, 7534, 14, 10730, 342, 523, 1798, 14, 525, 63, 2094, 360, 4990, 63, 354, 297, 730, 29, 495, 9, 523, 1249, 275, 1798, 14, 1122, 63, 589, 342, 819, 485, 9345, 342, 523, 862, 26, 272, 17766, 3120, 14, 9735, 3120, 14, 3306, 63, 15712, 63, 1562, 275, 715, 272, 1654, 63, 1562, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 378, 9, 272, 1654, 275, 17766, 3120, 14, 9735, 3120, 8, 1000, 63, 1562, 12, 603, 5474, 11149, 9, 272, 2429, 275, 4747, 708, 493, 14, 2499, 1173, 8, 589, 14, 4990, 63, 354, 12, 3303, 4747, 708, 493, 14, 29395, 63, 10387, 12, 3303, 378, 12, 488, 12, 3303, 4747, 708, 493, 14, 9935, 63, 13301, 1206, 12, 3303, 378, 12, 488, 9, 272, 5501, 1844, 275, 1654, 14, 1000, 63, 1562, 272, 4747, 708, 493, 14, 3534, 1173, 8, 2479, 12, 620, 8, 719, 430, 272, 4747, 708, 1246, 14, 4724, 5940, 8, 2479, 9, 272, 1654, 14, 4909, 63, 21327, 342, 523, 3753, 26, 272, 485, 872, 8489, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dmlc/mxnet
benchmark/python/sparse/dot.py
35
20888
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import ctypes import os import time import argparse import subprocess import scipy.sparse as sp import mxnet as mx import numpy as np import numpy.random as rnd from mxnet.test_utils import rand_ndarray, set_default_context, assert_almost_equal, get_bz2_data from mxnet.base import check_call, _LIB from util import estimate_density PARSER = argparse.ArgumentParser(description="Benchmark sparse operators", formatter_class=argparse.ArgumentDefaultsHelpFormatter) PARSER.add_argument('--num-omp-threads', type=int, default=1, help='number of omp threads to set in MXNet') PARSER.add_argument('--gpu', action='store_true', help="to be run on gpu") # TODO: Use logging later PARSER.add_argument('--verbose', action='store_true', help="Verbose output") ARGS = PARSER.parse_args() # some data information KDDA = { 'data_mini': 'kdda.t.mini', 'data_name': 'kdda.t', 'data_origin_name': 'kdda.t.bz2', 'url': "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/kdda.t.bz2", 'feature_dim': 20216830, 'm': [1, 8, 32], 'batch_size': [64], 'default_index': {'batch_size': 0, 'output_dim': 2}, 'num_batches': 10 } AVAZU = { 'data_mini': 'avazu-app.t.mini', 'data_name': 'avazu-app.t', 'data_origin_name': 'avazu-app.t.bz2', 'url': "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/avazu-app.t.bz2", 'feature_dim': 1000000, 'm': [1, 1000, 2000], 'batch_size': [128, 256], 'default_index': {'batch_size': 0, 'output_dim': 1}, 'num_batches': 10 } CRITEO = { 'data_mini': 'criteo.t.mini', 'data_name': 'criteo.t', 'data_origin_name': 'criteo.t.bz2', 'url' : "https://s3-us-west-2.amazonaws.com/sparse-dataset/criteo.t.bz2", 'feature_dim': 8388621, 'm': [1, 8, 16, 32, 64], 'batch_size': [64, 128], 'default_index': {'batch_size': 1, 'output_dim': 3}, 'num_batches': 10 } SYNTHETIC1 = { 'feature_dim': [1000000], 'm': [256, 1000], 'density': [0.001, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 0.65], 'batch_size': [64, 128], 'default_index': {'batch_size': 1, 'density': 2, 'output_dim': 1, 'feature_dim': 0}, 'num_repeat': 10 } SYNTHETIC2 = { 'feature_dim': [8000000, 16000000], 'm': [1, 32], 'density': [0.001, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 0.65], 'batch_size': [64, 128], 'default_index': {'batch_size': 1, 'density': 2, 'output_dim': 1, 'feature_dim': 0}, 'num_repeat': 10 } def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs): """Measure time cost of running a function """ mx.nd.waitall() args_list = [] for arg in args: args_list.append(arg) start = time.time() if scipy_trans_lhs: args_list[0] = np.transpose(args_list[0]) if scipy_dns_lhs else sp.spmatrix.transpose(args_list[0]) for _ in range(repeat): func_name(*args_list, **kwargs) mx.nd.waitall() end = time.time() diff = end - start return diff / repeat def _get_iter(path, data_shape, batch_size): data_train = mx.io.LibSVMIter(data_libsvm=path, data_shape=data_shape, batch_size=batch_size) data_iter = iter(data_train) return data_iter def _line_count(path): return int(subprocess.check_output('wc -l {}'.format(path), shell=True).split()[0]) def _compare_sparse_dense(data_dir, file_name, mini_file_name, feature_dim, output_dim, density, batch_size, num_batches=3, num_repeat=5, transpose=False, rsp=False): def create_mini_path(mini_path, path, num_batches): """Samples batches of size: batch_size, total number: num_batches from the dataset files for running benchmarks""" if not os.path.exists(mini_path): last = _line_count(path) - num_batches * batch_size last = last if last >= 1 else 1 start = int(rnd.uniform(1, last)) os.system("sed -n '%d,%dp' %r > %r" %(start, start + num_batches * batch_size, path, mini_path)) assert os.path.exists(mini_path) def run_benchmark(mini_path): """Run benchmarks """ data_shape = (feature_dim, ) train_iter = _get_iter(mini_path, data_shape, batch_size) weight_row_dim = batch_size if transpose else feature_dim weight_shape = (weight_row_dim, output_dim) if not rsp: weight = mx.nd.random.uniform(low=0, high=1, shape=weight_shape) else: weight = rand_ndarray(weight_shape, "row_sparse", density=0.05, distribution="uniform") total_cost = {} average_cost = {} count = 0 total_cost["sparse"] = 0. total_cost["dense"] = 0. for _ in train_iter: csr_data = train_iter.getdata() dns_data = csr_data.tostype('default') cost_sparse = measure_cost(num_repeat, False, False, mx.nd.sparse.dot, csr_data, weight, transpose_a=transpose) cost_dense = measure_cost(num_repeat, False, False, mx.nd.dot, dns_data, weight, transpose_a=transpose) total_cost["sparse"] += cost_sparse total_cost["dense"] += cost_dense count = count + 1 average_cost["sparse"] = total_cost["sparse"] / count average_cost["dense"] = total_cost["dense"] / count return (average_cost["sparse"], average_cost["dense"]) def print_result(average_cost_sparse, average_cost_dense): """Print result of comparison between sparse and dense """ ratio = average_cost_dense / average_cost_sparse fmt = '{:15.4f} {:10d} {:10d} {:10d} {:20.2f} {:15.2f} {:15.2f} {:10} {:10}' print(fmt.format(density * 100, batch_size, output_dim, feature_dim, ratio, average_cost_dense*1000, average_cost_sparse*1000, transpose, rsp)) mini_path = os.path.join(data_dir, mini_file_name) path = os.path.join(data_dir, file_name) create_mini_path(mini_path, path, num_batches) average_cost_sparse, average_cost_dense = run_benchmark(mini_path) print_result(average_cost_sparse, average_cost_dense) def test_dot_real(data_dict): """Dot operator testing with real datasets""" data_dir = os.path.join(os.getcwd(), 'data') path = os.path.join(data_dir, data_dict['data_name']) if not os.path.exists(path): get_bz2_data( data_dir, data_dict['data_name'], data_dict['url'], data_dict['data_origin_name'] ) assert os.path.exists(path) k = data_dict['feature_dim'] m = data_dict['m'] batch_size_list = data_dict['batch_size'] default_output_index = data_dict['default_index']['output_dim'] default_batch_size_index = data_dict['default_index']['batch_size'] density = estimate_density(path, data_dict['feature_dim']) num_batches = data_dict['num_batches'] assert default_batch_size_index < len(batch_size_list) assert default_output_index < len(m) if ARGS.verbose: print("Running Benchmarking on %r data") % data_dict['data_mini'] print('{:>15} {:>10} {:>10} {:>10} {:>20} {:>15} {:>15} {:>10} {:>10}'.format('density(%)', 'n', 'm', 'k', 't_dense/t_sparse', 't_dense(ms)', 't_sparse(ms)', 'is_transpose', 'rhs_rsp')) for output_dim in m: _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, output_dim, density, batch_size_list[default_batch_size_index], num_batches) _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, output_dim, density, batch_size_list[default_batch_size_index], num_batches, transpose=True) _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, output_dim, density, batch_size_list[default_batch_size_index], num_batches, rsp=True) for batch_size in batch_size_list: _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, m[default_output_index], density, batch_size, num_batches) _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, m[default_output_index], density, batch_size, num_batches, transpose=True) _compare_sparse_dense(data_dir, data_dict['data_name'], data_dict['data_mini'], k, output_dim, density, batch_size_list[default_batch_size_index], num_batches, rsp=True) def test_dot_synthetic(data_dict): """benchmark sparse mxnet dot and scipy dot operator with matrices of given density. `t_sparse` is the runtime of the invoked sparse dot operator in ms, while `t_dense` is the runtime of dot(dns, dns), with the same matrices except that they are in default storage type. """ # Benchmark MXNet and Scipys dot operator def bench_dot(lhs_shape, rhs_shape, lhs_stype, rhs_stype, lhs_den, rhs_den, trans_lhs, ctx, num_repeat=10, fw="mxnet", distribution="uniform"): set_default_context(ctx) assert fw == "mxnet" or fw == "scipy" # Set funcs dot_func_sparse = mx.nd.sparse.dot if fw == "mxnet" else sp.spmatrix.dot dot_func_dense = mx.nd.dot if fw == "mxnet" else np.dot # Create matrix instances lhs_nd = rand_ndarray(lhs_shape, lhs_stype, density=lhs_den, distribution=distribution) # only uniform distribution supported for rhs if rhs_stype == 'csr': rhs_nd = rand_ndarray(rhs_shape, rhs_stype, density=rhs_den, distribution=distribution) else: rhs_nd = rand_ndarray(rhs_shape, rhs_stype, density=rhs_den, distribution="uniform") lhs_dns = None rhs_dns = None dense_cost = None sparse_cost = None if fw == "mxnet": lhs_dns = lhs_nd if lhs_stype == 'default' else lhs_nd.tostype('default') rhs_dns = rhs_nd if rhs_stype == 'default' else rhs_nd.tostype('default') # One warm up run, verify correctness out = dot_func_sparse(lhs_nd, rhs_dns, trans_lhs) out_expected = dot_func_dense(lhs_dns, rhs_dns, trans_lhs) assert_almost_equal(out.asnumpy(), out_expected.asnumpy(), rtol=1e-1, atol=1e-1) sparse_cost = measure_cost(num_repeat, False, False, dot_func_sparse, lhs_nd, rhs_nd, trans_lhs) dense_cost = measure_cost(num_repeat, False, False, dot_func_dense, lhs_dns, rhs_dns, trans_lhs) else: lhs_dns = lhs_nd.asnumpy() rhs_dns = rhs_nd.asnumpy() lhs_nd = sp.csr_matrix(lhs_nd.asnumpy()) rhs_nd = rhs_nd.asnumpy() # One warm up run, verify correctness lhs_nd_copy = sp.spmatrix.transpose(lhs_nd) if trans_lhs else lhs_nd out = dot_func_sparse(lhs_nd_copy, rhs_dns) sparse_cost = measure_cost(num_repeat, trans_lhs, False, dot_func_sparse, lhs_nd, rhs_nd) dense_cost = measure_cost(num_repeat, trans_lhs, True, dot_func_dense, lhs_dns, rhs_dns) speedup = dense_cost / sparse_cost # Print results m = lhs_shape[0] k = lhs_shape[1] n = rhs_shape[1] result_pattern = '{:15.1f} {:15.1f} {:>10} {:8d} {:8d} {:8d} {:13.2f} {:13.2f} {:8.2f}' results = result_pattern.format(lhs_den*100, rhs_den*100, str(ctx), m, k, n, sparse_cost*1000, dense_cost*1000, speedup) print(results) def print_benchmark_info(lhs, rhs, lhs_trans, fw): trans_str = "^T" if lhs_trans else "" print("========================================================") print(" %s sparse dot benchmark: dot(%s, %s) = %s ") % (fw, lhs, rhs, rhs) print(" (matrix multiplication: (m x k)%s * (k x n) = m x n) ") % (trans_str) print("========================================================") headline_pattern = '{:>15} {:>15} {:>10} {:>8} {:>8} {:>8} {:>13} {:>13} {:>8}' headline = headline_pattern.format('lhs_density(%)', 'rhs_density(%)', 'context', 'm', 'k', 'n', 't_sparse(ms)', 't_dense(ms)', 'speedup') print(headline) def run_benchmark(ctx=None, lhs="csr", lhs_trans=False, rhs="dns", fw="mxnet", rhs_density=1, distribution="uniform"): if rhs_density > 1 or rhs_density < 0: raise ValueError("rhs_density has to be between 0 and 1") print_benchmark_info(lhs, rhs, lhs_trans, fw) if rhs == "csr": lhs_stype = "default" rhs_stype = "csr" assert (lhs_stype == 'default'), "Only dot(default, csr) supported" # Arrange dimensions according to use case. For below csr will have num_rows << num_cols feature_dim_list = data_dict['batch_size'] batch_size_list = data_dict['m'] output_dim_list = data_dict['feature_dim'] density_list = data_dict['density'] default_output_index = data_dict['default_index']['feature_dim'] default_density_index = data_dict['default_index']['density'] default_feature_index = data_dict['default_index']['batch_size'] default_batch_size_index = data_dict['default_index']['output_dim'] num_repeat = data_dict['num_repeat'] else: lhs_stype = "csr" rhs_stype = "row_sparse" if rhs == "rsp" else "default" feature_dim_list = data_dict['feature_dim'] output_dim_list = data_dict['m'] batch_size_list = data_dict['batch_size'] density_list = data_dict['density'] default_output_index = data_dict['default_index']['output_dim'] default_batch_size_index = data_dict['default_index']['batch_size'] default_feature_index = data_dict['default_index']['feature_dim'] default_density_index = data_dict['default_index']['density'] num_repeat = data_dict['num_repeat'] for output_dim in output_dim_list: if lhs_trans: output_row_dim = batch_size_list[default_batch_size_index] else: output_row_dim = feature_dim_list[default_feature_index] bench_dot((batch_size_list[default_batch_size_index], feature_dim_list[default_feature_index]), (output_row_dim, output_dim), lhs_stype, rhs_stype, density_list[default_density_index], rhs_density, lhs_trans, ctx, num_repeat=num_repeat, fw=fw, distribution=distribution) for feature_dim in feature_dim_list: if lhs_trans: output_row_dim = batch_size_list[default_batch_size_index] else: output_row_dim = feature_dim bench_dot((batch_size_list[default_batch_size_index], feature_dim), (output_row_dim, output_dim_list[default_output_index]), lhs_stype, rhs_stype, density_list[default_density_index], rhs_density, lhs_trans, ctx, num_repeat=num_repeat, fw=fw, distribution=distribution) for batch_size in batch_size_list: if lhs_trans: output_row_dim = batch_size else: output_row_dim = feature_dim_list[default_feature_index] bench_dot((batch_size, feature_dim_list[default_feature_index]), (output_row_dim, output_dim_list[default_output_index]), lhs_stype, rhs_stype, density_list[default_density_index], rhs_density, lhs_trans, ctx, num_repeat=num_repeat, fw=fw, distribution=distribution) for density in density_list: if lhs_trans: output_row_dim = batch_size_list[default_batch_size_index] else: output_row_dim = feature_dim_list[default_feature_index] bench_dot((batch_size_list[default_batch_size_index], feature_dim_list[default_feature_index]), (output_row_dim, output_dim_list[default_output_index]), lhs_stype, rhs_stype, density, density, lhs_trans, ctx, num_repeat=num_repeat, fw=fw, distribution=distribution) check_call(_LIB.MXSetNumOMPThreads(ctypes.c_int(ARGS.num_omp_threads))) context = mx.gpu() if ARGS.gpu else mx.cpu() # TODO(anirudh): make the data dicts to config which can be passed at runtime distributions = ["uniform", "powerlaw"] for distribution in distributions: run_benchmark(context, lhs="csr", rhs="default", lhs_trans=False, fw="mxnet", rhs_density=1, distribution=distribution) run_benchmark(context, lhs="csr", rhs="default", lhs_trans=True, fw="mxnet", rhs_density=1, distribution=distribution) run_benchmark(context, lhs="csr", rhs="rsp", lhs_trans=False, fw="mxnet", rhs_density=0.05, distribution=distribution) run_benchmark(context, lhs="default", rhs="csr", lhs_trans=False, fw="mxnet", rhs_density=0.001, distribution=distribution) if not ARGS.gpu: run_benchmark(context, lhs="csr", rhs="default", lhs_trans=False, fw="scipy", rhs_density=1, distribution=distribution) run_benchmark(context, lhs="csr", rhs="default", lhs_trans=True, fw="scipy", rhs_density=1, distribution=distribution) if __name__ == "__main__": begin_time = time.time() test_dot_real(KDDA) test_dot_real(AVAZU) test_dot_real(CRITEO) test_dot_synthetic(SYNTHETIC1) test_dot_synthetic(SYNTHETIC2) total_time = time.time() - begin_time print("total time is %f") % total_time
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 5577, 199, 199, 646, 747, 199, 646, 900, 199, 646, 7534, 199, 646, 3873, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 646, 8728, 846, 465, 8728, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 2355, 465, 20665, 199, 504, 8728, 846, 14, 396, 63, 1208, 492, 10261, 63, 8237, 12, 663, 63, 885, 63, 1100, 12, 702, 63, 4398, 63, 1452, 12, 664, 63, 10582, 18, 63, 576, 199, 504, 8728, 846, 14, 1095, 492, 1104, 63, 1250, 12, 485, 5617, 199, 504, 4884, 492, 14497, 63, 15669, 199, 199, 26078, 275, 7534, 14, 10730, 8, 1802, 628, 18644, 5178, 10211, 401, 639, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 26078, 14, 525, 63, 2094, 4517, 1507, 13, 22527, 13, 6962, 297, 730, 29, 442, 12, 490, 849, 29, 17, 12, 1720, 534, 1955, 402, 312, 311, 7183, 370, 663, 315, 603, 56, 2480, 358, 199, 26078, 14, 525, 63, 2094, 4517, 6477, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 475, 506, 1255, 641, 21758, 531, 199, 3, 3254, 26, 3645, 2050, 2945, 199, 26078, 14, 525, 63, 2094, 4517, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 21879, 1072, 531, 199, 13990, 275, 10263, 3279, 14, 1122, 63, 589, 342, 199, 199, 3, 2005, 666, 2556, 199, 43, 5745, 33, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 75, 617, 65, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 75, 617, 65, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 75, 617, 65, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 356, 298, 2859, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3008, 15, 75, 617, 65, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 19328, 6568, 1216, 12, 272, 283, 77, 356, 359, 17, 12, 1695, 12, 4337, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 378, 12, 1993, 283, 1199, 63, 3572, 356, 499, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 6087, 17613, 53, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 356, 298, 2859, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3008, 15, 3812, 90, 85, 13, 571, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 19492, 12, 272, 283, 77, 356, 359, 17, 12, 5198, 12, 12293, 467, 272, 283, 2912, 63, 890, 356, 359, 3933, 12, 7633, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 378, 12, 1993, 283, 1199, 63, 3572, 356, 413, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 2944, 4427, 47, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 67, 752, 79, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 67, 752, 79, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 67, 752, 79, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 7, 520, 298, 2859, 921, 83, 19, 13, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 15, 4421, 13, 5214, 15, 67, 752, 79, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 1695, 1703, 1184, 2025, 12, 272, 283, 77, 356, 359, 17, 12, 1695, 12, 3193, 12, 4337, 12, 5049, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 12, 7960, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 413, 12, 1993, 283, 1199, 63, 3572, 356, 650, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 31802, 2080, 775, 948, 17, 275, 469, 272, 283, 4445, 63, 3572, 356, 359, 22589, 467, 272, 283, 77, 356, 359, 3912, 12, 5198, 467, 272, 283, 15669, 356, 359, 16, 14, 4587, 12, 378, 14, 7972, 12, 378, 14, 614, 12, 378, 14, 996, 12, 378, 14, 1717, 12, 355, 378, 14, 17, 12, 378, 14, 18, 12, 378, 14, 21, 12, 378, 14, 2182, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 12, 7960, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 413, 12, 1993, 283, 15669, 356, 499, 12, 1993, 283, 1199, 63, 3572, 356, 413, 12, 1993, 283, 4445, 63, 3572, 356, 378, 1386, 272, 283, 1507, 63, 8755, 356, 1616, 199, 93, 199, 199, 31802, 2080, 775, 948, 18, 275, 469, 272, 283, 4445, 63, 3572, 356, 359, 24, 3273, 12, 3193, 3273, 467, 272, 283, 77, 356, 359, 17, 12, 4337, 467, 272 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 5577, 199, 199, 646, 747, 199, 646, 900, 199, 646, 7534, 199, 646, 3873, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 646, 8728, 846, 465, 8728, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 2355, 465, 20665, 199, 504, 8728, 846, 14, 396, 63, 1208, 492, 10261, 63, 8237, 12, 663, 63, 885, 63, 1100, 12, 702, 63, 4398, 63, 1452, 12, 664, 63, 10582, 18, 63, 576, 199, 504, 8728, 846, 14, 1095, 492, 1104, 63, 1250, 12, 485, 5617, 199, 504, 4884, 492, 14497, 63, 15669, 199, 199, 26078, 275, 7534, 14, 10730, 8, 1802, 628, 18644, 5178, 10211, 401, 639, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 26078, 14, 525, 63, 2094, 4517, 1507, 13, 22527, 13, 6962, 297, 730, 29, 442, 12, 490, 849, 29, 17, 12, 1720, 534, 1955, 402, 312, 311, 7183, 370, 663, 315, 603, 56, 2480, 358, 199, 26078, 14, 525, 63, 2094, 4517, 6477, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 475, 506, 1255, 641, 21758, 531, 199, 3, 3254, 26, 3645, 2050, 2945, 199, 26078, 14, 525, 63, 2094, 4517, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 21879, 1072, 531, 199, 13990, 275, 10263, 3279, 14, 1122, 63, 589, 342, 199, 199, 3, 2005, 666, 2556, 199, 43, 5745, 33, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 75, 617, 65, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 75, 617, 65, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 75, 617, 65, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 356, 298, 2859, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3008, 15, 75, 617, 65, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 19328, 6568, 1216, 12, 272, 283, 77, 356, 359, 17, 12, 1695, 12, 4337, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 378, 12, 1993, 283, 1199, 63, 3572, 356, 499, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 6087, 17613, 53, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 3812, 90, 85, 13, 571, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 356, 298, 2859, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3008, 15, 3812, 90, 85, 13, 571, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 19492, 12, 272, 283, 77, 356, 359, 17, 12, 5198, 12, 12293, 467, 272, 283, 2912, 63, 890, 356, 359, 3933, 12, 7633, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 378, 12, 1993, 283, 1199, 63, 3572, 356, 413, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 2944, 4427, 47, 275, 469, 272, 283, 576, 63, 18000, 356, 283, 67, 752, 79, 14, 84, 14, 18000, 297, 272, 283, 576, 63, 354, 356, 283, 67, 752, 79, 14, 84, 297, 272, 283, 576, 63, 6493, 63, 354, 356, 283, 67, 752, 79, 14, 84, 14, 10582, 18, 297, 272, 283, 633, 7, 520, 298, 2859, 921, 83, 19, 13, 527, 13, 19082, 13, 18, 14, 21442, 14, 957, 15, 4421, 13, 5214, 15, 67, 752, 79, 14, 84, 14, 10582, 18, 401, 272, 283, 4445, 63, 3572, 356, 1695, 1703, 1184, 2025, 12, 272, 283, 77, 356, 359, 17, 12, 1695, 12, 3193, 12, 4337, 12, 5049, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 12, 7960, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 413, 12, 1993, 283, 1199, 63, 3572, 356, 650, 1386, 272, 283, 1507, 63, 14896, 356, 1616, 199, 93, 199, 199, 31802, 2080, 775, 948, 17, 275, 469, 272, 283, 4445, 63, 3572, 356, 359, 22589, 467, 272, 283, 77, 356, 359, 3912, 12, 5198, 467, 272, 283, 15669, 356, 359, 16, 14, 4587, 12, 378, 14, 7972, 12, 378, 14, 614, 12, 378, 14, 996, 12, 378, 14, 1717, 12, 355, 378, 14, 17, 12, 378, 14, 18, 12, 378, 14, 21, 12, 378, 14, 2182, 467, 272, 283, 2912, 63, 890, 356, 359, 772, 12, 7960, 467, 272, 283, 885, 63, 1080, 356, 791, 2912, 63, 890, 356, 413, 12, 1993, 283, 15669, 356, 499, 12, 1993, 283, 1199, 63, 3572, 356, 413, 12, 1993, 283, 4445, 63, 3572, 356, 378, 1386, 272, 283, 1507, 63, 8755, 356, 1616, 199, 93, 199, 199, 31802, 2080, 775, 948, 18, 275, 469, 272, 283, 4445, 63, 3572, 356, 359, 24, 3273, 12, 3193, 3273, 467, 272, 283, 77, 356, 359, 17, 12, 4337, 467, 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, 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 ]
YutingZhang/lmdis-rep
exp-ae-aflw-30.py
1
2231
import tensorflow as tf import os import sys from copy import copy from model.pipeline import Pipeline from tensorflow.python import debug as tf_debug if __name__ == "__main__": num_keypoints = 30 patch_feature_dim = 8 decoding_levels = 5 kp_transform_loss = 1e4 recon_weight = 0.001 learning_rate=0.01 keypoint_separation_bandwidth=0.04 keypoint_separation_loss_weight = 10.0 opt = { "optimizer": "Adam", "data_name": "aflw_80x80", "recon_name": "gaussian_fixedvar_in_01", "encoder_name": "general_80x80", "decoder_name": "general_80x80", "latent_dim": num_keypoints*2+(num_keypoints+1)*patch_feature_dim, "train_color_jittering": True, "train_random_mirroring": False, "train_batch_size": 8, "train_shuffle_capacity": 1000, "learning_rate": learning_rate, "max_epochs": 2000, "weight_decay": 1e-6, "test_steps": 5000, "test_limit": 200, "recon_weight": recon_weight, } opt["encoder_options"] = { "keypoint_num": num_keypoints, "patch_feature_dim": patch_feature_dim, "ae_recon_type": opt["recon_name"], "keypoint_concentration_loss_weight": 100., "keypoint_axis_balancing_loss_weight": 200., "keypoint_separation_loss_weight": keypoint_separation_loss_weight, "keypoint_separation_bandwidth": keypoint_separation_bandwidth, "keypoint_transform_loss_weight": kp_transform_loss, "keypoint_decoding_heatmap_levels": decoding_levels, "keypoint_decoding_heatmap_level_base": 0.5**(1/2), "image_channels": 3, } opt["decoder_options"] = copy(opt["encoder_options"]) # ------------------------------------- model_dir = os.path.join("results/aflw_30") checkpoint_dir = 'pretrained_results' checkpoint_filename = 'celeba_30/model/snapshot_step_205317' vp = Pipeline(None, opt, model_dir=model_dir) print(vp.opt) with vp.graph.as_default(): sess = vp.create_session() vp.run_full_train_from_checkpoint(sess, checkpoint_dir = checkpoint_dir, checkpoint_filename=checkpoint_filename) vp.run_full_test(sess)
apache-2.0
[ 646, 3228, 465, 2833, 199, 646, 747, 199, 646, 984, 199, 504, 1331, 492, 1331, 199, 504, 1402, 14, 7379, 492, 19090, 199, 199, 504, 3228, 14, 1548, 492, 3105, 465, 2833, 63, 1757, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 1967, 63, 498, 3438, 275, 4233, 272, 3371, 63, 4445, 63, 3572, 275, 1695, 272, 15952, 63, 11402, 275, 959, 272, 1022, 80, 63, 4711, 63, 4358, 275, 413, 69, 20, 339, 24711, 63, 3463, 275, 378, 14, 4587, 339, 9328, 63, 1866, 29, 16, 14, 614, 339, 790, 1403, 63, 6175, 425, 63, 18358, 29, 16, 14, 966, 272, 790, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 275, 1616, 14, 16, 339, 2450, 275, 469, 267, 298, 12290, 582, 298, 32408, 401, 267, 298, 576, 63, 354, 582, 298, 65, 2327, 87, 63, 1257, 88, 1257, 401, 267, 298, 25981, 63, 354, 582, 298, 22911, 63, 5964, 1391, 63, 262, 63, 614, 401, 267, 298, 9347, 63, 354, 582, 298, 10706, 63, 1257, 88, 1257, 401, 267, 298, 8813, 63, 354, 582, 298, 10706, 63, 1257, 88, 1257, 401, 267, 298, 750, 343, 63, 3572, 582, 1967, 63, 498, 3438, 10, 18, 15622, 1507, 63, 498, 3438, 11, 17, 3342, 2068, 63, 4445, 63, 3572, 12, 267, 298, 2834, 63, 2326, 63, 17676, 351, 316, 582, 715, 12, 267, 298, 2834, 63, 2355, 63, 12324, 316, 582, 756, 12, 267, 298, 2834, 63, 2912, 63, 890, 582, 1695, 12, 267, 298, 2834, 63, 11777, 63, 10457, 582, 5198, 12, 267, 298, 10546, 63, 1866, 582, 9328, 63, 1866, 12, 267, 298, 988, 63, 13161, 582, 12293, 12, 4960, 298, 3463, 63, 16889, 582, 413, 69, 13, 22, 12, 267, 298, 396, 63, 5895, 582, 22369, 12, 259, 267, 298, 396, 63, 3097, 582, 1926, 12, 267, 298, 25981, 63, 3463, 582, 24711, 63, 3463, 12, 272, 789, 339, 2450, 905, 9347, 63, 1419, 937, 275, 469, 267, 298, 498, 1403, 63, 1507, 582, 1967, 63, 498, 3438, 12, 267, 298, 2068, 63, 4445, 63, 3572, 582, 3371, 63, 4445, 63, 3572, 12, 267, 298, 3624, 63, 25981, 63, 466, 582, 2450, 905, 25981, 63, 354, 2255, 4960, 298, 498, 1403, 63, 26823, 63, 4358, 63, 3463, 582, 2948, 2020, 267, 298, 498, 1403, 63, 3127, 63, 30260, 63, 4358, 63, 3463, 582, 1926, 2020, 267, 298, 498, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 582, 790, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 12, 267, 298, 498, 1403, 63, 6175, 425, 63, 18358, 582, 790, 1403, 63, 6175, 425, 63, 18358, 12, 267, 298, 498, 1403, 63, 4711, 63, 4358, 63, 3463, 582, 1022, 80, 63, 4711, 63, 4358, 12, 267, 298, 498, 1403, 63, 12796, 63, 16614, 1130, 63, 11402, 582, 15952, 63, 11402, 12, 267, 298, 498, 1403, 63, 12796, 63, 16614, 1130, 63, 1896, 63, 1095, 582, 378, 14, 21, 14192, 17, 15, 18, 395, 267, 298, 1569, 63, 6324, 582, 650, 12, 272, 789, 272, 2450, 905, 8813, 63, 1419, 937, 275, 1331, 8, 2992, 905, 9347, 63, 1419, 3135, 339, 327, 11016, 9858, 272, 1402, 63, 694, 275, 747, 14, 515, 14, 904, 480, 2604, 15, 65, 2327, 87, 63, 1216, 531, 272, 9997, 63, 694, 275, 283, 657, 23782, 63, 2604, 7, 272, 9997, 63, 1501, 275, 283, 15421, 2470, 63, 1216, 15, 1238, 15, 4753, 63, 2926, 63, 1165, 15341, 7, 272, 373, 80, 275, 19090, 8, 403, 12, 2450, 12, 1402, 63, 694, 29, 1238, 63, 694, 9, 272, 870, 8, 11702, 14, 2992, 9, 272, 543, 373, 80, 14, 2180, 14, 305, 63, 885, 837, 267, 4043, 275, 373, 80, 14, 981, 63, 1730, 342, 267, 373, 80, 14, 1065, 63, 2861, 63, 2834, 63, 504, 63, 10109, 8, 5480, 12, 9997, 63, 694, 275, 9997, 63, 694, 12, 9997, 63, 1501, 29, 10109, 63, 1501, 9, 267, 373, 80, 14, 1065, 63, 2861, 63, 396, 8, 5480, 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 ]
[ 3228, 465, 2833, 199, 646, 747, 199, 646, 984, 199, 504, 1331, 492, 1331, 199, 504, 1402, 14, 7379, 492, 19090, 199, 199, 504, 3228, 14, 1548, 492, 3105, 465, 2833, 63, 1757, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 1967, 63, 498, 3438, 275, 4233, 272, 3371, 63, 4445, 63, 3572, 275, 1695, 272, 15952, 63, 11402, 275, 959, 272, 1022, 80, 63, 4711, 63, 4358, 275, 413, 69, 20, 339, 24711, 63, 3463, 275, 378, 14, 4587, 339, 9328, 63, 1866, 29, 16, 14, 614, 339, 790, 1403, 63, 6175, 425, 63, 18358, 29, 16, 14, 966, 272, 790, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 275, 1616, 14, 16, 339, 2450, 275, 469, 267, 298, 12290, 582, 298, 32408, 401, 267, 298, 576, 63, 354, 582, 298, 65, 2327, 87, 63, 1257, 88, 1257, 401, 267, 298, 25981, 63, 354, 582, 298, 22911, 63, 5964, 1391, 63, 262, 63, 614, 401, 267, 298, 9347, 63, 354, 582, 298, 10706, 63, 1257, 88, 1257, 401, 267, 298, 8813, 63, 354, 582, 298, 10706, 63, 1257, 88, 1257, 401, 267, 298, 750, 343, 63, 3572, 582, 1967, 63, 498, 3438, 10, 18, 15622, 1507, 63, 498, 3438, 11, 17, 3342, 2068, 63, 4445, 63, 3572, 12, 267, 298, 2834, 63, 2326, 63, 17676, 351, 316, 582, 715, 12, 267, 298, 2834, 63, 2355, 63, 12324, 316, 582, 756, 12, 267, 298, 2834, 63, 2912, 63, 890, 582, 1695, 12, 267, 298, 2834, 63, 11777, 63, 10457, 582, 5198, 12, 267, 298, 10546, 63, 1866, 582, 9328, 63, 1866, 12, 267, 298, 988, 63, 13161, 582, 12293, 12, 4960, 298, 3463, 63, 16889, 582, 413, 69, 13, 22, 12, 267, 298, 396, 63, 5895, 582, 22369, 12, 259, 267, 298, 396, 63, 3097, 582, 1926, 12, 267, 298, 25981, 63, 3463, 582, 24711, 63, 3463, 12, 272, 789, 339, 2450, 905, 9347, 63, 1419, 937, 275, 469, 267, 298, 498, 1403, 63, 1507, 582, 1967, 63, 498, 3438, 12, 267, 298, 2068, 63, 4445, 63, 3572, 582, 3371, 63, 4445, 63, 3572, 12, 267, 298, 3624, 63, 25981, 63, 466, 582, 2450, 905, 25981, 63, 354, 2255, 4960, 298, 498, 1403, 63, 26823, 63, 4358, 63, 3463, 582, 2948, 2020, 267, 298, 498, 1403, 63, 3127, 63, 30260, 63, 4358, 63, 3463, 582, 1926, 2020, 267, 298, 498, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 582, 790, 1403, 63, 6175, 425, 63, 4358, 63, 3463, 12, 267, 298, 498, 1403, 63, 6175, 425, 63, 18358, 582, 790, 1403, 63, 6175, 425, 63, 18358, 12, 267, 298, 498, 1403, 63, 4711, 63, 4358, 63, 3463, 582, 1022, 80, 63, 4711, 63, 4358, 12, 267, 298, 498, 1403, 63, 12796, 63, 16614, 1130, 63, 11402, 582, 15952, 63, 11402, 12, 267, 298, 498, 1403, 63, 12796, 63, 16614, 1130, 63, 1896, 63, 1095, 582, 378, 14, 21, 14192, 17, 15, 18, 395, 267, 298, 1569, 63, 6324, 582, 650, 12, 272, 789, 272, 2450, 905, 8813, 63, 1419, 937, 275, 1331, 8, 2992, 905, 9347, 63, 1419, 3135, 339, 327, 11016, 9858, 272, 1402, 63, 694, 275, 747, 14, 515, 14, 904, 480, 2604, 15, 65, 2327, 87, 63, 1216, 531, 272, 9997, 63, 694, 275, 283, 657, 23782, 63, 2604, 7, 272, 9997, 63, 1501, 275, 283, 15421, 2470, 63, 1216, 15, 1238, 15, 4753, 63, 2926, 63, 1165, 15341, 7, 272, 373, 80, 275, 19090, 8, 403, 12, 2450, 12, 1402, 63, 694, 29, 1238, 63, 694, 9, 272, 870, 8, 11702, 14, 2992, 9, 272, 543, 373, 80, 14, 2180, 14, 305, 63, 885, 837, 267, 4043, 275, 373, 80, 14, 981, 63, 1730, 342, 267, 373, 80, 14, 1065, 63, 2861, 63, 2834, 63, 504, 63, 10109, 8, 5480, 12, 9997, 63, 694, 275, 9997, 63, 694, 12, 9997, 63, 1501, 29, 10109, 63, 1501, 9, 267, 373, 80, 14, 1065, 63, 2861, 63, 396, 8, 5480, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mark-me/Pi-Jukebox
venv/Lib/site-packages/mutagen/_senf/_temp.py
12
3282
# -*- coding: utf-8 -*- # Copyright 2016 Christoph Reiter # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import tempfile from ._fsnative import path2fsn, fsnative def gettempdir(): """ Returns: `fsnative` Like :func:`python3:tempfile.gettempdir`, but always returns a `fsnative` path """ # FIXME: I don't want to reimplement all that logic, reading env vars etc. # At least for the default it works. return path2fsn(tempfile.gettempdir()) def gettempprefix(): """ Returns: `fsnative` Like :func:`python3:tempfile.gettempprefix`, but always returns a `fsnative` path """ return path2fsn(tempfile.gettempprefix()) def mkstemp(suffix=None, prefix=None, dir=None, text=False): """ Args: suffix (`pathlike` or `None`): suffix or `None` to use the default prefix (`pathlike` or `None`): prefix or `None` to use the default dir (`pathlike` or `None`): temp dir or `None` to use the default text (bool): if the file should be opened in text mode Returns: Tuple[`int`, `fsnative`]: A tuple containing the file descriptor and the file path Raises: EnvironmentError Like :func:`python3:tempfile.mkstemp` but always returns a `fsnative` path. """ suffix = fsnative() if suffix is None else path2fsn(suffix) prefix = gettempprefix() if prefix is None else path2fsn(prefix) dir = gettempdir() if dir is None else path2fsn(dir) return tempfile.mkstemp(suffix, prefix, dir, text) def mkdtemp(suffix=None, prefix=None, dir=None): """ Args: suffix (`pathlike` or `None`): suffix or `None` to use the default prefix (`pathlike` or `None`): prefix or `None` to use the default dir (`pathlike` or `None`): temp dir or `None` to use the default Returns: `fsnative`: A path to a directory Raises: EnvironmentError Like :func:`python3:tempfile.mkstemp` but always returns a `fsnative` path. """ suffix = fsnative() if suffix is None else path2fsn(suffix) prefix = gettempprefix() if prefix is None else path2fsn(prefix) dir = gettempdir() if dir is None else path2fsn(dir) return tempfile.mkdtemp(suffix, prefix, dir)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7800, 2799, 322, 2379, 72, 799, 1661, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 199, 3, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 199, 3, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 199, 3, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 5549, 199, 199, 504, 13653, 2319, 6106, 492, 931, 18, 2319, 78, 12, 289, 5167, 1905, 421, 199, 318, 664, 11567, 837, 272, 408, 272, 1803, 26, 267, 658, 2319, 6106, 64, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 31572, 3559, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 272, 931, 272, 408, 339, 327, 7600, 26, 473, 2793, 1133, 2934, 370, 295, 21463, 1006, 626, 9661, 12, 7664, 2589, 6802, 5423, 14, 272, 327, 2854, 5210, 367, 314, 849, 652, 5419, 14, 272, 372, 931, 18, 2319, 78, 8, 17336, 14, 31572, 1012, 421, 199, 318, 664, 808, 1861, 837, 272, 408, 272, 1803, 26, 267, 658, 2319, 6106, 64, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 362, 808, 1861, 3559, 1325, 3544, 2529, 282, 272, 658, 2319, 6106, 64, 931, 272, 408, 339, 372, 931, 18, 2319, 78, 8, 17336, 14, 362, 808, 1861, 1012, 421, 199, 318, 333, 6080, 808, 8, 4511, 29, 403, 12, 2403, 29, 403, 12, 2935, 29, 403, 12, 1318, 29, 797, 304, 272, 408, 272, 3033, 26, 267, 4739, 13493, 515, 2930, 64, 503, 658, 403, 25452, 4739, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2403, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2403, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2935, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2388, 2935, 503, 658, 403, 64, 370, 675, 314, 849, 267, 1318, 334, 2245, 304, 340, 314, 570, 1077, 506, 12123, 315, 1318, 818, 272, 1803, 26, 267, 11634, 59, 64, 442, 3559, 658, 2319, 6106, 64, 2189, 288, 437, 2008, 3035, 314, 570, 5872, 436, 314, 570, 931, 272, 6218, 26, 267, 25139, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 17721, 64, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 272, 931, 14, 272, 408, 339, 4739, 275, 289, 5167, 1905, 342, 340, 4739, 365, 488, 587, 931, 18, 2319, 78, 8, 4511, 9, 272, 2403, 275, 664, 808, 1861, 342, 340, 2403, 365, 488, 587, 931, 18, 2319, 78, 8, 1861, 9, 272, 2935, 275, 664, 11567, 342, 340, 2935, 365, 488, 587, 931, 18, 2319, 78, 8, 694, 9, 339, 372, 5549, 14, 17721, 8, 4511, 12, 2403, 12, 2935, 12, 1318, 9, 421, 199, 318, 31781, 8, 4511, 29, 403, 12, 2403, 29, 403, 12, 2935, 29, 403, 304, 272, 408, 272, 3033, 26, 267, 4739, 13493, 515, 2930, 64, 503, 658, 403, 25452, 4739, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2403, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2403, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2935, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2388, 2935, 503, 658, 403, 64, 370, 675, 314, 849, 272, 1803, 26, 267, 658, 2319, 6106, 8340, 437, 931, 370, 282, 2082, 272, 6218, 26, 267, 25139, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 17721, 64, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 931, 14, 272, 408, 339, 4739, 275, 289, 5167, 1905, 342, 340, 4739, 365, 488, 587, 931, 18, 2319, 78, 8, 4511, 9, 272, 2403, 275, 664, 808, 1861, 342, 340, 2403, 365, 488, 587, 931, 18, 2319, 78, 8, 1861, 9, 272, 2935, 275, 664, 11567, 342, 340, 2935, 365, 488, 587, 931, 18, 2319, 78, 8, 694, 9, 339, 372, 5549, 14, 11983, 8, 4511, 12, 2403, 12, 2935, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7800, 2799, 322, 2379, 72, 799, 1661, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 199, 3, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 199, 3, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 199, 3, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 5549, 199, 199, 504, 13653, 2319, 6106, 492, 931, 18, 2319, 78, 12, 289, 5167, 1905, 421, 199, 318, 664, 11567, 837, 272, 408, 272, 1803, 26, 267, 658, 2319, 6106, 64, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 31572, 3559, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 272, 931, 272, 408, 339, 327, 7600, 26, 473, 2793, 1133, 2934, 370, 295, 21463, 1006, 626, 9661, 12, 7664, 2589, 6802, 5423, 14, 272, 327, 2854, 5210, 367, 314, 849, 652, 5419, 14, 272, 372, 931, 18, 2319, 78, 8, 17336, 14, 31572, 1012, 421, 199, 318, 664, 808, 1861, 837, 272, 408, 272, 1803, 26, 267, 658, 2319, 6106, 64, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 362, 808, 1861, 3559, 1325, 3544, 2529, 282, 272, 658, 2319, 6106, 64, 931, 272, 408, 339, 372, 931, 18, 2319, 78, 8, 17336, 14, 362, 808, 1861, 1012, 421, 199, 318, 333, 6080, 808, 8, 4511, 29, 403, 12, 2403, 29, 403, 12, 2935, 29, 403, 12, 1318, 29, 797, 304, 272, 408, 272, 3033, 26, 267, 4739, 13493, 515, 2930, 64, 503, 658, 403, 25452, 4739, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2403, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2403, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2935, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2388, 2935, 503, 658, 403, 64, 370, 675, 314, 849, 267, 1318, 334, 2245, 304, 340, 314, 570, 1077, 506, 12123, 315, 1318, 818, 272, 1803, 26, 267, 11634, 59, 64, 442, 3559, 658, 2319, 6106, 64, 2189, 288, 437, 2008, 3035, 314, 570, 5872, 436, 314, 570, 931, 272, 6218, 26, 267, 25139, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 17721, 64, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 272, 931, 14, 272, 408, 339, 4739, 275, 289, 5167, 1905, 342, 340, 4739, 365, 488, 587, 931, 18, 2319, 78, 8, 4511, 9, 272, 2403, 275, 664, 808, 1861, 342, 340, 2403, 365, 488, 587, 931, 18, 2319, 78, 8, 1861, 9, 272, 2935, 275, 664, 11567, 342, 340, 2935, 365, 488, 587, 931, 18, 2319, 78, 8, 694, 9, 339, 372, 5549, 14, 17721, 8, 4511, 12, 2403, 12, 2935, 12, 1318, 9, 421, 199, 318, 31781, 8, 4511, 29, 403, 12, 2403, 29, 403, 12, 2935, 29, 403, 304, 272, 408, 272, 3033, 26, 267, 4739, 13493, 515, 2930, 64, 503, 658, 403, 25452, 4739, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2403, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2403, 503, 658, 403, 64, 370, 675, 314, 849, 267, 2935, 13493, 515, 2930, 64, 503, 658, 403, 25452, 2388, 2935, 503, 658, 403, 64, 370, 675, 314, 849, 272, 1803, 26, 267, 658, 2319, 6106, 8340, 437, 931, 370, 282, 2082, 272, 6218, 26, 267, 25139, 339, 16485, 520, 1532, 1705, 1548, 19, 26, 17336, 14, 17721, 64, 1325, 3544, 2529, 282, 658, 2319, 6106, 64, 931, 14, 272, 408, 339, 4739, 275, 289, 5167, 1905, 342, 340, 4739, 365, 488, 587, 931, 18, 2319, 78, 8, 4511, 9, 272, 2403, 275, 664, 808, 1861, 342, 340, 2403, 365, 488, 587, 931, 18, 2319, 78, 8, 1861, 9, 272, 2935, 275, 664, 11567, 342, 340, 2935, 365, 488, 587, 931, 18, 2319, 78, 8, 694, 9, 339, 372, 5549, 14, 11983, 8, 4511, 12, 2403, 12, 2935, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
keskinbu/Laravel-e-Commerce
vendor/mockery/mockery/docs/conf.py
468
8442
# -*- coding: utf-8 -*- # # Mockery Docs documentation build configuration file, created by # sphinx-quickstart on Mon Mar 3 14:04:26 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.todo', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Mockery Docs' copyright = u'2014, Pádraic Brady, Dave Marshall, Wouter, Graham Campbell' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.9' # The full version, including alpha/beta/rc tags. release = '0.9' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'MockeryDocsdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index2', 'MockeryDocs.tex', u'Mockery Docs Documentation', u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index2', 'mockerydocs', u'Mockery Docs Documentation', [u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index2', 'MockeryDocs', u'Mockery Docs Documentation', u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'MockeryDocs', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False #on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] print sphinx_rtd_theme.get_html_theme_path()
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4420, 994, 5454, 83, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 16794, 221, 650, 4329, 26, 966, 26, 1479, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 11396, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3346, 994, 5454, 83, 7, 199, 7307, 275, 399, 7, 7280, 12, 510, 11302, 28385, 530, 32377, 8161, 12, 577, 811, 16794, 609, 452, 12, 644, 7837, 12, 10268, 10670, 24569, 30930, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4420, 994, 5454, 83, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 16794, 221, 650, 4329, 26, 966, 26, 1479, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 11396, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3346, 994, 5454, 83, 7, 199, 7307, 275, 399, 7, 7280, 12, 510, 11302, 28385, 530, 32377, 8161, 12, 577, 811, 16794, 609, 452, 12, 644, 7837, 12, 10268, 10670, 24569, 30930, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
andyzsf/django
tests/select_for_update/tests.py
11
9961
from __future__ import unicode_literals import time import unittest from django.conf import settings from django.db import transaction, connection, router from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError from django.test import ( TransactionTestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature, ) from multiple_database.routers import TestRouter from .models import Person # Some tests require threading, which might not be available. So create a # skip-test decorator for those test functions. try: import threading except ImportError: threading = None requires_threading = unittest.skipUnless(threading, 'requires threading') # We need to set settings.DEBUG to True so we can capture the output SQL # to examine. @override_settings(DEBUG=True) class SelectForUpdateTests(TransactionTestCase): available_apps = ['select_for_update'] def setUp(self): # This is executed in autocommit mode so that code in # run_select_for_update can see this data. self.person = Person.objects.create(name='Reinhardt') # We need another database connection in transaction to test that one # connection issuing a SELECT ... FOR UPDATE will block. new_connections = ConnectionHandler(settings.DATABASES) self.new_connection = new_connections[DEFAULT_DB_ALIAS] def tearDown(self): try: self.end_blocking_transaction() except (DatabaseError, AttributeError): pass self.new_connection.close() def start_blocking_transaction(self): self.new_connection.set_autocommit(False) # Start a blocking transaction. At some point, # end_blocking_transaction() should be called. self.cursor = self.new_connection.cursor() sql = 'SELECT * FROM %(db_table)s %(for_update)s;' % { 'db_table': Person._meta.db_table, 'for_update': self.new_connection.ops.for_update_sql(), } self.cursor.execute(sql, ()) self.cursor.fetchone() def end_blocking_transaction(self): # Roll back the blocking transaction. self.new_connection.rollback() self.new_connection.set_autocommit(True) def has_for_update_sql(self, tested_connection, nowait=False): # Examine the SQL that was executed to determine whether it # contains the 'SELECT..FOR UPDATE' stanza. for_update_sql = tested_connection.ops.for_update_sql(nowait) sql = tested_connection.queries[-1]['sql'] return bool(sql.find(for_update_sql) > -1) @skipUnlessDBFeature('has_select_for_update') def test_for_update_sql_generated(self): """ Test that the backend's FOR UPDATE variant appears in generated SQL when select_for_update is invoked. """ with transaction.atomic(): list(Person.objects.all().select_for_update()) self.assertTrue(self.has_for_update_sql(connection)) @skipUnlessDBFeature('has_select_for_update_nowait') def test_for_update_sql_generated_nowait(self): """ Test that the backend's FOR UPDATE NOWAIT variant appears in generated SQL when select_for_update is invoked. """ with transaction.atomic(): list(Person.objects.all().select_for_update(nowait=True)) self.assertTrue(self.has_for_update_sql(connection, nowait=True)) @requires_threading @skipUnlessDBFeature('has_select_for_update_nowait') def test_nowait_raises_error_on_block(self): """ If nowait is specified, we expect an error to be raised rather than blocking. """ self.start_blocking_transaction() status = [] thread = threading.Thread( target=self.run_select_for_update, args=(status,), kwargs={'nowait': True}, ) thread.start() time.sleep(1) thread.join() self.end_blocking_transaction() self.assertIsInstance(status[-1], DatabaseError) @skipIfDBFeature('has_select_for_update_nowait') @skipUnlessDBFeature('has_select_for_update') def test_unsupported_nowait_raises_error(self): """ If a SELECT...FOR UPDATE NOWAIT is run on a database backend that supports FOR UPDATE but not NOWAIT, then we should find that a DatabaseError is raised. """ self.assertRaises( DatabaseError, list, Person.objects.all().select_for_update(nowait=True) ) @skipUnlessDBFeature('has_select_for_update') def test_for_update_requires_transaction(self): """ Test that a TransactionManagementError is raised when a select_for_update query is executed outside of a transaction. """ with self.assertRaises(transaction.TransactionManagementError): list(Person.objects.all().select_for_update()) @skipUnlessDBFeature('has_select_for_update') def test_for_update_requires_transaction_only_in_execution(self): """ Test that no TransactionManagementError is raised when select_for_update is invoked outside of a transaction - only when the query is executed. """ people = Person.objects.all().select_for_update() with self.assertRaises(transaction.TransactionManagementError): list(people) def run_select_for_update(self, status, nowait=False): """ Utility method that runs a SELECT FOR UPDATE against all Person instances. After the select_for_update, it attempts to update the name of the only record, save, and commit. This function expects to run in a separate thread. """ status.append('started') try: # We need to enter transaction management again, as this is done on # per-thread basis with transaction.atomic(): people = list( Person.objects.all().select_for_update(nowait=nowait) ) people[0].name = 'Fred' people[0].save() except DatabaseError as e: status.append(e) finally: # This method is run in a separate thread. It uses its own # database connection. Close it without waiting for the GC. connection.close() @requires_threading @skipUnlessDBFeature('has_select_for_update') @skipUnlessDBFeature('supports_transactions') def test_block(self): """ Check that a thread running a select_for_update that accesses rows being touched by a similar operation on another connection blocks correctly. """ # First, let's start the transaction in our thread. self.start_blocking_transaction() # Now, try it again using the ORM's select_for_update # facility. Do this in a separate thread. status = [] thread = threading.Thread( target=self.run_select_for_update, args=(status,) ) # The thread should immediately block, but we'll sleep # for a bit to make sure. thread.start() sanity_count = 0 while len(status) != 1 and sanity_count < 10: sanity_count += 1 time.sleep(1) if sanity_count >= 10: raise ValueError('Thread did not run and block') # Check the person hasn't been updated. Since this isn't # using FOR UPDATE, it won't block. p = Person.objects.get(pk=self.person.pk) self.assertEqual('Reinhardt', p.name) # When we end our blocking transaction, our thread should # be able to continue. self.end_blocking_transaction() thread.join(5.0) # Check the thread has finished. Assuming it has, we should # find that it has updated the person's name. self.assertFalse(thread.isAlive()) # We must commit the transaction to ensure that MySQL gets a fresh read, # since by default it runs in REPEATABLE READ mode transaction.commit() p = Person.objects.get(pk=self.person.pk) self.assertEqual('Fred', p.name) @requires_threading @skipUnlessDBFeature('has_select_for_update') def test_raw_lock_not_available(self): """ Check that running a raw query which can't obtain a FOR UPDATE lock raises the correct exception """ self.start_blocking_transaction() def raw(status): try: list( Person.objects.raw( 'SELECT * FROM %s %s' % ( Person._meta.db_table, connection.ops.for_update_sql(nowait=True) ) ) ) except DatabaseError as e: status.append(e) finally: # This method is run in a separate thread. It uses its own # database connection. Close it without waiting for the GC. connection.close() status = [] thread = threading.Thread(target=raw, kwargs={'status': status}) thread.start() time.sleep(1) thread.join() self.end_blocking_transaction() self.assertIsInstance(status[-1], DatabaseError) @skipUnlessDBFeature('has_select_for_update') @override_settings(DATABASE_ROUTERS=[TestRouter()]) def test_select_for_update_on_multidb(self): query = Person.objects.select_for_update() self.assertEqual(router.db_for_write(Person), query.db) @skipUnlessDBFeature('has_select_for_update') def test_select_for_update_with_get(self): with transaction.atomic(): person = Person.objects.select_for_update().get(name='Reinhardt') self.assertEqual(person.name, 'Reinhardt')
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6008, 12, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 1208, 492, 8113, 2461, 12, 6186, 63, 2846, 63, 12644, 12, 27728, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 4278, 63, 1751, 12, 3372, 3917, 18093, 12, 272, 3372, 5524, 18093, 12, 199, 9, 199, 199, 504, 3663, 63, 4659, 14, 17292, 492, 1379, 11691, 199, 199, 504, 1275, 992, 492, 8028, 199, 199, 3, 6601, 2295, 4409, 5796, 12, 1314, 5594, 440, 506, 2808, 14, 2002, 1218, 282, 199, 3, 3372, 13, 396, 7531, 367, 5204, 511, 3423, 14, 199, 893, 26, 272, 492, 5796, 199, 2590, 3545, 26, 272, 5796, 275, 488, 199, 6537, 63, 12562, 275, 2882, 14, 11278, 8, 12562, 12, 283, 6537, 5796, 358, 421, 199, 3, 2136, 1929, 370, 663, 2202, 14, 5287, 370, 715, 880, 781, 883, 12296, 314, 1072, 5385, 199, 3, 370, 31758, 14, 199, 32, 4415, 63, 1751, 8, 5287, 29, 549, 9, 199, 533, 9496, 1858, 4152, 2925, 8, 10161, 1746, 304, 339, 2808, 63, 5181, 275, 788, 2416, 63, 509, 63, 873, 418, 339, 347, 3613, 8, 277, 304, 267, 327, 961, 365, 7934, 315, 24845, 818, 880, 626, 1233, 315, 267, 327, 1255, 63, 2416, 63, 509, 63, 873, 883, 1937, 642, 666, 14, 267, 291, 14, 5484, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 497, 262, 8726, 84, 358, 398, 327, 2136, 1929, 4573, 3050, 1950, 315, 6008, 370, 511, 626, 1373, 267, 327, 1950, 365, 9648, 316, 282, 10468, 2263, 2381, 17148, 911, 1853, 14, 267, 892, 63, 7995, 275, 8113, 2461, 8, 1751, 14, 27260, 9, 267, 291, 14, 1222, 63, 2105, 275, 892, 63, 7995, 59, 3472, 63, 2846, 63, 12644, 61, 339, 347, 6766, 8, 277, 304, 267, 862, 26, 288, 291, 14, 500, 63, 13091, 63, 5945, 342, 267, 871, 334, 25198, 12, 4281, 304, 288, 986, 267, 291, 14, 1222, 63, 2105, 14, 1600, 342, 339, 347, 1343, 63, 13091, 63, 5945, 8, 277, 304, 267, 291, 14, 1222, 63, 2105, 14, 409, 63, 17881, 8, 797, 9, 267, 327, 7707, 282, 14592, 6008, 14, 2854, 2005, 2376, 12, 267, 327, 1284, 63, 13091, 63, 5945, 342, 1077, 506, 2797, 14, 267, 291, 14, 3937, 275, 291, 14, 1222, 63, 2105, 14, 3937, 342, 267, 3875, 275, 283, 4859, 627, 4442, 2818, 697, 63, 1224, 9, 83, 2818, 509, 63, 873, 9, 83, 8942, 450, 469, 288, 283, 697, 63, 1224, 356, 8028, 423, 2024, 14, 697, 63, 1224, 12, 288, 283, 509, 63, 873, 356, 291, 14, 1222, 63, 2105, 14, 1483, 14, 509, 63, 873, 63, 3009, 1062, 267, 789, 267, 291, 14, 3937, 14, 2526, 8, 3009, 12, 14515, 267, 291, 14, 3937, 14, 11591, 342, 339, 347, 1284, 63, 13091, 63, 5945, 8, 277, 304, 267, 327, 820, 14385, 1771, 314, 14592, 6008, 14, 267, 291, 14, 1222, 63, 2105, 14, 10437, 342, 267, 291, 14, 1222, 63, 2105, 14, 409, 63, 17881, 8, 549, 9, 339, 347, 965, 63, 509, 63, 873, 63, 3009, 8, 277, 12, 12470, 63, 2105, 12, 3063, 2781, 29, 797, 304, 267, 327, 1316, 455, 1132, 314, 5385, 626, 1990, 7934, 370, 6705, 3775, 652, 267, 327, 3509, 314, 283, 4859, 703, 2707, 17148, 7, 24267, 14, 267, 367, 63, 873, 63, 3009, 275, 12470, 63, 2105, 14, 1483, 14, 509, 63, 873, 63, 3009, 8, 20870, 9, 267, 3875, 275, 12470, 63, 2105, 14, 10590, 1988, 17, 2733, 3009, 418, 267, 372, 2155, 8, 3009, 14, 1623, 8, 509, 63, 873, 63, 3009, 9, 690, 446, 17, 9, 339, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 358, 272, 347, 511, 63, 509, 63, 873, 63, 3009, 63, 10176, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 4865, 1159, 2381, 17148, 9854, 11337, 315, 267, 4046, 5385, 1380, 3504, 63, 509, 63, 873, 365, 10302, 14, 267, 408, 267, 543, 6008, 14, 10910, 837, 288, 769, 8, 7344, 14, 1462, 14, 452, 1252, 2416, 63, 509, 63, 873, 1012, 267, 291, 14, 1815, 8, 277, 14, 1989, 63, 509, 63, 873, 63, 3009, 8, 2105, 430, 339, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 347, 511, 63, 509, 63, 873, 63, 3009, 63, 10176, 63, 20870, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 4865, 1159, 2381, 17148, 4825, 12458, 9854, 11337, 315, 267, 4046, 5385, 1380, 3504, 63, 509, 63, 873, 365, 10302, 14, 267, 408, 267, 543, 6008, 14, 10910, 837, 288, 769, 8, 7344, 14, 1462, 14, 452, 1252, 2416, 63, 509, 63, 873, 8, 20870, 29, 549, 430, 267, 291, 14, 1815, 8, 277, 14, 1989, 63, 509, 63, 873, 63, 3009, 8, 2105, 12, 3063, 2781, 29, 549, 430, 339, 768, 6537, 63, 12562, 272, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 347, 511, 63, 20870, 63, 3536, 63, 705, 63, 265, 63, 1457, 8, 277, 304, 267, 408, 267, 982, 3063, 2781, 365, 2013, 12, 781, 4282, 376, 1125, 370, 506, 4915, 7830, 267, 2419, 14592, 14, 267, 408, 267, 291, 14, 928, 63, 13091, 63, 5945, 342, 267, 2004, 275, 942, 398, 2462, 275, 5796, 14, 4436, 8, 288, 1347, 29, 277, 14, 1065, 63, 2416, 63, 509, 63, 873, 12, 288, 1249, 2687, 1205, 4706, 288, 2074, 3713, 20870, 356, 715, 1386, 267, 776, 398, 2462, 14, 928, 342, 267, 900, 14, 4532, 8, 17, 9, 267, 2462, 14, 904, 342, 267, 291, 14, 500, 63, 13091, 63, 5945, 342, 267, 291, 14, 6926, 8, 1205, 1988, 17, 467, 27728, 9, 339, 768, 15118, 18093, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 358, 272, 347, 511, 63, 15267, 63, 20870, 63, 3536, 63, 705, 8, 277, 304, 267, 408, 267, 982, 282, 10468, 1396, 2707, 17148, 4825, 12458, 365, 1255, 641, 282, 3050, 4865, 267, 626 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6008, 12, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 1208, 492, 8113, 2461, 12, 6186, 63, 2846, 63, 12644, 12, 27728, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 4278, 63, 1751, 12, 3372, 3917, 18093, 12, 272, 3372, 5524, 18093, 12, 199, 9, 199, 199, 504, 3663, 63, 4659, 14, 17292, 492, 1379, 11691, 199, 199, 504, 1275, 992, 492, 8028, 199, 199, 3, 6601, 2295, 4409, 5796, 12, 1314, 5594, 440, 506, 2808, 14, 2002, 1218, 282, 199, 3, 3372, 13, 396, 7531, 367, 5204, 511, 3423, 14, 199, 893, 26, 272, 492, 5796, 199, 2590, 3545, 26, 272, 5796, 275, 488, 199, 6537, 63, 12562, 275, 2882, 14, 11278, 8, 12562, 12, 283, 6537, 5796, 358, 421, 199, 3, 2136, 1929, 370, 663, 2202, 14, 5287, 370, 715, 880, 781, 883, 12296, 314, 1072, 5385, 199, 3, 370, 31758, 14, 199, 32, 4415, 63, 1751, 8, 5287, 29, 549, 9, 199, 533, 9496, 1858, 4152, 2925, 8, 10161, 1746, 304, 339, 2808, 63, 5181, 275, 788, 2416, 63, 509, 63, 873, 418, 339, 347, 3613, 8, 277, 304, 267, 327, 961, 365, 7934, 315, 24845, 818, 880, 626, 1233, 315, 267, 327, 1255, 63, 2416, 63, 509, 63, 873, 883, 1937, 642, 666, 14, 267, 291, 14, 5484, 275, 8028, 14, 1462, 14, 981, 8, 354, 534, 497, 262, 8726, 84, 358, 398, 327, 2136, 1929, 4573, 3050, 1950, 315, 6008, 370, 511, 626, 1373, 267, 327, 1950, 365, 9648, 316, 282, 10468, 2263, 2381, 17148, 911, 1853, 14, 267, 892, 63, 7995, 275, 8113, 2461, 8, 1751, 14, 27260, 9, 267, 291, 14, 1222, 63, 2105, 275, 892, 63, 7995, 59, 3472, 63, 2846, 63, 12644, 61, 339, 347, 6766, 8, 277, 304, 267, 862, 26, 288, 291, 14, 500, 63, 13091, 63, 5945, 342, 267, 871, 334, 25198, 12, 4281, 304, 288, 986, 267, 291, 14, 1222, 63, 2105, 14, 1600, 342, 339, 347, 1343, 63, 13091, 63, 5945, 8, 277, 304, 267, 291, 14, 1222, 63, 2105, 14, 409, 63, 17881, 8, 797, 9, 267, 327, 7707, 282, 14592, 6008, 14, 2854, 2005, 2376, 12, 267, 327, 1284, 63, 13091, 63, 5945, 342, 1077, 506, 2797, 14, 267, 291, 14, 3937, 275, 291, 14, 1222, 63, 2105, 14, 3937, 342, 267, 3875, 275, 283, 4859, 627, 4442, 2818, 697, 63, 1224, 9, 83, 2818, 509, 63, 873, 9, 83, 8942, 450, 469, 288, 283, 697, 63, 1224, 356, 8028, 423, 2024, 14, 697, 63, 1224, 12, 288, 283, 509, 63, 873, 356, 291, 14, 1222, 63, 2105, 14, 1483, 14, 509, 63, 873, 63, 3009, 1062, 267, 789, 267, 291, 14, 3937, 14, 2526, 8, 3009, 12, 14515, 267, 291, 14, 3937, 14, 11591, 342, 339, 347, 1284, 63, 13091, 63, 5945, 8, 277, 304, 267, 327, 820, 14385, 1771, 314, 14592, 6008, 14, 267, 291, 14, 1222, 63, 2105, 14, 10437, 342, 267, 291, 14, 1222, 63, 2105, 14, 409, 63, 17881, 8, 549, 9, 339, 347, 965, 63, 509, 63, 873, 63, 3009, 8, 277, 12, 12470, 63, 2105, 12, 3063, 2781, 29, 797, 304, 267, 327, 1316, 455, 1132, 314, 5385, 626, 1990, 7934, 370, 6705, 3775, 652, 267, 327, 3509, 314, 283, 4859, 703, 2707, 17148, 7, 24267, 14, 267, 367, 63, 873, 63, 3009, 275, 12470, 63, 2105, 14, 1483, 14, 509, 63, 873, 63, 3009, 8, 20870, 9, 267, 3875, 275, 12470, 63, 2105, 14, 10590, 1988, 17, 2733, 3009, 418, 267, 372, 2155, 8, 3009, 14, 1623, 8, 509, 63, 873, 63, 3009, 9, 690, 446, 17, 9, 339, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 358, 272, 347, 511, 63, 509, 63, 873, 63, 3009, 63, 10176, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 4865, 1159, 2381, 17148, 9854, 11337, 315, 267, 4046, 5385, 1380, 3504, 63, 509, 63, 873, 365, 10302, 14, 267, 408, 267, 543, 6008, 14, 10910, 837, 288, 769, 8, 7344, 14, 1462, 14, 452, 1252, 2416, 63, 509, 63, 873, 1012, 267, 291, 14, 1815, 8, 277, 14, 1989, 63, 509, 63, 873, 63, 3009, 8, 2105, 430, 339, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 347, 511, 63, 509, 63, 873, 63, 3009, 63, 10176, 63, 20870, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 4865, 1159, 2381, 17148, 4825, 12458, 9854, 11337, 315, 267, 4046, 5385, 1380, 3504, 63, 509, 63, 873, 365, 10302, 14, 267, 408, 267, 543, 6008, 14, 10910, 837, 288, 769, 8, 7344, 14, 1462, 14, 452, 1252, 2416, 63, 509, 63, 873, 8, 20870, 29, 549, 430, 267, 291, 14, 1815, 8, 277, 14, 1989, 63, 509, 63, 873, 63, 3009, 8, 2105, 12, 3063, 2781, 29, 549, 430, 339, 768, 6537, 63, 12562, 272, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 347, 511, 63, 20870, 63, 3536, 63, 705, 63, 265, 63, 1457, 8, 277, 304, 267, 408, 267, 982, 3063, 2781, 365, 2013, 12, 781, 4282, 376, 1125, 370, 506, 4915, 7830, 267, 2419, 14592, 14, 267, 408, 267, 291, 14, 928, 63, 13091, 63, 5945, 342, 267, 2004, 275, 942, 398, 2462, 275, 5796, 14, 4436, 8, 288, 1347, 29, 277, 14, 1065, 63, 2416, 63, 509, 63, 873, 12, 288, 1249, 2687, 1205, 4706, 288, 2074, 3713, 20870, 356, 715, 1386, 267, 776, 398, 2462, 14, 928, 342, 267, 900, 14, 4532, 8, 17, 9, 267, 2462, 14, 904, 342, 267, 291, 14, 500, 63, 13091, 63, 5945, 342, 267, 291, 14, 6926, 8, 1205, 1988, 17, 467, 27728, 9, 339, 768, 15118, 18093, 360, 1989, 63, 2416, 63, 509, 63, 873, 63, 20870, 358, 272, 768, 22424, 360, 1989, 63, 2416, 63, 509, 63, 873, 358, 272, 347, 511, 63, 15267,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mikalstill/nova
nova/virt/hyperv/pathutils.py
4
8531
# Copyright 2013 Cloudbase Solutions Srl # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os import six import tempfile import time from os_win.utils import pathutils from oslo_log import log as logging import nova.conf from nova import exception from nova.i18n import _ from nova.virt.hyperv import constants LOG = logging.getLogger(__name__) CONF = nova.conf.CONF ERROR_INVALID_NAME = 123 # NOTE(claudiub): part of the pre-existing PathUtils is nova-specific and # it does not belong in the os-win library. In order to ensure the same # functionality with the least amount of changes necessary, adding as a mixin # the os_win.pathutils.PathUtils class into this PathUtils. class PathUtils(pathutils.PathUtils): def get_instances_dir(self, remote_server=None): local_instance_path = os.path.normpath(CONF.instances_path) if remote_server and not local_instance_path.startswith(r'\\'): if CONF.hyperv.instances_path_share: path = CONF.hyperv.instances_path_share else: # Use an administrative share path = local_instance_path.replace(':', '$') return ('\\\\%(remote_server)s\\%(path)s' % {'remote_server': remote_server, 'path': path}) else: return local_instance_path def _get_instances_sub_dir(self, dir_name, remote_server=None, create_dir=True, remove_dir=False): instances_path = self.get_instances_dir(remote_server) path = os.path.join(instances_path, dir_name) try: if remove_dir: self.check_remove_dir(path) if create_dir: self.check_create_dir(path) return path except WindowsError as ex: if ex.winerror == ERROR_INVALID_NAME: raise exception.AdminRequired(_( "Cannot access \"%(instances_path)s\", make sure the " "path exists and that you have the proper permissions. " "In particular Nova-Compute must not be executed with the " "builtin SYSTEM account or other accounts unable to " "authenticate on a remote host.") % {'instances_path': instances_path}) raise def get_instance_migr_revert_dir(self, instance_name, create_dir=False, remove_dir=False): dir_name = '%s_revert' % instance_name return self._get_instances_sub_dir(dir_name, None, create_dir, remove_dir) def get_instance_dir(self, instance_name, remote_server=None, create_dir=True, remove_dir=False): return self._get_instances_sub_dir(instance_name, remote_server, create_dir, remove_dir) def _lookup_vhd_path(self, instance_name, vhd_path_func, *args, **kwargs): vhd_path = None for format_ext in ['vhd', 'vhdx']: test_path = vhd_path_func(instance_name, format_ext, *args, **kwargs) if self.exists(test_path): vhd_path = test_path break return vhd_path def lookup_root_vhd_path(self, instance_name, rescue=False): return self._lookup_vhd_path(instance_name, self.get_root_vhd_path, rescue) def lookup_configdrive_path(self, instance_name, rescue=False): configdrive_path = None for format_ext in constants.DISK_FORMAT_MAP: test_path = self.get_configdrive_path(instance_name, format_ext, rescue=rescue) if self.exists(test_path): configdrive_path = test_path break return configdrive_path def lookup_ephemeral_vhd_path(self, instance_name, eph_name): return self._lookup_vhd_path(instance_name, self.get_ephemeral_vhd_path, eph_name) def get_root_vhd_path(self, instance_name, format_ext, rescue=False): instance_path = self.get_instance_dir(instance_name) image_name = 'root' if rescue: image_name += '-rescue' return os.path.join(instance_path, image_name + '.' + format_ext.lower()) def get_configdrive_path(self, instance_name, format_ext, remote_server=None, rescue=False): instance_path = self.get_instance_dir(instance_name, remote_server) configdrive_image_name = 'configdrive' if rescue: configdrive_image_name += '-rescue' return os.path.join(instance_path, configdrive_image_name + '.' + format_ext.lower()) def get_ephemeral_vhd_path(self, instance_name, format_ext, eph_name): instance_path = self.get_instance_dir(instance_name) return os.path.join(instance_path, eph_name + '.' + format_ext.lower()) def get_base_vhd_dir(self): return self._get_instances_sub_dir('_base') def get_export_dir(self, instance_name): dir_name = os.path.join('export', instance_name) return self._get_instances_sub_dir(dir_name, create_dir=True, remove_dir=True) def get_vm_console_log_paths(self, instance_name, remote_server=None): instance_dir = self.get_instance_dir(instance_name, remote_server) console_log_path = os.path.join(instance_dir, 'console.log') return console_log_path, console_log_path + '.1' def copy_vm_console_logs(self, instance_name, dest_host): local_log_paths = self.get_vm_console_log_paths( instance_name) remote_log_paths = self.get_vm_console_log_paths( instance_name, remote_server=dest_host) for local_log_path, remote_log_path in zip(local_log_paths, remote_log_paths): if self.exists(local_log_path): self.copy(local_log_path, remote_log_path) def get_image_path(self, image_name): # Note: it is possible that the path doesn't exist base_dir = self.get_base_vhd_dir() for ext in ['vhd', 'vhdx']: file_path = os.path.join(base_dir, image_name + '.' + ext.lower()) if self.exists(file_path): return file_path return None def get_age_of_file(self, file_name): return time.time() - os.path.getmtime(file_name) def check_dirs_shared_storage(self, src_dir, dest_dir): # Check if shared storage is being used by creating a temporary # file at the destination path and checking if it exists at the # source path. LOG.debug("Checking if %(src_dir)s and %(dest_dir)s point " "to the same location.", dict(src_dir=src_dir, dest_dir=dest_dir)) try: with tempfile.NamedTemporaryFile(dir=dest_dir) as tmp_file: src_path = os.path.join(src_dir, os.path.basename(tmp_file.name)) shared_storage = os.path.exists(src_path) except OSError as e: raise exception.FileNotFound(six.text_type(e)) return shared_storage def check_remote_instances_dir_shared(self, dest): # Checks if the instances dir from a remote host points # to the same storage location as the local instances dir. local_inst_dir = self.get_instances_dir() remote_inst_dir = self.get_instances_dir(dest) return self.check_dirs_shared_storage(local_inst_dir, remote_inst_dir)
apache-2.0
[ 3, 1898, 6171, 5980, 8301, 482, 17991, 8653, 428, 4308, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 3816, 199, 646, 5549, 199, 646, 900, 199, 199, 504, 747, 63, 2676, 14, 1208, 492, 931, 1208, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 646, 5913, 14, 2190, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 14, 4549, 14, 9547, 86, 492, 5262, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 275, 5913, 14, 2190, 14, 3103, 199, 199, 3170, 63, 9692, 63, 2339, 275, 11869, 199, 199, 3, 6944, 8, 3995, 14525, 456, 304, 1777, 402, 314, 876, 13, 5952, 6912, 7535, 365, 5913, 13, 6100, 436, 199, 3, 652, 1630, 440, 13511, 315, 314, 747, 13, 2676, 3555, 14, 1010, 1865, 370, 4868, 314, 2011, 199, 3, 9330, 543, 314, 5210, 5982, 402, 4493, 5784, 12, 7791, 465, 282, 20048, 199, 3, 314, 747, 63, 2676, 14, 515, 1208, 14, 2042, 7535, 1021, 1901, 642, 6912, 7535, 14, 421, 199, 533, 6912, 7535, 8, 515, 1208, 14, 2042, 7535, 304, 339, 347, 664, 63, 5990, 63, 694, 8, 277, 12, 3982, 63, 1000, 29, 403, 304, 267, 2257, 63, 842, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 3103, 14, 5990, 63, 515, 9, 398, 340, 3982, 63, 1000, 436, 440, 2257, 63, 842, 63, 515, 14, 2460, 8, 82, 8124, 735, 288, 340, 6392, 14, 9547, 86, 14, 5990, 63, 515, 63, 6251, 26, 355, 931, 275, 6392, 14, 9547, 86, 14, 5990, 63, 515, 63, 6251, 288, 587, 26, 355, 327, 3645, 376, 4628, 25124, 8663, 355, 931, 275, 2257, 63, 842, 63, 515, 14, 1814, 16451, 4505, 358, 288, 372, 661, 8712, 2840, 3846, 63, 1000, 9, 83, 1103, 2840, 515, 9, 83, 7, 450, 355, 791, 3846, 63, 1000, 356, 3982, 63, 1000, 12, 283, 515, 356, 931, 1552, 267, 587, 26, 288, 372, 2257, 63, 842, 63, 515, 339, 347, 485, 362, 63, 5990, 63, 954, 63, 694, 8, 277, 12, 2935, 63, 354, 12, 3982, 63, 1000, 29, 403, 12, 3044, 1218, 63, 694, 29, 549, 12, 2813, 63, 694, 29, 797, 304, 267, 4454, 63, 515, 275, 291, 14, 362, 63, 5990, 63, 694, 8, 3846, 63, 1000, 9, 267, 931, 275, 747, 14, 515, 14, 904, 8, 5990, 63, 515, 12, 2935, 63, 354, 9, 267, 862, 26, 288, 340, 2813, 63, 694, 26, 355, 291, 14, 1074, 63, 2168, 63, 694, 8, 515, 9, 288, 340, 1218, 63, 694, 26, 355, 291, 14, 1074, 63, 981, 63, 694, 8, 515, 9, 288, 372, 931, 267, 871, 23950, 465, 444, 26, 288, 340, 444, 14, 2676, 705, 508, 12539, 63, 9692, 63, 2339, 26, 355, 746, 1919, 14, 4880, 8030, 27594, 490, 298, 6612, 2879, 8441, 2840, 5990, 63, 515, 9, 83, 20756, 1852, 3238, 314, 298, 490, 298, 515, 3495, 436, 626, 1265, 1172, 314, 5576, 3443, 14, 298, 490, 298, 607, 6770, 28184, 13, 8564, 1471, 440, 506, 7934, 543, 314, 298, 490, 298, 5351, 20859, 2933, 503, 1163, 12639, 17329, 370, 298, 490, 298, 13975, 641, 282, 3982, 1591, 2685, 450, 490, 791, 5990, 63, 515, 356, 4454, 63, 515, 1552, 288, 746, 339, 347, 664, 63, 842, 63, 4071, 82, 63, 19092, 63, 694, 8, 277, 12, 1256, 63, 354, 12, 1218, 63, 694, 29, 797, 12, 3660, 2813, 63, 694, 29, 797, 304, 267, 2935, 63, 354, 275, 1543, 83, 63, 19092, 7, 450, 1256, 63, 354, 267, 372, 291, 423, 362, 63, 5990, 63, 954, 63, 694, 8, 694, 63, 354, 12, 488, 12, 1218, 63, 694, 12, 5644, 2813, 63, 694, 9, 339, 347, 664, 63, 842, 63, 694, 8, 277, 12, 1256, 63, 354, 12, 3982, 63, 1000, 29, 403, 12, 586, 1218, 63, 694, 29, 549, 12, 2813, 63, 694, 29, 797, 304, 267, 372, 291, 423, 362, 63, 5990, 63, 954, 63, 694, 8, 842, 63, 354, 12, 3982, 63, 1000, 12, 5644, 1218, 63, 694, 12, 2813, 63, 694, 9, 339, 347, 485, 3892, 63, 20961, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 373, 7952, 63, 515, 63, 1532, 12, 586, 627, 589, 12, 1011, 958, 304, 267, 373, 7952, 63, 515, 275, 488, 267, 367, 1475, 63, 832, 315, 788, 20961, 297, 283, 20961, 88, 2565, 288, 511, 63, 515, 275, 373, 7952, 63, 515, 63, 1532, 8, 842, 63, 354, 12, 1475, 63, 832, 12, 4228, 627, 589, 12, 1011, 958, 9, 288, 340, 291, 14, 2444, 8, 396, 63, 515, 304, 355, 373, 7952, 63, 515, 275, 511, 63, 515, 355, 2059, 267, 372, 373, 7952, 63, 515, 339, 347, 4237, 63, 1231, 63, 20961, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 522, 14932, 29, 797, 304, 267, 372, 291, 423, 3892, 63, 20961, 63, 515, 8, 842, 63, 354, 12, 291, 14, 362, 63, 1231, 63, 20961, 63, 515, 12, 3660, 522, 14932, 9, 339, 347, 4237, 63, 888, 9541, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 522, 14932, 29, 797, 304, 267, 1101, 9541, 63, 515, 275, 488, 267, 367, 1475, 63, 832, 315, 5262, 14, 20492, 63, 4807, 63, 5443, 26, 288, 511, 63, 515, 275, 291, 14, 362, 63 ]
[ 1898, 6171, 5980, 8301, 482, 17991, 8653, 428, 4308, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 3816, 199, 646, 5549, 199, 646, 900, 199, 199, 504, 747, 63, 2676, 14, 1208, 492, 931, 1208, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 199, 646, 5913, 14, 2190, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 14, 4549, 14, 9547, 86, 492, 5262, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 275, 5913, 14, 2190, 14, 3103, 199, 199, 3170, 63, 9692, 63, 2339, 275, 11869, 199, 199, 3, 6944, 8, 3995, 14525, 456, 304, 1777, 402, 314, 876, 13, 5952, 6912, 7535, 365, 5913, 13, 6100, 436, 199, 3, 652, 1630, 440, 13511, 315, 314, 747, 13, 2676, 3555, 14, 1010, 1865, 370, 4868, 314, 2011, 199, 3, 9330, 543, 314, 5210, 5982, 402, 4493, 5784, 12, 7791, 465, 282, 20048, 199, 3, 314, 747, 63, 2676, 14, 515, 1208, 14, 2042, 7535, 1021, 1901, 642, 6912, 7535, 14, 421, 199, 533, 6912, 7535, 8, 515, 1208, 14, 2042, 7535, 304, 339, 347, 664, 63, 5990, 63, 694, 8, 277, 12, 3982, 63, 1000, 29, 403, 304, 267, 2257, 63, 842, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 3103, 14, 5990, 63, 515, 9, 398, 340, 3982, 63, 1000, 436, 440, 2257, 63, 842, 63, 515, 14, 2460, 8, 82, 8124, 735, 288, 340, 6392, 14, 9547, 86, 14, 5990, 63, 515, 63, 6251, 26, 355, 931, 275, 6392, 14, 9547, 86, 14, 5990, 63, 515, 63, 6251, 288, 587, 26, 355, 327, 3645, 376, 4628, 25124, 8663, 355, 931, 275, 2257, 63, 842, 63, 515, 14, 1814, 16451, 4505, 358, 288, 372, 661, 8712, 2840, 3846, 63, 1000, 9, 83, 1103, 2840, 515, 9, 83, 7, 450, 355, 791, 3846, 63, 1000, 356, 3982, 63, 1000, 12, 283, 515, 356, 931, 1552, 267, 587, 26, 288, 372, 2257, 63, 842, 63, 515, 339, 347, 485, 362, 63, 5990, 63, 954, 63, 694, 8, 277, 12, 2935, 63, 354, 12, 3982, 63, 1000, 29, 403, 12, 3044, 1218, 63, 694, 29, 549, 12, 2813, 63, 694, 29, 797, 304, 267, 4454, 63, 515, 275, 291, 14, 362, 63, 5990, 63, 694, 8, 3846, 63, 1000, 9, 267, 931, 275, 747, 14, 515, 14, 904, 8, 5990, 63, 515, 12, 2935, 63, 354, 9, 267, 862, 26, 288, 340, 2813, 63, 694, 26, 355, 291, 14, 1074, 63, 2168, 63, 694, 8, 515, 9, 288, 340, 1218, 63, 694, 26, 355, 291, 14, 1074, 63, 981, 63, 694, 8, 515, 9, 288, 372, 931, 267, 871, 23950, 465, 444, 26, 288, 340, 444, 14, 2676, 705, 508, 12539, 63, 9692, 63, 2339, 26, 355, 746, 1919, 14, 4880, 8030, 27594, 490, 298, 6612, 2879, 8441, 2840, 5990, 63, 515, 9, 83, 20756, 1852, 3238, 314, 298, 490, 298, 515, 3495, 436, 626, 1265, 1172, 314, 5576, 3443, 14, 298, 490, 298, 607, 6770, 28184, 13, 8564, 1471, 440, 506, 7934, 543, 314, 298, 490, 298, 5351, 20859, 2933, 503, 1163, 12639, 17329, 370, 298, 490, 298, 13975, 641, 282, 3982, 1591, 2685, 450, 490, 791, 5990, 63, 515, 356, 4454, 63, 515, 1552, 288, 746, 339, 347, 664, 63, 842, 63, 4071, 82, 63, 19092, 63, 694, 8, 277, 12, 1256, 63, 354, 12, 1218, 63, 694, 29, 797, 12, 3660, 2813, 63, 694, 29, 797, 304, 267, 2935, 63, 354, 275, 1543, 83, 63, 19092, 7, 450, 1256, 63, 354, 267, 372, 291, 423, 362, 63, 5990, 63, 954, 63, 694, 8, 694, 63, 354, 12, 488, 12, 1218, 63, 694, 12, 5644, 2813, 63, 694, 9, 339, 347, 664, 63, 842, 63, 694, 8, 277, 12, 1256, 63, 354, 12, 3982, 63, 1000, 29, 403, 12, 586, 1218, 63, 694, 29, 549, 12, 2813, 63, 694, 29, 797, 304, 267, 372, 291, 423, 362, 63, 5990, 63, 954, 63, 694, 8, 842, 63, 354, 12, 3982, 63, 1000, 12, 5644, 1218, 63, 694, 12, 2813, 63, 694, 9, 339, 347, 485, 3892, 63, 20961, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 373, 7952, 63, 515, 63, 1532, 12, 586, 627, 589, 12, 1011, 958, 304, 267, 373, 7952, 63, 515, 275, 488, 267, 367, 1475, 63, 832, 315, 788, 20961, 297, 283, 20961, 88, 2565, 288, 511, 63, 515, 275, 373, 7952, 63, 515, 63, 1532, 8, 842, 63, 354, 12, 1475, 63, 832, 12, 4228, 627, 589, 12, 1011, 958, 9, 288, 340, 291, 14, 2444, 8, 396, 63, 515, 304, 355, 373, 7952, 63, 515, 275, 511, 63, 515, 355, 2059, 267, 372, 373, 7952, 63, 515, 339, 347, 4237, 63, 1231, 63, 20961, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 522, 14932, 29, 797, 304, 267, 372, 291, 423, 3892, 63, 20961, 63, 515, 8, 842, 63, 354, 12, 291, 14, 362, 63, 1231, 63, 20961, 63, 515, 12, 3660, 522, 14932, 9, 339, 347, 4237, 63, 888, 9541, 63, 515, 8, 277, 12, 1256, 63, 354, 12, 522, 14932, 29, 797, 304, 267, 1101, 9541, 63, 515, 275, 488, 267, 367, 1475, 63, 832, 315, 5262, 14, 20492, 63, 4807, 63, 5443, 26, 288, 511, 63, 515, 275, 291, 14, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
keeeener/nicki
platform/external/wpa_supplicant_8/hostapd/wps-ap-nfc.py
5
7106
#!/usr/bin/python # # Example nfcpy to hostapd wrapper for WPS NFC operations # Copyright (c) 2012-2013, Jouni Malinen <j@w1.fi> # # This software may be distributed under the terms of the BSD license. # See README for more details. import os import sys import time import nfc import nfc.ndef import nfc.llcp import nfc.handover import logging logging.basicConfig() import wpaspy wpas_ctrl = '/var/run/hostapd' def wpas_connect(): ifaces = [] if os.path.isdir(wpas_ctrl): try: ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)] except OSError, error: print "Could not find hostapd: ", error return None if len(ifaces) < 1: print "No hostapd control interface found" return None for ctrl in ifaces: try: wpas = wpaspy.Ctrl(ctrl) return wpas except Exception, e: pass return None def wpas_tag_read(message): wpas = wpas_connect() if (wpas == None): return print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex")) def wpas_get_config_token(): wpas = wpas_connect() if (wpas == None): return None return wpas.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip().decode("hex") def wpas_get_password_token(): wpas = wpas_connect() if (wpas == None): return None return wpas.request("WPS_NFC_TOKEN NDEF").rstrip().decode("hex") def wpas_get_handover_sel(): wpas = wpas_connect() if (wpas == None): return None return wpas.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip().decode("hex") def wpas_report_handover(req, sel): wpas = wpas_connect() if (wpas == None): return None return wpas.request("NFC_REPORT_HANDOVER RESP WPS " + str(req).encode("hex") + " " + str(sel).encode("hex")) class HandoverServer(nfc.handover.HandoverServer): def __init__(self): super(HandoverServer, self).__init__() def process_request(self, request): print "HandoverServer - request received" print "Parsed handover request: " + request.pretty() sel = nfc.ndef.HandoverSelectMessage(version="1.2") for carrier in request.carriers: print "Remote carrier type: " + carrier.type if carrier.type == "application/vnd.wfa.wsc": print "WPS carrier type match - add WPS carrier record" self.received_carrier = carrier.record data = wpas_get_handover_sel() if data is None: print "Could not get handover select carrier record from hostapd" continue print "Handover select carrier record from hostapd:" print data.encode("hex") self.sent_carrier = data message = nfc.ndef.Message(data); sel.add_carrier(message[0], "active", message[1:]) print "Handover select:" print sel.pretty() print str(sel).encode("hex") print "Sending handover select" return sel def wps_handover_resp(peer): print "Trying to handle WPS handover" srv = HandoverServer() srv.sent_carrier = None nfc.llcp.activate(peer); try: print "Trying handover"; srv.start() print "Wait for disconnect" while nfc.llcp.connected(): time.sleep(0.1) print "Disconnected after handover" except nfc.llcp.ConnectRefused: print "Handover connection refused" nfc.llcp.shutdown() return if srv.sent_carrier: wpas_report_handover(srv.received_carrier, srv.sent_carrier) print "Remove peer" nfc.llcp.shutdown() print "Done with handover" def wps_tag_read(tag): if len(tag.ndef.message): message = nfc.ndef.Message(tag.ndef.message) print "message type " + message.type for record in message: print "record type " + record.type if record.type == "application/vnd.wfa.wsc": print "WPS tag - send to hostapd" wpas_tag_read(tag.ndef.message) break else: print "Empty tag" print "Remove tag" while tag.is_present: time.sleep(0.1) def wps_write_config_tag(clf): print "Write WPS config token" data = wpas_get_config_token() if (data == None): print "Could not get WPS config token from hostapd" return print "Touch an NFC tag" while True: tag = clf.poll() if tag == None: time.sleep(0.1) continue break print "Tag found - writing" tag.ndef.message = data print "Done - remove tag" while tag.is_present: time.sleep(0.1) def wps_write_password_tag(clf): print "Write WPS password token" data = wpas_get_password_token() if (data == None): print "Could not get WPS password token from hostapd" return print "Touch an NFC tag" while True: tag = clf.poll() if tag == None: time.sleep(0.1) continue break print "Tag found - writing" tag.ndef.message = data print "Done - remove tag" while tag.is_present: time.sleep(0.1) def find_peer(clf): while True: if nfc.llcp.connected(): print "LLCP connected" general_bytes = nfc.llcp.startup({}) peer = clf.listen(ord(os.urandom(1)) + 250, general_bytes) if isinstance(peer, nfc.DEP): print "listen -> DEP"; if peer.general_bytes.startswith("Ffm"): print "Found DEP" return peer print "mismatch in general_bytes" print peer.general_bytes peer = clf.poll(general_bytes) if isinstance(peer, nfc.DEP): print "poll -> DEP"; if peer.general_bytes.startswith("Ffm"): print "Found DEP" return peer print "mismatch in general_bytes" print peer.general_bytes if peer: print "Found tag" return peer def main(): clf = nfc.ContactlessFrontend() try: if len(sys.argv) > 1 and sys.argv[1] == "write-config": wps_write_config_tag(clf) raise SystemExit if len(sys.argv) > 1 and sys.argv[1] == "write-password": wps_write_password_tag(clf) raise SystemExit while True: print "Waiting for a tag or peer to be touched" tag = find_peer(clf) if isinstance(tag, nfc.DEP): wps_handover_resp(tag) continue if tag.ndef: wps_tag_read(tag) continue print "Not an NDEF tag - remove tag" while tag.is_present: time.sleep(0.1) except KeyboardInterrupt: raise SystemExit finally: clf.close() raise SystemExit if __name__ == '__main__': main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 5679, 302, 3003, 647, 370, 1591, 439, 68, 4975, 367, 644, 5067, 653, 4161, 5331, 199, 3, 1898, 334, 67, 9, 6029, 13, 6965, 12, 7135, 5411, 29936, 262, 287, 665, 74, 32, 87, 17, 14, 329, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 6289, 4190, 14, 199, 3, 1666, 27781, 367, 1655, 2436, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 646, 302, 3003, 199, 646, 302, 3003, 14, 18467, 199, 646, 302, 3003, 14, 914, 1850, 199, 646, 302, 3003, 14, 6868, 1883, 199, 199, 646, 2050, 199, 4806, 14, 19602, 342, 199, 199, 646, 336, 15534, 647, 199, 199, 14649, 305, 63, 12476, 275, 1994, 1391, 15, 1065, 15, 1102, 439, 68, 7, 199, 199, 318, 336, 15534, 63, 2242, 837, 272, 340, 65, 823, 275, 942, 272, 340, 747, 14, 515, 14, 6027, 8, 14649, 305, 63, 12476, 304, 267, 862, 26, 288, 340, 65, 823, 275, 359, 736, 14, 515, 14, 904, 8, 14649, 305, 63, 12476, 12, 284, 9, 367, 284, 315, 747, 14, 7374, 8, 14649, 305, 63, 12476, 1874, 267, 871, 6440, 12, 1125, 26, 288, 870, 298, 6531, 440, 2342, 1591, 439, 68, 26, 3872, 1125, 288, 372, 488, 339, 340, 822, 8, 73, 4309, 9, 665, 413, 26, 267, 870, 298, 1944, 1591, 439, 68, 3304, 3217, 1911, 2, 267, 372, 488, 339, 367, 15427, 315, 340, 65, 823, 26, 267, 862, 26, 288, 336, 15534, 275, 336, 15534, 647, 14, 9778, 8, 12476, 9, 288, 372, 336, 15534, 267, 871, 2186, 12, 325, 26, 288, 986, 272, 372, 488, 421, 199, 318, 336, 15534, 63, 1450, 63, 739, 8, 1188, 304, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 272, 870, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 6967, 63, 5670, 298, 435, 1245, 14, 2143, 480, 4097, 2237, 421, 199, 318, 336, 15534, 63, 362, 63, 888, 63, 1418, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 5569, 63, 8803, 653, 5638, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 362, 63, 2060, 63, 1418, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 8803, 653, 5638, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 362, 63, 6868, 1883, 63, 5891, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 46, 4161, 63, 2970, 63, 40, 879, 1649, 2111, 63, 899, 44, 653, 5638, 644, 5067, 13, 2944, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 3070, 63, 6868, 1883, 8, 2103, 12, 13680, 304, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 46, 4161, 63, 17356, 63, 40, 879, 1649, 2111, 820, 7613, 644, 5067, 298, 435, 717, 620, 8, 2103, 680, 2143, 480, 4097, 531, 435, 298, 298, 435, 717, 620, 8, 5891, 680, 2143, 480, 4097, 2237, 421, 199, 533, 18405, 1883, 3120, 8, 78, 3003, 14, 6868, 1883, 14, 13220, 1883, 3120, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 13220, 1883, 3120, 12, 291, 2843, 826, 4533, 339, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 870, 298, 13220, 1883, 3120, 446, 1056, 3086, 2, 267, 870, 298, 1262, 939, 4926, 1883, 1056, 26, 298, 435, 1056, 14, 9118, 342, 398, 13680, 275, 302, 3003, 14, 18467, 14, 13220, 1883, 5446, 2209, 8, 1023, 628, 17, 14, 18, 531, 398, 367, 9590, 10742, 315, 1056, 14, 7007, 322, 1192, 26, 288, 870, 298, 6713, 9590, 10742, 730, 26, 298, 435, 9590, 10742, 14, 466, 288, 340, 9590, 10742, 14, 466, 508, 298, 3578, 15, 26379, 14, 87, 667, 14, 87, 551, 582, 355, 870, 298, 55, 5067, 9590, 10742, 730, 1336, 446, 1050, 644, 5067, 9590, 10742, 2777, 2, 355, 291, 14, 9226, 63, 24499, 275, 9590, 10742, 14, 3059, 355, 666, 275, 336, 15534, 63, 362, 63, 6868, 1883, 63, 5891, 342, 355, 340, 666, 365, 488, 26, 490, 870, 298, 6531, 440, 664, 4926, 1883, 3504, 9590, 10742, 2777, 687, 1591, 439, 68, 2, 490, 1980, 355, 870, 298, 13220, 1883, 3504, 9590, 10742, 2777, 687, 1591, 439, 68, 5424, 355, 870, 666, 14, 2143, 480, 4097, 531, 355, 291, 14, 1150, 63, 24499, 275, 666, 2234, 1245, 275, 302, 3003, 14, 18467, 14, 2209, 8, 576, 2736, 355, 13680, 14, 525, 63, 24499, 8, 1188, 59, 16, 467, 298, 2682, 401, 1245, 59, 17, 5728, 398, 870, 298, 13220, 1883, 3504, 5424, 267, 870, 13680, 14, 9118, 342, 267, 870, 620, 8, 5891, 680, 2143, 480, 4097, 531, 398, 870, 298, 27219, 4926, 1883, 3504, 2, 267, 372, 13680, 421, 199, 318, 336, 1190, 63, 6868, 1883, 63, 4518, 8, 7866, 304, 272, 870, 298, 27693, 370, 2429, 644, 5067, 4926, 1883, 2, 339, 20006, 275, 18405, 1883, 3120, 342, 272, 20006, 14, 1150, 63, 24499, 275, 488, 339, 302, 3003, 14, 914, 1850, 14, 8222, 8, 7866, 2736, 339, 862, 26, 267, 870, 298, 27693, 4926, 1883, 11436, 267, 20006, 14, 928, 342, 267, 870, 298, 7536, 367, 17639, 2, 267, 1830, 302, 3003, 14, 914, 1850, 14, 7113, 837, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 267, 870, 298, 2825, 7113, 2410, 4926, 1883, 2, 272, 871, 302, 3003, 14, 914, 1850, 14, 8631, 2891, 2972, 26, 267, 870, 298, 13220, 1883, 1950, 2984, 2972, 2, 267, 302, 3003, 14, 914, 1850, 14, 8831, 342, 267, 372, 339, 340, 20006, 14, 1150, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 5679, 302, 3003, 647, 370, 1591, 439, 68, 4975, 367, 644, 5067, 653, 4161, 5331, 199, 3, 1898, 334, 67, 9, 6029, 13, 6965, 12, 7135, 5411, 29936, 262, 287, 665, 74, 32, 87, 17, 14, 329, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 6289, 4190, 14, 199, 3, 1666, 27781, 367, 1655, 2436, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 646, 302, 3003, 199, 646, 302, 3003, 14, 18467, 199, 646, 302, 3003, 14, 914, 1850, 199, 646, 302, 3003, 14, 6868, 1883, 199, 199, 646, 2050, 199, 4806, 14, 19602, 342, 199, 199, 646, 336, 15534, 647, 199, 199, 14649, 305, 63, 12476, 275, 1994, 1391, 15, 1065, 15, 1102, 439, 68, 7, 199, 199, 318, 336, 15534, 63, 2242, 837, 272, 340, 65, 823, 275, 942, 272, 340, 747, 14, 515, 14, 6027, 8, 14649, 305, 63, 12476, 304, 267, 862, 26, 288, 340, 65, 823, 275, 359, 736, 14, 515, 14, 904, 8, 14649, 305, 63, 12476, 12, 284, 9, 367, 284, 315, 747, 14, 7374, 8, 14649, 305, 63, 12476, 1874, 267, 871, 6440, 12, 1125, 26, 288, 870, 298, 6531, 440, 2342, 1591, 439, 68, 26, 3872, 1125, 288, 372, 488, 339, 340, 822, 8, 73, 4309, 9, 665, 413, 26, 267, 870, 298, 1944, 1591, 439, 68, 3304, 3217, 1911, 2, 267, 372, 488, 339, 367, 15427, 315, 340, 65, 823, 26, 267, 862, 26, 288, 336, 15534, 275, 336, 15534, 647, 14, 9778, 8, 12476, 9, 288, 372, 336, 15534, 267, 871, 2186, 12, 325, 26, 288, 986, 272, 372, 488, 421, 199, 318, 336, 15534, 63, 1450, 63, 739, 8, 1188, 304, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 272, 870, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 6967, 63, 5670, 298, 435, 1245, 14, 2143, 480, 4097, 2237, 421, 199, 318, 336, 15534, 63, 362, 63, 888, 63, 1418, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 5569, 63, 8803, 653, 5638, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 362, 63, 2060, 63, 1418, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 55, 5067, 63, 46, 4161, 63, 8803, 653, 5638, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 362, 63, 6868, 1883, 63, 5891, 837, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 46, 4161, 63, 2970, 63, 40, 879, 1649, 2111, 63, 899, 44, 653, 5638, 644, 5067, 13, 2944, 3471, 6735, 1252, 2708, 480, 4097, 531, 421, 199, 318, 336, 15534, 63, 3070, 63, 6868, 1883, 8, 2103, 12, 13680, 304, 272, 336, 15534, 275, 336, 15534, 63, 2242, 342, 272, 340, 334, 14649, 305, 508, 488, 304, 267, 372, 488, 272, 372, 336, 15534, 14, 1069, 480, 46, 4161, 63, 17356, 63, 40, 879, 1649, 2111, 820, 7613, 644, 5067, 298, 435, 717, 620, 8, 2103, 680, 2143, 480, 4097, 531, 435, 298, 298, 435, 717, 620, 8, 5891, 680, 2143, 480, 4097, 2237, 421, 199, 533, 18405, 1883, 3120, 8, 78, 3003, 14, 6868, 1883, 14, 13220, 1883, 3120, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 13220, 1883, 3120, 12, 291, 2843, 826, 4533, 339, 347, 2112, 63, 1069, 8, 277, 12, 1056, 304, 267, 870, 298, 13220, 1883, 3120, 446, 1056, 3086, 2, 267, 870, 298, 1262, 939, 4926, 1883, 1056, 26, 298, 435, 1056, 14, 9118, 342, 398, 13680, 275, 302, 3003, 14, 18467, 14, 13220, 1883, 5446, 2209, 8, 1023, 628, 17, 14, 18, 531, 398, 367, 9590, 10742, 315, 1056, 14, 7007, 322, 1192, 26, 288, 870, 298, 6713, 9590, 10742, 730, 26, 298, 435, 9590, 10742, 14, 466, 288, 340, 9590, 10742, 14, 466, 508, 298, 3578, 15, 26379, 14, 87, 667, 14, 87, 551, 582, 355, 870, 298, 55, 5067, 9590, 10742, 730, 1336, 446, 1050, 644, 5067, 9590, 10742, 2777, 2, 355, 291, 14, 9226, 63, 24499, 275, 9590, 10742, 14, 3059, 355, 666, 275, 336, 15534, 63, 362, 63, 6868, 1883, 63, 5891, 342, 355, 340, 666, 365, 488, 26, 490, 870, 298, 6531, 440, 664, 4926, 1883, 3504, 9590, 10742, 2777, 687, 1591, 439, 68, 2, 490, 1980, 355, 870, 298, 13220, 1883, 3504, 9590, 10742, 2777, 687, 1591, 439, 68, 5424, 355, 870, 666, 14, 2143, 480, 4097, 531, 355, 291, 14, 1150, 63, 24499, 275, 666, 2234, 1245, 275, 302, 3003, 14, 18467, 14, 2209, 8, 576, 2736, 355, 13680, 14, 525, 63, 24499, 8, 1188, 59, 16, 467, 298, 2682, 401, 1245, 59, 17, 5728, 398, 870, 298, 13220, 1883, 3504, 5424, 267, 870, 13680, 14, 9118, 342, 267, 870, 620, 8, 5891, 680, 2143, 480, 4097, 531, 398, 870, 298, 27219, 4926, 1883, 3504, 2, 267, 372, 13680, 421, 199, 318, 336, 1190, 63, 6868, 1883, 63, 4518, 8, 7866, 304, 272, 870, 298, 27693, 370, 2429, 644, 5067, 4926, 1883, 2, 339, 20006, 275, 18405, 1883, 3120, 342, 272, 20006, 14, 1150, 63, 24499, 275, 488, 339, 302, 3003, 14, 914, 1850, 14, 8222, 8, 7866, 2736, 339, 862, 26, 267, 870, 298, 27693, 4926, 1883, 11436, 267, 20006, 14, 928, 342, 267, 870, 298, 7536, 367, 17639, 2, 267, 1830, 302, 3003, 14, 914, 1850, 14, 7113, 837, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 267, 870, 298, 2825, 7113, 2410, 4926, 1883, 2, 272, 871, 302, 3003, 14, 914, 1850, 14, 8631, 2891, 2972, 26, 267, 870, 298, 13220, 1883, 1950, 2984, 2972, 2, 267, 302, 3003, 14, 914, 1850, 14, 8831, 342, 267, 372, 339, 340, 20006, 14, 1150, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
svenstaro/ansible
lib/ansible/plugins/action/ops_template.py
35
1776
# # Copyright 2015 Peter Sprygada <psprygada@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json from ansible.module_utils.six import string_types from ansible.plugins.action import ActionBase from ansible.plugins.action.net_template import ActionModule as NetActionModule class ActionModule(NetActionModule, ActionBase): def run(self, tmp=None, task_vars=None): if self._connection.transport == 'local': return super(ActionModule, self).run(tmp, task_vars) result = dict(changed=False) if isinstance(self._task.args['src'], string_types): self._handle_template() result.update(self._execute_module(module_name=self._task.action, module_args=self._task.args, task_vars=task_vars)) if self._task.args.get('backup') and result.get('_backup'): contents = json.dumps(result['_backup'], indent=4) self._write_backup(task_vars['inventory_hostname'], contents) if '_backup' in result: del result['_backup'] return result
gpl-3.0
[ 3, 199, 3, 1898, 6900, 22912, 8360, 651, 71, 10641, 665, 80, 681, 651, 71, 10641, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5265, 14, 1287, 492, 10033, 1563, 199, 504, 3242, 14, 5265, 14, 1287, 14, 846, 63, 1160, 492, 10033, 2377, 465, 5365, 3310, 2377, 421, 199, 533, 10033, 2377, 8, 2480, 3310, 2377, 12, 10033, 1563, 304, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 403, 304, 267, 340, 291, 423, 2105, 14, 5545, 508, 283, 1832, 356, 288, 372, 1613, 8, 3310, 2377, 12, 291, 680, 1065, 8, 2791, 12, 2120, 63, 2936, 9, 398, 754, 275, 1211, 8, 2489, 29, 797, 9, 398, 340, 1228, 8, 277, 423, 1765, 14, 589, 459, 2164, 995, 1059, 63, 1313, 304, 288, 291, 423, 2479, 63, 1160, 342, 398, 754, 14, 873, 8, 277, 423, 2526, 63, 578, 8, 578, 63, 354, 29, 277, 423, 1765, 14, 1287, 12, 288, 859, 63, 589, 29, 277, 423, 1765, 14, 589, 12, 2120, 63, 2936, 29, 1765, 63, 2936, 430, 398, 340, 291, 423, 1765, 14, 589, 14, 362, 360, 5751, 358, 436, 754, 14, 362, 6412, 5751, 735, 288, 4072, 275, 2022, 14, 4180, 8, 1099, 8680, 5751, 995, 4363, 29, 20, 9, 288, 291, 423, 952, 63, 5751, 8, 1765, 63, 2936, 459, 7212, 63, 4269, 995, 4072, 9, 398, 340, 2513, 5751, 7, 315, 754, 26, 288, 2150, 754, 8680, 5751, 418, 398, 372, 754, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 6900, 22912, 8360, 651, 71, 10641, 665, 80, 681, 651, 71, 10641, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5265, 14, 1287, 492, 10033, 1563, 199, 504, 3242, 14, 5265, 14, 1287, 14, 846, 63, 1160, 492, 10033, 2377, 465, 5365, 3310, 2377, 421, 199, 533, 10033, 2377, 8, 2480, 3310, 2377, 12, 10033, 1563, 304, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 403, 304, 267, 340, 291, 423, 2105, 14, 5545, 508, 283, 1832, 356, 288, 372, 1613, 8, 3310, 2377, 12, 291, 680, 1065, 8, 2791, 12, 2120, 63, 2936, 9, 398, 754, 275, 1211, 8, 2489, 29, 797, 9, 398, 340, 1228, 8, 277, 423, 1765, 14, 589, 459, 2164, 995, 1059, 63, 1313, 304, 288, 291, 423, 2479, 63, 1160, 342, 398, 754, 14, 873, 8, 277, 423, 2526, 63, 578, 8, 578, 63, 354, 29, 277, 423, 1765, 14, 1287, 12, 288, 859, 63, 589, 29, 277, 423, 1765, 14, 589, 12, 2120, 63, 2936, 29, 1765, 63, 2936, 430, 398, 340, 291, 423, 1765, 14, 589, 14, 362, 360, 5751, 358, 436, 754, 14, 362, 6412, 5751, 735, 288, 4072, 275, 2022, 14, 4180, 8, 1099, 8680, 5751, 995, 4363, 29, 20, 9, 288, 291, 423, 952, 63, 5751, 8, 1765, 63, 2936, 459, 7212, 63, 4269, 995, 4072, 9, 398, 340, 2513, 5751, 7, 315, 754, 26, 288, 2150, 754, 8680, 5751, 418, 398, 372, 754, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
yukoba/sympy
sympy/vector/tests/test_printing.py
52
5613
# -*- coding: utf-8 -*- from sympy import Integral, latex, Function from sympy import pretty as xpretty from sympy.vector import CoordSysCartesian, Vector, express from sympy.abc import a, b, c from sympy.core.compatibility import u_decode as u from sympy.utilities.pytest import XFAIL def pretty(expr): """ASCII pretty-printing""" return xpretty(expr, use_unicode=False, wrap_line=False) def upretty(expr): """Unicode pretty-printing""" return xpretty(expr, use_unicode=True, wrap_line=False) #Initialize the basic and tedious vector/dyadic expressions #needed for testing. #Some of the pretty forms shown denote how the expressions just #above them should look with pretty printing. N = CoordSysCartesian('N') C = N.orient_new_axis('C', a, N.k) v = [] d = [] v.append(Vector.zero) v.append(N.i) v.append(-N.i) v.append(N.i + N.j) v.append(a*N.i) v.append(a*N.i - b*N.j) v.append((a**2 + N.x)*N.i + N.k) v.append((a**2 + b)*N.i + 3*(C.y - c)*N.k) f = Function('f') v.append(N.j - (Integral(f(b)) - C.x**2)*N.k) upretty_v_8 = u( """\ N_j + ⎛ 2 ⌠ ⎞ N_k\n\ ⎜C_x - ⎮ f(b) db⎟ \n\ ⎝ ⌡ ⎠ \ """) pretty_v_8 = u( """\ N_j + / / \\\n\ | 2 | |\n\ |C_x - | f(b) db|\n\ | | |\n\ \\ / / \ """) v.append(N.i + C.k) v.append(express(N.i, C)) v.append((a**2 + b)*N.i + (Integral(f(b)))*N.k) upretty_v_11 = u( """\ ⎛ 2 ⎞ N_i + ⎛⌠ ⎞ N_k\n\ ⎝a + b⎠ ⎜⎮ f(b) db⎟ \n\ ⎝⌡ ⎠ \ """) pretty_v_11 = u( """\ / 2 \\ + / / \\\n\ \\a + b/ N_i| | |\n\ | | f(b) db|\n\ | | |\n\ \\/ / \ """) for x in v: d.append(x | N.k) s = 3*N.x**2*C.y upretty_s = u( """\ 2\n\ 3⋅C_y⋅N_x \ """) pretty_s = u( """\ 2\n\ 3*C_y*N_x \ """) #This is the pretty form for ((a**2 + b)*N.i + 3*(C.y - c)*N.k) | N.k upretty_d_7 = u( """\ ⎛ 2 ⎞ (N_i|N_k) + (3⋅C_y - 3⋅c) (N_k|N_k)\n\ ⎝a + b⎠ \ """) pretty_d_7 = u( """\ / 2 \\ (N_i|N_k) + (3*C_y - 3*c) (N_k|N_k)\n\ \\a + b/ \ """) def test_str_printing(): assert str(v[0]) == '0' assert str(v[1]) == 'N.i' assert str(v[2]) == '(-1)*N.i' assert str(v[3]) == 'N.i + N.j' assert str(v[8]) == 'N.j + (C.x**2 - Integral(f(b), b))*N.k' assert str(v[9]) == 'C.k + N.i' assert str(s) == '3*C.y*N.x**2' assert str(d[0]) == '0' assert str(d[1]) == '(N.i|N.k)' assert str(d[4]) == 'a*(N.i|N.k)' assert str(d[5]) == 'a*(N.i|N.k) + (-b)*(N.j|N.k)' assert str(d[8]) == ('(N.j|N.k) + (C.x**2 - ' + 'Integral(f(b), b))*(N.k|N.k)') @XFAIL def test_pretty_printing_ascii(): assert pretty(v[0]) == u('0') assert pretty(v[1]) == u('N_i') assert pretty(v[5]) == u('(a) N_i + (-b) N_j') assert pretty(v[8]) == pretty_v_8 assert pretty(v[2]) == u('(-1) N_i') assert pretty(v[11]) == pretty_v_11 assert pretty(s) == pretty_s assert pretty(d[0]) == u('(0|0)') assert pretty(d[5]) == u('(a) (N_i|N_k) + (-b) (N_j|N_k)') assert pretty(d[7]) == pretty_d_7 assert pretty(d[10]) == u('(cos(a)) (C_i|N_k) + (-sin(a)) (C_j|N_k)') def test_pretty_print_unicode(): assert upretty(v[0]) == u('0') assert upretty(v[1]) == u('N_i') assert upretty(v[5]) == u('(a) N_i + (-b) N_j') assert upretty(v[8]) == upretty_v_8 assert upretty(v[2]) == u('(-1) N_i') assert upretty(v[11]) == upretty_v_11 assert upretty(s) == upretty_s assert upretty(d[0]) == u('(0|0)') assert upretty(d[5]) == u('(a) (N_i|N_k) + (-b) (N_j|N_k)') assert upretty(d[7]) == upretty_d_7 assert upretty(d[10]) == u('(cos(a)) (C_i|N_k) + (-sin(a)) (C_j|N_k)') def test_latex_printing(): assert latex(v[0]) == '\\mathbf{\\hat{0}}' assert latex(v[1]) == '\\mathbf{\\hat{i}_{N}}' assert latex(v[2]) == '- \\mathbf{\\hat{i}_{N}}' assert latex(v[5]) == ('(a)\\mathbf{\\hat{i}_{N}} + ' + '(- b)\\mathbf{\\hat{j}_{N}}') assert latex(v[6]) == ('(\\mathbf{{x}_{N}} + a^{2})\\mathbf{\\' + 'hat{i}_{N}} + \\mathbf{\\hat{k}_{N}}') assert latex(v[8]) == ('\\mathbf{\\hat{j}_{N}} + (\\mathbf{{x}_' + '{C}}^{2} - \\int f{\\left (b \\right )}\\,' + ' db)\\mathbf{\\hat{k}_{N}}') assert latex(s) == '3 \\mathbf{{y}_{C}} \\mathbf{{x}_{N}}^{2}' assert latex(d[0]) == '(\\mathbf{\\hat{0}}|\\mathbf{\\hat{0}})' assert latex(d[4]) == ('(a)(\\mathbf{\\hat{i}_{N}}{|}\\mathbf' + '{\\hat{k}_{N}})') assert latex(d[9]) == ('(\\mathbf{\\hat{k}_{C}}{|}\\mathbf{\\' + 'hat{k}_{N}}) + (\\mathbf{\\hat{i}_{N}}{|' + '}\\mathbf{\\hat{k}_{N}})') assert latex(d[11]) == ('(a^{2} + b)(\\mathbf{\\hat{i}_{N}}{|}\\' + 'mathbf{\\hat{k}_{N}}) + (\\int f{\\left (' + 'b \\right )}\\, db)(\\mathbf{\\hat{k}_{N}' + '}{|}\\mathbf{\\hat{k}_{N}})') def test_custom_names(): A = CoordSysCartesian('A', vector_names=['x', 'y', 'z'], variable_names=['i', 'j', 'k']) assert A.i.__str__() == 'x' assert A.x.__str__() == 'i' assert A.i._pretty_form == 'A_x' assert A.x._pretty_form == 'A_i' assert A.i._latex_form == r'\mathbf{\hat{x}_{A}}' assert A.x._latex_form == r"\mathbf{{i}_{A}}"
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 5840, 492, 23095, 12, 15571, 12, 6801, 199, 504, 5840, 492, 7268, 465, 671, 9118, 199, 504, 5840, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 12, 11388, 12, 4056, 199, 504, 5840, 14, 3175, 492, 282, 12, 330, 12, 286, 199, 504, 5840, 14, 1018, 14, 15390, 492, 399, 63, 2708, 465, 399, 199, 504, 5840, 14, 16355, 14, 4462, 492, 1323, 8784, 199, 199, 318, 7268, 8, 3684, 304, 272, 408, 12292, 7268, 13, 26514, 624, 272, 372, 671, 9118, 8, 3684, 12, 675, 63, 2975, 29, 797, 12, 4816, 63, 604, 29, 797, 9, 421, 199, 318, 1536, 21958, 8, 3684, 304, 272, 408, 7087, 7268, 13, 26514, 624, 272, 372, 671, 9118, 8, 3684, 12, 675, 63, 2975, 29, 549, 12, 4816, 63, 604, 29, 797, 9, 199, 199, 3, 9345, 314, 5678, 436, 1565, 328, 1785, 5477, 15, 8161, 31764, 8455, 199, 3, 11368, 367, 5343, 14, 199, 3, 7700, 402, 314, 7268, 4513, 9164, 477, 4610, 4212, 314, 8455, 2951, 199, 3, 16181, 3062, 1077, 3648, 543, 7268, 16116, 14, 199, 46, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 199, 35, 275, 653, 14, 19676, 63, 1222, 63, 3127, 360, 35, 297, 282, 12, 653, 14, 75, 9, 199, 86, 275, 942, 199, 68, 275, 942, 199, 86, 14, 740, 8, 3646, 14, 4262, 9, 199, 86, 14, 740, 8, 46, 14, 73, 9, 199, 86, 14, 740, 2801, 46, 14, 73, 9, 199, 86, 14, 740, 8, 46, 14, 73, 435, 653, 14, 74, 9, 199, 86, 14, 740, 8, 65, 10, 46, 14, 73, 9, 199, 86, 14, 740, 8, 65, 10, 46, 14, 73, 446, 330, 10, 46, 14, 74, 9, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 653, 14, 88, 3342, 46, 14, 73, 435, 653, 14, 75, 9, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 650, 5830, 35, 14, 89, 446, 286, 3342, 46, 14, 75, 9, 199, 70, 275, 6801, 360, 70, 358, 199, 86, 14, 740, 8, 46, 14, 74, 446, 334, 18949, 8, 70, 8, 66, 430, 446, 445, 14, 88, 538, 18, 3342, 46, 14, 75, 9, 199, 384, 21958, 63, 86, 63, 24, 275, 399, 8, 199, 19659, 199, 46, 63, 74, 435, 22410, 237, 250, 257, 499, 257, 22410, 235, 255, 263, 22410, 237, 253, 653, 63, 75, 60, 78, 60, 489, 22410, 237, 251, 35, 63, 88, 221, 446, 22410, 237, 107, 289, 8, 66, 9, 1592, 159, 237, 254, 259, 971, 78, 60, 489, 22410, 237, 252, 755, 22410, 235, 95, 263, 22410, 237, 255, 259, 971, 199, 6141, 199, 9118, 63, 86, 63, 24, 275, 399, 8, 199, 19659, 199, 46, 63, 74, 435, 1182, 260, 1182, 755, 32432, 78, 60, 489, 1204, 257, 499, 259, 1204, 263, 12196, 78, 60, 489, 1204, 35, 63, 88, 221, 446, 221, 1204, 289, 8, 66, 9, 1592, 6113, 78, 60, 489, 1204, 263, 1204, 263, 12196, 78, 60, 489, 8522, 755, 1182, 260, 1182, 971, 199, 6141, 199, 199, 86, 14, 740, 8, 46, 14, 73, 435, 445, 14, 75, 9, 199, 86, 14, 740, 8, 476, 2915, 8, 46, 14, 73, 12, 445, 430, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 334, 18949, 8, 70, 8, 66, 1724, 10, 46, 14, 75, 9, 199, 384, 21958, 63, 86, 63, 845, 275, 399, 8, 199, 19659, 199, 159, 237, 250, 499, 259, 22410, 237, 253, 653, 63, 73, 435, 22410, 237, 250, 159, 235, 255, 263, 22410, 237, 253, 653, 63, 75, 60, 78, 60, 199, 159, 237, 252, 65, 221, 435, 330, 159, 237, 255, 755, 22410, 237, 251, 159, 237, 107, 289, 8, 66, 9, 1592, 159, 237, 254, 259, 971, 78, 60, 2049, 22410, 237, 252, 159, 235, 95, 263, 22410, 237, 255, 259, 971, 199, 6141, 199, 9118, 63, 86, 63, 845, 275, 399, 8, 199, 19659, 199, 15, 499, 259, 8522, 435, 1182, 221, 1182, 755, 32432, 78, 60, 199, 1103, 65, 221, 435, 330, 15, 653, 63, 73, 92, 1204, 263, 12196, 78, 60, 1779, 1204, 1204, 289, 8, 66, 9, 1592, 6113, 78, 60, 1779, 1204, 1204, 263, 12196, 78, 60, 1779, 8522, 15, 260, 1182, 971, 199, 6141, 199, 199, 509, 671, 315, 373, 26, 272, 366, 14, 740, 8, 88, 1204, 653, 14, 75, 9, 199, 83, 275, 650, 10, 46, 14, 88, 538, 18, 10, 35, 14, 89, 199, 384, 21958, 63, 83, 275, 399, 8, 199, 19659, 268, 499, 60, 78, 60, 199, 19, 159, 234, 228, 35, 63, 89, 159, 234, 228, 46, 63, 88, 971, 199, 6141, 199, 9118, 63, 83, 275, 399, 8, 199, 19659, 268, 499, 60, 78, 60, 199, 19, 10, 35, 63, 89, 10, 46, 63, 88, 971, 199, 6141, 199, 199, 3, 2765, 365, 314, 7268, 1824, 367, 3666, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 650, 5830, 35, 14, 89, 446, 286, 3342, 46, 14, 75, 9, 1204, 653, 14, 75, 199, 384, 21958, 63, 68, 63, 23, 275, 399, 8, 199, 19659, 199, 159, 237, 250, 499, 259, 22410, 237, 253, 334, 46, 63, 73, 92, 46, 63, 75, 9, 435, 334, 19, 159, 234, 228, 35, 63, 89, 446, 650, 159, 234, 228, 67, 9, 334, 46, 63, 75, 92, 46, 63, 75, 2862, 78, 60, 199, 159, 237, 252, 65, 221, 435, 330, 159, 237, 255, 27503, 971, 199, 6141, 199, 9118, 63, 68, 63, 23, 275, 399, 8, 199, 19659, 199, 15, 499, 259, 8522, 334, 46, 63, 73, 92, 46, 63, 75, 9, 435, 334, 19, 10, 35, 63, 89, 446, 650, 10, 67, 9, 334, 46, 63, 75, 92, 46, 63, 75, 2862, 78, 60, 199, 1103, 65, 221, 435, 330, 15, 27503, 971, 199, 6141, 421, 199, 318, 511, 63, 495, 63, 26514, 837, 272, 702, 620, 8, 86, 59, 16, 566, 508, 283, 16, 7, 272, 702, 620, 8, 86, 59, 17, 566, 508, 283, 46, 14, 73, 7, 272, 702, 620, 8, 86, 59, 18 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 5840, 492, 23095, 12, 15571, 12, 6801, 199, 504, 5840, 492, 7268, 465, 671, 9118, 199, 504, 5840, 14, 4106, 492, 1849, 2181, 11319, 16034, 19157, 12, 11388, 12, 4056, 199, 504, 5840, 14, 3175, 492, 282, 12, 330, 12, 286, 199, 504, 5840, 14, 1018, 14, 15390, 492, 399, 63, 2708, 465, 399, 199, 504, 5840, 14, 16355, 14, 4462, 492, 1323, 8784, 199, 199, 318, 7268, 8, 3684, 304, 272, 408, 12292, 7268, 13, 26514, 624, 272, 372, 671, 9118, 8, 3684, 12, 675, 63, 2975, 29, 797, 12, 4816, 63, 604, 29, 797, 9, 421, 199, 318, 1536, 21958, 8, 3684, 304, 272, 408, 7087, 7268, 13, 26514, 624, 272, 372, 671, 9118, 8, 3684, 12, 675, 63, 2975, 29, 549, 12, 4816, 63, 604, 29, 797, 9, 199, 199, 3, 9345, 314, 5678, 436, 1565, 328, 1785, 5477, 15, 8161, 31764, 8455, 199, 3, 11368, 367, 5343, 14, 199, 3, 7700, 402, 314, 7268, 4513, 9164, 477, 4610, 4212, 314, 8455, 2951, 199, 3, 16181, 3062, 1077, 3648, 543, 7268, 16116, 14, 199, 46, 275, 1849, 2181, 11319, 16034, 19157, 360, 46, 358, 199, 35, 275, 653, 14, 19676, 63, 1222, 63, 3127, 360, 35, 297, 282, 12, 653, 14, 75, 9, 199, 86, 275, 942, 199, 68, 275, 942, 199, 86, 14, 740, 8, 3646, 14, 4262, 9, 199, 86, 14, 740, 8, 46, 14, 73, 9, 199, 86, 14, 740, 2801, 46, 14, 73, 9, 199, 86, 14, 740, 8, 46, 14, 73, 435, 653, 14, 74, 9, 199, 86, 14, 740, 8, 65, 10, 46, 14, 73, 9, 199, 86, 14, 740, 8, 65, 10, 46, 14, 73, 446, 330, 10, 46, 14, 74, 9, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 653, 14, 88, 3342, 46, 14, 73, 435, 653, 14, 75, 9, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 650, 5830, 35, 14, 89, 446, 286, 3342, 46, 14, 75, 9, 199, 70, 275, 6801, 360, 70, 358, 199, 86, 14, 740, 8, 46, 14, 74, 446, 334, 18949, 8, 70, 8, 66, 430, 446, 445, 14, 88, 538, 18, 3342, 46, 14, 75, 9, 199, 384, 21958, 63, 86, 63, 24, 275, 399, 8, 199, 19659, 199, 46, 63, 74, 435, 22410, 237, 250, 257, 499, 257, 22410, 235, 255, 263, 22410, 237, 253, 653, 63, 75, 60, 78, 60, 489, 22410, 237, 251, 35, 63, 88, 221, 446, 22410, 237, 107, 289, 8, 66, 9, 1592, 159, 237, 254, 259, 971, 78, 60, 489, 22410, 237, 252, 755, 22410, 235, 95, 263, 22410, 237, 255, 259, 971, 199, 6141, 199, 9118, 63, 86, 63, 24, 275, 399, 8, 199, 19659, 199, 46, 63, 74, 435, 1182, 260, 1182, 755, 32432, 78, 60, 489, 1204, 257, 499, 259, 1204, 263, 12196, 78, 60, 489, 1204, 35, 63, 88, 221, 446, 221, 1204, 289, 8, 66, 9, 1592, 6113, 78, 60, 489, 1204, 263, 1204, 263, 12196, 78, 60, 489, 8522, 755, 1182, 260, 1182, 971, 199, 6141, 199, 199, 86, 14, 740, 8, 46, 14, 73, 435, 445, 14, 75, 9, 199, 86, 14, 740, 8, 476, 2915, 8, 46, 14, 73, 12, 445, 430, 199, 86, 14, 740, 1332, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 334, 18949, 8, 70, 8, 66, 1724, 10, 46, 14, 75, 9, 199, 384, 21958, 63, 86, 63, 845, 275, 399, 8, 199, 19659, 199, 159, 237, 250, 499, 259, 22410, 237, 253, 653, 63, 73, 435, 22410, 237, 250, 159, 235, 255, 263, 22410, 237, 253, 653, 63, 75, 60, 78, 60, 199, 159, 237, 252, 65, 221, 435, 330, 159, 237, 255, 755, 22410, 237, 251, 159, 237, 107, 289, 8, 66, 9, 1592, 159, 237, 254, 259, 971, 78, 60, 2049, 22410, 237, 252, 159, 235, 95, 263, 22410, 237, 255, 259, 971, 199, 6141, 199, 9118, 63, 86, 63, 845, 275, 399, 8, 199, 19659, 199, 15, 499, 259, 8522, 435, 1182, 221, 1182, 755, 32432, 78, 60, 199, 1103, 65, 221, 435, 330, 15, 653, 63, 73, 92, 1204, 263, 12196, 78, 60, 1779, 1204, 1204, 289, 8, 66, 9, 1592, 6113, 78, 60, 1779, 1204, 1204, 263, 12196, 78, 60, 1779, 8522, 15, 260, 1182, 971, 199, 6141, 199, 199, 509, 671, 315, 373, 26, 272, 366, 14, 740, 8, 88, 1204, 653, 14, 75, 9, 199, 83, 275, 650, 10, 46, 14, 88, 538, 18, 10, 35, 14, 89, 199, 384, 21958, 63, 83, 275, 399, 8, 199, 19659, 268, 499, 60, 78, 60, 199, 19, 159, 234, 228, 35, 63, 89, 159, 234, 228, 46, 63, 88, 971, 199, 6141, 199, 9118, 63, 83, 275, 399, 8, 199, 19659, 268, 499, 60, 78, 60, 199, 19, 10, 35, 63, 89, 10, 46, 63, 88, 971, 199, 6141, 199, 199, 3, 2765, 365, 314, 7268, 1824, 367, 3666, 65, 538, 18, 435, 330, 3342, 46, 14, 73, 435, 650, 5830, 35, 14, 89, 446, 286, 3342, 46, 14, 75, 9, 1204, 653, 14, 75, 199, 384, 21958, 63, 68, 63, 23, 275, 399, 8, 199, 19659, 199, 159, 237, 250, 499, 259, 22410, 237, 253, 334, 46, 63, 73, 92, 46, 63, 75, 9, 435, 334, 19, 159, 234, 228, 35, 63, 89, 446, 650, 159, 234, 228, 67, 9, 334, 46, 63, 75, 92, 46, 63, 75, 2862, 78, 60, 199, 159, 237, 252, 65, 221, 435, 330, 159, 237, 255, 27503, 971, 199, 6141, 199, 9118, 63, 68, 63, 23, 275, 399, 8, 199, 19659, 199, 15, 499, 259, 8522, 334, 46, 63, 73, 92, 46, 63, 75, 9, 435, 334, 19, 10, 35, 63, 89, 446, 650, 10, 67, 9, 334, 46, 63, 75, 92, 46, 63, 75, 2862, 78, 60, 199, 1103, 65, 221, 435, 330, 15, 27503, 971, 199, 6141, 421, 199, 318, 511, 63, 495, 63, 26514, 837, 272, 702, 620, 8, 86, 59, 16, 566, 508, 283, 16, 7, 272, 702, 620, 8, 86, 59, 17, 566, 508, 283, 46, 14, 73, 7, 272, 702, 620, 8, 86, 59, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
q14035/pimouse_ros
scripts/motors2.py
1
2178
#!/usr/bin/env python #encoding: utf8 import sys, rospy, math from pimouse_ros.msg import MotorFreqs from geometry_msgs.msg import Twist from std_srvs.srv import Trigger, TriggerResponse class Motor(): def __init__(self): if not self.set_power(False): sys.exit(1) rospy.on_shutdown(self.set_power) self.sub_raw = rospy.Subscriber('motor_raw', MotorFreqs, self.callback_raw_freq) self.sub_cmd_vel = rospy.Subscriber('cmd_vel', Twist, self.callback_cmd_vel) self.srv_on = rospy.Service('motor_on', Trigger, self.callback_on) self.srv_off = rospy.Service('motor_off', Trigger, self.callback_off) self.last_time = rospy.Time.now() self.using_cmd_vel = False def set_power(self, onoff = False): en = "/dev/rtmotoren0" try: with open(en, 'w') as f: f.write("1\n" if onoff else "0\n") self.is_on = onoff return True except: rospy.logerr("cannot write to " + en) return False def set_raw_freq(self, left_hz, right_hz): if not self.is_on: rospy.logerr("not enpowered") return try: with open("/dev/rtmotor_raw_l0", 'w') as lf, open("/dev/rtmotor_raw_r0", 'w') as rf: lf.write(str(int(round(left_hz))) + "\n") rf.write(str(int(round(right_hz))) + "\n") except: rospy.logerr("cannot write to rtmotor_raw_*") def callback_raw_freq(self, message): self.set_raw_freq(message.left_hz, message.right_hz) def callback_cmd_vel(self, message): forward_hz = 80000.0*message.linear.x/(9*math.pi) rot_hz = 400.0*message.angular.z/math.pi self.set_raw_freq(forward_hz-rot_hz, forward_hz+rot_hz) self.using_cmd_vel = True self.last_time = rospy.Time.now() def onoff_response(self, onoff): d = TriggerResponse() d.success = self.set_power(onoff) d.message = "ON" if self.is_on else "OFF" return d def callback_on(self, message): return self.onoff_response(True) def callback_off(self, message): return self.onoff_response(False) if __name__ == '__main__': rospy.init_node('motors') m = Motor() rate = rospy.Rate(10) while not rospy.is_shutdown(): if m.using_cmd_vel and rospy.Time.now().to_sec() - m.last_time.to_sec() >= 1.0: m.set_raw_freq(0, 0) m.using_cmd_vel = False rate.sleep()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2991, 26, 2774, 24, 199, 646, 984, 12, 21848, 12, 3473, 199, 504, 6682, 10544, 63, 4796, 14, 1328, 492, 603, 13147, 38, 12720, 199, 504, 3400, 63, 13429, 14, 1328, 492, 377, 87, 631, 199, 504, 2418, 63, 5474, 3122, 14, 15165, 492, 24015, 12, 24015, 2364, 199, 199, 533, 603, 13147, 837, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 692, 440, 291, 14, 409, 63, 5652, 8, 797, 304, 984, 14, 2224, 8, 17, 9, 2742, 198, 4796, 647, 14, 265, 63, 8831, 8, 277, 14, 409, 63, 5652, 9, 507, 198, 277, 14, 954, 63, 1773, 275, 21848, 14, 28638, 360, 27840, 63, 1773, 297, 603, 13147, 38, 12720, 12, 291, 14, 3058, 63, 1773, 63, 5646, 9, 507, 198, 277, 14, 954, 63, 1760, 63, 1090, 275, 21848, 14, 28638, 360, 1760, 63, 1090, 297, 377, 87, 631, 12, 291, 14, 3058, 63, 1760, 63, 1090, 9, 507, 198, 277, 14, 15165, 63, 265, 275, 21848, 14, 3167, 360, 27840, 63, 265, 297, 24015, 12, 291, 14, 3058, 63, 265, 9, 507, 198, 277, 14, 15165, 63, 1997, 275, 21848, 14, 3167, 360, 27840, 63, 1997, 297, 24015, 12, 291, 14, 3058, 63, 1997, 9, 507, 198, 277, 14, 2019, 63, 521, 275, 21848, 14, 1366, 14, 2131, 342, 507, 198, 277, 14, 4941, 63, 1760, 63, 1090, 275, 756, 421, 198, 318, 663, 63, 5652, 8, 277, 12, 641, 1997, 275, 756, 304, 507, 198, 287, 275, 3286, 2374, 15, 2591, 30034, 720, 78, 16, 2, 507, 198, 893, 26, 686, 198, 1045, 1551, 8, 287, 12, 283, 87, 358, 465, 289, 26, 1585, 198, 70, 14, 952, 480, 17, 60, 78, 2, 340, 641, 1997, 587, 298, 16, 60, 78, 531, 686, 198, 277, 14, 374, 63, 265, 275, 641, 1997, 686, 198, 1107, 715, 507, 198, 2590, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 11250, 2218, 370, 298, 435, 655, 9, 2742, 198, 1107, 756, 421, 198, 318, 663, 63, 1773, 63, 5646, 8, 277, 12, 3602, 63, 19552, 12, 2451, 63, 19552, 304, 507, 198, 692, 440, 291, 14, 374, 63, 265, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 1397, 655, 555, 21221, 531, 686, 198, 1107, 2742, 198, 893, 26, 686, 198, 1045, 1551, 4769, 2374, 15, 2591, 27840, 63, 1773, 63, 76, 16, 401, 283, 87, 358, 465, 14642, 12, 1551, 4769, 2374, 15, 2591, 27840, 63, 1773, 63, 82, 16, 401, 283, 87, 358, 465, 17781, 26, 1585, 198, 276, 14, 952, 8, 495, 8, 442, 8, 2363, 8, 3039, 63, 19552, 1724, 435, 1867, 78, 531, 1585, 198, 3941, 14, 952, 8, 495, 8, 442, 8, 2363, 8, 1019, 63, 19552, 1724, 435, 1867, 78, 531, 507, 198, 2590, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 11250, 2218, 370, 519, 7574, 13147, 63, 1773, 15192, 531, 421, 198, 318, 3233, 63, 1773, 63, 5646, 8, 277, 12, 1245, 304, 507, 198, 277, 14, 409, 63, 1773, 63, 5646, 8, 1188, 14, 3039, 63, 19552, 12, 1245, 14, 1019, 63, 19552, 9, 421, 198, 318, 3233, 63, 1760, 63, 1090, 8, 277, 12, 1245, 304, 507, 198, 6688, 63, 19552, 275, 1695, 993, 14, 16, 10, 1188, 14, 6676, 14, 88, 7985, 25, 10, 3442, 14, 1038, 9, 507, 198, 4571, 63, 19552, 275, 8290, 14, 16, 10, 1188, 14, 11572, 14, 90, 15, 3442, 14, 1038, 507, 198, 277, 14, 409, 63, 1773, 63, 5646, 8, 6688, 63, 19552, 13, 4571, 63, 19552, 12, 7568, 63, 19552, 11, 4571, 63, 19552, 9, 507, 198, 277, 14, 4941, 63, 1760, 63, 1090, 275, 715, 507, 198, 277, 14, 2019, 63, 521, 275, 21848, 14, 1366, 14, 2131, 342, 421, 198, 318, 641, 1997, 63, 1310, 8, 277, 12, 641, 1997, 304, 507, 198, 68, 275, 24015, 2364, 342, 507, 198, 68, 14, 3742, 275, 291, 14, 409, 63, 5652, 8, 265, 1997, 9, 507, 198, 68, 14, 1188, 275, 298, 615, 2, 340, 291, 14, 374, 63, 265, 587, 298, 7517, 2, 507, 198, 1107, 366, 199, 198, 318, 3233, 63, 265, 8, 277, 12, 1245, 304, 198, 1107, 291, 14, 265, 1997, 63, 1310, 8, 549, 9, 199, 198, 318, 3233, 63, 1997, 8, 277, 12, 1245, 304, 372, 291, 14, 265, 1997, 63, 1310, 8, 797, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 4796, 647, 14, 826, 63, 932, 360, 30034, 1384, 358, 199, 198, 77, 275, 603, 13147, 342, 421, 198, 1866, 275, 21848, 14, 6621, 8, 709, 9, 199, 198, 6710, 440, 21848, 14, 374, 63, 8831, 837, 507, 198, 692, 333, 14, 4941, 63, 1760, 63, 1090, 436, 21848, 14, 1366, 14, 2131, 1252, 475, 63, 3321, 342, 446, 333, 14, 2019, 63, 521, 14, 475, 63, 3321, 342, 2356, 413, 14, 16, 26, 686, 198, 77, 14, 409, 63, 1773, 63, 5646, 8, 16, 12, 378, 9, 686, 198, 77, 14, 4941, 63, 1760, 63, 1090, 275, 756, 507, 198, 1866, 14, 4532, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2991, 26, 2774, 24, 199, 646, 984, 12, 21848, 12, 3473, 199, 504, 6682, 10544, 63, 4796, 14, 1328, 492, 603, 13147, 38, 12720, 199, 504, 3400, 63, 13429, 14, 1328, 492, 377, 87, 631, 199, 504, 2418, 63, 5474, 3122, 14, 15165, 492, 24015, 12, 24015, 2364, 199, 199, 533, 603, 13147, 837, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 692, 440, 291, 14, 409, 63, 5652, 8, 797, 304, 984, 14, 2224, 8, 17, 9, 2742, 198, 4796, 647, 14, 265, 63, 8831, 8, 277, 14, 409, 63, 5652, 9, 507, 198, 277, 14, 954, 63, 1773, 275, 21848, 14, 28638, 360, 27840, 63, 1773, 297, 603, 13147, 38, 12720, 12, 291, 14, 3058, 63, 1773, 63, 5646, 9, 507, 198, 277, 14, 954, 63, 1760, 63, 1090, 275, 21848, 14, 28638, 360, 1760, 63, 1090, 297, 377, 87, 631, 12, 291, 14, 3058, 63, 1760, 63, 1090, 9, 507, 198, 277, 14, 15165, 63, 265, 275, 21848, 14, 3167, 360, 27840, 63, 265, 297, 24015, 12, 291, 14, 3058, 63, 265, 9, 507, 198, 277, 14, 15165, 63, 1997, 275, 21848, 14, 3167, 360, 27840, 63, 1997, 297, 24015, 12, 291, 14, 3058, 63, 1997, 9, 507, 198, 277, 14, 2019, 63, 521, 275, 21848, 14, 1366, 14, 2131, 342, 507, 198, 277, 14, 4941, 63, 1760, 63, 1090, 275, 756, 421, 198, 318, 663, 63, 5652, 8, 277, 12, 641, 1997, 275, 756, 304, 507, 198, 287, 275, 3286, 2374, 15, 2591, 30034, 720, 78, 16, 2, 507, 198, 893, 26, 686, 198, 1045, 1551, 8, 287, 12, 283, 87, 358, 465, 289, 26, 1585, 198, 70, 14, 952, 480, 17, 60, 78, 2, 340, 641, 1997, 587, 298, 16, 60, 78, 531, 686, 198, 277, 14, 374, 63, 265, 275, 641, 1997, 686, 198, 1107, 715, 507, 198, 2590, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 11250, 2218, 370, 298, 435, 655, 9, 2742, 198, 1107, 756, 421, 198, 318, 663, 63, 1773, 63, 5646, 8, 277, 12, 3602, 63, 19552, 12, 2451, 63, 19552, 304, 507, 198, 692, 440, 291, 14, 374, 63, 265, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 1397, 655, 555, 21221, 531, 686, 198, 1107, 2742, 198, 893, 26, 686, 198, 1045, 1551, 4769, 2374, 15, 2591, 27840, 63, 1773, 63, 76, 16, 401, 283, 87, 358, 465, 14642, 12, 1551, 4769, 2374, 15, 2591, 27840, 63, 1773, 63, 82, 16, 401, 283, 87, 358, 465, 17781, 26, 1585, 198, 276, 14, 952, 8, 495, 8, 442, 8, 2363, 8, 3039, 63, 19552, 1724, 435, 1867, 78, 531, 1585, 198, 3941, 14, 952, 8, 495, 8, 442, 8, 2363, 8, 1019, 63, 19552, 1724, 435, 1867, 78, 531, 507, 198, 2590, 26, 686, 198, 4796, 647, 14, 793, 1508, 480, 11250, 2218, 370, 519, 7574, 13147, 63, 1773, 15192, 531, 421, 198, 318, 3233, 63, 1773, 63, 5646, 8, 277, 12, 1245, 304, 507, 198, 277, 14, 409, 63, 1773, 63, 5646, 8, 1188, 14, 3039, 63, 19552, 12, 1245, 14, 1019, 63, 19552, 9, 421, 198, 318, 3233, 63, 1760, 63, 1090, 8, 277, 12, 1245, 304, 507, 198, 6688, 63, 19552, 275, 1695, 993, 14, 16, 10, 1188, 14, 6676, 14, 88, 7985, 25, 10, 3442, 14, 1038, 9, 507, 198, 4571, 63, 19552, 275, 8290, 14, 16, 10, 1188, 14, 11572, 14, 90, 15, 3442, 14, 1038, 507, 198, 277, 14, 409, 63, 1773, 63, 5646, 8, 6688, 63, 19552, 13, 4571, 63, 19552, 12, 7568, 63, 19552, 11, 4571, 63, 19552, 9, 507, 198, 277, 14, 4941, 63, 1760, 63, 1090, 275, 715, 507, 198, 277, 14, 2019, 63, 521, 275, 21848, 14, 1366, 14, 2131, 342, 421, 198, 318, 641, 1997, 63, 1310, 8, 277, 12, 641, 1997, 304, 507, 198, 68, 275, 24015, 2364, 342, 507, 198, 68, 14, 3742, 275, 291, 14, 409, 63, 5652, 8, 265, 1997, 9, 507, 198, 68, 14, 1188, 275, 298, 615, 2, 340, 291, 14, 374, 63, 265, 587, 298, 7517, 2, 507, 198, 1107, 366, 199, 198, 318, 3233, 63, 265, 8, 277, 12, 1245, 304, 198, 1107, 291, 14, 265, 1997, 63, 1310, 8, 549, 9, 199, 198, 318, 3233, 63, 1997, 8, 277, 12, 1245, 304, 372, 291, 14, 265, 1997, 63, 1310, 8, 797, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 4796, 647, 14, 826, 63, 932, 360, 30034, 1384, 358, 199, 198, 77, 275, 603, 13147, 342, 421, 198, 1866, 275, 21848, 14, 6621, 8, 709, 9, 199, 198, 6710, 440, 21848, 14, 374, 63, 8831, 837, 507, 198, 692, 333, 14, 4941, 63, 1760, 63, 1090, 436, 21848, 14, 1366, 14, 2131, 1252, 475, 63, 3321, 342, 446, 333, 14, 2019, 63, 521, 14, 475, 63, 3321, 342, 2356, 413, 14, 16, 26, 686, 198, 77, 14, 409, 63, 1773, 63, 5646, 8, 16, 12, 378, 9, 686, 198, 77, 14, 4941, 63, 1760, 63, 1090, 275, 756, 507, 198, 1866, 14, 4532, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Hasimir/brython
www/src/Lib/sre_parse.py
630
29657
# # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # """Internal support module for sre""" # XXX: show string offset and offending character for all errors import sys from sre_constants import * from _sre import MAXREPEAT SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" DIGITS = set("0123456789") OCTDIGITS = set("01234567") HEXDIGITS = set("0123456789abcdefABCDEF") WHITESPACE = set(" \t\n\r\v\f") ESCAPES = { r"\a": (LITERAL, ord("\a")), r"\b": (LITERAL, ord("\b")), r"\f": (LITERAL, ord("\f")), r"\n": (LITERAL, ord("\n")), r"\r": (LITERAL, ord("\r")), r"\t": (LITERAL, ord("\t")), r"\v": (LITERAL, ord("\v")), r"\\": (LITERAL, ord("\\")) } CATEGORIES = { r"\A": (AT, AT_BEGINNING_STRING), # start of string r"\b": (AT, AT_BOUNDARY), r"\B": (AT, AT_NON_BOUNDARY), r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]), r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), r"\Z": (AT, AT_END_STRING), # end of string } FLAGS = { # standard flags "i": SRE_FLAG_IGNORECASE, "L": SRE_FLAG_LOCALE, "m": SRE_FLAG_MULTILINE, "s": SRE_FLAG_DOTALL, "x": SRE_FLAG_VERBOSE, # extensions "a": SRE_FLAG_ASCII, "t": SRE_FLAG_TEMPLATE, "u": SRE_FLAG_UNICODE, } class Pattern: # master pattern object. keeps track of global attributes def __init__(self): self.flags = 0 self.open = [] self.groups = 1 self.groupdict = {} def opengroup(self, name=None): gid = self.groups self.groups = gid + 1 if name is not None: ogid = self.groupdict.get(name, None) if ogid is not None: raise error("redefinition of group name %s as group %d; " "was group %d" % (repr(name), gid, ogid)) self.groupdict[name] = gid self.open.append(gid) return gid def closegroup(self, gid): self.open.remove(gid) def checkgroup(self, gid): return gid < self.groups and gid not in self.open class SubPattern: # a subpattern, in intermediate form def __init__(self, pattern, data=None): self.pattern = pattern if data is None: data = [] self.data = data self.width = None def __iter__(self): return iter(self.data) def dump(self, level=0): nl = 1 seqtypes = (tuple, list) for op, av in self.data: print(level*" " + op, end=' '); nl = 0 if op == "in": # member sublanguage print(); nl = 1 for op, a in av: print((level+1)*" " + op, a) elif op == "branch": print(); nl = 1 i = 0 for a in av[1]: if i > 0: print(level*" " + "or") a.dump(level+1); nl = 1 i = i + 1 elif isinstance(av, seqtypes): for a in av: if isinstance(a, SubPattern): if not nl: print() a.dump(level+1); nl = 1 else: print(a, end=' ') ; nl = 0 else: print(av, end=' ') ; nl = 0 if not nl: print() def __repr__(self): return repr(self.data) def __len__(self): return len(self.data) def __delitem__(self, index): del self.data[index] def __getitem__(self, index): if isinstance(index, slice): return SubPattern(self.pattern, self.data[index]) return self.data[index] def __setitem__(self, index, code): self.data[index] = code def insert(self, index, code): self.data.insert(index, code) def append(self, code): self.data.append(code) def getwidth(self): # determine the width (min, max) for this subpattern if self.width: return self.width lo = hi = 0 UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY) REPEATCODES = (MIN_REPEAT, MAX_REPEAT) for op, av in self.data: if op is BRANCH: i = sys.maxsize j = 0 for av in av[1]: l, h = av.getwidth() i = min(i, l) j = max(j, h) lo = lo + i hi = hi + j elif op is CALL: i, j = av.getwidth() lo = lo + i hi = hi + j elif op is SUBPATTERN: i, j = av[1].getwidth() lo = lo + i hi = hi + j elif op in REPEATCODES: i, j = av[2].getwidth() lo = lo + int(i) * av[0] hi = hi + int(j) * av[1] elif op in UNITCODES: lo = lo + 1 hi = hi + 1 elif op == SUCCESS: break self.width = int(min(lo, sys.maxsize)), int(min(hi, sys.maxsize)) return self.width class Tokenizer: def __init__(self, string): self.istext = isinstance(string, str) self.string = string self.index = 0 self.__next() def __next(self): if self.index >= len(self.string): self.next = None return char = self.string[self.index:self.index+1] # Special case for the str8, since indexing returns a integer # XXX This is only needed for test_bug_926075 in test_re.py if char and not self.istext: char = chr(char[0]) if char == "\\": try: c = self.string[self.index + 1] except IndexError: raise error("bogus escape (end of line)") if not self.istext: c = chr(c) char = char + c self.index = self.index + len(char) self.next = char def match(self, char, skip=1): if char == self.next: if skip: self.__next() return 1 return 0 def get(self): this = self.next self.__next() return this def getwhile(self, n, charset): result = '' for _ in range(n): c = self.next if c not in charset: break result += c self.__next() return result def tell(self): return self.index, self.next def seek(self, index): self.index, self.next = index def isident(char): return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" def isdigit(char): return "0" <= char <= "9" def isname(name): # check that group name is a valid string if not isident(name[0]): return False for char in name[1:]: if not isident(char) and not isdigit(char): return False return True def _class_escape(source, escape): # handle escape code inside character class code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) if code and code[0] == IN: return code try: c = escape[1:2] if c == "x": # hexadecimal escape (exactly two digits) escape += source.getwhile(2, HEXDIGITS) if len(escape) != 4: raise ValueError return LITERAL, int(escape[2:], 16) & 0xff elif c == "u" and source.istext: # unicode escape (exactly four digits) escape += source.getwhile(4, HEXDIGITS) if len(escape) != 6: raise ValueError return LITERAL, int(escape[2:], 16) elif c == "U" and source.istext: # unicode escape (exactly eight digits) escape += source.getwhile(8, HEXDIGITS) if len(escape) != 10: raise ValueError c = int(escape[2:], 16) chr(c) # raise ValueError for invalid code return LITERAL, c elif c in OCTDIGITS: # octal escape (up to three digits) escape += source.getwhile(2, OCTDIGITS) return LITERAL, int(escape[1:], 8) & 0xff elif c in DIGITS: raise ValueError if len(escape) == 2: return LITERAL, ord(escape[1]) except ValueError: pass raise error("bogus escape: %s" % repr(escape)) def _escape(source, escape, state): # handle escape code in expression code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code try: c = escape[1:2] if c == "x": # hexadecimal escape escape += source.getwhile(2, HEXDIGITS) if len(escape) != 4: raise ValueError return LITERAL, int(escape[2:], 16) & 0xff elif c == "u" and source.istext: # unicode escape (exactly four digits) escape += source.getwhile(4, HEXDIGITS) if len(escape) != 6: raise ValueError return LITERAL, int(escape[2:], 16) elif c == "U" and source.istext: # unicode escape (exactly eight digits) escape += source.getwhile(8, HEXDIGITS) if len(escape) != 10: raise ValueError c = int(escape[2:], 16) chr(c) # raise ValueError for invalid code return LITERAL, c elif c == "0": # octal escape escape += source.getwhile(2, OCTDIGITS) return LITERAL, int(escape[1:], 8) & 0xff elif c in DIGITS: # octal escape *or* decimal group reference (sigh) if source.next in DIGITS: escape = escape + source.get() if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and source.next in OCTDIGITS): # got three octal digits; this is an octal escape escape = escape + source.get() return LITERAL, int(escape[1:], 8) & 0xff # not an octal escape, so this is a group reference group = int(escape[1:]) if group < state.groups: if not state.checkgroup(group): raise error("cannot refer to open group") return GROUPREF, group raise ValueError if len(escape) == 2: return LITERAL, ord(escape[1]) except ValueError: pass raise error("bogus escape: %s" % repr(escape)) def _parse_sub(source, state, nested=1): # parse an alternation: a|b|c items = [] itemsappend = items.append sourcematch = source.match while 1: itemsappend(_parse(source, state)) if sourcematch("|"): continue if not nested: break if not source.next or sourcematch(")", 0): break else: raise error("pattern not properly closed") if len(items) == 1: return items[0] subpattern = SubPattern(state) subpatternappend = subpattern.append # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpatternappend(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (the compiler may optimize this even more) set = [] setappend = set.append for item in items: setappend(item[0]) subpatternappend((IN, set)) return subpattern subpattern.append((BRANCH, (None, items))) return subpattern def _parse_sub_cond(source, state, condgroup): item_yes = _parse(source, state) if source.match("|"): item_no = _parse(source, state) if source.match("|"): raise error("conditional backref with more than two branches") else: item_no = None if source.next and not source.match(")", 0): raise error("pattern not properly closed") subpattern = SubPattern(state) subpattern.append((GROUPREF_EXISTS, (condgroup, item_yes, item_no))) return subpattern _PATTERNENDERS = set("|)") _ASSERTCHARS = set("=!<") _LOOKBEHINDASSERTCHARS = set("=!") _REPEATCODES = set([MIN_REPEAT, MAX_REPEAT]) def _parse(source, state): # parse a simple pattern subpattern = SubPattern(state) # precompute constants into local variables subpatternappend = subpattern.append sourceget = source.get sourcematch = source.match _len = len PATTERNENDERS = _PATTERNENDERS ASSERTCHARS = _ASSERTCHARS LOOKBEHINDASSERTCHARS = _LOOKBEHINDASSERTCHARS REPEATCODES = _REPEATCODES while 1: if source.next in PATTERNENDERS: break # end of subpattern this = sourceget() if this is None: break # end of pattern if state.flags & SRE_FLAG_VERBOSE: # skip whitespace and comments if this in WHITESPACE: continue if this == "#": while 1: this = sourceget() if this in (None, "\n"): break continue if this and this[0] not in SPECIAL_CHARS: subpatternappend((LITERAL, ord(this))) elif this == "[": # character set set = [] setappend = set.append ## if sourcematch(":"): ## pass # handle character classes if sourcematch("^"): setappend((NEGATE, None)) # check remaining characters start = set[:] while 1: this = sourceget() if this == "]" and set != start: break elif this and this[0] == "\\": code1 = _class_escape(source, this) elif this: code1 = LITERAL, ord(this) else: raise error("unexpected end of regular expression") if sourcematch("-"): # potential range this = sourceget() if this == "]": if code1[0] is IN: code1 = code1[1][0] setappend(code1) setappend((LITERAL, ord("-"))) break elif this: if this[0] == "\\": code2 = _class_escape(source, this) else: code2 = LITERAL, ord(this) if code1[0] != LITERAL or code2[0] != LITERAL: raise error("bad character range") lo = code1[1] hi = code2[1] if hi < lo: raise error("bad character range") setappend((RANGE, (lo, hi))) else: raise error("unexpected end of regular expression") else: if code1[0] is IN: code1 = code1[1][0] setappend(code1) # XXX: <fl> should move set optimization to compiler! if _len(set)==1 and set[0][0] is LITERAL: subpatternappend(set[0]) # optimization elif _len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: subpatternappend((NOT_LITERAL, set[1][1])) # optimization else: # XXX: <fl> should add charmap optimization here subpatternappend((IN, set)) elif this and this[0] in REPEAT_CHARS: # repeat previous item if this == "?": min, max = 0, 1 elif this == "*": min, max = 0, MAXREPEAT elif this == "+": min, max = 1, MAXREPEAT elif this == "{": if source.next == "}": subpatternappend((LITERAL, ord(this))) continue here = source.tell() min, max = 0, MAXREPEAT lo = hi = "" while source.next in DIGITS: lo = lo + source.get() if sourcematch(","): while source.next in DIGITS: hi = hi + sourceget() else: hi = lo if not sourcematch("}"): subpatternappend((LITERAL, ord(this))) source.seek(here) continue if lo: min = int(lo) if min >= MAXREPEAT: raise OverflowError("the repetition number is too large") if hi: max = int(hi) if max >= MAXREPEAT: raise OverflowError("the repetition number is too large") if max < min: raise error("bad repeat interval") else: raise error("not supported") # figure out which item to repeat if subpattern: item = subpattern[-1:] else: item = None if not item or (_len(item) == 1 and item[0][0] == AT): raise error("nothing to repeat") if item[0][0] in REPEATCODES: raise error("multiple repeat") if sourcematch("?"): subpattern[-1] = (MIN_REPEAT, (min, max, item)) else: subpattern[-1] = (MAX_REPEAT, (min, max, item)) elif this == ".": subpatternappend((ANY, None)) elif this == "(": group = 1 name = None condgroup = None if sourcematch("?"): group = 0 # options if sourcematch("P"): # python extensions if sourcematch("<"): # named group: skip forward to end of name name = "" while 1: char = sourceget() if char is None: raise error("unterminated name") if char == ">": break name = name + char group = 1 if not name: raise error("missing group name") if not isname(name): raise error("bad character in group name") elif sourcematch("="): # named backreference name = "" while 1: char = sourceget() if char is None: raise error("unterminated name") if char == ")": break name = name + char if not name: raise error("missing group name") if not isname(name): raise error("bad character in group name") gid = state.groupdict.get(name) if gid is None: raise error("unknown group name") subpatternappend((GROUPREF, gid)) continue else: char = sourceget() if char is None: raise error("unexpected end of pattern") raise error("unknown specifier: ?P%s" % char) elif sourcematch(":"): # non-capturing group group = 2 elif sourcematch("#"): # comment while 1: if source.next is None or source.next == ")": break sourceget() if not sourcematch(")"): raise error("unbalanced parenthesis") continue elif source.next in ASSERTCHARS: # lookahead assertions char = sourceget() dir = 1 if char == "<": if source.next not in LOOKBEHINDASSERTCHARS: raise error("syntax error") dir = -1 # lookbehind char = sourceget() p = _parse_sub(source, state) if not sourcematch(")"): raise error("unbalanced parenthesis") if char == "=": subpatternappend((ASSERT, (dir, p))) else: subpatternappend((ASSERT_NOT, (dir, p))) continue elif sourcematch("("): # conditional backreference group condname = "" while 1: char = sourceget() if char is None: raise error("unterminated name") if char == ")": break condname = condname + char group = 2 if not condname: raise error("missing group name") if isname(condname): condgroup = state.groupdict.get(condname) if condgroup is None: raise error("unknown group name") else: try: condgroup = int(condname) except ValueError: raise error("bad character in group name") else: # flags if not source.next in FLAGS: raise error("unexpected end of pattern") while source.next in FLAGS: state.flags = state.flags | FLAGS[sourceget()] if group: # parse group contents if group == 2: # anonymous group group = None else: group = state.opengroup(name) if condgroup: p = _parse_sub_cond(source, state, condgroup) else: p = _parse_sub(source, state) if not sourcematch(")"): raise error("unbalanced parenthesis") if group is not None: state.closegroup(group) subpatternappend((SUBPATTERN, (group, p))) else: while 1: char = sourceget() if char is None: raise error("unexpected end of pattern") if char == ")": break raise error("unknown extension") elif this == "^": subpatternappend((AT, AT_BEGINNING)) elif this == "$": subpattern.append((AT, AT_END)) elif this and this[0] == "\\": code = _escape(source, this, state) subpatternappend(code) else: raise error("parser error") return subpattern def fix_flags(src, flags): # Check and fix flags according to the type of pattern (str or bytes) if isinstance(src, str): if not flags & SRE_FLAG_ASCII: flags |= SRE_FLAG_UNICODE elif flags & SRE_FLAG_UNICODE: raise ValueError("ASCII and UNICODE flags are incompatible") else: if flags & SRE_FLAG_UNICODE: raise ValueError("can't use UNICODE flag with a bytes pattern") return flags def parse(str, flags=0, pattern=None): # parse 're' pattern into list of (opcode, argument) tuples source = Tokenizer(str) if pattern is None: pattern = Pattern() pattern.flags = flags pattern.str = str p = _parse_sub(source, pattern, 0) p.pattern.flags = fix_flags(str, p.pattern.flags) tail = source.get() if tail == ")": raise error("unbalanced parenthesis") elif tail: raise error("bogus characters at end of regular expression") if flags & SRE_FLAG_DEBUG: p.dump() if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE: # the VERBOSE flag was switched on inside the pattern. to be # on the safe side, we'll parse the whole thing again... return parse(str, p.pattern.flags) return p def parse_template(source, pattern): # parse 're' replacement string into list of literals and # group references s = Tokenizer(source) sget = s.get p = [] a = p.append def literal(literal, p=p, pappend=a): if p and p[-1][0] is LITERAL: p[-1] = LITERAL, p[-1][1] + literal else: pappend((LITERAL, literal)) sep = source[:0] if isinstance(sep, str): makechar = chr else: makechar = chr while 1: this = sget() if this is None: break # end of replacement string if this and this[0] == "\\": # group c = this[1:2] if c == "g": name = "" if s.match("<"): while 1: char = sget() if char is None: raise error("unterminated group name") if char == ">": break name = name + char if not name: raise error("missing group name") try: index = int(name) if index < 0: raise error("negative group number") except ValueError: if not isname(name): raise error("bad character in group name") try: index = pattern.groupindex[name] except KeyError: raise IndexError("unknown group name") a((MARK, index)) elif c == "0": if s.next in OCTDIGITS: this = this + sget() if s.next in OCTDIGITS: this = this + sget() literal(makechar(int(this[1:], 8) & 0xff)) elif c in DIGITS: isoctal = False if s.next in DIGITS: this = this + sget() if (c in OCTDIGITS and this[2] in OCTDIGITS and s.next in OCTDIGITS): this = this + sget() isoctal = True literal(makechar(int(this[1:], 8) & 0xff)) if not isoctal: a((MARK, int(this[1:]))) else: try: this = makechar(ESCAPES[this][1]) except KeyError: pass literal(this) else: literal(this) # convert template to groups and literals lists i = 0 groups = [] groupsappend = groups.append literals = [None] * len(p) if isinstance(source, str): encode = lambda x: x else: # The tokenizer implicitly decodes bytes objects as latin-1, we must # therefore re-encode the final representation. encode = lambda x: x.encode('latin-1') for c, s in p: if c is MARK: groupsappend((i, s)) # literal[i] is already None else: literals[i] = encode(s) i = i + 1 return groups, literals def expand_template(template, match): g = match.group sep = match.string[:0] groups, literals = template literals = literals[:] try: for index, group in groups: literals[index] = s = g(group) if s is None: raise error("unmatched group") except IndexError: raise error("invalid group reference") return sep.join(literals)
bsd-3-clause
[ 3, 199, 3, 23580, 491, 2101, 7, 18528, 22013, 12580, 199, 3, 199, 3, 3957, 295, 13, 2487, 5578, 3965, 370, 25877, 3851, 199, 3, 199, 3, 1898, 334, 67, 9, 19960, 13, 8339, 701, 23580, 491, 2101, 14840, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 314, 25877, 14, 647, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 624, 8405, 2291, 859, 367, 25877, 624, 199, 199, 3, 5787, 26, 2498, 1059, 3268, 436, 2331, 3219, 4528, 367, 1006, 2552, 199, 199, 646, 984, 199, 199, 504, 25877, 63, 5559, 492, 627, 199, 504, 485, 31026, 492, 9141, 23851, 199, 199, 25748, 63, 16326, 275, 3680, 1103, 59, 91, 25608, 23778, 62, 4, 25576, 199, 23851, 63, 16326, 275, 8969, 23778, 6641, 199, 199, 22855, 5930, 275, 663, 480, 11371, 531, 199, 199, 47, 1028, 22855, 5930, 275, 663, 480, 9461, 5308, 531, 199, 21377, 22855, 5930, 275, 663, 480, 11371, 10678, 18820, 531, 199, 199, 20620, 275, 663, 480, 971, 84, 60, 78, 60, 82, 60, 86, 60, 70, 531, 199, 199, 654, 8549, 654, 275, 469, 272, 519, 3212, 65, 582, 334, 21692, 12, 6206, 4582, 65, 8150, 272, 519, 3212, 66, 582, 334, 21692, 12, 6206, 4582, 66, 8150, 272, 519, 3212, 70, 582, 334, 21692, 12, 6206, 4582, 70, 8150, 272, 519, 3212, 78, 582, 334, 21692, 12, 6206, 4582, 78, 8150, 272, 519, 3212, 82, 582, 334, 21692, 12, 6206, 4582, 82, 8150, 272, 519, 3212, 84, 582, 334, 21692, 12, 6206, 4582, 84, 8150, 272, 519, 3212, 86, 582, 334, 21692, 12, 6206, 4582, 86, 8150, 272, 519, 22996, 582, 334, 21692, 12, 6206, 23236, 2237, 199, 93, 199, 199, 35, 12649, 28743, 275, 469, 272, 519, 3212, 33, 582, 334, 619, 12, 15059, 63, 15947, 6024, 63, 5353, 395, 327, 1343, 402, 1059, 272, 519, 3212, 66, 582, 334, 619, 12, 15059, 63, 21489, 395, 272, 519, 3212, 34, 582, 334, 619, 12, 15059, 63, 13887, 63, 21489, 395, 272, 519, 3212, 68, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 36, 6995, 16636, 272, 519, 3212, 36, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 36, 6995, 16636, 272, 519, 3212, 83, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 11658, 16636, 272, 519, 3212, 51, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 11658, 16636, 272, 519, 3212, 87, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 5172, 16636, 272, 519, 3212, 55, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 5172, 16636, 272, 519, 3212, 58, 582, 334, 619, 12, 15059, 63, 3902, 63, 5353, 395, 327, 1284, 402, 1059, 199, 93, 199, 199, 4831, 275, 469, 272, 327, 4465, 3285, 272, 298, 73, 582, 26421, 63, 3719, 63, 15434, 12, 272, 298, 44, 582, 26421, 63, 3719, 63, 20828, 12, 272, 298, 77, 582, 26421, 63, 3719, 63, 16661, 12, 272, 298, 83, 582, 26421, 63, 3719, 63, 16504, 12, 272, 298, 88, 582, 26421, 63, 3719, 63, 16075, 12, 272, 327, 5478, 272, 298, 65, 582, 26421, 63, 3719, 63, 12292, 12, 272, 298, 84, 582, 26421, 63, 3719, 63, 7433, 12, 272, 298, 85, 582, 26421, 63, 3719, 63, 12819, 12, 199, 93, 199, 199, 533, 27019, 26, 272, 327, 5288, 3851, 909, 14, 221, 18578, 4426, 402, 2288, 3004, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2469, 275, 378, 267, 291, 14, 1490, 275, 942, 267, 291, 14, 2634, 275, 413, 267, 291, 14, 20567, 275, 1052, 272, 347, 1551, 923, 8, 277, 12, 536, 29, 403, 304, 267, 15122, 275, 291, 14, 2634, 267, 291, 14, 2634, 275, 15122, 435, 413, 267, 340, 536, 365, 440, 488, 26, 288, 312, 8787, 275, 291, 14, 20567, 14, 362, 8, 354, 12, 488, 9, 288, 340, 312, 8787, 365, 440, 488, 26, 355, 746, 1125, 480, 264, 7463, 402, 1572, 536, 450, 83, 465, 1572, 450, 68, 27, 298, 1169, 298, 10274, 1572, 450, 68, 2, 450, 334, 2722, 8, 354, 395, 15122, 12, 221, 312, 8787, 430, 288, 291, 14, 20567, 59, 354, 61, 275, 15122, 267, 291, 14, 1490, 14, 740, 8, 8787, 9, 267, 372, 15122, 272, 347, 4002, 923, 8, 277, 12, 15122, 304, 267, 291, 14, 1490, 14, 2168, 8, 8787, 9, 272, 347, 1104, 923, 8, 277, 12, 15122, 304, 267, 372, 15122, 665, 291, 14, 2634, 436, 15122, 440, 315, 291, 14, 1490, 199, 199, 533, 4804, 9959, 26, 272, 327, 282, 30179, 12, 315, 13197, 1824, 272, 347, 636, 826, 721, 277, 12, 3851, 12, 666, 29, 403, 304, 267, 291, 14, 3401, 275, 3851, 267, 340, 666, 365, 488, 26, 288, 666, 275, 942, 267, 291, 14, 576, 275, 666, 267, 291, 14, 2063, 275, 488, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 576, 9, 339, 347, 5461, 8, 277, 12, 2166, 29, 16, 304, 267, 12992, 275, 413, 267, 5412, 1313, 275, 334, 2960, 12, 769, 9, 267, 367, 1687, 12, 2289, 315, 291, 14, 576, 26, 288, 870, 8, 1896, 12469, 221, 298, 435, 1687, 12, 1284, 534, 283, 2736, 12992, 275, 378, 288, 340, 1687, 508, 298, 262, 582, 355, 327, 3653, 1007, 3671, 355, 870, 7303, 12992, 275, 413, 355, 367, 1687, 12, 282, 315, 2289, 26, 490, 870, 1332, 1896, 11, 17, 3342, 2, 221, 298, 435, 1687, 12, 282, 9, 288, 916, 1687, 508, 298, 4694, 582, 355, 870, 7303, 12992, 275, 413, 355, 284, 275, 378, 355, 367, 282, 315, 2289, 59, 17, 2189, 490, 340, 284, 690, 378, 26, 717, 870, 8, 1896, 12469, 221, 298, 435, 298, 269, 531, 490, 282, 14, 2724, 8, 1896, 11, 17, 2736, 12992, 275, 413, 490, 284, 275, 284, 435, 413, 288, 916, 1228, 8, 1214, 12, 5412, 1313, 304, 355, 367, 282, 315, 2289, 26, 490, 340, 1228, 8, 65, 12, 4804, 9959, 304, 717, 340, 440, 12992, 26, 870, 342, 717, 282, 14, 2724, 8, 1896, 11, 17, 2736, 12992, 275, 413, 490, 587, 26, 717, 870, 8, 65, 12, 1284, 534, 5320, 8700, 12992 ]
[ 199, 3, 23580, 491, 2101, 7, 18528, 22013, 12580, 199, 3, 199, 3, 3957, 295, 13, 2487, 5578, 3965, 370, 25877, 3851, 199, 3, 199, 3, 1898, 334, 67, 9, 19960, 13, 8339, 701, 23580, 491, 2101, 14840, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 314, 25877, 14, 647, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 624, 8405, 2291, 859, 367, 25877, 624, 199, 199, 3, 5787, 26, 2498, 1059, 3268, 436, 2331, 3219, 4528, 367, 1006, 2552, 199, 199, 646, 984, 199, 199, 504, 25877, 63, 5559, 492, 627, 199, 504, 485, 31026, 492, 9141, 23851, 199, 199, 25748, 63, 16326, 275, 3680, 1103, 59, 91, 25608, 23778, 62, 4, 25576, 199, 23851, 63, 16326, 275, 8969, 23778, 6641, 199, 199, 22855, 5930, 275, 663, 480, 11371, 531, 199, 199, 47, 1028, 22855, 5930, 275, 663, 480, 9461, 5308, 531, 199, 21377, 22855, 5930, 275, 663, 480, 11371, 10678, 18820, 531, 199, 199, 20620, 275, 663, 480, 971, 84, 60, 78, 60, 82, 60, 86, 60, 70, 531, 199, 199, 654, 8549, 654, 275, 469, 272, 519, 3212, 65, 582, 334, 21692, 12, 6206, 4582, 65, 8150, 272, 519, 3212, 66, 582, 334, 21692, 12, 6206, 4582, 66, 8150, 272, 519, 3212, 70, 582, 334, 21692, 12, 6206, 4582, 70, 8150, 272, 519, 3212, 78, 582, 334, 21692, 12, 6206, 4582, 78, 8150, 272, 519, 3212, 82, 582, 334, 21692, 12, 6206, 4582, 82, 8150, 272, 519, 3212, 84, 582, 334, 21692, 12, 6206, 4582, 84, 8150, 272, 519, 3212, 86, 582, 334, 21692, 12, 6206, 4582, 86, 8150, 272, 519, 22996, 582, 334, 21692, 12, 6206, 23236, 2237, 199, 93, 199, 199, 35, 12649, 28743, 275, 469, 272, 519, 3212, 33, 582, 334, 619, 12, 15059, 63, 15947, 6024, 63, 5353, 395, 327, 1343, 402, 1059, 272, 519, 3212, 66, 582, 334, 619, 12, 15059, 63, 21489, 395, 272, 519, 3212, 34, 582, 334, 619, 12, 15059, 63, 13887, 63, 21489, 395, 272, 519, 3212, 68, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 36, 6995, 16636, 272, 519, 3212, 36, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 36, 6995, 16636, 272, 519, 3212, 83, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 11658, 16636, 272, 519, 3212, 51, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 11658, 16636, 272, 519, 3212, 87, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 5172, 16636, 272, 519, 3212, 55, 582, 334, 568, 12, 3842, 22690, 12, 24004, 63, 4609, 63, 5172, 16636, 272, 519, 3212, 58, 582, 334, 619, 12, 15059, 63, 3902, 63, 5353, 395, 327, 1284, 402, 1059, 199, 93, 199, 199, 4831, 275, 469, 272, 327, 4465, 3285, 272, 298, 73, 582, 26421, 63, 3719, 63, 15434, 12, 272, 298, 44, 582, 26421, 63, 3719, 63, 20828, 12, 272, 298, 77, 582, 26421, 63, 3719, 63, 16661, 12, 272, 298, 83, 582, 26421, 63, 3719, 63, 16504, 12, 272, 298, 88, 582, 26421, 63, 3719, 63, 16075, 12, 272, 327, 5478, 272, 298, 65, 582, 26421, 63, 3719, 63, 12292, 12, 272, 298, 84, 582, 26421, 63, 3719, 63, 7433, 12, 272, 298, 85, 582, 26421, 63, 3719, 63, 12819, 12, 199, 93, 199, 199, 533, 27019, 26, 272, 327, 5288, 3851, 909, 14, 221, 18578, 4426, 402, 2288, 3004, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2469, 275, 378, 267, 291, 14, 1490, 275, 942, 267, 291, 14, 2634, 275, 413, 267, 291, 14, 20567, 275, 1052, 272, 347, 1551, 923, 8, 277, 12, 536, 29, 403, 304, 267, 15122, 275, 291, 14, 2634, 267, 291, 14, 2634, 275, 15122, 435, 413, 267, 340, 536, 365, 440, 488, 26, 288, 312, 8787, 275, 291, 14, 20567, 14, 362, 8, 354, 12, 488, 9, 288, 340, 312, 8787, 365, 440, 488, 26, 355, 746, 1125, 480, 264, 7463, 402, 1572, 536, 450, 83, 465, 1572, 450, 68, 27, 298, 1169, 298, 10274, 1572, 450, 68, 2, 450, 334, 2722, 8, 354, 395, 15122, 12, 221, 312, 8787, 430, 288, 291, 14, 20567, 59, 354, 61, 275, 15122, 267, 291, 14, 1490, 14, 740, 8, 8787, 9, 267, 372, 15122, 272, 347, 4002, 923, 8, 277, 12, 15122, 304, 267, 291, 14, 1490, 14, 2168, 8, 8787, 9, 272, 347, 1104, 923, 8, 277, 12, 15122, 304, 267, 372, 15122, 665, 291, 14, 2634, 436, 15122, 440, 315, 291, 14, 1490, 199, 199, 533, 4804, 9959, 26, 272, 327, 282, 30179, 12, 315, 13197, 1824, 272, 347, 636, 826, 721, 277, 12, 3851, 12, 666, 29, 403, 304, 267, 291, 14, 3401, 275, 3851, 267, 340, 666, 365, 488, 26, 288, 666, 275, 942, 267, 291, 14, 576, 275, 666, 267, 291, 14, 2063, 275, 488, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 576, 9, 339, 347, 5461, 8, 277, 12, 2166, 29, 16, 304, 267, 12992, 275, 413, 267, 5412, 1313, 275, 334, 2960, 12, 769, 9, 267, 367, 1687, 12, 2289, 315, 291, 14, 576, 26, 288, 870, 8, 1896, 12469, 221, 298, 435, 1687, 12, 1284, 534, 283, 2736, 12992, 275, 378, 288, 340, 1687, 508, 298, 262, 582, 355, 327, 3653, 1007, 3671, 355, 870, 7303, 12992, 275, 413, 355, 367, 1687, 12, 282, 315, 2289, 26, 490, 870, 1332, 1896, 11, 17, 3342, 2, 221, 298, 435, 1687, 12, 282, 9, 288, 916, 1687, 508, 298, 4694, 582, 355, 870, 7303, 12992, 275, 413, 355, 284, 275, 378, 355, 367, 282, 315, 2289, 59, 17, 2189, 490, 340, 284, 690, 378, 26, 717, 870, 8, 1896, 12469, 221, 298, 435, 298, 269, 531, 490, 282, 14, 2724, 8, 1896, 11, 17, 2736, 12992, 275, 413, 490, 284, 275, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alxgu/ansible
test/units/modules/network/frr/frr_module.py
38
1962
# -*- coding: utf-8 -*- # (c) 2019, Ansible by Red Hat, inc # 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 import os import json from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} def load_fixture(name): path = os.path.join(fixture_path, name) if path in fixture_data: return fixture_data[path] with open(path) as f: data = f.read() try: data = json.loads(data) except Exception: pass fixture_data[path] = data return data class TestFrrModule(ModuleTestCase): def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False): self.load_fixtures(commands) if failed: result = self.failed() self.assertTrue(result['failed'], result) else: result = self.changed(changed) self.assertEqual(result['changed'], changed, result) if commands is not None: if sort: self.assertEqual(sorted(commands), sorted(result['commands']), result['commands']) else: self.assertEqual(commands, result['commands'], result['commands']) return result def failed(self): with self.assertRaises(AnsibleFailJson) as exc: self.module.main() result = exc.exception.args[0] self.assertTrue(result['failed'], result) return result def changed(self, changed=False): with self.assertRaises(AnsibleExitJson) as exc: self.module.main() result = exc.exception.args[0] self.assertEqual(result['changed'], changed, result) return result def load_fixtures(self, commands=None): pass
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 20312, 12, 2622, 701, 9572, 13002, 12, 12864, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 199, 504, 6204, 14, 3112, 14, 1208, 492, 2622, 6699, 9653, 12, 2622, 4874, 9653, 12, 5673, 1746, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 38, 9734, 2377, 8, 2377, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 304, 398, 291, 14, 912, 63, 8769, 8, 4405, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 340, 3718, 365, 440, 488, 26, 288, 340, 4069, 26, 355, 291, 14, 629, 8, 5917, 8, 4405, 395, 3355, 8, 1099, 459, 4405, 3815, 754, 459, 4405, 1105, 288, 587, 26, 355, 291, 14, 629, 8, 4405, 12, 754, 459, 4405, 995, 754, 459, 4405, 1105, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 20312, 12, 2622, 701, 9572, 13002, 12, 12864, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 199, 504, 6204, 14, 3112, 14, 1208, 492, 2622, 6699, 9653, 12, 2622, 4874, 9653, 12, 5673, 1746, 421, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 38, 9734, 2377, 8, 2377, 1746, 304, 339, 347, 5341, 63, 578, 8, 277, 12, 3405, 29, 797, 12, 2896, 29, 797, 12, 3718, 29, 403, 12, 4069, 29, 549, 12, 4243, 29, 797, 304, 398, 291, 14, 912, 63, 8769, 8, 4405, 9, 398, 340, 3405, 26, 288, 754, 275, 291, 14, 4892, 342, 288, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 587, 26, 288, 754, 275, 291, 14, 2489, 8, 2489, 9, 288, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 398, 340, 3718, 365, 440, 488, 26, 288, 340, 4069, 26, 355, 291, 14, 629, 8, 5917, 8, 4405, 395, 3355, 8, 1099, 459, 4405, 3815, 754, 459, 4405, 1105, 288, 587, 26, 355, 291, 14, 629, 8, 4405, 12, 754, 459, 4405, 995, 754, 459, 4405, 1105, 398, 372, 754, 339, 347, 3405, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 10047, 4874, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 1815, 8, 1099, 459, 4892, 995, 754, 9, 267, 372, 754, 339, 347, 2896, 8, 277, 12, 2896, 29, 797, 304, 267, 543, 291, 14, 1855, 8, 10047, 6699, 9653, 9, 465, 3178, 26, 288, 291, 14, 578, 14, 973, 342, 398, 754, 275, 3178, 14, 1971, 14, 589, 59, 16, 61, 267, 291, 14, 629, 8, 1099, 459, 2489, 995, 2896, 12, 754, 9, 267, 372, 754, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
antoinecarme/pyaf
tests/perf/test_ozone_debug_perf.py
1
1566
import pandas as pd import numpy as np # from memory_profiler import profile # from memprof import * import pyaf.ForecastEngine as autof import pyaf.Bench.TS_datasets as tsds #get_ipython().magic('matplotlib inline') # @memprof def test_ozone_debug_perf(): b1 = tsds.load_ozone() df = b1.mPastData # df.tail(10) # df[:-10].tail() # df[:-10:-1] # df.describe() lEngine = autof.cForecastEngine() lEngine H = b1.mHorizon; lEngine.mOptions.mDebugPerformance = True; lEngine.mOptions.mEnableCycles = False; lEngine.mOptions.mEnableTimeBasedTrends = False; lEngine.mOptions.mEnableARModels = False; lEngine.train(df , b1.mTimeVar , b1.mSignalVar, H); lEngine.getModelInfo(); print(lEngine.mSignalDecomposition.mTrPerfDetails.head()); lEngine.mSignalDecomposition.mBestModel.mTimeInfo.mResolution lEngine.standardPlots("outputs/my_ozone"); dfapp_in = df.copy(); dfapp_in.tail() dfapp_out = lEngine.forecast(dfapp_in, H); #dfapp_out.to_csv("outputs/ozone_apply_out.csv") dfapp_out.tail(2 * H) print("Forecast Columns " , dfapp_out.columns); Forecast_DF = dfapp_out[[b1.mTimeVar , b1.mSignalVar, b1.mSignalVar + '_Forecast']] print(Forecast_DF.info()) print("Forecasts\n" , Forecast_DF.tail(H).values); print("\n\n<ModelInfo>") print(lEngine.to_json()); print("</ModelInfo>\n\n") print("\n\n<Forecast>") print(Forecast_DF.tail(2*H).to_json(date_format='iso')) print("</Forecast>\n\n") test_ozone_debug_perf();
bsd-3-clause
[ 646, 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 199, 3, 687, 4402, 63, 20132, 492, 4690, 199, 3, 687, 562, 311, 293, 70, 492, 627, 199, 199, 646, 1134, 2756, 14, 13099, 2931, 8524, 465, 2599, 70, 199, 646, 1134, 2756, 14, 34, 5368, 14, 9730, 63, 12281, 465, 6714, 795, 199, 199, 3, 362, 63, 22691, 1252, 11523, 360, 16440, 8308, 358, 421, 199, 3, 768, 278, 311, 293, 70, 199, 318, 511, 63, 79, 2619, 63, 1757, 63, 9452, 837, 272, 330, 17, 275, 6714, 795, 14, 912, 63, 79, 2619, 342, 272, 4051, 275, 330, 17, 14, 77, 48, 1810, 1451, 339, 327, 4051, 14, 1521, 8, 709, 9, 272, 327, 4051, 4439, 709, 1055, 1521, 342, 272, 327, 4051, 4439, 709, 6809, 17, 61, 272, 327, 4051, 14, 11935, 342, 339, 634, 8524, 275, 2599, 70, 14, 67, 13099, 2931, 8524, 342, 272, 634, 8524, 339, 869, 275, 330, 17, 14, 77, 40, 11925, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 7084, 25635, 275, 715, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 28016, 275, 756, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 1366, 1563, 19772, 828, 795, 275, 756, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 689, 20474, 275, 756, 27, 272, 634, 8524, 14, 2834, 8, 1587, 2360, 330, 17, 14, 77, 1366, 5894, 2360, 330, 17, 14, 77, 11274, 5894, 12, 869, 2736, 272, 634, 8524, 14, 362, 1685, 2354, 7303, 272, 870, 8, 76, 8524, 14, 77, 11274, 872, 13000, 14, 77, 14064, 12387, 11347, 14, 2993, 30910, 2286, 634, 8524, 14, 77, 11274, 872, 13000, 14, 77, 19478, 1685, 14, 77, 1366, 2354, 14, 77, 18508, 2286, 634, 8524, 14, 6807, 48, 4555, 480, 4467, 15, 1662, 63, 79, 2619, 3547, 2286, 4051, 571, 63, 262, 275, 4051, 14, 1574, 7303, 272, 4051, 571, 63, 262, 14, 1521, 342, 339, 4051, 571, 63, 548, 275, 634, 8524, 14, 29693, 8, 1587, 571, 63, 262, 12, 869, 2736, 272, 327, 1587, 571, 63, 548, 14, 475, 63, 4737, 480, 4467, 15, 79, 2619, 63, 4998, 63, 548, 14, 4737, 531, 272, 4051, 571, 63, 548, 14, 1521, 8, 18, 627, 869, 9, 272, 870, 480, 13099, 2931, 3626, 2346, 298, 2360, 4051, 571, 63, 548, 14, 3406, 2736, 272, 21684, 2931, 63, 3888, 275, 4051, 571, 63, 548, 9046, 66, 17, 14, 77, 1366, 5894, 2360, 330, 17, 14, 77, 11274, 5894, 12, 330, 17, 14, 77, 11274, 5894, 435, 2513, 13099, 2931, 6538, 272, 870, 8, 13099, 2931, 63, 3888, 14, 815, 1012, 272, 870, 480, 13099, 2931, 83, 60, 78, 2, 2360, 21684, 2931, 63, 3888, 14, 1521, 8, 40, 680, 1459, 2736, 2286, 870, 4582, 78, 60, 78, 28, 1685, 2354, 9579, 272, 870, 8, 76, 8524, 14, 475, 63, 1001, 30910, 272, 870, 23790, 1685, 2354, 3072, 78, 60, 78, 531, 272, 870, 4582, 78, 60, 78, 28, 13099, 2931, 9579, 272, 870, 8, 13099, 2931, 63, 3888, 14, 1521, 8, 18, 10, 40, 680, 475, 63, 1001, 8, 602, 63, 908, 534, 4595, 1333, 272, 870, 23790, 13099, 2931, 3072, 78, 60, 78, 531, 6905, 199, 396, 63, 79, 2619, 63, 1757, 63, 9452, 7303, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 199, 3, 687, 4402, 63, 20132, 492, 4690, 199, 3, 687, 562, 311, 293, 70, 492, 627, 199, 199, 646, 1134, 2756, 14, 13099, 2931, 8524, 465, 2599, 70, 199, 646, 1134, 2756, 14, 34, 5368, 14, 9730, 63, 12281, 465, 6714, 795, 199, 199, 3, 362, 63, 22691, 1252, 11523, 360, 16440, 8308, 358, 421, 199, 3, 768, 278, 311, 293, 70, 199, 318, 511, 63, 79, 2619, 63, 1757, 63, 9452, 837, 272, 330, 17, 275, 6714, 795, 14, 912, 63, 79, 2619, 342, 272, 4051, 275, 330, 17, 14, 77, 48, 1810, 1451, 339, 327, 4051, 14, 1521, 8, 709, 9, 272, 327, 4051, 4439, 709, 1055, 1521, 342, 272, 327, 4051, 4439, 709, 6809, 17, 61, 272, 327, 4051, 14, 11935, 342, 339, 634, 8524, 275, 2599, 70, 14, 67, 13099, 2931, 8524, 342, 272, 634, 8524, 339, 869, 275, 330, 17, 14, 77, 40, 11925, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 7084, 25635, 275, 715, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 28016, 275, 756, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 1366, 1563, 19772, 828, 795, 275, 756, 27, 272, 634, 8524, 14, 77, 4558, 14, 77, 6476, 689, 20474, 275, 756, 27, 272, 634, 8524, 14, 2834, 8, 1587, 2360, 330, 17, 14, 77, 1366, 5894, 2360, 330, 17, 14, 77, 11274, 5894, 12, 869, 2736, 272, 634, 8524, 14, 362, 1685, 2354, 7303, 272, 870, 8, 76, 8524, 14, 77, 11274, 872, 13000, 14, 77, 14064, 12387, 11347, 14, 2993, 30910, 2286, 634, 8524, 14, 77, 11274, 872, 13000, 14, 77, 19478, 1685, 14, 77, 1366, 2354, 14, 77, 18508, 2286, 634, 8524, 14, 6807, 48, 4555, 480, 4467, 15, 1662, 63, 79, 2619, 3547, 2286, 4051, 571, 63, 262, 275, 4051, 14, 1574, 7303, 272, 4051, 571, 63, 262, 14, 1521, 342, 339, 4051, 571, 63, 548, 275, 634, 8524, 14, 29693, 8, 1587, 571, 63, 262, 12, 869, 2736, 272, 327, 1587, 571, 63, 548, 14, 475, 63, 4737, 480, 4467, 15, 79, 2619, 63, 4998, 63, 548, 14, 4737, 531, 272, 4051, 571, 63, 548, 14, 1521, 8, 18, 627, 869, 9, 272, 870, 480, 13099, 2931, 3626, 2346, 298, 2360, 4051, 571, 63, 548, 14, 3406, 2736, 272, 21684, 2931, 63, 3888, 275, 4051, 571, 63, 548, 9046, 66, 17, 14, 77, 1366, 5894, 2360, 330, 17, 14, 77, 11274, 5894, 12, 330, 17, 14, 77, 11274, 5894, 435, 2513, 13099, 2931, 6538, 272, 870, 8, 13099, 2931, 63, 3888, 14, 815, 1012, 272, 870, 480, 13099, 2931, 83, 60, 78, 2, 2360, 21684, 2931, 63, 3888, 14, 1521, 8, 40, 680, 1459, 2736, 2286, 870, 4582, 78, 60, 78, 28, 1685, 2354, 9579, 272, 870, 8, 76, 8524, 14, 475, 63, 1001, 30910, 272, 870, 23790, 1685, 2354, 3072, 78, 60, 78, 531, 272, 870, 4582, 78, 60, 78, 28, 13099, 2931, 9579, 272, 870, 8, 13099, 2931, 63, 3888, 14, 1521, 8, 18, 10, 40, 680, 475, 63, 1001, 8, 602, 63, 908, 534, 4595, 1333, 272, 870, 23790, 13099, 2931, 3072, 78, 60, 78, 531, 6905, 199, 396, 63, 79, 2619, 63, 1757, 63, 9452, 7303, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
adeepkit01/networks
.waf-1.8.13-4da49748f68a49832130c7ef124357f6/waflib/Tools/python.py
8
15735
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import os,sys from waflib import Utils,Options,Errors,Logs,Task,Node from waflib.TaskGen import extension,before_method,after_method,feature from waflib.Configure import conf FRAG=''' #include <Python.h> #ifdef __cplusplus extern "C" { #endif void Py_Initialize(void); void Py_Finalize(void); #ifdef __cplusplus } #endif int main(int argc, char **argv) { (void)argc; (void)argv; Py_Initialize(); Py_Finalize(); return 0; } ''' INST=''' import sys, py_compile py_compile.compile(sys.argv[1], sys.argv[2], sys.argv[3], True) ''' DISTUTILS_IMP=['from distutils.sysconfig import get_config_var, get_python_lib'] @before_method('process_source') @feature('py') def feature_py(self): self.install_path=getattr(self,'install_path','${PYTHONDIR}') install_from=getattr(self,'install_from',None) if install_from and not isinstance(install_from,Node.Node): install_from=self.path.find_dir(install_from) self.install_from=install_from ver=self.env.PYTHON_VERSION if not ver: self.bld.fatal('Installing python files requires PYTHON_VERSION, try conf.check_python_version') if int(ver.replace('.',''))>31: self.install_32=True @extension('.py') def process_py(self,node): assert(getattr(self,'install_path')),'add features="py"' if self.install_path: if self.install_from: self.bld.install_files(self.install_path,[node],cwd=self.install_from,relative_trick=True) else: self.bld.install_files(self.install_path,[node],relative_trick=True) lst=[] if self.env.PYC: lst.append('pyc') if self.env.PYO: lst.append('pyo') if self.install_path: if self.install_from: pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.install_from)),self.env) else: pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.path)),self.env) else: pyd=node.abspath() for ext in lst: if self.env.PYTAG: name=node.name[:-3] pyobj=node.parent.get_bld().make_node('__pycache__').make_node("%s.%s.%s"%(name,self.env.PYTAG,ext)) pyobj.parent.mkdir() else: pyobj=node.change_ext(".%s"%ext) tsk=self.create_task(ext,node,pyobj) tsk.pyd=pyd if self.install_path: self.bld.install_files(os.path.dirname(pyd),pyobj,cwd=node.parent.get_bld(),relative_trick=True) class pyc(Task.Task): color='PINK' def run(self): cmd=[Utils.subst_vars('${PYTHON}',self.env),'-c',INST,self.inputs[0].abspath(),self.outputs[0].abspath(),self.pyd] ret=self.generator.bld.exec_command(cmd) return ret class pyo(Task.Task): color='PINK' def run(self): cmd=[Utils.subst_vars('${PYTHON}',self.env),Utils.subst_vars('${PYFLAGS_OPT}',self.env),'-c',INST,self.inputs[0].abspath(),self.outputs[0].abspath(),self.pyd] ret=self.generator.bld.exec_command(cmd) return ret @feature('pyext') @before_method('propagate_uselib_vars','apply_link') @after_method('apply_bundle') def init_pyext(self): self.uselib=self.to_list(getattr(self,'uselib',[])) if not'PYEXT'in self.uselib: self.uselib.append('PYEXT') self.env.cshlib_PATTERN=self.env.cxxshlib_PATTERN=self.env.macbundle_PATTERN=self.env.pyext_PATTERN self.env.fcshlib_PATTERN=self.env.dshlib_PATTERN=self.env.pyext_PATTERN try: if not self.install_path: return except AttributeError: self.install_path='${PYTHONARCHDIR}' @feature('pyext') @before_method('apply_link','apply_bundle') def set_bundle(self): if Utils.unversioned_sys_platform()=='darwin': self.mac_bundle=True @before_method('propagate_uselib_vars') @feature('pyembed') def init_pyembed(self): self.uselib=self.to_list(getattr(self,'uselib',[])) if not'PYEMBED'in self.uselib: self.uselib.append('PYEMBED') @conf def get_python_variables(self,variables,imports=None): if not imports: try: imports=self.python_imports except AttributeError: imports=DISTUTILS_IMP program=list(imports) program.append('') for v in variables: program.append("print(repr(%s))"%v) os_env=dict(os.environ) try: del os_env['MACOSX_DEPLOYMENT_TARGET'] except KeyError: pass try: out=self.cmd_and_log(self.env.PYTHON+['-c','\n'.join(program)],env=os_env) except Errors.WafError: self.fatal('The distutils module is unusable: install "python-devel"?') self.to_log(out) return_values=[] for s in out.splitlines(): s=s.strip() if not s: continue if s=='None': return_values.append(None) elif(s[0]=="'"and s[-1]=="'")or(s[0]=='"'and s[-1]=='"'): return_values.append(eval(s)) elif s[0].isdigit(): return_values.append(int(s)) else:break return return_values @conf def python_cross_compile(self,features='pyembed pyext'): features=Utils.to_list(features) if not('PYTHON_LDFLAGS'in self.environ or'PYTHON_PYEXT_LDFLAGS'in self.environ or'PYTHON_PYEMBED_LDFLAGS'in self.environ): return False for x in'PYTHON_VERSION PYTAG pyext_PATTERN'.split(): if not x in self.environ: self.fatal('Please set %s in the os environment'%x) else: self.env[x]=self.environ[x] xx=self.env.CXX_NAME and'cxx'or'c' if'pyext'in features: flags=self.environ.get('PYTHON_PYEXT_LDFLAGS',self.environ.get('PYTHON_LDFLAGS',None)) if flags is None: self.fatal('No flags provided through PYTHON_PYEXT_LDFLAGS as required') else: self.parse_flags(flags,'PYEXT') self.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Testing pyext configuration',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions') if'pyembed'in features: flags=self.environ.get('PYTHON_PYEMBED_LDFLAGS',self.environ.get('PYTHON_LDFLAGS',None)) if flags is None: self.fatal('No flags provided through PYTHON_PYEMBED_LDFLAGS as required') else: self.parse_flags(flags,'PYEMBED') self.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Testing pyembed configuration',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx)) return True @conf def check_python_headers(conf,features='pyembed pyext'): features=Utils.to_list(features) assert('pyembed'in features)or('pyext'in features),"check_python_headers features must include 'pyembed' and/or 'pyext'" env=conf.env if not env['CC_NAME']and not env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if conf.python_cross_compile(features): return if not env['PYTHON_VERSION']: conf.check_python_version() pybin=env.PYTHON if not pybin: conf.fatal('Could not find the python executable') v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split() try: lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v]) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") vals=['%s = %r'%(x,y)for(x,y)in zip(v,lst)] conf.to_log("Configuration returned from %r:\n%s\n"%(pybin,'\n'.join(vals))) dct=dict(zip(v,lst)) x='MACOSX_DEPLOYMENT_TARGET' if dct[x]: env[x]=conf.environ[x]=dct[x] env['pyext_PATTERN']='%s'+dct['SO'] num='.'.join(env['PYTHON_VERSION'].split('.')[:2]) conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',msg="python-config",mandatory=False) if env.PYTHON_CONFIG: all_flags=[['--cflags','--libs','--ldflags']] if sys.hexversion<0x2070000: all_flags=[[k]for k in all_flags[0]] xx=env.CXX_NAME and'cxx'or'c' if'pyembed'in features: for flags in all_flags: conf.check_cfg(msg='Asking python-config for pyembed %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=flags) conf.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx)) if'pyext'in features: for flags in all_flags: conf.check_cfg(msg='Asking python-config for pyext %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=flags) conf.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions') conf.define('HAVE_PYTHON_H',1) return all_flags=dct['LDFLAGS']+' '+dct['CFLAGS'] conf.parse_flags(all_flags,'PYEMBED') all_flags=dct['LDFLAGS']+' '+dct['LDSHARED']+' '+dct['CFLAGS'] conf.parse_flags(all_flags,'PYEXT') result=None if not dct["LDVERSION"]: dct["LDVERSION"]=env['PYTHON_VERSION'] for name in('python'+dct['LDVERSION'],'python'+env['PYTHON_VERSION']+'m','python'+env['PYTHON_VERSION'].replace('.','')): if not result and env['LIBPATH_PYEMBED']: path=env['LIBPATH_PYEMBED'] conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n"%path) result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in LIBPATH_PYEMBED'%name) if not result and dct['LIBDIR']: path=[dct['LIBDIR']] conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n"%path) result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in LIBDIR'%name) if not result and dct['LIBPL']: path=[dct['LIBPL']] conf.to_log("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n") result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in python_LIBPL'%name) if not result: path=[os.path.join(dct['prefix'],"libs")] conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n") result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in $prefix/libs'%name) if result: break if result: env['LIBPATH_PYEMBED']=path env.append_value('LIB_PYEMBED',[name]) else: conf.to_log("\n\n### LIB NOT FOUND\n") if Utils.is_win32 or dct['Py_ENABLE_SHARED']: env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED'] env['LIB_PYEXT']=env['LIB_PYEMBED'] conf.to_log("Include path for Python extensions (found via distutils module): %r\n"%(dct['INCLUDEPY'],)) env['INCLUDES_PYEXT']=[dct['INCLUDEPY']] env['INCLUDES_PYEMBED']=[dct['INCLUDEPY']] if env['CC_NAME']=='gcc': env.append_value('CFLAGS_PYEMBED',['-fno-strict-aliasing']) env.append_value('CFLAGS_PYEXT',['-fno-strict-aliasing']) if env['CXX_NAME']=='gcc': env.append_value('CXXFLAGS_PYEMBED',['-fno-strict-aliasing']) env.append_value('CXXFLAGS_PYEXT',['-fno-strict-aliasing']) if env.CC_NAME=="msvc": from distutils.msvccompiler import MSVCCompiler dist_compiler=MSVCCompiler() dist_compiler.initialize() env.append_value('CFLAGS_PYEXT',dist_compiler.compile_options) env.append_value('CXXFLAGS_PYEXT',dist_compiler.compile_options) env.append_value('LINKFLAGS_PYEXT',dist_compiler.ldflags_shared) conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg='Distutils not installed? Broken python installation? Get python-config now!') @conf def check_python_version(conf,minver=None): assert minver is None or isinstance(minver,tuple) pybin=conf.env['PYTHON'] if not pybin: conf.fatal('could not find the python executable') cmd=pybin+['-c','import sys\nfor x in sys.version_info: print(str(x))'] Logs.debug('python: Running python command %r'%cmd) lines=conf.cmd_and_log(cmd).split() assert len(lines)==5,"found %i lines, expected 5: %r"%(len(lines),lines) pyver_tuple=(int(lines[0]),int(lines[1]),int(lines[2]),lines[3],int(lines[4])) result=(minver is None)or(pyver_tuple>=minver) if result: pyver='.'.join([str(x)for x in pyver_tuple[:2]]) conf.env['PYTHON_VERSION']=pyver if'PYTHONDIR'in conf.env: pydir=conf.env['PYTHONDIR'] elif'PYTHONDIR'in conf.environ: pydir=conf.environ['PYTHONDIR'] else: if Utils.is_win32: (python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0) or ''"]) else: python_LIBDEST=None (pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0, prefix=%r) or ''"%conf.env.PREFIX]) if python_LIBDEST is None: if conf.env['LIBDIR']: python_LIBDEST=os.path.join(conf.env['LIBDIR'],"python"+pyver) else: python_LIBDEST=os.path.join(conf.env['PREFIX'],"lib","python"+pyver) if'PYTHONARCHDIR'in conf.env: pyarchdir=conf.env['PYTHONARCHDIR'] elif'PYTHONARCHDIR'in conf.environ: pyarchdir=conf.environ['PYTHONARCHDIR'] else: (pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''"%conf.env.PREFIX]) if not pyarchdir: pyarchdir=pydir if hasattr(conf,'define'): conf.define('PYTHONDIR',pydir) conf.define('PYTHONARCHDIR',pyarchdir) conf.env['PYTHONDIR']=pydir conf.env['PYTHONARCHDIR']=pyarchdir pyver_full='.'.join(map(str,pyver_tuple[:3])) if minver is None: conf.msg('Checking for python version',pyver_full) else: minver_str='.'.join(map(str,minver)) conf.msg('Checking for python version',pyver_tuple,">= %s"%(minver_str,)and'GREEN'or'YELLOW') if not result: conf.fatal('The python version is too old, expecting %r'%(minver,)) PYTHON_MODULE_TEMPLATE=''' import %s as current_module version = getattr(current_module, '__version__', None) if version is not None: print(str(version)) else: print('unknown version') ''' @conf def check_python_module(conf,module_name,condition=''): msg="Checking for python module '%s'"%module_name if condition: msg='%s (%s)'%(msg,condition) conf.start_msg(msg) try: ret=conf.cmd_and_log(conf.env['PYTHON']+['-c',PYTHON_MODULE_TEMPLATE%module_name]) except Exception: conf.end_msg(False) conf.fatal('Could not find the python module %r'%module_name) ret=ret.strip() if condition: conf.end_msg(ret) if ret=='unknown version': conf.fatal('Could not check the %s version'%module_name) from distutils.version import LooseVersion def num(*k): if isinstance(k[0],int): return LooseVersion('.'.join([str(x)for x in k])) else: return LooseVersion(k[0]) d={'num':num,'ver':LooseVersion(ret)} ev=eval(condition,{},d) if not ev: conf.fatal('The %s version does not satisfy the requirements'%module_name) else: if ret=='unknown version': conf.end_msg(True) else: conf.end_msg(ret) def configure(conf): v=conf.env v['PYTHON']=Options.options.python or os.environ.get('PYTHON',sys.executable) if Options.options.pythondir: v['PYTHONDIR']=Options.options.pythondir if Options.options.pythonarchdir: v['PYTHONARCHDIR']=Options.options.pythonarchdir conf.find_program('python',var='PYTHON') v['PYFLAGS']='' v['PYFLAGS_OPT']='-O' v['PYC']=getattr(Options.options,'pyc',1) v['PYO']=getattr(Options.options,'pyo',1) try: v.PYTAG=conf.cmd_and_log(conf.env.PYTHON+['-c',"import imp;print(imp.get_tag())"]).strip() except Errors.WafError: pass def options(opt): pyopt=opt.add_option_group("Python Options") pyopt.add_option('--nopyc',dest='pyc',action='store_false',default=1,help='Do not install bytecode compiled .pyc files (configuration) [Default:install]') pyopt.add_option('--nopyo',dest='pyo',action='store_false',default=1,help='Do not install optimised compiled .pyo files (configuration) [Default:install]') pyopt.add_option('--python',dest="python",help='python binary to be used [Default: %s]'%sys.executable) pyopt.add_option('--pythondir',dest='pythondir',help='Installation path for python modules (py, platform-independent .py and .pyc files)') pyopt.add_option('--pythonarchdir',dest='pythonarchdir',help='Installation path for python extension (pyext, platform-dependent .so or .dylib files)')
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 4178, 921, 21500, 14, 2308, 15, 2706, 15, 1080, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 199, 504, 31380, 492, 17397, 12, 4558, 12, 9298, 12, 16333, 12, 4476, 12, 1716, 199, 504, 31380, 14, 4476, 8168, 492, 3329, 12, 5182, 63, 765, 12, 4399, 63, 765, 12, 4445, 199, 504, 31380, 14, 17324, 492, 3743, 199, 24439, 19938, 199, 3, 2613, 665, 4718, 14, 72, 30, 199, 3, 27737, 636, 67, 6666, 6666, 199, 18587, 298, 35, 2, 469, 199, 3, 13739, 199, 198, 1647, 1611, 63, 9345, 8, 1647, 2736, 199, 198, 1647, 1611, 63, 12776, 794, 8, 1647, 2736, 199, 3, 27737, 636, 67, 6666, 6666, 199, 93, 199, 3, 13739, 199, 442, 2446, 8, 442, 1680, 67, 12, 1495, 1011, 3020, 9, 199, 91, 2043, 334, 1647, 9, 1273, 67, 27, 334, 1647, 9, 3020, 27, 2043, 1611, 63, 9345, 7303, 2043, 1611, 63, 12776, 794, 7303, 2043, 372, 378, 27, 199, 93, 199, 2344, 199, 7834, 19938, 199, 646, 984, 12, 1134, 63, 2014, 199, 647, 63, 2014, 14, 2014, 8, 1274, 14, 3020, 59, 17, 467, 984, 14, 3020, 59, 18, 467, 984, 14, 3020, 59, 19, 467, 715, 9, 199, 2344, 199, 13783, 29076, 51, 63, 8947, 2968, 504, 7065, 14, 24030, 492, 664, 63, 888, 63, 1391, 12, 664, 63, 1548, 63, 773, 418, 199, 32, 5182, 63, 765, 360, 1412, 63, 1365, 358, 199, 32, 4445, 360, 647, 358, 199, 318, 3878, 63, 647, 8, 277, 304, 199, 198, 277, 14, 3174, 63, 515, 29, 5675, 8, 277, 2584, 3174, 63, 515, 1673, 10545, 11720, 3022, 12216, 199, 198, 3174, 63, 504, 29, 5675, 8, 277, 2584, 3174, 63, 504, 297, 403, 9, 199, 198, 692, 3907, 63, 504, 436, 440, 1228, 8, 3174, 63, 504, 12, 1716, 14, 1716, 304, 507, 198, 3174, 63, 504, 29, 277, 14, 515, 14, 1623, 63, 694, 8, 3174, 63, 504, 9, 199, 198, 277, 14, 3174, 63, 504, 29, 3174, 63, 504, 199, 198, 422, 29, 277, 14, 1813, 14, 11720, 63, 4612, 199, 198, 692, 440, 809, 26, 507, 198, 277, 14, 14341, 14, 16208, 360, 31376, 2366, 1584, 5074, 18280, 63, 4612, 12, 862, 3743, 14, 1074, 63, 1548, 63, 1023, 358, 199, 198, 692, 1109, 8, 422, 14, 1814, 5175, 1673, 1333, 30, 2192, 26, 507, 198, 277, 14, 3174, 63, 708, 29, 549, 199, 32, 3435, 5175, 647, 358, 199, 318, 2112, 63, 647, 8, 277, 12, 932, 304, 199, 198, 479, 8, 5675, 8, 277, 2584, 3174, 63, 515, 3855, 7, 525, 4534, 628, 647, 4507, 199, 198, 692, 291, 14, 3174, 63, 515, 26, 507, 198, 692, 291, 14, 3174, 63, 504, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 277, 14, 3174, 63, 515, 14343, 932, 467, 6525, 29, 277, 14, 3174, 63, 504, 12, 6188, 63, 599, 346, 29, 549, 9, 507, 198, 2836, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 277, 14, 3174, 63, 515, 14343, 932, 467, 6188, 63, 599, 346, 29, 549, 9, 199, 198, 6916, 9811, 199, 198, 692, 291, 14, 1813, 14, 4521, 35, 26, 507, 198, 6916, 14, 740, 360, 11357, 358, 199, 198, 692, 291, 14, 1813, 14, 4521, 47, 26, 507, 198, 6916, 14, 740, 360, 22345, 358, 199, 198, 692, 291, 14, 3174, 63, 515, 26, 507, 198, 692, 291, 14, 3174, 63, 504, 26, 686, 198, 647, 68, 29, 7535, 14, 16747, 63, 2936, 3647, 83, 3149, 83, 14007, 277, 14, 3174, 63, 515, 12, 932, 14, 515, 63, 504, 8, 277, 14, 3174, 63, 504, 1826, 277, 14, 1813, 9, 507, 198, 2836, 26, 686, 198, 647, 68, 29, 7535, 14, 16747, 63, 2936, 3647, 83, 3149, 83, 14007, 277, 14, 3174, 63, 515, 12, 932, 14, 515, 63, 504, 8, 277, 14, 515, 1826, 277, 14, 1813, 9, 199, 198, 2836, 26, 507, 198, 647, 68, 29, 932, 14, 4832, 342, 199, 198, 509, 1599, 315, 9877, 26, 507, 198, 692, 291, 14, 1813, 14, 4521, 6967, 26, 686, 198, 354, 29, 932, 14, 354, 4439, 19, 61, 686, 198, 29797, 29, 932, 14, 1708, 14, 362, 63, 14341, 1252, 1875, 63, 932, 10714, 647, 1637, 363, 1959, 1875, 63, 932, 3647, 83, 4111, 83, 4111, 83, 14007, 354, 12, 277, 14, 1813, 14, 4521, 6967, 12, 832, 430, 686, 198, 29797, 14, 1708, 14, 8215, 342, 507, 198, 2836, 26, 686, 198, 29797, 29, 932, 14, 1461, 63, 832, 480, 4111, 83, 6808, 832, 9, 507, 198, 21563, 29, 277, 14, 981, 63, 1765, 8, 832, 12, 932, 12, 29797, 9, 507, 198, 21563, 14, 647, 68, 29, 647, 68, 507, 198, 692, 291, 14, 3174, 63, 515, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 736, 14, 515, 14, 3475, 8, 647, 68, 395, 29797, 12, 6525, 29, 932, 14, 1708, 14, 362, 63, 14341, 1062, 6188, 63, 599, 346, 29, 549, 9, 199, 533, 28968, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1760, 1524, 7535, 14, 16747, 63, 2936, 360, 10545, 11720, 7293, 277, 14, 1813, 395, 12418, 67, 297, 7834, 12, 277, 14, 3711, 59, 16, 1055, 4832, 1062, 277, 14, 4467, 59, 16, 1055, 4832, 1062, 277, 14, 647, 68, 61, 507, 198, 3292, 29, 277, 14, 4679, 14, 14341, 14, 1628, 63, 1531, 8, 1760, 9, 507, 198, 1107, 2203, 199, 533, 1134, 79, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1760, 1524, 7535, 14, 16747, 63, 2936, 360, 10545, 11720, 7293, 277, 14, 1813, 395, 7535, 14, 16747, 63, 2936, 360, 10545, 4521, 4831, 63, 5123, 7293, 277, 14, 1813, 395, 12418, 67, 297, 7834, 12, 277, 14, 3711, 59, 16, 1055, 4832, 1062, 277, 14, 4467, 59, 16, 1055, 4832, 1062, 277, 14, 647, 68, 61, 507, 198 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 4178, 921, 21500, 14, 2308, 15, 2706, 15, 1080, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 199, 504, 31380, 492, 17397, 12, 4558, 12, 9298, 12, 16333, 12, 4476, 12, 1716, 199, 504, 31380, 14, 4476, 8168, 492, 3329, 12, 5182, 63, 765, 12, 4399, 63, 765, 12, 4445, 199, 504, 31380, 14, 17324, 492, 3743, 199, 24439, 19938, 199, 3, 2613, 665, 4718, 14, 72, 30, 199, 3, 27737, 636, 67, 6666, 6666, 199, 18587, 298, 35, 2, 469, 199, 3, 13739, 199, 198, 1647, 1611, 63, 9345, 8, 1647, 2736, 199, 198, 1647, 1611, 63, 12776, 794, 8, 1647, 2736, 199, 3, 27737, 636, 67, 6666, 6666, 199, 93, 199, 3, 13739, 199, 442, 2446, 8, 442, 1680, 67, 12, 1495, 1011, 3020, 9, 199, 91, 2043, 334, 1647, 9, 1273, 67, 27, 334, 1647, 9, 3020, 27, 2043, 1611, 63, 9345, 7303, 2043, 1611, 63, 12776, 794, 7303, 2043, 372, 378, 27, 199, 93, 199, 2344, 199, 7834, 19938, 199, 646, 984, 12, 1134, 63, 2014, 199, 647, 63, 2014, 14, 2014, 8, 1274, 14, 3020, 59, 17, 467, 984, 14, 3020, 59, 18, 467, 984, 14, 3020, 59, 19, 467, 715, 9, 199, 2344, 199, 13783, 29076, 51, 63, 8947, 2968, 504, 7065, 14, 24030, 492, 664, 63, 888, 63, 1391, 12, 664, 63, 1548, 63, 773, 418, 199, 32, 5182, 63, 765, 360, 1412, 63, 1365, 358, 199, 32, 4445, 360, 647, 358, 199, 318, 3878, 63, 647, 8, 277, 304, 199, 198, 277, 14, 3174, 63, 515, 29, 5675, 8, 277, 2584, 3174, 63, 515, 1673, 10545, 11720, 3022, 12216, 199, 198, 3174, 63, 504, 29, 5675, 8, 277, 2584, 3174, 63, 504, 297, 403, 9, 199, 198, 692, 3907, 63, 504, 436, 440, 1228, 8, 3174, 63, 504, 12, 1716, 14, 1716, 304, 507, 198, 3174, 63, 504, 29, 277, 14, 515, 14, 1623, 63, 694, 8, 3174, 63, 504, 9, 199, 198, 277, 14, 3174, 63, 504, 29, 3174, 63, 504, 199, 198, 422, 29, 277, 14, 1813, 14, 11720, 63, 4612, 199, 198, 692, 440, 809, 26, 507, 198, 277, 14, 14341, 14, 16208, 360, 31376, 2366, 1584, 5074, 18280, 63, 4612, 12, 862, 3743, 14, 1074, 63, 1548, 63, 1023, 358, 199, 198, 692, 1109, 8, 422, 14, 1814, 5175, 1673, 1333, 30, 2192, 26, 507, 198, 277, 14, 3174, 63, 708, 29, 549, 199, 32, 3435, 5175, 647, 358, 199, 318, 2112, 63, 647, 8, 277, 12, 932, 304, 199, 198, 479, 8, 5675, 8, 277, 2584, 3174, 63, 515, 3855, 7, 525, 4534, 628, 647, 4507, 199, 198, 692, 291, 14, 3174, 63, 515, 26, 507, 198, 692, 291, 14, 3174, 63, 504, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 277, 14, 3174, 63, 515, 14343, 932, 467, 6525, 29, 277, 14, 3174, 63, 504, 12, 6188, 63, 599, 346, 29, 549, 9, 507, 198, 2836, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 277, 14, 3174, 63, 515, 14343, 932, 467, 6188, 63, 599, 346, 29, 549, 9, 199, 198, 6916, 9811, 199, 198, 692, 291, 14, 1813, 14, 4521, 35, 26, 507, 198, 6916, 14, 740, 360, 11357, 358, 199, 198, 692, 291, 14, 1813, 14, 4521, 47, 26, 507, 198, 6916, 14, 740, 360, 22345, 358, 199, 198, 692, 291, 14, 3174, 63, 515, 26, 507, 198, 692, 291, 14, 3174, 63, 504, 26, 686, 198, 647, 68, 29, 7535, 14, 16747, 63, 2936, 3647, 83, 3149, 83, 14007, 277, 14, 3174, 63, 515, 12, 932, 14, 515, 63, 504, 8, 277, 14, 3174, 63, 504, 1826, 277, 14, 1813, 9, 507, 198, 2836, 26, 686, 198, 647, 68, 29, 7535, 14, 16747, 63, 2936, 3647, 83, 3149, 83, 14007, 277, 14, 3174, 63, 515, 12, 932, 14, 515, 63, 504, 8, 277, 14, 515, 1826, 277, 14, 1813, 9, 199, 198, 2836, 26, 507, 198, 647, 68, 29, 932, 14, 4832, 342, 199, 198, 509, 1599, 315, 9877, 26, 507, 198, 692, 291, 14, 1813, 14, 4521, 6967, 26, 686, 198, 354, 29, 932, 14, 354, 4439, 19, 61, 686, 198, 29797, 29, 932, 14, 1708, 14, 362, 63, 14341, 1252, 1875, 63, 932, 10714, 647, 1637, 363, 1959, 1875, 63, 932, 3647, 83, 4111, 83, 4111, 83, 14007, 354, 12, 277, 14, 1813, 14, 4521, 6967, 12, 832, 430, 686, 198, 29797, 14, 1708, 14, 8215, 342, 507, 198, 2836, 26, 686, 198, 29797, 29, 932, 14, 1461, 63, 832, 480, 4111, 83, 6808, 832, 9, 507, 198, 21563, 29, 277, 14, 981, 63, 1765, 8, 832, 12, 932, 12, 29797, 9, 507, 198, 21563, 14, 647, 68, 29, 647, 68, 507, 198, 692, 291, 14, 3174, 63, 515, 26, 686, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 736, 14, 515, 14, 3475, 8, 647, 68, 395, 29797, 12, 6525, 29, 932, 14, 1708, 14, 362, 63, 14341, 1062, 6188, 63, 599, 346, 29, 549, 9, 199, 533, 28968, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1760, 1524, 7535, 14, 16747, 63, 2936, 360, 10545, 11720, 7293, 277, 14, 1813, 395, 12418, 67, 297, 7834, 12, 277, 14, 3711, 59, 16, 1055, 4832, 1062, 277, 14, 4467, 59, 16, 1055, 4832, 1062, 277, 14, 647, 68, 61, 507, 198, 3292, 29, 277, 14, 4679, 14, 14341, 14, 1628, 63, 1531, 8, 1760, 9, 507, 198, 1107, 2203, 199, 533, 1134, 79, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1760, 1524, 7535, 14, 16747, 63, 2936, 360, 10545, 11720, 7293, 277, 14, 1813, 395, 7535, 14, 16747, 63, 2936, 360, 10545, 4521, 4831, 63, 5123, 7293, 277, 14, 1813, 395, 12418, 67,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JackieXie168/rethinkdb
test/common/http_support/jinja2/_compat.py
638
4042
# -*- coding: utf-8 -*- """ jinja2._compat ~~~~~~~~~~~~~~ Some py2/py3 compatibility support based on a stripped down version of six so we don't have to depend on a specific version of it. :copyright: Copyright 2013 by the Jinja team, see AUTHORS. :license: BSD, see LICENSE for details. """ import sys PY2 = sys.version_info[0] == 2 PYPY = hasattr(sys, 'pypy_translation_info') _identity = lambda x: x if not PY2: unichr = chr range_type = range text_type = str string_types = (str,) iterkeys = lambda d: iter(d.keys()) itervalues = lambda d: iter(d.values()) iteritems = lambda d: iter(d.items()) import pickle from io import BytesIO, StringIO NativeStringIO = StringIO def reraise(tp, value, tb=None): if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value ifilter = filter imap = map izip = zip intern = sys.intern implements_iterator = _identity implements_to_string = _identity encode_filename = _identity get_next = lambda x: x.__next__ else: unichr = unichr text_type = unicode range_type = xrange string_types = (str, unicode) iterkeys = lambda d: d.iterkeys() itervalues = lambda d: d.itervalues() iteritems = lambda d: d.iteritems() import cPickle as pickle from cStringIO import StringIO as BytesIO, StringIO NativeStringIO = BytesIO exec('def reraise(tp, value, tb=None):\n raise tp, value, tb') from itertools import imap, izip, ifilter intern = intern def implements_iterator(cls): cls.next = cls.__next__ del cls.__next__ return cls def implements_to_string(cls): cls.__unicode__ = cls.__str__ cls.__str__ = lambda x: x.__unicode__().encode('utf-8') return cls get_next = lambda x: x.next def encode_filename(filename): if isinstance(filename, unicode): return filename.encode('utf-8') return filename try: next = next except NameError: def next(it): return it.next() def with_metaclass(meta, *bases): # This requires a bit of explanation: the basic idea is to make a # dummy metaclass for one level of class instanciation that replaces # itself with the actual metaclass. Because of internal type checks # we also need to make sure that we downgrade the custom metaclass # for one level to something closer to type (that's why __call__ and # __init__ comes back from type etc.). # # This has the advantage over six.with_metaclass in that it does not # introduce dummy classes into the final MRO. class metaclass(meta): __call__ = type.__call__ __init__ = type.__init__ def __new__(cls, name, this_bases, d): if this_bases is None: return type.__new__(cls, name, (), d) return meta(name, bases, d) return metaclass('temporary_class', None, {}) try: from collections import Mapping as mapping_types except ImportError: import UserDict mapping_types = (UserDict.UserDict, UserDict.DictMixin, dict) # common types. These do exist in the special types module too which however # does not exist in IronPython out of the box. Also that way we don't have # to deal with implementation specific stuff here class _C(object): def method(self): pass def _func(): yield None function_type = type(_func) generator_type = type(_func()) method_type = type(_C().method) code_type = type(_C.method.__code__) try: raise TypeError() except TypeError: _tb = sys.exc_info()[2] traceback_type = type(_tb) frame_type = type(_tb.tb_frame) try: from urllib.parse import quote_from_bytes as url_quote except ImportError: from urllib import quote as url_quote try: from thread import allocate_lock except ImportError: try: from threading import Lock as allocate_lock except ImportError: from dummy_thread import allocate_lock
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 423, 5819, 272, 32202, 1714, 339, 6601, 1134, 18, 15, 647, 19, 7163, 2291, 4079, 641, 282, 14489, 3224, 272, 1015, 402, 3816, 880, 781, 2793, 1133, 1172, 370, 11687, 641, 282, 2488, 1015, 272, 402, 652, 14, 339, 520, 7307, 26, 1898, 6171, 701, 314, 17300, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 646, 984, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 4521, 275, 2688, 8, 1274, 12, 283, 20233, 63, 6893, 63, 815, 358, 199, 63, 5582, 275, 2400, 671, 26, 671, 421, 199, 692, 440, 7843, 18, 26, 272, 17742, 275, 8678, 272, 1425, 63, 466, 275, 1425, 272, 1318, 63, 466, 275, 620, 272, 1059, 63, 1313, 275, 334, 495, 4258, 339, 25706, 275, 2400, 366, 26, 2740, 8, 68, 14, 1612, 1012, 272, 24451, 275, 2400, 366, 26, 2740, 8, 68, 14, 1459, 1012, 272, 10849, 275, 2400, 366, 26, 2740, 8, 68, 14, 1744, 1012, 339, 492, 5927, 272, 687, 5890, 492, 11808, 12, 5228, 272, 653, 1905, 6424, 275, 5228, 339, 347, 24139, 8, 683, 12, 574, 12, 7070, 29, 403, 304, 267, 340, 574, 855, 6894, 363, 365, 440, 7070, 26, 288, 746, 574, 14, 1045, 63, 6894, 8, 5842, 9, 267, 746, 574, 339, 284, 1541, 275, 2457, 272, 23646, 275, 2341, 272, 28697, 275, 3482, 272, 10757, 275, 984, 14, 4404, 339, 9031, 63, 5778, 275, 485, 5582, 272, 9031, 63, 475, 63, 875, 275, 485, 5582, 272, 3752, 63, 1501, 275, 485, 5582, 272, 664, 63, 2184, 275, 2400, 671, 26, 671, 855, 2184, 363, 199, 199, 2836, 26, 272, 17742, 275, 17742, 272, 1318, 63, 466, 275, 2649, 272, 1425, 63, 466, 275, 4945, 272, 1059, 63, 1313, 275, 334, 495, 12, 2649, 9, 339, 25706, 275, 2400, 366, 26, 366, 14, 16007, 342, 272, 24451, 275, 2400, 366, 26, 366, 14, 13012, 342, 272, 10849, 275, 2400, 366, 26, 366, 14, 4611, 342, 339, 492, 17572, 465, 5927, 272, 687, 15073, 492, 5228, 465, 11808, 12, 5228, 272, 653, 1905, 6424, 275, 11808, 339, 2146, 360, 318, 24139, 8, 683, 12, 574, 12, 7070, 29, 403, 17211, 78, 746, 9253, 12, 574, 12, 7070, 358, 339, 687, 7975, 492, 23646, 12, 28697, 12, 284, 1541, 272, 10757, 275, 10757, 339, 347, 9031, 63, 5778, 8, 1886, 304, 267, 843, 14, 2184, 275, 843, 855, 2184, 363, 267, 2150, 843, 855, 2184, 363, 267, 372, 843, 339, 347, 9031, 63, 475, 63, 875, 8, 1886, 304, 267, 843, 855, 2975, 363, 275, 843, 855, 495, 363, 267, 843, 855, 495, 363, 275, 2400, 671, 26, 671, 855, 2975, 31261, 2143, 360, 1624, 13, 24, 358, 267, 372, 843, 339, 664, 63, 2184, 275, 2400, 671, 26, 671, 14, 2184, 339, 347, 3752, 63, 1501, 8, 1501, 304, 267, 340, 1228, 8, 1501, 12, 2649, 304, 288, 372, 1788, 14, 2143, 360, 1624, 13, 24, 358, 267, 372, 1788, 199, 199, 893, 26, 272, 2163, 275, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 390, 304, 267, 372, 652, 14, 2184, 342, 421, 199, 318, 543, 63, 6577, 8, 2024, 12, 627, 12087, 304, 272, 327, 961, 5074, 282, 4546, 402, 17531, 26, 314, 5678, 16819, 365, 370, 1852, 282, 272, 327, 7283, 17074, 367, 1373, 2166, 402, 1021, 2727, 290, 559, 425, 626, 19058, 272, 327, 6337, 543, 314, 3503, 17074, 14, 221, 13821, 402, 5007, 730, 5920, 272, 327, 781, 2597, 1929, 370, 1852, 3238, 626, 781, 32498, 314, 3537, 17074, 272, 327, 367, 1373, 2166, 370, 6020, 2463, 332, 370, 730, 334, 9099, 1159, 10842, 636, 1250, 363, 436, 272, 327, 636, 826, 363, 12477, 1771, 687, 730, 5423, 25860, 272, 327, 272, 327, 961, 965, 314, 30268, 1806, 3816, 14, 1045, 63, 6577, 315, 626, 652, 1630, 440, 272, 327, 13318, 3402, 7283, 3992, 1901, 314, 4242, 603, 1092, 14, 272, 1021, 17074, 8, 2024, 304, 267, 636, 1250, 363, 275, 730, 855, 1250, 363, 267, 636, 826, 363, 275, 730, 855, 826, 363, 267, 347, 636, 1222, 721, 1886, 12, 536, 12, 642, 63, 12087, 12, 366, 304, 288, 340, 642, 63, 12087, 365, 488, 26, 355, 372, 730, 855, 1222, 721, 1886, 12, 536, 12, 11969, 366, 9, 288, 372, 3404, 8, 354, 12, 9768, 12, 366, 9, 272, 372, 17074, 360, 13555, 63, 533, 297, 488, 12, 5009, 421, 199, 893, 26, 272, 687, 5055, 492, 12340, 465, 4412, 63, 1313, 199, 2590, 3545, 26, 272, 492, 32241, 272, 4412, 63, 1313, 275, 334, 30088, 14, 30088, 12, 32241, 14, 2141, 4256, 12, 1211, 9, 421, 199, 3, 2863, 2943, 14, 221, 5723, 886, 2187, 315, 314, 4539, 2943, 859, 4634, 1314, 13432, 199, 3, 1630, 440, 2187, 315, 473, 2641, 4718, 734, 402, 314, 5689, 14, 221, 6121, 626, 4340, 781, 2793, 1133, 1172, 199, 3, 370, 7962, 543, 4514, 2488, 8292, 2348, 199, 533, 485, 35, 8, 785, 304, 272, 347, 1083, 8, 277, 304, 986, 199, 318, 485, 1532, 837, 272, 1995, 488, 199, 1593, 63, 466, 275, 730, 1547, 1532, 9, 199, 4679, 63, 466, 275, 730, 1547, 1532, 1012, 199, 765, 63, 466, 275, 730, 1547, 35, 1252, 765, 9, 199, 600, 63, 466, 275, 730, 1547, 35, 14, 765, 855, 600, 3368, 199, 893, 26, 272, 746, 3146, 342, 199, 2590, 3146, 26, 272, 485, 5842, 275, 984, 14, 2804, 63, 815, 3430, 18, 61, 272, 5190, 63, 466, 275, 730, 1547, 5842, 9, 272, 2787, 63, 466, 275, 730, 1547, 5842, 14, 5842, 63, 1943, 9, 421, 199, 893, 26, 272, 687, 4011, 14, 1122, 492, 6313, 63, 504, 63, 2394, 465, 1166, 63, 3513, 199, 2590, 3545, 26, 272, 687, 4011, 492, 6313, 465, 1166, 63, 3513, 421, 199, 893, 26, 272, 687, 2462, 492, 18310, 63, 831, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 5796, 492, 15536, 465, 18310, 63, 831, 272, 871, 3545, 26, 267, 687, 7283, 63, 2671, 492, 18310, 63, 831, 199, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 423, 5819, 272, 32202, 1714, 339, 6601, 1134, 18, 15, 647, 19, 7163, 2291, 4079, 641, 282, 14489, 3224, 272, 1015, 402, 3816, 880, 781, 2793, 1133, 1172, 370, 11687, 641, 282, 2488, 1015, 272, 402, 652, 14, 339, 520, 7307, 26, 1898, 6171, 701, 314, 17300, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 646, 984, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 4521, 275, 2688, 8, 1274, 12, 283, 20233, 63, 6893, 63, 815, 358, 199, 63, 5582, 275, 2400, 671, 26, 671, 421, 199, 692, 440, 7843, 18, 26, 272, 17742, 275, 8678, 272, 1425, 63, 466, 275, 1425, 272, 1318, 63, 466, 275, 620, 272, 1059, 63, 1313, 275, 334, 495, 4258, 339, 25706, 275, 2400, 366, 26, 2740, 8, 68, 14, 1612, 1012, 272, 24451, 275, 2400, 366, 26, 2740, 8, 68, 14, 1459, 1012, 272, 10849, 275, 2400, 366, 26, 2740, 8, 68, 14, 1744, 1012, 339, 492, 5927, 272, 687, 5890, 492, 11808, 12, 5228, 272, 653, 1905, 6424, 275, 5228, 339, 347, 24139, 8, 683, 12, 574, 12, 7070, 29, 403, 304, 267, 340, 574, 855, 6894, 363, 365, 440, 7070, 26, 288, 746, 574, 14, 1045, 63, 6894, 8, 5842, 9, 267, 746, 574, 339, 284, 1541, 275, 2457, 272, 23646, 275, 2341, 272, 28697, 275, 3482, 272, 10757, 275, 984, 14, 4404, 339, 9031, 63, 5778, 275, 485, 5582, 272, 9031, 63, 475, 63, 875, 275, 485, 5582, 272, 3752, 63, 1501, 275, 485, 5582, 272, 664, 63, 2184, 275, 2400, 671, 26, 671, 855, 2184, 363, 199, 199, 2836, 26, 272, 17742, 275, 17742, 272, 1318, 63, 466, 275, 2649, 272, 1425, 63, 466, 275, 4945, 272, 1059, 63, 1313, 275, 334, 495, 12, 2649, 9, 339, 25706, 275, 2400, 366, 26, 366, 14, 16007, 342, 272, 24451, 275, 2400, 366, 26, 366, 14, 13012, 342, 272, 10849, 275, 2400, 366, 26, 366, 14, 4611, 342, 339, 492, 17572, 465, 5927, 272, 687, 15073, 492, 5228, 465, 11808, 12, 5228, 272, 653, 1905, 6424, 275, 11808, 339, 2146, 360, 318, 24139, 8, 683, 12, 574, 12, 7070, 29, 403, 17211, 78, 746, 9253, 12, 574, 12, 7070, 358, 339, 687, 7975, 492, 23646, 12, 28697, 12, 284, 1541, 272, 10757, 275, 10757, 339, 347, 9031, 63, 5778, 8, 1886, 304, 267, 843, 14, 2184, 275, 843, 855, 2184, 363, 267, 2150, 843, 855, 2184, 363, 267, 372, 843, 339, 347, 9031, 63, 475, 63, 875, 8, 1886, 304, 267, 843, 855, 2975, 363, 275, 843, 855, 495, 363, 267, 843, 855, 495, 363, 275, 2400, 671, 26, 671, 855, 2975, 31261, 2143, 360, 1624, 13, 24, 358, 267, 372, 843, 339, 664, 63, 2184, 275, 2400, 671, 26, 671, 14, 2184, 339, 347, 3752, 63, 1501, 8, 1501, 304, 267, 340, 1228, 8, 1501, 12, 2649, 304, 288, 372, 1788, 14, 2143, 360, 1624, 13, 24, 358, 267, 372, 1788, 199, 199, 893, 26, 272, 2163, 275, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 390, 304, 267, 372, 652, 14, 2184, 342, 421, 199, 318, 543, 63, 6577, 8, 2024, 12, 627, 12087, 304, 272, 327, 961, 5074, 282, 4546, 402, 17531, 26, 314, 5678, 16819, 365, 370, 1852, 282, 272, 327, 7283, 17074, 367, 1373, 2166, 402, 1021, 2727, 290, 559, 425, 626, 19058, 272, 327, 6337, 543, 314, 3503, 17074, 14, 221, 13821, 402, 5007, 730, 5920, 272, 327, 781, 2597, 1929, 370, 1852, 3238, 626, 781, 32498, 314, 3537, 17074, 272, 327, 367, 1373, 2166, 370, 6020, 2463, 332, 370, 730, 334, 9099, 1159, 10842, 636, 1250, 363, 436, 272, 327, 636, 826, 363, 12477, 1771, 687, 730, 5423, 25860, 272, 327, 272, 327, 961, 965, 314, 30268, 1806, 3816, 14, 1045, 63, 6577, 315, 626, 652, 1630, 440, 272, 327, 13318, 3402, 7283, 3992, 1901, 314, 4242, 603, 1092, 14, 272, 1021, 17074, 8, 2024, 304, 267, 636, 1250, 363, 275, 730, 855, 1250, 363, 267, 636, 826, 363, 275, 730, 855, 826, 363, 267, 347, 636, 1222, 721, 1886, 12, 536, 12, 642, 63, 12087, 12, 366, 304, 288, 340, 642, 63, 12087, 365, 488, 26, 355, 372, 730, 855, 1222, 721, 1886, 12, 536, 12, 11969, 366, 9, 288, 372, 3404, 8, 354, 12, 9768, 12, 366, 9, 272, 372, 17074, 360, 13555, 63, 533, 297, 488, 12, 5009, 421, 199, 893, 26, 272, 687, 5055, 492, 12340, 465, 4412, 63, 1313, 199, 2590, 3545, 26, 272, 492, 32241, 272, 4412, 63, 1313, 275, 334, 30088, 14, 30088, 12, 32241, 14, 2141, 4256, 12, 1211, 9, 421, 199, 3, 2863, 2943, 14, 221, 5723, 886, 2187, 315, 314, 4539, 2943, 859, 4634, 1314, 13432, 199, 3, 1630, 440, 2187, 315, 473, 2641, 4718, 734, 402, 314, 5689, 14, 221, 6121, 626, 4340, 781, 2793, 1133, 1172, 199, 3, 370, 7962, 543, 4514, 2488, 8292, 2348, 199, 533, 485, 35, 8, 785, 304, 272, 347, 1083, 8, 277, 304, 986, 199, 318, 485, 1532, 837, 272, 1995, 488, 199, 1593, 63, 466, 275, 730, 1547, 1532, 9, 199, 4679, 63, 466, 275, 730, 1547, 1532, 1012, 199, 765, 63, 466, 275, 730, 1547, 35, 1252, 765, 9, 199, 600, 63, 466, 275, 730, 1547, 35, 14, 765, 855, 600, 3368, 199, 893, 26, 272, 746, 3146, 342, 199, 2590, 3146, 26, 272, 485, 5842, 275, 984, 14, 2804, 63, 815, 3430, 18, 61, 272, 5190, 63, 466, 275, 730, 1547, 5842, 9, 272, 2787, 63, 466, 275, 730, 1547, 5842, 14, 5842, 63, 1943, 9, 421, 199, 893, 26, 272, 687, 4011, 14, 1122, 492, 6313, 63, 504, 63, 2394, 465, 1166, 63, 3513, 199, 2590, 3545, 26, 272, 687, 4011, 492, 6313, 465, 1166, 63, 3513, 421, 199, 893, 26, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ]
brianwoo/django-tutorial
ENV/lib/python2.7/site-packages/django/utils/autoreload.py
19
10731
# Autoreloading launcher. # Borrowed from Peter Hunt and the CherryPy project (http://www.cherrypy.org). # Some taken from Ian Bicking's Paste (http://pythonpaste.org/). # # Portions copyright (c) 2004, CherryPy Team (team@cherrypy.org) # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the CherryPy Team 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. # Avoid importing `importlib` from this package. from __future__ import absolute_import import os import signal import sys import time import traceback from django.apps import apps from django.conf import settings from django.core.signals import request_finished from django.utils.six.moves import _thread as thread # This import does nothing, but it's necessary to avoid some race conditions # in the threading module. See http://code.djangoproject.com/ticket/2330 . try: import threading # NOQA except ImportError: pass try: import termios except ImportError: termios = None USE_INOTIFY = False try: # Test whether inotify is enabled and likely to work import pyinotify fd = pyinotify.INotifyWrapper.create().inotify_init() if fd >= 0: USE_INOTIFY = True os.close(fd) except ImportError: pass RUN_RELOADER = True FILE_MODIFIED = 1 I18N_MODIFIED = 2 _mtimes = {} _win = (sys.platform == "win32") _error_files = [] _cached_modules = set() _cached_filenames = [] def gen_filenames(only_new=False): """ Returns a list of filenames referenced in sys.modules and translation files. """ # N.B. ``list(...)`` is needed, because this runs in parallel with # application code which might be mutating ``sys.modules``, and this will # fail with RuntimeError: cannot mutate dictionary while iterating global _cached_modules, _cached_filenames module_values = set(sys.modules.values()) _cached_filenames = clean_files(_cached_filenames) if _cached_modules == module_values: # No changes in module list, short-circuit the function if only_new: return [] else: return _cached_filenames new_modules = module_values - _cached_modules new_filenames = clean_files( [filename.__file__ for filename in new_modules if hasattr(filename, '__file__')]) if not _cached_filenames and settings.USE_I18N: # Add the names of the .mo files that can be generated # by compilemessages management command to the list of files watched. basedirs = [os.path.join(os.path.dirname(os.path.dirname(__file__)), 'conf', 'locale'), 'locale'] for app_config in reversed(list(apps.get_app_configs())): basedirs.append(os.path.join(app_config.path, 'locale')) basedirs.extend(settings.LOCALE_PATHS) basedirs = [os.path.abspath(basedir) for basedir in basedirs if os.path.isdir(basedir)] for basedir in basedirs: for dirpath, dirnames, locale_filenames in os.walk(basedir): for filename in locale_filenames: if filename.endswith('.mo'): new_filenames.append(os.path.join(dirpath, filename)) _cached_modules = _cached_modules.union(new_modules) _cached_filenames += new_filenames if only_new: return new_filenames else: return _cached_filenames + clean_files(_error_files) def clean_files(filelist): filenames = [] for filename in filelist: if not filename: continue if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] if filename.endswith("$py.class"): filename = filename[:-9] + ".py" if os.path.exists(filename): filenames.append(filename) return filenames def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local() def inotify_code_changed(): """ Checks for changed code using inotify. After being called it blocks until a change event has been fired. """ class EventHandler(pyinotify.ProcessEvent): modified_code = None def process_default(self, event): if event.path.endswith('.mo'): EventHandler.modified_code = I18N_MODIFIED else: EventHandler.modified_code = FILE_MODIFIED wm = pyinotify.WatchManager() notifier = pyinotify.Notifier(wm, EventHandler()) def update_watch(sender=None, **kwargs): if sender and getattr(sender, 'handles_files', False): # No need to update watches when request serves files. # (sender is supposed to be a django.core.handlers.BaseHandler subclass) return mask = ( pyinotify.IN_MODIFY | pyinotify.IN_DELETE | pyinotify.IN_ATTRIB | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO | pyinotify.IN_CREATE | pyinotify.IN_DELETE_SELF | pyinotify.IN_MOVE_SELF ) for path in gen_filenames(only_new=True): wm.add_watch(path, mask) # New modules may get imported when a request is processed. request_finished.connect(update_watch) # Block until an event happens. update_watch() notifier.check_events(timeout=None) notifier.read_events() notifier.process_events() notifier.stop() # If we are here the code must have changed. return EventHandler.modified_code def code_changed(): global _mtimes, _win for filename in gen_filenames(): stat = os.stat(filename) mtime = stat.st_mtime if _win: mtime -= stat.st_ctime if filename not in _mtimes: _mtimes[filename] = mtime continue if mtime != _mtimes[filename]: _mtimes = {} try: del _error_files[_error_files.index(filename)] except ValueError: pass return I18N_MODIFIED if filename.endswith('.mo') else FILE_MODIFIED return False def check_errors(fn): def wrapper(*args, **kwargs): try: fn(*args, **kwargs) except (ImportError, IndentationError, NameError, SyntaxError, TypeError, AttributeError): et, ev, tb = sys.exc_info() if getattr(ev, 'filename', None) is None: # get the filename from the last item in the stack filename = traceback.extract_tb(tb)[-1][0] else: filename = ev.filename if filename not in _error_files: _error_files.append(filename) raise return wrapper def ensure_echo_on(): if termios: fd = sys.stdin if fd.isatty(): attr_list = termios.tcgetattr(fd) if not attr_list[3] & termios.ECHO: attr_list[3] |= termios.ECHO if hasattr(signal, 'SIGTTOU'): old_handler = signal.signal(signal.SIGTTOU, signal.SIG_IGN) else: old_handler = None termios.tcsetattr(fd, termios.TCSANOW, attr_list) if old_handler is not None: signal.signal(signal.SIGTTOU, old_handler) def reloader_thread(): ensure_echo_on() if USE_INOTIFY: fn = inotify_code_changed else: fn = code_changed while RUN_RELOADER: change = fn() if change == FILE_MODIFIED: sys.exit(3) # force reload elif change == I18N_MODIFIED: reset_translations() time.sleep(1) def restart_with_reloader(): while True: args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv if sys.platform == "win32": args = ['"%s"' % arg for arg in args] new_environ = os.environ.copy() new_environ["RUN_MAIN"] = 'true' exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ) if exit_code != 3: return exit_code def python_reloader(main_func, args, kwargs): if os.environ.get("RUN_MAIN") == "true": thread.start_new_thread(main_func, args, kwargs) try: reloader_thread() except KeyboardInterrupt: pass else: try: exit_code = restart_with_reloader() if exit_code < 0: os.kill(os.getpid(), -exit_code) else: sys.exit(exit_code) except KeyboardInterrupt: pass def jython_reloader(main_func, args, kwargs): from _systemrestart import SystemRestart thread.start_new_thread(main_func, args) while True: if code_changed(): raise SystemRestart time.sleep(1) def main(main_func, args=None, kwargs=None): if args is None: args = () if kwargs is None: kwargs = {} if sys.platform.startswith('java'): reloader = jython_reloader else: reloader = python_reloader wrapped_main_func = check_errors(main_func) reloader(wrapped_main_func, args, kwargs)
gpl-3.0
[ 3, 27722, 720, 8786, 28757, 14, 199, 3, 699, 19598, 379, 687, 22912, 869, 638, 436, 314, 30992, 27794, 2199, 334, 1014, 921, 1544, 14, 23438, 14, 1308, 680, 199, 3, 6601, 9394, 687, 473, 290, 699, 2000, 316, 1159, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 15, 680, 199, 3, 199, 3, 20825, 4248, 334, 67, 9, 8353, 12, 30992, 27794, 11682, 334, 5969, 32, 23438, 14, 1308, 9, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 755, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 30992, 27794, 11682, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 755, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 755, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 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, 3, 19503, 16306, 658, 25893, 64, 687, 642, 2559, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 4673, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 10458, 492, 1056, 63, 8669, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 485, 2671, 465, 2462, 199, 199, 3, 961, 492, 1630, 6548, 12, 1325, 652, 1159, 5784, 370, 5126, 2005, 21209, 3704, 199, 3, 315, 314, 5796, 859, 14, 1666, 1455, 921, 600, 14, 14013, 14, 957, 15, 9201, 15, 10034, 16, 1275, 199, 893, 26, 272, 492, 5796, 221, 327, 20432, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 28725, 199, 2590, 3545, 26, 272, 28725, 275, 488, 199, 199, 4701, 63, 568, 1387, 13367, 275, 756, 199, 893, 26, 272, 327, 1379, 3775, 315, 79, 3338, 365, 5223, 436, 12060, 370, 1736, 272, 492, 1134, 10175, 3338, 339, 6111, 275, 1134, 10175, 3338, 14, 568, 79, 3338, 4590, 14, 981, 1252, 10175, 3338, 63, 826, 342, 272, 340, 6111, 2356, 378, 26, 267, 4815, 63, 568, 1387, 13367, 275, 715, 267, 747, 14, 1600, 8, 2592, 9, 199, 2590, 3545, 26, 272, 986, 199, 199, 9390, 63, 907, 7405, 540, 275, 715, 199, 199, 3817, 63, 30389, 275, 413, 199, 41, 1085, 46, 63, 30389, 275, 499, 199, 199, 63, 77, 4508, 275, 1052, 199, 63, 2676, 275, 334, 1274, 14, 3246, 508, 298, 2676, 708, 531, 199, 199, 63, 705, 63, 1725, 275, 942, 199, 63, 5245, 63, 3112, 275, 663, 342, 199, 63, 5245, 63, 10309, 275, 942, 421, 199, 318, 3805, 63, 10309, 8, 2118, 63, 1222, 29, 797, 304, 272, 408, 272, 1803, 282, 769, 402, 6203, 11812, 315, 984, 14, 3112, 436, 7761, 272, 1584, 14, 272, 408, 272, 327, 653, 14, 34, 14, 1124, 513, 29195, 9719, 365, 4346, 12, 2952, 642, 7858, 315, 9861, 543, 272, 327, 4223, 1233, 1314, 5594, 506, 8567, 1958, 1124, 1274, 14, 3112, 4542, 436, 642, 911, 272, 327, 2449, 543, 6064, 26, 3913, 31173, 2600, 1830, 25012, 272, 2288, 485, 5245, 63, 3112, 12, 485, 5245, 63, 10309, 272, 859, 63, 1459, 275, 663, 8, 1274, 14, 3112, 14, 1459, 1012, 272, 485, 5245, 63, 10309, 275, 3633, 63, 1725, 1547, 5245, 63, 10309, 9, 272, 340, 485, 5245, 63, 3112, 508, 859, 63, 1459, 26, 267, 327, 3091, 4493, 315, 859, 769, 12, 3974, 13, 18516, 314, 805, 267, 340, 1454, 63, 1222, 26, 288, 372, 942, 267, 587, 26, 288, 372, 485, 5245, 63, 10309, 339, 892, 63, 3112, 275, 859, 63, 1459, 446, 485, 5245, 63, 3112, 272, 892, 63, 10309, 275, 3633, 63, 1725, 8, 267, 359, 1501, 855, 493, 363, 367, 1788, 315, 892, 63, 3112, 268, 340, 2688, 8, 1501, 12, 2560, 493, 363, 2023, 339, 340, 440, 485, 5245, 63, 10309, 436, 2202, 14, 4701, 63, 41, 1085, 46, 26, 267, 327, 2654, 314, 1561, 402, 314, 1275, 573, 1584, 626, 883, 506, 4046, 267, 327, 701, 6555, 3431, 10041, 1414, 370, 314, 769, 402, 1584, 9626, 379, 14, 267, 1300, 3220, 275, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 639, 283, 2190, 297, 283, 5508, 659, 490, 283, 5508, 418, 267, 367, 1145, 63, 888, 315, 10822, 8, 513, 8, 5181, 14, 362, 63, 571, 63, 7532, 28256, 288, 1300, 3220, 14, 740, 8, 736, 14, 515, 14, 904, 8, 571, 63, 888, 14, 515, 12, 283, 5508, 1333, 267, 1300, 3220, 14, 2880, 8, 1751, 14, 20828, 63, 20202, 9, 267, 1300, 3220, 275, 359, 736, 14, 515, 14, 4832, 8, 12484, 9, 367, 19380 ]
[ 27722, 720, 8786, 28757, 14, 199, 3, 699, 19598, 379, 687, 22912, 869, 638, 436, 314, 30992, 27794, 2199, 334, 1014, 921, 1544, 14, 23438, 14, 1308, 680, 199, 3, 6601, 9394, 687, 473, 290, 699, 2000, 316, 1159, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 15, 680, 199, 3, 199, 3, 20825, 4248, 334, 67, 9, 8353, 12, 30992, 27794, 11682, 334, 5969, 32, 23438, 14, 1308, 9, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 755, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 755, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 30992, 27794, 11682, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 755, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 755, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 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, 3, 19503, 16306, 658, 25893, 64, 687, 642, 2559, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 4673, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 10458, 492, 1056, 63, 8669, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 485, 2671, 465, 2462, 199, 199, 3, 961, 492, 1630, 6548, 12, 1325, 652, 1159, 5784, 370, 5126, 2005, 21209, 3704, 199, 3, 315, 314, 5796, 859, 14, 1666, 1455, 921, 600, 14, 14013, 14, 957, 15, 9201, 15, 10034, 16, 1275, 199, 893, 26, 272, 492, 5796, 221, 327, 20432, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 28725, 199, 2590, 3545, 26, 272, 28725, 275, 488, 199, 199, 4701, 63, 568, 1387, 13367, 275, 756, 199, 893, 26, 272, 327, 1379, 3775, 315, 79, 3338, 365, 5223, 436, 12060, 370, 1736, 272, 492, 1134, 10175, 3338, 339, 6111, 275, 1134, 10175, 3338, 14, 568, 79, 3338, 4590, 14, 981, 1252, 10175, 3338, 63, 826, 342, 272, 340, 6111, 2356, 378, 26, 267, 4815, 63, 568, 1387, 13367, 275, 715, 267, 747, 14, 1600, 8, 2592, 9, 199, 2590, 3545, 26, 272, 986, 199, 199, 9390, 63, 907, 7405, 540, 275, 715, 199, 199, 3817, 63, 30389, 275, 413, 199, 41, 1085, 46, 63, 30389, 275, 499, 199, 199, 63, 77, 4508, 275, 1052, 199, 63, 2676, 275, 334, 1274, 14, 3246, 508, 298, 2676, 708, 531, 199, 199, 63, 705, 63, 1725, 275, 942, 199, 63, 5245, 63, 3112, 275, 663, 342, 199, 63, 5245, 63, 10309, 275, 942, 421, 199, 318, 3805, 63, 10309, 8, 2118, 63, 1222, 29, 797, 304, 272, 408, 272, 1803, 282, 769, 402, 6203, 11812, 315, 984, 14, 3112, 436, 7761, 272, 1584, 14, 272, 408, 272, 327, 653, 14, 34, 14, 1124, 513, 29195, 9719, 365, 4346, 12, 2952, 642, 7858, 315, 9861, 543, 272, 327, 4223, 1233, 1314, 5594, 506, 8567, 1958, 1124, 1274, 14, 3112, 4542, 436, 642, 911, 272, 327, 2449, 543, 6064, 26, 3913, 31173, 2600, 1830, 25012, 272, 2288, 485, 5245, 63, 3112, 12, 485, 5245, 63, 10309, 272, 859, 63, 1459, 275, 663, 8, 1274, 14, 3112, 14, 1459, 1012, 272, 485, 5245, 63, 10309, 275, 3633, 63, 1725, 1547, 5245, 63, 10309, 9, 272, 340, 485, 5245, 63, 3112, 508, 859, 63, 1459, 26, 267, 327, 3091, 4493, 315, 859, 769, 12, 3974, 13, 18516, 314, 805, 267, 340, 1454, 63, 1222, 26, 288, 372, 942, 267, 587, 26, 288, 372, 485, 5245, 63, 10309, 339, 892, 63, 3112, 275, 859, 63, 1459, 446, 485, 5245, 63, 3112, 272, 892, 63, 10309, 275, 3633, 63, 1725, 8, 267, 359, 1501, 855, 493, 363, 367, 1788, 315, 892, 63, 3112, 268, 340, 2688, 8, 1501, 12, 2560, 493, 363, 2023, 339, 340, 440, 485, 5245, 63, 10309, 436, 2202, 14, 4701, 63, 41, 1085, 46, 26, 267, 327, 2654, 314, 1561, 402, 314, 1275, 573, 1584, 626, 883, 506, 4046, 267, 327, 701, 6555, 3431, 10041, 1414, 370, 314, 769, 402, 1584, 9626, 379, 14, 267, 1300, 3220, 275, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 639, 283, 2190, 297, 283, 5508, 659, 490, 283, 5508, 418, 267, 367, 1145, 63, 888, 315, 10822, 8, 513, 8, 5181, 14, 362, 63, 571, 63, 7532, 28256, 288, 1300, 3220, 14, 740, 8, 736, 14, 515, 14, 904, 8, 571, 63, 888, 14, 515, 12, 283, 5508, 1333, 267, 1300, 3220, 14, 2880, 8, 1751, 14, 20828, 63, 20202, 9, 267, 1300, 3220, 275, 359, 736, 14, 515, 14, 4832, 8, 12484, 9, 367, 19380, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
craigcitro/gsutil
gslib/addlhelp/encoding.py
23
5302
# -*- coding: utf-8 -*- # Copyright 2014 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Additional help about CRC32C and installing crcmod.""" from __future__ import absolute_import from gslib.help_provider import HelpProvider _DETAILED_HELP_TEXT = (""" <B>OVERVIEW</B> To minimize the chance for `filename encoding interoperability problems <https://en.wikipedia.org/wiki/Filename#Encoding_indication_interoperability>`_ gsutil requires use of the `UTF-8 <https://en.wikipedia.org/wiki/UTF-8>`_ character encoding when uploading and downloading files. Because UTF-8 is in widespread (and growing) use, for most users nothing needs to be done to use UTF-8. Users with files stored in other encodings (such as `Latin 1 <https://en.wikipedia.org/wiki/ISO/IEC_8859-1>`_) must convert those filenames to UTF-8 before attempting to upload the files. The most common place where users who have filenames that use some other encoding encounter a gsutil error is while uploading files using the recursive (-R) option on the gsutil cp , mv, or rsync commands. When this happens you'll get an error like this: CommandException: Invalid Unicode path encountered ('dir1/dir2/file_name_with_\\xf6n_bad_chars'). gsutil cannot proceed with such files present. Please remove or rename this file and try again. Note that the invalid Unicode characters have been hex-encoded in this error message because otherwise trying to print them would result in another error. If you encounter such an error you can either remove the problematic file(s) or try to rename them and re-run the command. If you have a modest number of such files the simplest thing to do is to think of a different name for the file and manually rename the file (using local filesystem tools). If you have too many files for that to be practical you can use a tool to convert the old character encoding to UTF-8. One such tool is `native2ascii <http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/native2ascii.html>`_. Note also that there's no restriction on the character encoding used in file content - it can be UTF-8, a different encoding, or non-character data (like audio or video content). The gsutil UTF-8 character encoding requirement applies only to filenames. <B>CROSS-PLATFORM ENCODING PROBLEMS OF WHICH TO BE AWARE</B> Using UTF-8 for all object names and filenames will ensure that gsutil doesn't encounter character encoding errors while operating on the files. Unfortunately, it's still possible that files uploaded / downloaded this way can have interoperability problems, for a number of reasons unrelated to gsutil. For example: - Windows filenames are case-insensitive, while GCS, Linux and MacOS are not. Thus, for example, if you have two filenames on Linux differing only in case and upload both to GCS and then subsequently download them to Windows, you will end up with just one file whose contents came from the last of these files to be written to the filesystem. Moreover, case translation is handled by tables that change across OS versions. - Mac OS performs character encoding decomposition based on tables stored in the OS, and the tables change between Unicode versions. Thus the encoding used by an external library may not match that performed by the the OS. - Windows console support for Unicode is difficult to use correctly. For a more thorough list of such issues see `this presentation <http://www.i18nguy.com/unicode/filename-issues-iuc33.pdf>`_ These problems mostly arise when sharing data across platforms (e.g., uploading data from a Windows machine to GCS, and then downloading from GCS to a machine running MacOS). Unfortunately these problems are a consequence of the lack of a filename encoding standard, and users need to be aware of the kinds of problems that can arise when copying filenames across platforms. There is one precaution users can exercise to prevent some of these problems: When using the Windows console specify wildcards or folders (using the -R option) rather than explicitly named individual files. """) class CommandOptions(HelpProvider): """Additional help about filename encoding and interoperability problems.""" # Help specification. See help_provider.py for documentation. help_spec = HelpProvider.HelpSpec( help_name='encoding', help_name_aliases=['encodings', 'utf8', 'utf-8', 'latin1', 'unicode', 'interoperability'], help_type='additional_help', help_one_line_summary='Filename encoding and interoperability problems', help_text=_DETAILED_HELP_TEXT, subcommand_help_text={}, )
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 8824, 1720, 3595, 26658, 708, 35, 436, 22200, 18080, 1494, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 29563, 14, 3437, 63, 3780, 492, 15456, 6663, 199, 199, 63, 17442, 25349, 63, 17930, 63, 3876, 275, 334, 624, 199, 28, 34, 30, 14336, 12058, 1108, 34, 30, 523, 4005, 24720, 314, 22044, 367, 658, 1501, 2644, 4661, 9198, 3616, 8826, 523, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 8117, 3, 7630, 63, 3558, 1063, 63, 5707, 9198, 3616, 18740, 16421, 24986, 5074, 675, 402, 314, 658, 6610, 13, 24, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 6610, 13, 24, 18740, 523, 4528, 2644, 1380, 24349, 436, 25937, 1584, 14, 13821, 9094, 13, 24, 365, 315, 523, 20239, 29889, 334, 460, 20772, 316, 9, 675, 12, 367, 4750, 4390, 6548, 4839, 370, 506, 4224, 370, 675, 523, 9094, 13, 24, 14, 20123, 543, 1584, 5489, 315, 1163, 14134, 334, 10180, 465, 523, 658, 27317, 413, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 7336, 15, 41, 4220, 63, 4830, 13, 17, 8637, 4602, 1471, 3957, 5204, 523, 6203, 370, 9094, 13, 24, 2544, 19595, 370, 5802, 314, 1584, 14, 221, 819, 710, 4750, 2863, 4192, 2382, 4390, 3963, 1172, 6203, 626, 675, 2005, 1163, 523, 2644, 655, 5337, 282, 24986, 1125, 365, 1830, 24349, 1584, 1808, 314, 9133, 523, 5868, 50, 9, 945, 641, 314, 24986, 7667, 2360, 15413, 12, 503, 27633, 3718, 14, 3979, 642, 10986, 1265, 7171, 523, 664, 376, 1125, 2839, 642, 26, 2541, 5817, 1726, 26, 6378, 6140, 931, 14556, 489, 661, 694, 17, 15, 694, 18, 15, 493, 63, 354, 63, 1045, 63, 1103, 1949, 22, 78, 63, 4087, 63, 6574, 1959, 489, 24986, 3913, 20320, 543, 4066, 1584, 3451, 14, 489, 7754, 2813, 503, 11441, 642, 570, 436, 862, 4020, 14, 819, 3390, 626, 314, 3866, 6140, 4110, 1172, 2757, 6318, 13, 8167, 315, 642, 1125, 523, 1245, 2952, 4257, 9936, 370, 870, 3062, 3955, 754, 315, 4573, 523, 1125, 14, 819, 982, 1265, 655, 5337, 4066, 376, 1125, 1265, 883, 1902, 2813, 314, 557, 31197, 570, 8, 83, 9, 523, 503, 862, 370, 11441, 3062, 436, 295, 13, 1065, 314, 1414, 14, 982, 1265, 1172, 282, 818, 270, 1329, 402, 523, 4066, 1584, 314, 3486, 270, 8377, 370, 886, 365, 370, 13516, 402, 282, 3365, 536, 367, 314, 523, 570, 436, 10250, 11441, 314, 570, 334, 4941, 2257, 10036, 7249, 680, 982, 1265, 1172, 523, 4634, 5002, 1584, 367, 626, 370, 506, 20594, 3294, 1265, 883, 675, 282, 4744, 370, 3957, 314, 2269, 523, 4528, 2644, 370, 9094, 13, 24, 14, 7309, 4066, 4744, 365, 658, 6106, 18, 4371, 523, 665, 1014, 921, 4757, 14, 16404, 14, 957, 15, 30738, 482, 15, 23, 15, 4757, 15, 15970, 5983, 15, 2537, 15, 7873, 4663, 15, 6106, 18, 4371, 14, 1360, 8637, 3754, 819, 3390, 2597, 626, 2337, 1159, 949, 10588, 641, 314, 4528, 2644, 1202, 315, 570, 523, 1564, 446, 652, 883, 506, 9094, 13, 24, 12, 282, 3365, 2644, 12, 503, 2222, 13, 10856, 523, 666, 334, 2930, 10491, 503, 3991, 1564, 680, 710, 24986, 9094, 13, 24, 4528, 2644, 523, 10685, 12966, 1454, 370, 6203, 14, 421, 199, 28, 34, 30, 28368, 13, 17805, 5070, 14878, 3611, 34, 906, 3053, 1634, 5732, 948, 40, 2296, 6262, 437, 3695, 1108, 34, 30, 523, 11719, 9094, 13, 24, 367, 1006, 909, 1561, 436, 6203, 911, 4868, 626, 24986, 3181, 1133, 523, 655, 5337, 4528, 2644, 2552, 1830, 17406, 641, 314, 1584, 14, 523, 31076, 12, 652, 1159, 5139, 3962, 626, 1584, 14238, 1182, 13557, 642, 4340, 523, 883, 1172, 4661, 9198, 3616, 8826, 12, 367, 282, 1329, 402, 14872, 625, 2407, 370, 523, 24986, 14, 2104, 2893, 26, 339, 446, 5417, 6203, 787, 1930, 13, 15851, 12, 1830, 598, 3298, 12, 10130, 436, 10444, 3100, 787, 489, 440, 14, 20227, 12, 367, 2893, 12, 340, 1265, 1172, 2877, 6203, 641, 10130, 28488, 1454, 489, 315, 1930, 436, 5802, 3865, 370, 598, 3298, 436, 2066, 13372, 590, 5235, 3062, 370, 489, 5417, 12, 1265, 911, 1284, 1536, 543, 2951, 1373, 570, 7447, 4072, 20382, 687, 314, 489, 2061, 402, 3520, 1584, 370, 506, 5313, 370, 314, 10036, 14, 16917, 1883, 12, 1930, 489, 7761, 365, 8860, 701, 6716, 626, 1570, 9371, 4403, 5459, 14, 272, 446, 10444, 4403, 18628, 4528, 2644, 22706, 4079, 641, 6716, 5489, 315, 489, 314, 4403, 12, 436, 314, 6716, 1570, 3382, 6140, 5459, 14, 20227, 314, 2644, 489, 1202, 701, 376, 5957, 3555, 1443, 440, 1336, 626, 10585, 701, 314, 314, 4403, 14, 272, 446, 5417, 8559, 2291, 367, 6140, 365, 29870, 370, 675, 6657, 14, 819, 2104, 282, 1655, 294, 269, 4937, 769, 402, 4066, 10876, 1937, 658, 3749, 3451, 425, 523, 665, 1014, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 1501, 13, 10115, 13, 73, 947, 1153, 14, 5607, 18740, 819, 5723, 8826, 19762, 14554, 261, 1380, 26994, 666, 9371, 10677, 334, 69, 14, 71, 2020, 523, 24349, 666, 687, 282, 5417, 6844, 370, 598, 3298, 12, 436, 2066, 25937, 687, 598, 3298, 523, 370, 282, 6844, 3879, 10444, 3100, 680, 31076, 3520, 8826, 787, 282, 406, 4041, 523 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 624, 8824, 1720, 3595, 26658, 708, 35, 436, 22200, 18080, 1494, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 29563, 14, 3437, 63, 3780, 492, 15456, 6663, 199, 199, 63, 17442, 25349, 63, 17930, 63, 3876, 275, 334, 624, 199, 28, 34, 30, 14336, 12058, 1108, 34, 30, 523, 4005, 24720, 314, 22044, 367, 658, 1501, 2644, 4661, 9198, 3616, 8826, 523, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 8117, 3, 7630, 63, 3558, 1063, 63, 5707, 9198, 3616, 18740, 16421, 24986, 5074, 675, 402, 314, 658, 6610, 13, 24, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 6610, 13, 24, 18740, 523, 4528, 2644, 1380, 24349, 436, 25937, 1584, 14, 13821, 9094, 13, 24, 365, 315, 523, 20239, 29889, 334, 460, 20772, 316, 9, 675, 12, 367, 4750, 4390, 6548, 4839, 370, 506, 4224, 370, 675, 523, 9094, 13, 24, 14, 20123, 543, 1584, 5489, 315, 1163, 14134, 334, 10180, 465, 523, 658, 27317, 413, 665, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 7336, 15, 41, 4220, 63, 4830, 13, 17, 8637, 4602, 1471, 3957, 5204, 523, 6203, 370, 9094, 13, 24, 2544, 19595, 370, 5802, 314, 1584, 14, 221, 819, 710, 4750, 2863, 4192, 2382, 4390, 3963, 1172, 6203, 626, 675, 2005, 1163, 523, 2644, 655, 5337, 282, 24986, 1125, 365, 1830, 24349, 1584, 1808, 314, 9133, 523, 5868, 50, 9, 945, 641, 314, 24986, 7667, 2360, 15413, 12, 503, 27633, 3718, 14, 3979, 642, 10986, 1265, 7171, 523, 664, 376, 1125, 2839, 642, 26, 2541, 5817, 1726, 26, 6378, 6140, 931, 14556, 489, 661, 694, 17, 15, 694, 18, 15, 493, 63, 354, 63, 1045, 63, 1103, 1949, 22, 78, 63, 4087, 63, 6574, 1959, 489, 24986, 3913, 20320, 543, 4066, 1584, 3451, 14, 489, 7754, 2813, 503, 11441, 642, 570, 436, 862, 4020, 14, 819, 3390, 626, 314, 3866, 6140, 4110, 1172, 2757, 6318, 13, 8167, 315, 642, 1125, 523, 1245, 2952, 4257, 9936, 370, 870, 3062, 3955, 754, 315, 4573, 523, 1125, 14, 819, 982, 1265, 655, 5337, 4066, 376, 1125, 1265, 883, 1902, 2813, 314, 557, 31197, 570, 8, 83, 9, 523, 503, 862, 370, 11441, 3062, 436, 295, 13, 1065, 314, 1414, 14, 982, 1265, 1172, 282, 818, 270, 1329, 402, 523, 4066, 1584, 314, 3486, 270, 8377, 370, 886, 365, 370, 13516, 402, 282, 3365, 536, 367, 314, 523, 570, 436, 10250, 11441, 314, 570, 334, 4941, 2257, 10036, 7249, 680, 982, 1265, 1172, 523, 4634, 5002, 1584, 367, 626, 370, 506, 20594, 3294, 1265, 883, 675, 282, 4744, 370, 3957, 314, 2269, 523, 4528, 2644, 370, 9094, 13, 24, 14, 7309, 4066, 4744, 365, 658, 6106, 18, 4371, 523, 665, 1014, 921, 4757, 14, 16404, 14, 957, 15, 30738, 482, 15, 23, 15, 4757, 15, 15970, 5983, 15, 2537, 15, 7873, 4663, 15, 6106, 18, 4371, 14, 1360, 8637, 3754, 819, 3390, 2597, 626, 2337, 1159, 949, 10588, 641, 314, 4528, 2644, 1202, 315, 570, 523, 1564, 446, 652, 883, 506, 9094, 13, 24, 12, 282, 3365, 2644, 12, 503, 2222, 13, 10856, 523, 666, 334, 2930, 10491, 503, 3991, 1564, 680, 710, 24986, 9094, 13, 24, 4528, 2644, 523, 10685, 12966, 1454, 370, 6203, 14, 421, 199, 28, 34, 30, 28368, 13, 17805, 5070, 14878, 3611, 34, 906, 3053, 1634, 5732, 948, 40, 2296, 6262, 437, 3695, 1108, 34, 30, 523, 11719, 9094, 13, 24, 367, 1006, 909, 1561, 436, 6203, 911, 4868, 626, 24986, 3181, 1133, 523, 655, 5337, 4528, 2644, 2552, 1830, 17406, 641, 314, 1584, 14, 523, 31076, 12, 652, 1159, 5139, 3962, 626, 1584, 14238, 1182, 13557, 642, 4340, 523, 883, 1172, 4661, 9198, 3616, 8826, 12, 367, 282, 1329, 402, 14872, 625, 2407, 370, 523, 24986, 14, 2104, 2893, 26, 339, 446, 5417, 6203, 787, 1930, 13, 15851, 12, 1830, 598, 3298, 12, 10130, 436, 10444, 3100, 787, 489, 440, 14, 20227, 12, 367, 2893, 12, 340, 1265, 1172, 2877, 6203, 641, 10130, 28488, 1454, 489, 315, 1930, 436, 5802, 3865, 370, 598, 3298, 436, 2066, 13372, 590, 5235, 3062, 370, 489, 5417, 12, 1265, 911, 1284, 1536, 543, 2951, 1373, 570, 7447, 4072, 20382, 687, 314, 489, 2061, 402, 3520, 1584, 370, 506, 5313, 370, 314, 10036, 14, 16917, 1883, 12, 1930, 489, 7761, 365, 8860, 701, 6716, 626, 1570, 9371, 4403, 5459, 14, 272, 446, 10444, 4403, 18628, 4528, 2644, 22706, 4079, 641, 6716, 5489, 315, 489, 314, 4403, 12, 436, 314, 6716, 1570, 3382, 6140, 5459, 14, 20227, 314, 2644, 489, 1202, 701, 376, 5957, 3555, 1443, 440, 1336, 626, 10585, 701, 314, 314, 4403, 14, 272, 446, 5417, 8559, 2291, 367, 6140, 365, 29870, 370, 675, 6657, 14, 819, 2104, 282, 1655, 294, 269, 4937, 769, 402, 4066, 10876, 1937, 658, 3749, 3451, 425, 523, 665, 1014, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 1501, 13, 10115, 13, 73, 947, 1153, 14, 5607, 18740, 819, 5723, 8826, 19762, 14554, 261, 1380, 26994, 666, 9371, 10677, 334, 69, 14, 71, 2020, 523, 24349, 666, 687, 282, 5417, 6844, 370, 598, 3298, 12, 436, 2066, 25937, 687, 598, 3298, 523, 370, 282, 6844, 3879, 10444, 3100, 680, 31076, 3520, 8826, 787, 282, 406, 4041, 523, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rschmidtz/cloudtunes
cloudtunes-server/cloudtunes/services/dropbox/sync.py
14
3394
import os import datetime from operator import itemgetter from itertools import groupby from celery.utils.log import get_task_logger from cloudtunes.users.models import User from cloudtunes.library.models import Track from cloudtunes.worker import celery from .id3 import get_id3 from .client import Client from .models import DropboxTrack logger = get_task_logger(__name__) @celery.task def sync_account(account_id): """ https://www.dropbox.com/developers/reference/api#delta """ try: user = User.objects.get(dropbox__id=account_id) except User.DoesNotExist: logger.warning('Dropbox account not found: %s', account_id) return client = Client.for_account(user.dropbox) while True: logger.info('getting delta for cursor=%s', user.dropbox.delta_cursor) delta = client.delta(cursor=user.dropbox.delta_cursor) entries = [] logger.info( 'got delta: reset=%r; has_more=%r; len(entries)=%d; cursor=%r', delta['reset'], delta['has_more'], len(delta['entries']), delta['cursor'] ) if delta['reset']: Track.objects.filter(user=user.pk, source='dropbox').delete() user.emit('sync', 'dropbox:reset') for path, meta in delta['entries']: if meta and meta.get('mime_type', None) != 'audio/mpeg': logger.info('not a song, skipping: %s', meta) continue do_delete = not meta entries.append((path, do_delete)) user.dropbox.delta_cursor = delta['cursor'] entries.sort(key=itemgetter(0)) folders = groupby(entries, lambda entry: os.path.dirname(entry[0])) for folder, entries in folders: for path, do_delete in entries: sync_track.delay(account_id, path, do_delete) if not delta['has_more']: break user.dropbox.synced = datetime.datetime.utcnow() user.save() user.emit_change() @celery.task(ack_late=True, retry=3) def sync_track(account_id, path, do_delete): logger.info('updating path=%r; do_delete=%r', path, do_delete) try: user = User.objects.get(dropbox__id=account_id) except User.DoesNotExist: logger.warning('dropbox account not found: %s; bailing out', account_id) return client = Client.for_account(user.dropbox) try: id3 = get_id3(client, path, title=os.path.basename(path)) except Exception: logger.exception('could not get tags') return logger.debug('id3 dict=%r', id3) if not id3: return try: track = Track.objects.get(user=user.pk, dropbox__path=path) except Track.DoesNotExist: if do_delete: logger.warning('track %s already deleted', path) return track = Track() action = 'add' else: if do_delete: logger.info('deleting track %s @ %s', track.id, path) track.delete() user.emit('sync', 'track:remove', str(track.id)) return else: action = 'update' track.update_fields( user=user, source='dropbox', dropbox=DropboxTrack(path=path), **id3 ) track.save() user.emit('sync', 'track:' + action, track.to_json()) logger.info('track %s @ %s saved', track.id, path)
bsd-3-clause
[ 646, 747, 199, 646, 2197, 199, 504, 4182, 492, 1242, 7416, 199, 504, 7975, 492, 20371, 199, 199, 504, 22748, 14, 1208, 14, 793, 492, 664, 63, 1765, 63, 2921, 199, 199, 504, 8002, 10032, 397, 14, 3707, 14, 992, 492, 2876, 199, 504, 8002, 10032, 397, 14, 4342, 14, 992, 492, 17507, 199, 504, 8002, 10032, 397, 14, 6599, 492, 22748, 199, 504, 1275, 344, 19, 492, 664, 63, 344, 19, 199, 504, 1275, 1258, 492, 6810, 199, 504, 1275, 992, 492, 18110, 1977, 7927, 421, 199, 2921, 275, 664, 63, 1765, 63, 2921, 3460, 354, 3368, 421, 199, 32, 23593, 14, 1765, 199, 318, 7604, 63, 2048, 8, 2048, 63, 344, 304, 272, 408, 339, 4178, 921, 1544, 14, 32118, 14, 957, 15, 23826, 15, 4443, 15, 1246, 3, 3136, 339, 408, 272, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 32118, 363, 344, 29, 2048, 63, 344, 9, 272, 871, 2876, 14, 7400, 26, 267, 2512, 14, 3764, 360, 11070, 1977, 2933, 440, 1911, 26, 450, 83, 297, 2933, 63, 344, 9, 267, 372, 339, 1890, 275, 6810, 14, 509, 63, 2048, 8, 751, 14, 32118, 9, 339, 1830, 715, 26, 398, 2512, 14, 815, 360, 362, 1337, 5762, 367, 3920, 2458, 83, 297, 922, 14, 32118, 14, 3136, 63, 3937, 9, 398, 5762, 275, 1890, 14, 3136, 8, 3937, 29, 751, 14, 32118, 14, 3136, 63, 3937, 9, 267, 4811, 275, 942, 398, 2512, 14, 815, 8, 288, 283, 7808, 5762, 26, 5305, 2458, 82, 27, 965, 63, 6878, 2458, 82, 27, 822, 8, 3189, 9, 2458, 68, 27, 3920, 2458, 82, 297, 288, 5762, 459, 3958, 995, 5762, 459, 1989, 63, 6878, 995, 288, 822, 8, 3136, 459, 3189, 3815, 5762, 459, 3937, 418, 267, 776, 398, 340, 5762, 459, 3958, 2565, 288, 17507, 14, 1462, 14, 1541, 8, 751, 29, 751, 14, 2051, 12, 1350, 534, 32118, 1959, 1807, 342, 288, 922, 14, 8159, 360, 5186, 297, 283, 32118, 26, 3958, 358, 398, 367, 931, 12, 3404, 315, 5762, 459, 3189, 2565, 288, 340, 3404, 436, 3404, 14, 362, 360, 7626, 63, 466, 297, 488, 9, 1137, 283, 8130, 15, 16801, 356, 355, 2512, 14, 815, 360, 1397, 282, 20178, 12, 16068, 26, 450, 83, 297, 3404, 9, 355, 1980, 288, 886, 63, 1807, 275, 440, 3404, 288, 4811, 14, 740, 1332, 515, 12, 886, 63, 1807, 430, 398, 922, 14, 32118, 14, 3136, 63, 3937, 275, 5762, 459, 3937, 418, 398, 4811, 14, 3191, 8, 498, 29, 20832, 8, 16, 430, 267, 16533, 275, 20371, 8, 3189, 12, 2400, 2397, 26, 747, 14, 515, 14, 3475, 8, 2373, 59, 16, 2459, 267, 367, 4922, 12, 4811, 315, 16533, 26, 288, 367, 931, 12, 886, 63, 1807, 315, 4811, 26, 355, 7604, 63, 3885, 14, 5814, 8, 2048, 63, 344, 12, 931, 12, 886, 63, 1807, 9, 398, 340, 440, 5762, 459, 1989, 63, 6878, 2565, 288, 2059, 339, 922, 14, 32118, 14, 9466, 6867, 275, 2197, 14, 2083, 14, 10779, 342, 272, 922, 14, 2117, 342, 272, 922, 14, 8159, 63, 1461, 342, 421, 199, 32, 23593, 14, 1765, 8, 564, 63, 750, 29, 549, 12, 7269, 29, 19, 9, 199, 318, 7604, 63, 3885, 8, 2048, 63, 344, 12, 931, 12, 886, 63, 1807, 304, 339, 2512, 14, 815, 360, 28669, 931, 2458, 82, 27, 886, 63, 1807, 2458, 82, 297, 931, 12, 886, 63, 1807, 9, 339, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 32118, 363, 344, 29, 2048, 63, 344, 9, 272, 871, 2876, 14, 7400, 26, 267, 2512, 14, 3764, 360, 32118, 2933, 440, 1911, 26, 450, 83, 27, 31571, 316, 734, 297, 2933, 63, 344, 9, 267, 372, 339, 1890, 275, 6810, 14, 509, 63, 2048, 8, 751, 14, 32118, 9, 339, 862, 26, 267, 1305, 19, 275, 664, 63, 344, 19, 8, 1258, 12, 931, 12, 2538, 29, 736, 14, 515, 14, 4846, 8, 515, 430, 272, 871, 2186, 26, 267, 2512, 14, 1971, 360, 15153, 440, 664, 3762, 358, 267, 372, 339, 2512, 14, 1757, 360, 344, 19, 1211, 2458, 82, 297, 1305, 19, 9, 339, 340, 440, 1305, 19, 26, 267, 372, 339, 862, 26, 267, 4426, 275, 17507, 14, 1462, 14, 362, 8, 751, 29, 751, 14, 2051, 12, 5978, 1977, 363, 515, 29, 515, 9, 272, 871, 17507, 14, 7400, 26, 267, 340, 886, 63, 1807, 26, 288, 2512, 14, 3764, 360, 3885, 450, 83, 2575, 5463, 297, 931, 9, 288, 372, 267, 4426, 275, 17507, 342, 267, 1595, 275, 283, 525, 7, 272, 587, 26, 267, 340, 886, 63, 1807, 26, 288, 2512, 14, 815, 360, 7346, 1337, 4426, 450, 83, 768, 450, 83, 297, 4426, 14, 344, 12, 931, 9, 288, 4426, 14, 1807, 342, 288, 922, 14, 8159, 360, 5186, 297, 283, 3885, 26, 2168, 297, 620, 8, 3885, 14, 344, 430, 288, 372, 267, 587, 26, 288, 1595, 275, 283, 873, 7, 339, 4426, 14, 873, 63, 955, 8, 267, 922, 29, 751, 12, 267, 1350, 534, 32118, 297, 267, 5978, 1977, 29, 11070, 1977, 7927, 8, 515, 29, 515, 395, 267, 1011, 344, 19, 272, 776, 272, 4426, 14, 2117, 342, 272, 922, 14, 8159, 360, 5186, 297, 283, 3885, 4881, 435, 1595, 12, 4426, 14, 475, 63, 1001, 1012, 272, 2512, 14, 815, 360, 3885, 450, 83, 768, 450, 83, 6290, 297, 4426, 14, 344, 12, 931, 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 ]
[ 747, 199, 646, 2197, 199, 504, 4182, 492, 1242, 7416, 199, 504, 7975, 492, 20371, 199, 199, 504, 22748, 14, 1208, 14, 793, 492, 664, 63, 1765, 63, 2921, 199, 199, 504, 8002, 10032, 397, 14, 3707, 14, 992, 492, 2876, 199, 504, 8002, 10032, 397, 14, 4342, 14, 992, 492, 17507, 199, 504, 8002, 10032, 397, 14, 6599, 492, 22748, 199, 504, 1275, 344, 19, 492, 664, 63, 344, 19, 199, 504, 1275, 1258, 492, 6810, 199, 504, 1275, 992, 492, 18110, 1977, 7927, 421, 199, 2921, 275, 664, 63, 1765, 63, 2921, 3460, 354, 3368, 421, 199, 32, 23593, 14, 1765, 199, 318, 7604, 63, 2048, 8, 2048, 63, 344, 304, 272, 408, 339, 4178, 921, 1544, 14, 32118, 14, 957, 15, 23826, 15, 4443, 15, 1246, 3, 3136, 339, 408, 272, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 32118, 363, 344, 29, 2048, 63, 344, 9, 272, 871, 2876, 14, 7400, 26, 267, 2512, 14, 3764, 360, 11070, 1977, 2933, 440, 1911, 26, 450, 83, 297, 2933, 63, 344, 9, 267, 372, 339, 1890, 275, 6810, 14, 509, 63, 2048, 8, 751, 14, 32118, 9, 339, 1830, 715, 26, 398, 2512, 14, 815, 360, 362, 1337, 5762, 367, 3920, 2458, 83, 297, 922, 14, 32118, 14, 3136, 63, 3937, 9, 398, 5762, 275, 1890, 14, 3136, 8, 3937, 29, 751, 14, 32118, 14, 3136, 63, 3937, 9, 267, 4811, 275, 942, 398, 2512, 14, 815, 8, 288, 283, 7808, 5762, 26, 5305, 2458, 82, 27, 965, 63, 6878, 2458, 82, 27, 822, 8, 3189, 9, 2458, 68, 27, 3920, 2458, 82, 297, 288, 5762, 459, 3958, 995, 5762, 459, 1989, 63, 6878, 995, 288, 822, 8, 3136, 459, 3189, 3815, 5762, 459, 3937, 418, 267, 776, 398, 340, 5762, 459, 3958, 2565, 288, 17507, 14, 1462, 14, 1541, 8, 751, 29, 751, 14, 2051, 12, 1350, 534, 32118, 1959, 1807, 342, 288, 922, 14, 8159, 360, 5186, 297, 283, 32118, 26, 3958, 358, 398, 367, 931, 12, 3404, 315, 5762, 459, 3189, 2565, 288, 340, 3404, 436, 3404, 14, 362, 360, 7626, 63, 466, 297, 488, 9, 1137, 283, 8130, 15, 16801, 356, 355, 2512, 14, 815, 360, 1397, 282, 20178, 12, 16068, 26, 450, 83, 297, 3404, 9, 355, 1980, 288, 886, 63, 1807, 275, 440, 3404, 288, 4811, 14, 740, 1332, 515, 12, 886, 63, 1807, 430, 398, 922, 14, 32118, 14, 3136, 63, 3937, 275, 5762, 459, 3937, 418, 398, 4811, 14, 3191, 8, 498, 29, 20832, 8, 16, 430, 267, 16533, 275, 20371, 8, 3189, 12, 2400, 2397, 26, 747, 14, 515, 14, 3475, 8, 2373, 59, 16, 2459, 267, 367, 4922, 12, 4811, 315, 16533, 26, 288, 367, 931, 12, 886, 63, 1807, 315, 4811, 26, 355, 7604, 63, 3885, 14, 5814, 8, 2048, 63, 344, 12, 931, 12, 886, 63, 1807, 9, 398, 340, 440, 5762, 459, 1989, 63, 6878, 2565, 288, 2059, 339, 922, 14, 32118, 14, 9466, 6867, 275, 2197, 14, 2083, 14, 10779, 342, 272, 922, 14, 2117, 342, 272, 922, 14, 8159, 63, 1461, 342, 421, 199, 32, 23593, 14, 1765, 8, 564, 63, 750, 29, 549, 12, 7269, 29, 19, 9, 199, 318, 7604, 63, 3885, 8, 2048, 63, 344, 12, 931, 12, 886, 63, 1807, 304, 339, 2512, 14, 815, 360, 28669, 931, 2458, 82, 27, 886, 63, 1807, 2458, 82, 297, 931, 12, 886, 63, 1807, 9, 339, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 32118, 363, 344, 29, 2048, 63, 344, 9, 272, 871, 2876, 14, 7400, 26, 267, 2512, 14, 3764, 360, 32118, 2933, 440, 1911, 26, 450, 83, 27, 31571, 316, 734, 297, 2933, 63, 344, 9, 267, 372, 339, 1890, 275, 6810, 14, 509, 63, 2048, 8, 751, 14, 32118, 9, 339, 862, 26, 267, 1305, 19, 275, 664, 63, 344, 19, 8, 1258, 12, 931, 12, 2538, 29, 736, 14, 515, 14, 4846, 8, 515, 430, 272, 871, 2186, 26, 267, 2512, 14, 1971, 360, 15153, 440, 664, 3762, 358, 267, 372, 339, 2512, 14, 1757, 360, 344, 19, 1211, 2458, 82, 297, 1305, 19, 9, 339, 340, 440, 1305, 19, 26, 267, 372, 339, 862, 26, 267, 4426, 275, 17507, 14, 1462, 14, 362, 8, 751, 29, 751, 14, 2051, 12, 5978, 1977, 363, 515, 29, 515, 9, 272, 871, 17507, 14, 7400, 26, 267, 340, 886, 63, 1807, 26, 288, 2512, 14, 3764, 360, 3885, 450, 83, 2575, 5463, 297, 931, 9, 288, 372, 267, 4426, 275, 17507, 342, 267, 1595, 275, 283, 525, 7, 272, 587, 26, 267, 340, 886, 63, 1807, 26, 288, 2512, 14, 815, 360, 7346, 1337, 4426, 450, 83, 768, 450, 83, 297, 4426, 14, 344, 12, 931, 9, 288, 4426, 14, 1807, 342, 288, 922, 14, 8159, 360, 5186, 297, 283, 3885, 26, 2168, 297, 620, 8, 3885, 14, 344, 430, 288, 372, 267, 587, 26, 288, 1595, 275, 283, 873, 7, 339, 4426, 14, 873, 63, 955, 8, 267, 922, 29, 751, 12, 267, 1350, 534, 32118, 297, 267, 5978, 1977, 29, 11070, 1977, 7927, 8, 515, 29, 515, 395, 267, 1011, 344, 19, 272, 776, 272, 4426, 14, 2117, 342, 272, 922, 14, 8159, 360, 5186, 297, 283, 3885, 4881, 435, 1595, 12, 4426, 14, 475, 63, 1001, 1012, 272, 2512, 14, 815, 360, 3885, 450, 83, 768, 450, 83, 6290, 297, 4426, 14, 344, 12, 931, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
felixbuenemann/sentry
src/sentry/web/decorators.py
25
9447
from __future__ import absolute_import import logging import warnings from functools import wraps from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponse from django.shortcuts import get_object_or_404 from sudo.decorators import sudo_required from sentry.constants import MEMBER_OWNER from sentry.models import Organization, Project, Team, Group from sentry.web.helpers import ( render_to_response, get_login_url) def has_access(access_or_func=None, organization=None, access=None): """ Tests and transforms project_id for permissions based on the requesting user. Passes the actual project instance to the decorated view. The default permission scope is 'user', which allows both 'user' and 'owner' access, but not 'system agent'. >>> @has_access(MEMBER_OWNER) >>> def foo(request, project): >>> return >>> @has_access >>> def foo(request, project): >>> return """ # TODO(dcramer): this code is far too hacky these days and should # be replaced with class based views if callable(access_or_func): return has_access(None)(access_or_func) access = access_or_func def wrapped(func): warnings.warn( '%s.%s is used deprecated @has_access' % (func.__module__, func.__name__), DeprecationWarning) @wraps(func) def _wrapped(request, *args, **kwargs): # All requests require authentication if not request.user.is_authenticated(): request.session['_next'] = request.get_full_path() if request.is_ajax(): return HttpResponse(status=401) if 'organization_slug' in kwargs: redirect_uri = reverse('sentry-auth-organization', args=[kwargs['organization_slug']]) else: redirect_uri = get_login_url() return HttpResponseRedirect(redirect_uri) has_org = 'organization_slug' in kwargs has_team = 'team_slug' in kwargs has_project = 'project_id' in kwargs organization_slug = kwargs.pop('organization_slug', None) team_slug = kwargs.pop('team_slug', None) project_id = kwargs.pop('project_id', None) assert not has_team or has_org, \ 'Must pass organization_slug with team_slug' if organization_slug: if not request.user.is_superuser: if has_team or has_project: org_access = None else: org_access = access org_list = Organization.objects.get_for_user( user=request.user, access=org_access, ) for o in org_list: if o.slug == organization_slug: organization = o break else: logging.debug('User %s is not listed in organization with slug %s', request.user.id, organization_slug) if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: try: organization = Organization.objects.get_from_cache( slug=organization_slug, ) except Organization.DoesNotExist: logging.debug('Organization with slug %s does not exist', organization_slug) if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: organization = None if team_slug: if not request.user.is_superuser: team_list = Team.objects.get_for_user( user=request.user, access=access, organization=organization, ) for t in team_list: if t.slug == team_slug: team = t break else: logging.debug('User %s is not listed in team with slug %s', request.user.id, team_slug) if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: try: team = Team.objects.get_from_cache( slug=team_slug, organization=organization, ) except Team.DoesNotExist: logging.debug('Team with slug %s does not exist', team_slug) if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: team = None if project_id: # Support project id's if project_id.isdigit(): lookup_kwargs = {'id': int(project_id)} elif organization: lookup_kwargs = {'slug': project_id, 'organization': organization} else: return HttpResponseRedirect(reverse('sentry')) try: project = Project.objects.get_from_cache(**lookup_kwargs) except Project.DoesNotExist: if project_id.isdigit(): # It could be a numerical slug try: project = Project.objects.get_from_cache(slug=project_id) except Project.DoesNotExist: if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) if not request.user.is_superuser and not project.has_access(request.user, access=access): if request.is_ajax(): return HttpResponse(status=400) return HttpResponseRedirect(reverse('sentry')) else: project = None if has_project: kwargs['project'] = project if has_team: kwargs['team'] = team if has_org: kwargs['organization'] = organization return func(request, *args, **kwargs) if access == MEMBER_OWNER: _wrapped = login_required(sudo_required(_wrapped)) return _wrapped return wrapped def has_group_access(func=None, **kwargs): """ Tests and transforms project_id and group_id for permissions based on the requesting user. Passes the actual project and group instances to the decorated view. >>> @has_group_access(allow_public=True) >>> def foo(request, project, group): >>> return """ if func: return has_group_access(**kwargs)(func) allow_public = kwargs.get('allow_public') def decorator(func): prv_func = login_required(has_access(func)) @wraps(func) def wrapped(request, organization_slug, project_id, group_id, *args, **kwargs): group = get_object_or_404(Group, pk=group_id) if project_id not in (group.project.slug, str(group.project.id)): return HttpResponse(status=404) if allow_public and (group.is_public or group.project.public): organization = Organization.objects.get_from_cache(slug=organization_slug) group.project.organization = organization return func(request, organization=organization, project=group.project, group=group, *args, **kwargs) return prv_func(request, organization_slug=organization_slug, project_id=project_id, group=group, *args, **kwargs) return wrapped return decorator def login_required(func): @wraps(func) def wrapped(request, *args, **kwargs): if not request.user.is_authenticated(): request.session['_next'] = request.get_full_path() if 'organization_slug' in kwargs: redirect_uri = reverse('sentry-auth-organization', args=[kwargs['organization_slug']]) else: redirect_uri = get_login_url() return HttpResponseRedirect(redirect_uri) return func(request, *args, **kwargs) return wrapped def requires_admin(func): @wraps(func) def wrapped(request, *args, **kwargs): if not request.user.is_staff: return render_to_response('sentry/missing_permissions.html', status=400) return func(request, *args, **kwargs) return login_required(wrapped)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 9143, 492, 14018, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 14935, 12, 6183, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 14682, 14, 11582, 492, 14682, 63, 2427, 199, 199, 504, 26230, 14, 5559, 492, 31424, 12003, 63, 22307, 199, 504, 26230, 14, 992, 492, 18863, 12, 7290, 12, 11682, 12, 5611, 199, 504, 26230, 14, 2520, 14, 7546, 492, 334, 272, 3795, 63, 475, 63, 1310, 12, 664, 63, 2886, 63, 633, 9, 421, 199, 318, 965, 63, 2732, 8, 2732, 63, 269, 63, 1532, 29, 403, 12, 13237, 29, 403, 12, 2879, 29, 403, 304, 272, 408, 272, 6496, 436, 18501, 2199, 63, 344, 367, 3443, 4079, 641, 314, 23502, 272, 922, 14, 510, 1916, 314, 3503, 2199, 1256, 370, 314, 16225, 2455, 14, 339, 710, 849, 4983, 4194, 365, 283, 751, 297, 1314, 272, 6127, 3865, 283, 751, 7, 436, 283, 4597, 7, 2879, 12, 1325, 440, 283, 2253, 6631, 1370, 339, 1306, 768, 1989, 63, 2732, 8, 26682, 63, 22307, 9, 272, 1306, 347, 3925, 8, 1069, 12, 2199, 304, 272, 1306, 258, 372, 339, 1306, 768, 1989, 63, 2732, 272, 1306, 347, 3925, 8, 1069, 12, 2199, 304, 272, 1306, 258, 372, 272, 408, 272, 327, 3254, 8, 3833, 1186, 82, 304, 642, 1233, 365, 12474, 4634, 11176, 89, 3520, 7609, 436, 1077, 272, 327, 506, 8717, 543, 1021, 4079, 6858, 339, 340, 4550, 8, 2732, 63, 269, 63, 1532, 304, 267, 372, 965, 63, 2732, 8, 403, 5130, 2732, 63, 269, 63, 1532, 9, 339, 2879, 275, 2879, 63, 269, 63, 1532, 339, 347, 8072, 8, 1532, 304, 267, 3598, 14, 4050, 8, 288, 1543, 83, 4111, 83, 365, 1202, 5906, 768, 1989, 63, 2732, 7, 450, 334, 1532, 855, 578, 3108, 2562, 855, 354, 10139, 288, 13413, 9, 398, 768, 13582, 8, 1532, 9, 267, 347, 485, 9130, 8, 1069, 12, 627, 589, 12, 1011, 958, 304, 288, 327, 2900, 4145, 4409, 6299, 288, 340, 440, 1056, 14, 751, 14, 374, 63, 12177, 837, 355, 1056, 14, 1730, 8680, 2184, 418, 275, 1056, 14, 362, 63, 2861, 63, 515, 342, 355, 340, 1056, 14, 374, 63, 12774, 837, 490, 372, 6183, 8, 1205, 29, 8854, 9, 2234, 340, 283, 9071, 63, 5464, 7, 315, 2074, 26, 490, 4660, 63, 2302, 275, 3837, 360, 3870, 13, 1178, 13, 9071, 297, 5644, 1249, 1524, 958, 459, 9071, 63, 5464, 12121, 355, 587, 26, 490, 4660, 63, 2302, 275, 664, 63, 2886, 63, 633, 342, 355, 372, 14935, 8, 4876, 63, 2302, 9, 953, 965, 63, 1308, 275, 283, 9071, 63, 5464, 7, 315, 2074, 288, 965, 63, 5969, 275, 283, 5969, 63, 5464, 7, 315, 2074, 288, 965, 63, 1715, 275, 283, 1715, 63, 344, 7, 315, 2074, 953, 13237, 63, 5464, 275, 2074, 14, 1935, 360, 9071, 63, 5464, 297, 488, 9, 288, 8099, 63, 5464, 275, 2074, 14, 1935, 360, 5969, 63, 5464, 297, 488, 9, 288, 2199, 63, 344, 275, 2074, 14, 1935, 360, 1715, 63, 344, 297, 488, 9, 953, 702, 440, 965, 63, 5969, 503, 965, 63, 1308, 12, 971, 355, 283, 13757, 986, 13237, 63, 5464, 543, 8099, 63, 5464, 7, 953, 340, 13237, 63, 5464, 26, 355, 340, 440, 1056, 14, 751, 14, 374, 63, 11434, 26, 490, 340, 965, 63, 5969, 503, 965, 63, 1715, 26, 717, 5981, 63, 2732, 275, 488, 490, 587, 26, 717, 5981, 63, 2732, 275, 2879, 490, 5981, 63, 513, 275, 18863, 14, 1462, 14, 362, 63, 509, 63, 751, 8, 717, 922, 29, 1069, 14, 751, 12, 717, 2879, 29, 1308, 63, 2732, 12, 490, 776, 4951, 367, 312, 315, 5981, 63, 513, 26, 717, 340, 312, 14, 5464, 508, 13237, 63, 5464, 26, 1169, 13237, 275, 312, 1169, 2059, 490, 587, 26, 717, 2050, 14, 1757, 360, 1899, 450, 83, 365, 440, 10532, 315, 13237, 543, 8889, 450, 83, 297, 1056, 14, 751, 14, 344, 12, 13237, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 2234, 587, 26, 490, 862, 26, 717, 13237, 275, 18863, 14, 1462, 14, 362, 63, 504, 63, 1637, 8, 1169, 8889, 29, 9071, 63, 5464, 12, 717, 776, 490, 871, 18863, 14, 7400, 26, 717, 2050, 14, 1757, 360, 15928, 543, 8889, 450, 83, 1630, 440, 2187, 297, 13237, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 953, 587, 26, 355, 13237, 275, 488, 953, 340, 8099, 63, 5464, 26, 355, 340, 440, 1056, 14, 751, 14, 374, 63, 11434, 26, 490, 8099, 63, 513, 275, 11682, 14, 1462, 14, 362, 63, 509, 63, 751, 8, 717, 922, 29, 1069, 14, 751, 12, 717, 2879, 29, 2732, 12, 717, 13237, 29, 9071, 12, 490, 776, 4951, 367, 307, 315, 8099, 63, 513, 26, 717, 340, 307, 14, 5464, 508, 8099, 63, 5464, 26, 1169, 8099, 275, 307, 1169, 2059, 490, 587, 26, 717, 2050, 14, 1757, 360, 1899, 450, 83, 365, 440, 10532, 315, 8099, 543, 8889, 450, 83, 297, 1056, 14, 751, 14, 344, 12, 8099, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 2234, 587, 26, 490, 862, 26, 717, 8099, 275, 11682, 14, 1462, 14, 362, 63, 504, 63, 1637, 8, 1169, 8889, 29, 5969, 63, 5464, 12, 1169, 13237, 29, 9071, 12, 717, 776, 490, 871, 11682, 14, 7400, 26, 717, 2050, 14, 1757, 360, 13126, 543, 8889, 450, 83, 1630, 440, 2187, 297, 8099, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 953, 587, 26, 355, 8099, 275, 488, 953, 340, 2199, 63, 344, 26, 355, 327, 12502, 2199, 1305, 1159, 355, 340, 2199, 63 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 646, 3598, 199, 199, 504, 9143, 492, 14018, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1014, 492, 14935, 12, 6183, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 14682, 14, 11582, 492, 14682, 63, 2427, 199, 199, 504, 26230, 14, 5559, 492, 31424, 12003, 63, 22307, 199, 504, 26230, 14, 992, 492, 18863, 12, 7290, 12, 11682, 12, 5611, 199, 504, 26230, 14, 2520, 14, 7546, 492, 334, 272, 3795, 63, 475, 63, 1310, 12, 664, 63, 2886, 63, 633, 9, 421, 199, 318, 965, 63, 2732, 8, 2732, 63, 269, 63, 1532, 29, 403, 12, 13237, 29, 403, 12, 2879, 29, 403, 304, 272, 408, 272, 6496, 436, 18501, 2199, 63, 344, 367, 3443, 4079, 641, 314, 23502, 272, 922, 14, 510, 1916, 314, 3503, 2199, 1256, 370, 314, 16225, 2455, 14, 339, 710, 849, 4983, 4194, 365, 283, 751, 297, 1314, 272, 6127, 3865, 283, 751, 7, 436, 283, 4597, 7, 2879, 12, 1325, 440, 283, 2253, 6631, 1370, 339, 1306, 768, 1989, 63, 2732, 8, 26682, 63, 22307, 9, 272, 1306, 347, 3925, 8, 1069, 12, 2199, 304, 272, 1306, 258, 372, 339, 1306, 768, 1989, 63, 2732, 272, 1306, 347, 3925, 8, 1069, 12, 2199, 304, 272, 1306, 258, 372, 272, 408, 272, 327, 3254, 8, 3833, 1186, 82, 304, 642, 1233, 365, 12474, 4634, 11176, 89, 3520, 7609, 436, 1077, 272, 327, 506, 8717, 543, 1021, 4079, 6858, 339, 340, 4550, 8, 2732, 63, 269, 63, 1532, 304, 267, 372, 965, 63, 2732, 8, 403, 5130, 2732, 63, 269, 63, 1532, 9, 339, 2879, 275, 2879, 63, 269, 63, 1532, 339, 347, 8072, 8, 1532, 304, 267, 3598, 14, 4050, 8, 288, 1543, 83, 4111, 83, 365, 1202, 5906, 768, 1989, 63, 2732, 7, 450, 334, 1532, 855, 578, 3108, 2562, 855, 354, 10139, 288, 13413, 9, 398, 768, 13582, 8, 1532, 9, 267, 347, 485, 9130, 8, 1069, 12, 627, 589, 12, 1011, 958, 304, 288, 327, 2900, 4145, 4409, 6299, 288, 340, 440, 1056, 14, 751, 14, 374, 63, 12177, 837, 355, 1056, 14, 1730, 8680, 2184, 418, 275, 1056, 14, 362, 63, 2861, 63, 515, 342, 355, 340, 1056, 14, 374, 63, 12774, 837, 490, 372, 6183, 8, 1205, 29, 8854, 9, 2234, 340, 283, 9071, 63, 5464, 7, 315, 2074, 26, 490, 4660, 63, 2302, 275, 3837, 360, 3870, 13, 1178, 13, 9071, 297, 5644, 1249, 1524, 958, 459, 9071, 63, 5464, 12121, 355, 587, 26, 490, 4660, 63, 2302, 275, 664, 63, 2886, 63, 633, 342, 355, 372, 14935, 8, 4876, 63, 2302, 9, 953, 965, 63, 1308, 275, 283, 9071, 63, 5464, 7, 315, 2074, 288, 965, 63, 5969, 275, 283, 5969, 63, 5464, 7, 315, 2074, 288, 965, 63, 1715, 275, 283, 1715, 63, 344, 7, 315, 2074, 953, 13237, 63, 5464, 275, 2074, 14, 1935, 360, 9071, 63, 5464, 297, 488, 9, 288, 8099, 63, 5464, 275, 2074, 14, 1935, 360, 5969, 63, 5464, 297, 488, 9, 288, 2199, 63, 344, 275, 2074, 14, 1935, 360, 1715, 63, 344, 297, 488, 9, 953, 702, 440, 965, 63, 5969, 503, 965, 63, 1308, 12, 971, 355, 283, 13757, 986, 13237, 63, 5464, 543, 8099, 63, 5464, 7, 953, 340, 13237, 63, 5464, 26, 355, 340, 440, 1056, 14, 751, 14, 374, 63, 11434, 26, 490, 340, 965, 63, 5969, 503, 965, 63, 1715, 26, 717, 5981, 63, 2732, 275, 488, 490, 587, 26, 717, 5981, 63, 2732, 275, 2879, 490, 5981, 63, 513, 275, 18863, 14, 1462, 14, 362, 63, 509, 63, 751, 8, 717, 922, 29, 1069, 14, 751, 12, 717, 2879, 29, 1308, 63, 2732, 12, 490, 776, 4951, 367, 312, 315, 5981, 63, 513, 26, 717, 340, 312, 14, 5464, 508, 13237, 63, 5464, 26, 1169, 13237, 275, 312, 1169, 2059, 490, 587, 26, 717, 2050, 14, 1757, 360, 1899, 450, 83, 365, 440, 10532, 315, 13237, 543, 8889, 450, 83, 297, 1056, 14, 751, 14, 344, 12, 13237, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 2234, 587, 26, 490, 862, 26, 717, 13237, 275, 18863, 14, 1462, 14, 362, 63, 504, 63, 1637, 8, 1169, 8889, 29, 9071, 63, 5464, 12, 717, 776, 490, 871, 18863, 14, 7400, 26, 717, 2050, 14, 1757, 360, 15928, 543, 8889, 450, 83, 1630, 440, 2187, 297, 13237, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 953, 587, 26, 355, 13237, 275, 488, 953, 340, 8099, 63, 5464, 26, 355, 340, 440, 1056, 14, 751, 14, 374, 63, 11434, 26, 490, 8099, 63, 513, 275, 11682, 14, 1462, 14, 362, 63, 509, 63, 751, 8, 717, 922, 29, 1069, 14, 751, 12, 717, 2879, 29, 2732, 12, 717, 13237, 29, 9071, 12, 490, 776, 4951, 367, 307, 315, 8099, 63, 513, 26, 717, 340, 307, 14, 5464, 508, 8099, 63, 5464, 26, 1169, 8099, 275, 307, 1169, 2059, 490, 587, 26, 717, 2050, 14, 1757, 360, 1899, 450, 83, 365, 440, 10532, 315, 8099, 543, 8889, 450, 83, 297, 1056, 14, 751, 14, 344, 12, 8099, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 2234, 587, 26, 490, 862, 26, 717, 8099, 275, 11682, 14, 1462, 14, 362, 63, 504, 63, 1637, 8, 1169, 8889, 29, 5969, 63, 5464, 12, 1169, 13237, 29, 9071, 12, 717, 776, 490, 871, 11682, 14, 7400, 26, 717, 2050, 14, 1757, 360, 13126, 543, 8889, 450, 83, 1630, 440, 2187, 297, 8099, 63, 5464, 9, 717, 340, 1056, 14, 374, 63, 12774, 837, 1169, 372, 6183, 8, 1205, 29, 5303, 9, 717, 372, 14935, 8, 4471, 360, 3870, 1333, 953, 587, 26, 355, 8099, 275, 488, 953, 340, 2199, 63, 344, 26, 355, 327, 12502, 2199, 1305, 1159, 355, 340, 2199, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JimCircadian/ansible
lib/ansible/modules/commands/script.py
10
3056
# Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = """ --- module: script version_added: "0.9" short_description: Runs a local script on a remote node after transferring it description: - "The C(script) module takes the script name followed by a list of space-delimited arguments. " - "The local script at path will be transferred to the remote node and then executed. " - "The given script will be processed through the shell environment on the remote node. " - "This module does not require python on the remote system, much like the M(raw) module. " - This module is also supported for Windows targets. options: free_form: description: - Path to the local script file followed by optional arguments. There is no parameter actually named 'free form'; see the examples! required: true creates: description: - a filename, when it already exists, this step will B(not) be run. version_added: "1.5" removes: description: - a filename, when it does not exist, this step will B(not) be run. version_added: "1.5" chdir: description: - cd into this directory on the remote node before running the script version_added: "2.4" executable: description: - Name or path of a executable to invoke the script with version_added: "2.6" notes: - It is usually preferable to write Ansible modules than pushing scripts. Convert your script to an Ansible module for bonus points! - The ssh connection plugin will force pseudo-tty allocation via -tt when scripts are executed. pseudo-ttys do not have a stderr channel and all stderr is sent to stdout. If you depend on separated stdout and stderr result keys, please switch to a copy+command set of tasks instead of using script. - This module is also supported for Windows targets. - If the path to the local script contains spaces, it needs to be quoted. author: - Ansible Core Team - Michael DeHaan extends_documentation_fragment: - decrypt """ EXAMPLES = ''' # Example from Ansible Playbooks - script: /some/local/script.sh --some-arguments 1234 # Run a script that creates a file, but only if the file is not yet created - script: /some/local/create_file.sh --some-arguments 1234 args: creates: /the/created/file.txt # Run a script that removes a file, but only if the file is not yet removed - script: /some/local/remove_file.sh --some-arguments 1234 args: removes: /the/removed/file.txt # Run a script using a executable in a non-system path - script: /some/local/script args: executable: /some/remote/executable # Run a script using a executable in a system path - script: /some/local/script.py args: executable: python3 '''
gpl-3.0
[ 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 2884, 199, 1023, 63, 3270, 26, 298, 16, 14, 25, 2, 199, 3612, 63, 1802, 26, 23773, 282, 2257, 2884, 641, 282, 3982, 1031, 2410, 28183, 17756, 652, 199, 1802, 26, 1362, 446, 298, 1918, 445, 8, 1579, 9, 859, 6181, 314, 2884, 536, 9437, 701, 282, 769, 402, 2126, 4601, 13, 25672, 2368, 14, 298, 1362, 446, 298, 1918, 2257, 2884, 737, 931, 911, 506, 1752, 5057, 370, 314, 3982, 1031, 436, 2066, 7934, 14, 298, 1362, 446, 298, 1918, 1627, 2884, 911, 506, 7686, 4012, 314, 5218, 3734, 641, 314, 3982, 1031, 14, 298, 1362, 446, 298, 2765, 859, 1630, 440, 4409, 2366, 641, 314, 3982, 2656, 12, 8298, 2839, 2126, 314, 603, 8, 1773, 9, 859, 14, 298, 1362, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 199, 1419, 26, 523, 2867, 63, 964, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 2257, 2884, 570, 9437, 701, 2716, 2368, 14, 6006, 365, 949, 2725, 5965, 4310, 283, 4624, 1824, 13619, 1937, 314, 7251, 1, 272, 1415, 26, 2549, 523, 8491, 26, 272, 1369, 26, 489, 446, 282, 1788, 12, 1380, 652, 2575, 3495, 12, 642, 3650, 911, 699, 8, 1397, 9, 506, 1255, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 14185, 26, 272, 1369, 26, 489, 446, 282, 1788, 12, 1380, 652, 1630, 440, 2187, 12, 642, 3650, 911, 699, 8, 1397, 9, 506, 1255, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 13097, 26, 272, 1369, 26, 489, 446, 12829, 1901, 642, 2082, 641, 314, 3982, 1031, 2544, 3879, 314, 2884, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 7286, 26, 272, 1369, 26, 489, 446, 2812, 503, 931, 402, 282, 7286, 370, 12677, 314, 2884, 543, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 199, 5983, 26, 523, 446, 2779, 365, 9987, 16602, 461, 370, 2218, 2622, 4621, 2419, 6675, 316, 10554, 14, 7905, 2195, 2884, 370, 376, 2622, 859, 367, 23672, 527, 4501, 1, 523, 446, 710, 8635, 1950, 3589, 911, 3542, 15984, 13, 4707, 18723, 4799, 446, 6215, 1380, 10554, 787, 7934, 14, 15984, 13, 4707, 83, 886, 440, 1172, 282, 4635, 3623, 436, 1006, 272, 4635, 365, 4847, 370, 3839, 14, 982, 1265, 11687, 641, 11673, 3839, 436, 4635, 754, 2883, 12, 8749, 6258, 370, 282, 1331, 11, 1531, 663, 402, 6527, 3140, 402, 1808, 2884, 14, 523, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 523, 446, 982, 314, 931, 370, 314, 2257, 2884, 3509, 7883, 12, 652, 4839, 370, 506, 10999, 14, 199, 2502, 26, 272, 446, 2622, 11672, 11682, 272, 446, 16922, 22453, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 20090, 199, 624, 199, 199, 8918, 275, 1449, 199, 3, 5679, 687, 2622, 16527, 8858, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 14, 609, 1553, 3972, 13, 4958, 14763, 199, 199, 3, 3378, 282, 2884, 626, 8491, 282, 570, 12, 1325, 1454, 340, 314, 570, 365, 440, 5966, 2737, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 981, 63, 493, 14, 609, 1553, 3972, 13, 4958, 14763, 523, 1249, 26, 272, 8491, 26, 1182, 1589, 15, 3966, 15, 493, 14, 2424, 199, 199, 3, 3378, 282, 2884, 626, 14185, 282, 570, 12, 1325, 1454, 340, 314, 570, 365, 440, 5966, 4829, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 2168, 63, 493, 14, 609, 1553, 3972, 13, 4958, 14763, 523, 1249, 26, 272, 14185, 26, 1182, 1589, 15, 10649, 15, 493, 14, 2424, 199, 199, 3, 3378, 282, 2884, 1808, 282, 7286, 315, 282, 2222, 13, 2253, 931, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 523, 1249, 26, 272, 7286, 26, 1182, 3972, 15, 3846, 15, 5904, 199, 199, 3, 3378, 282, 2884, 1808, 282, 7286, 315, 282, 2656, 931, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 14, 647, 523, 1249, 26, 272, 7286, 26, 2366, 19, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 2884, 199, 1023, 63, 3270, 26, 298, 16, 14, 25, 2, 199, 3612, 63, 1802, 26, 23773, 282, 2257, 2884, 641, 282, 3982, 1031, 2410, 28183, 17756, 652, 199, 1802, 26, 1362, 446, 298, 1918, 445, 8, 1579, 9, 859, 6181, 314, 2884, 536, 9437, 701, 282, 769, 402, 2126, 4601, 13, 25672, 2368, 14, 298, 1362, 446, 298, 1918, 2257, 2884, 737, 931, 911, 506, 1752, 5057, 370, 314, 3982, 1031, 436, 2066, 7934, 14, 298, 1362, 446, 298, 1918, 1627, 2884, 911, 506, 7686, 4012, 314, 5218, 3734, 641, 314, 3982, 1031, 14, 298, 1362, 446, 298, 2765, 859, 1630, 440, 4409, 2366, 641, 314, 3982, 2656, 12, 8298, 2839, 2126, 314, 603, 8, 1773, 9, 859, 14, 298, 1362, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 199, 1419, 26, 523, 2867, 63, 964, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 2257, 2884, 570, 9437, 701, 2716, 2368, 14, 6006, 365, 949, 2725, 5965, 4310, 283, 4624, 1824, 13619, 1937, 314, 7251, 1, 272, 1415, 26, 2549, 523, 8491, 26, 272, 1369, 26, 489, 446, 282, 1788, 12, 1380, 652, 2575, 3495, 12, 642, 3650, 911, 699, 8, 1397, 9, 506, 1255, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 14185, 26, 272, 1369, 26, 489, 446, 282, 1788, 12, 1380, 652, 1630, 440, 2187, 12, 642, 3650, 911, 699, 8, 1397, 9, 506, 1255, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 21, 2, 523, 13097, 26, 272, 1369, 26, 489, 446, 12829, 1901, 642, 2082, 641, 314, 3982, 1031, 2544, 3879, 314, 2884, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 7286, 26, 272, 1369, 26, 489, 446, 2812, 503, 931, 402, 282, 7286, 370, 12677, 314, 2884, 543, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 199, 5983, 26, 523, 446, 2779, 365, 9987, 16602, 461, 370, 2218, 2622, 4621, 2419, 6675, 316, 10554, 14, 7905, 2195, 2884, 370, 376, 2622, 859, 367, 23672, 527, 4501, 1, 523, 446, 710, 8635, 1950, 3589, 911, 3542, 15984, 13, 4707, 18723, 4799, 446, 6215, 1380, 10554, 787, 7934, 14, 15984, 13, 4707, 83, 886, 440, 1172, 282, 4635, 3623, 436, 1006, 272, 4635, 365, 4847, 370, 3839, 14, 982, 1265, 11687, 641, 11673, 3839, 436, 4635, 754, 2883, 12, 8749, 6258, 370, 282, 1331, 11, 1531, 663, 402, 6527, 3140, 402, 1808, 2884, 14, 523, 446, 961, 859, 365, 2597, 3748, 367, 5417, 4545, 14, 523, 446, 982, 314, 931, 370, 314, 2257, 2884, 3509, 7883, 12, 652, 4839, 370, 506, 10999, 14, 199, 2502, 26, 272, 446, 2622, 11672, 11682, 272, 446, 16922, 22453, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 20090, 199, 624, 199, 199, 8918, 275, 1449, 199, 3, 5679, 687, 2622, 16527, 8858, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 14, 609, 1553, 3972, 13, 4958, 14763, 199, 199, 3, 3378, 282, 2884, 626, 8491, 282, 570, 12, 1325, 1454, 340, 314, 570, 365, 440, 5966, 2737, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 981, 63, 493, 14, 609, 1553, 3972, 13, 4958, 14763, 523, 1249, 26, 272, 8491, 26, 1182, 1589, 15, 3966, 15, 493, 14, 2424, 199, 199, 3, 3378, 282, 2884, 626, 14185, 282, 570, 12, 1325, 1454, 340, 314, 570, 365, 440, 5966, 4829, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 2168, 63, 493, 14, 609, 1553, 3972, 13, 4958, 14763, 523, 1249, 26, 272, 14185, 26, 1182, 1589, 15, 10649, 15, 493, 14, 2424, 199, 199, 3, 3378, 282, 2884, 1808, 282, 7286, 315, 282, 2222, 13, 2253, 931, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 523, 1249, 26, 272, 7286, 26, 1182, 3972, 15, 3846, 15, 5904, 199, 199, 3, 3378, 282, 2884, 1808, 282, 7286, 315, 282, 2656, 931, 199, 13, 2884, 26, 1182, 3972, 15, 1832, 15, 1579, 14, 647, 523, 1249, 26, 272, 7286, 26, 2366, 19, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Neil741/ryu-master
ryu/app/rest_firewall.py
6
38429
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import json from webob import Response from ryu.app.wsgi import ControllerBase from ryu.app.wsgi import WSGIApplication from ryu.base import app_manager from ryu.controller import ofp_event from ryu.controller import dpset from ryu.controller.handler import MAIN_DISPATCHER from ryu.controller.handler import set_ev_cls from ryu.exception import OFPUnknownVersion from ryu.lib import mac from ryu.lib import dpid as dpid_lib from ryu.lib import ofctl_v1_0 from ryu.lib import ofctl_v1_2 from ryu.lib import ofctl_v1_3 from ryu.lib.packet import packet from ryu.ofproto import ether from ryu.ofproto import inet from ryu.ofproto import ofproto_v1_0 from ryu.ofproto import ofproto_v1_2 from ryu.ofproto import ofproto_v1_2_parser from ryu.ofproto import ofproto_v1_3 from ryu.ofproto import ofproto_v1_3_parser # ============================= # REST API # ============================= # # Note: specify switch and vlan group, as follows. # {switch-id} : 'all' or switchID # {vlan-id} : 'all' or vlanID # # # about Firewall status # # get status of all firewall switches # GET /firewall/module/status # # set enable the firewall switches # PUT /firewall/module/enable/{switch-id} # # set disable the firewall switches # PUT /firewall/module/disable/{switch-id} # # about Firewall logs # # get log status of all firewall switches # GET /firewall/log/status # # set log enable the firewall switches # PUT /firewall/log/enable/{switch-id} # # set log disable the firewall switches # PUT /firewall/log/disable/{switch-id} # # about Firewall rules # # get rules of the firewall switches # * for no vlan # GET /firewall/rules/{switch-id} # # * for specific vlan group # GET /firewall/rules/{switch-id}/{vlan-id} # # # set a rule to the firewall switches # * for no vlan # POST /firewall/rules/{switch-id} # # * for specific vlan group # POST /firewall/rules/{switch-id}/{vlan-id} # # request body format: # {"<field1>":"<value1>", "<field2>":"<value2>",...} # # <field> : <value> # "priority": "0 to 65533" # "in_port" : "<int>" # "dl_src" : "<xx:xx:xx:xx:xx:xx>" # "dl_dst" : "<xx:xx:xx:xx:xx:xx>" # "dl_type" : "<ARP or IPv4 or IPv6>" # "nw_src" : "<A.B.C.D/M>" # "nw_dst" : "<A.B.C.D/M>" # "ipv6_src": "<xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/M>" # "ipv6_dst": "<xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/M>" # "nw_proto": "<TCP or UDP or ICMP or ICMPv6>" # "tp_src" : "<int>" # "tp_dst" : "<int>" # "actions" : "<ALLOW or DENY>" # # Note: specifying nw_src/nw_dst # without specifying dl-type as "ARP" or "IPv4" # will automatically set dl-type as "IPv4". # # Note: specifying ipv6_src/ipv6_dst # without specifying dl-type as "IPv6" # will automatically set dl-type as "IPv6". # # Note: When "priority" has not been set up, # "0" is set to "priority". # # Note: When "actions" has not been set up, # "ALLOW" is set to "actions". # # # delete a rule of the firewall switches from ruleID # * for no vlan # DELETE /firewall/rules/{switch-id} # # * for specific vlan group # DELETE /firewall/rules/{switch-id}/{vlan-id} # # request body format: # {"<field>":"<value>"} # # <field> : <value> # "rule_id" : "<int>" or "all" # SWITCHID_PATTERN = dpid_lib.DPID_PATTERN + r'|all' VLANID_PATTERN = r'[0-9]{1,4}|all' REST_ALL = 'all' REST_SWITCHID = 'switch_id' REST_VLANID = 'vlan_id' REST_RULE_ID = 'rule_id' REST_STATUS = 'status' REST_LOG_STATUS = 'log_status' REST_STATUS_ENABLE = 'enable' REST_STATUS_DISABLE = 'disable' REST_COMMAND_RESULT = 'command_result' REST_ACL = 'access_control_list' REST_RULES = 'rules' REST_COOKIE = 'cookie' REST_PRIORITY = 'priority' REST_MATCH = 'match' REST_IN_PORT = 'in_port' REST_SRC_MAC = 'dl_src' REST_DST_MAC = 'dl_dst' REST_DL_TYPE = 'dl_type' REST_DL_TYPE_ARP = 'ARP' REST_DL_TYPE_IPV4 = 'IPv4' REST_DL_TYPE_IPV6 = 'IPv6' REST_DL_VLAN = 'dl_vlan' REST_SRC_IP = 'nw_src' REST_DST_IP = 'nw_dst' REST_SRC_IPV6 = 'ipv6_src' REST_DST_IPV6 = 'ipv6_dst' REST_NW_PROTO = 'nw_proto' REST_NW_PROTO_TCP = 'TCP' REST_NW_PROTO_UDP = 'UDP' REST_NW_PROTO_ICMP = 'ICMP' REST_NW_PROTO_ICMPV6 = 'ICMPv6' REST_TP_SRC = 'tp_src' REST_TP_DST = 'tp_dst' REST_ACTION = 'actions' REST_ACTION_ALLOW = 'ALLOW' REST_ACTION_DENY = 'DENY' REST_ACTION_PACKETIN = 'PACKETIN' STATUS_FLOW_PRIORITY = ofproto_v1_3_parser.UINT16_MAX ARP_FLOW_PRIORITY = ofproto_v1_3_parser.UINT16_MAX - 1 LOG_FLOW_PRIORITY = 0 ACL_FLOW_PRIORITY_MIN = LOG_FLOW_PRIORITY + 1 ACL_FLOW_PRIORITY_MAX = ofproto_v1_3_parser.UINT16_MAX - 2 VLANID_NONE = 0 VLANID_MIN = 2 VLANID_MAX = 4094 COOKIE_SHIFT_VLANID = 32 class RestFirewallAPI(app_manager.RyuApp): OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION, ofproto_v1_2.OFP_VERSION, ofproto_v1_3.OFP_VERSION] _CONTEXTS = {'dpset': dpset.DPSet, 'wsgi': WSGIApplication} def __init__(self, *args, **kwargs): super(RestFirewallAPI, self).__init__(*args, **kwargs) # logger configure FirewallController.set_logger(self.logger) self.dpset = kwargs['dpset'] wsgi = kwargs['wsgi'] self.waiters = {} self.data = {} self.data['dpset'] = self.dpset self.data['waiters'] = self.waiters mapper = wsgi.mapper wsgi.registory['FirewallController'] = self.data path = '/firewall' requirements = {'switchid': SWITCHID_PATTERN, 'vlanid': VLANID_PATTERN} # for firewall status uri = path + '/module/status' mapper.connect('firewall', uri, controller=FirewallController, action='get_status', conditions=dict(method=['GET'])) uri = path + '/module/enable/{switchid}' mapper.connect('firewall', uri, controller=FirewallController, action='set_enable', conditions=dict(method=['PUT']), requirements=requirements) uri = path + '/module/disable/{switchid}' mapper.connect('firewall', uri, controller=FirewallController, action='set_disable', conditions=dict(method=['PUT']), requirements=requirements) # for firewall logs uri = path + '/log/status' mapper.connect('firewall', uri, controller=FirewallController, action='get_log_status', conditions=dict(method=['GET'])) uri = path + '/log/enable/{switchid}' mapper.connect('firewall', uri, controller=FirewallController, action='set_log_enable', conditions=dict(method=['PUT']), requirements=requirements) uri = path + '/log/disable/{switchid}' mapper.connect('firewall', uri, controller=FirewallController, action='set_log_disable', conditions=dict(method=['PUT']), requirements=requirements) # for no VLAN data uri = path + '/rules/{switchid}' mapper.connect('firewall', uri, controller=FirewallController, action='get_rules', conditions=dict(method=['GET']), requirements=requirements) mapper.connect('firewall', uri, controller=FirewallController, action='set_rule', conditions=dict(method=['POST']), requirements=requirements) mapper.connect('firewall', uri, controller=FirewallController, action='delete_rule', conditions=dict(method=['DELETE']), requirements=requirements) # for VLAN data uri += '/{vlanid}' mapper.connect('firewall', uri, controller=FirewallController, action='get_vlan_rules', conditions=dict(method=['GET']), requirements=requirements) mapper.connect('firewall', uri, controller=FirewallController, action='set_vlan_rule', conditions=dict(method=['POST']), requirements=requirements) mapper.connect('firewall', uri, controller=FirewallController, action='delete_vlan_rule', conditions=dict(method=['DELETE']), requirements=requirements) def stats_reply_handler(self, ev): msg = ev.msg dp = msg.datapath if dp.id not in self.waiters: return if msg.xid not in self.waiters[dp.id]: return lock, msgs = self.waiters[dp.id][msg.xid] msgs.append(msg) flags = 0 if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \ dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION: flags = dp.ofproto.OFPSF_REPLY_MORE elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION: flags = dp.ofproto.OFPMPF_REPLY_MORE if msg.flags & flags: return del self.waiters[dp.id][msg.xid] lock.set() @set_ev_cls(dpset.EventDP, dpset.DPSET_EV_DISPATCHER) def handler_datapath(self, ev): if ev.enter: FirewallController.regist_ofs(ev.dp) else: FirewallController.unregist_ofs(ev.dp) # for OpenFlow version1.0 @set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER) def stats_reply_handler_v1_0(self, ev): self.stats_reply_handler(ev) # for OpenFlow version1.2 or later @set_ev_cls(ofp_event.EventOFPStatsReply, MAIN_DISPATCHER) def stats_reply_handler_v1_2(self, ev): self.stats_reply_handler(ev) @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) def packet_in_handler(self, ev): FirewallController.packet_in_handler(ev.msg) class FirewallOfsList(dict): def __init__(self): super(FirewallOfsList, self).__init__() def get_ofs(self, dp_id): if len(self) == 0: raise ValueError('firewall sw is not connected.') dps = {} if dp_id == REST_ALL: dps = self else: try: dpid = dpid_lib.str_to_dpid(dp_id) except: raise ValueError('Invalid switchID.') if dpid in self: dps = {dpid: self[dpid]} else: msg = 'firewall sw is not connected. : switchID=%s' % dp_id raise ValueError(msg) return dps class FirewallController(ControllerBase): _OFS_LIST = FirewallOfsList() _LOGGER = None def __init__(self, req, link, data, **config): super(FirewallController, self).__init__(req, link, data, **config) self.dpset = data['dpset'] self.waiters = data['waiters'] @classmethod def set_logger(cls, logger): cls._LOGGER = logger cls._LOGGER.propagate = False hdlr = logging.StreamHandler() fmt_str = '[FW][%(levelname)s] %(message)s' hdlr.setFormatter(logging.Formatter(fmt_str)) cls._LOGGER.addHandler(hdlr) @staticmethod def regist_ofs(dp): dpid_str = dpid_lib.dpid_to_str(dp.id) try: f_ofs = Firewall(dp) except OFPUnknownVersion, message: FirewallController._LOGGER.info('dpid=%s: %s', dpid_str, message) return FirewallController._OFS_LIST.setdefault(dp.id, f_ofs) f_ofs.set_disable_flow() f_ofs.set_arp_flow() f_ofs.set_log_enable() FirewallController._LOGGER.info('dpid=%s: Join as firewall.', dpid_str) @staticmethod def unregist_ofs(dp): if dp.id in FirewallController._OFS_LIST: del FirewallController._OFS_LIST[dp.id] FirewallController._LOGGER.info('dpid=%s: Leave firewall.', dpid_lib.dpid_to_str(dp.id)) # GET /firewall/module/status def get_status(self, req, **_kwargs): return self._access_module(REST_ALL, 'get_status', waiters=self.waiters) # POST /firewall/module/enable/{switchid} def set_enable(self, req, switchid, **_kwargs): return self._access_module(switchid, 'set_enable_flow') # POST /firewall/module/disable/{switchid} def set_disable(self, req, switchid, **_kwargs): return self._access_module(switchid, 'set_disable_flow') # GET /firewall/log/status def get_log_status(self, dummy, **_kwargs): return self._access_module(REST_ALL, 'get_log_status', waiters=self.waiters) # PUT /firewall/log/enable/{switchid} def set_log_enable(self, dummy, switchid, **_kwargs): return self._access_module(switchid, 'set_log_enable', waiters=self.waiters) # PUT /firewall/log/disable/{switchid} def set_log_disable(self, dummy, switchid, **_kwargs): return self._access_module(switchid, 'set_log_disable', waiters=self.waiters) def _access_module(self, switchid, func, waiters=None): try: dps = self._OFS_LIST.get_ofs(switchid) except ValueError, message: return Response(status=400, body=str(message)) msgs = [] for f_ofs in dps.values(): function = getattr(f_ofs, func) msg = function() if waiters is None else function(waiters) msgs.append(msg) body = json.dumps(msgs) return Response(content_type='application/json', body=body) # GET /firewall/rules/{switchid} def get_rules(self, req, switchid, **_kwargs): return self._get_rules(switchid) # GET /firewall/rules/{switchid}/{vlanid} def get_vlan_rules(self, req, switchid, vlanid, **_kwargs): return self._get_rules(switchid, vlan_id=vlanid) # POST /firewall/rules/{switchid} def set_rule(self, req, switchid, **_kwargs): return self._set_rule(req, switchid) # POST /firewall/rules/{switchid}/{vlanid} def set_vlan_rule(self, req, switchid, vlanid, **_kwargs): return self._set_rule(req, switchid, vlan_id=vlanid) # DELETE /firewall/rules/{switchid} def delete_rule(self, req, switchid, **_kwargs): return self._delete_rule(req, switchid) # DELETE /firewall/rules/{switchid}/{vlanid} def delete_vlan_rule(self, req, switchid, vlanid, **_kwargs): return self._delete_rule(req, switchid, vlan_id=vlanid) def _get_rules(self, switchid, vlan_id=VLANID_NONE): try: dps = self._OFS_LIST.get_ofs(switchid) vid = FirewallController._conv_toint_vlanid(vlan_id) except ValueError, message: return Response(status=400, body=str(message)) msgs = [] for f_ofs in dps.values(): rules = f_ofs.get_rules(self.waiters, vid) msgs.append(rules) body = json.dumps(msgs) return Response(content_type='application/json', body=body) def _set_rule(self, req, switchid, vlan_id=VLANID_NONE): try: rule = json.loads(req.body) except SyntaxError: FirewallController._LOGGER.debug('invalid syntax %s', req.body) return Response(status=400) try: dps = self._OFS_LIST.get_ofs(switchid) vid = FirewallController._conv_toint_vlanid(vlan_id) except ValueError, message: return Response(status=400, body=str(message)) msgs = [] for f_ofs in dps.values(): try: msg = f_ofs.set_rule(rule, self.waiters, vid) msgs.append(msg) except ValueError, message: return Response(status=400, body=str(message)) body = json.dumps(msgs) return Response(content_type='application/json', body=body) def _delete_rule(self, req, switchid, vlan_id=VLANID_NONE): try: ruleid = json.loads(req.body) except SyntaxError: FirewallController._LOGGER.debug('invalid syntax %s', req.body) return Response(status=400) try: dps = self._OFS_LIST.get_ofs(switchid) vid = FirewallController._conv_toint_vlanid(vlan_id) except ValueError, message: return Response(status=400, body=str(message)) msgs = [] for f_ofs in dps.values(): try: msg = f_ofs.delete_rule(ruleid, self.waiters, vid) msgs.append(msg) except ValueError, message: return Response(status=400, body=str(message)) body = json.dumps(msgs) return Response(content_type='application/json', body=body) @staticmethod def _conv_toint_vlanid(vlan_id): if vlan_id != REST_ALL: vlan_id = int(vlan_id) if (vlan_id != VLANID_NONE and (vlan_id < VLANID_MIN or VLANID_MAX < vlan_id)): msg = 'Invalid {vlan_id} value. Set [%d-%d]' % (VLANID_MIN, VLANID_MAX) raise ValueError(msg) return vlan_id @staticmethod def packet_in_handler(msg): pkt = packet.Packet(msg.data) dpid_str = dpid_lib.dpid_to_str(msg.datapath.id) FirewallController._LOGGER.info('dpid=%s: Blocked packet = %s', dpid_str, pkt) class Firewall(object): _OFCTL = {ofproto_v1_0.OFP_VERSION: ofctl_v1_0, ofproto_v1_2.OFP_VERSION: ofctl_v1_2, ofproto_v1_3.OFP_VERSION: ofctl_v1_3} def __init__(self, dp): super(Firewall, self).__init__() self.vlan_list = {} self.vlan_list[VLANID_NONE] = 0 # for VLAN=None self.dp = dp version = dp.ofproto.OFP_VERSION if version not in self._OFCTL: raise OFPUnknownVersion(version=version) self.ofctl = self._OFCTL[version] def _update_vlan_list(self, vlan_list): for vlan_id in self.vlan_list.keys(): if vlan_id is not VLANID_NONE and vlan_id not in vlan_list: del self.vlan_list[vlan_id] def _get_cookie(self, vlan_id): if vlan_id == REST_ALL: vlan_ids = self.vlan_list.keys() else: vlan_ids = [vlan_id] cookie_list = [] for vlan_id in vlan_ids: self.vlan_list.setdefault(vlan_id, 0) self.vlan_list[vlan_id] += 1 self.vlan_list[vlan_id] &= ofproto_v1_3_parser.UINT32_MAX cookie = (vlan_id << COOKIE_SHIFT_VLANID) + \ self.vlan_list[vlan_id] cookie_list.append([cookie, vlan_id]) return cookie_list @staticmethod def _cookie_to_ruleid(cookie): return cookie & ofproto_v1_3_parser.UINT32_MAX # REST command template def rest_command(func): def _rest_command(*args, **kwargs): key, value = func(*args, **kwargs) switch_id = dpid_lib.dpid_to_str(args[0].dp.id) return {REST_SWITCHID: switch_id, key: value} return _rest_command @rest_command def get_status(self, waiters): msgs = self.ofctl.get_flow_stats(self.dp, waiters) status = REST_STATUS_ENABLE if str(self.dp.id) in msgs: flow_stats = msgs[str(self.dp.id)] for flow_stat in flow_stats: if flow_stat['priority'] == STATUS_FLOW_PRIORITY: status = REST_STATUS_DISABLE return REST_STATUS, status @rest_command def set_disable_flow(self): cookie = 0 priority = STATUS_FLOW_PRIORITY match = {} actions = [] flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) cmd = self.dp.ofproto.OFPFC_ADD self.ofctl.mod_flow_entry(self.dp, flow, cmd) msg = {'result': 'success', 'details': 'firewall stopped.'} return REST_COMMAND_RESULT, msg @rest_command def set_enable_flow(self): cookie = 0 priority = STATUS_FLOW_PRIORITY match = {} actions = [] flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) cmd = self.dp.ofproto.OFPFC_DELETE_STRICT self.ofctl.mod_flow_entry(self.dp, flow, cmd) msg = {'result': 'success', 'details': 'firewall running.'} return REST_COMMAND_RESULT, msg @rest_command def get_log_status(self, waiters): msgs = self.ofctl.get_flow_stats(self.dp, waiters) status = REST_STATUS_DISABLE if str(self.dp.id) in msgs: flow_stats = msgs[str(self.dp.id)] for flow_stat in flow_stats: if flow_stat['priority'] == LOG_FLOW_PRIORITY: if flow_stat['actions']: status = REST_STATUS_ENABLE return REST_LOG_STATUS, status @rest_command def set_log_disable(self, waiters=None): return self._set_log_status(False, waiters) @rest_command def set_log_enable(self, waiters=None): return self._set_log_status(True, waiters) def _set_log_status(self, is_enable, waiters): if is_enable: actions = Action.to_openflow(self.dp, {REST_ACTION: REST_ACTION_PACKETIN}) details = 'Log collection started.' else: actions = [] details = 'Log collection stopped.' cmd = self.dp.ofproto.OFPFC_ADD if waiters: msgs = self.ofctl.get_flow_stats(self.dp, waiters) if str(self.dp.id) in msgs: flow_stats = msgs[str(self.dp.id)] for flow_stat in flow_stats: priority = flow_stat[REST_PRIORITY] if (priority == STATUS_FLOW_PRIORITY or priority == ARP_FLOW_PRIORITY): continue action = flow_stat[REST_ACTION] if action == ['OUTPUT:%d' % self.dp.ofproto.OFPP_NORMAL]: continue cookie = flow_stat[REST_COOKIE] match = Match.to_mod_openflow(flow_stat[REST_MATCH]) flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) self.ofctl.mod_flow_entry(self.dp, flow, cmd) else: # Initialize. flow = self._to_of_flow(cookie=0, priority=LOG_FLOW_PRIORITY, match={}, actions=actions) self.ofctl.mod_flow_entry(self.dp, flow, cmd) msg = {'result': 'success', 'details': details} return REST_COMMAND_RESULT, msg def set_arp_flow(self): cookie = 0 priority = ARP_FLOW_PRIORITY match = {REST_DL_TYPE: ether.ETH_TYPE_ARP} action = {REST_ACTION: REST_ACTION_ALLOW} actions = Action.to_openflow(self.dp, action) flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) cmd = self.dp.ofproto.OFPFC_ADD self.ofctl.mod_flow_entry(self.dp, flow, cmd) @rest_command def set_rule(self, rest, waiters, vlan_id): msgs = [] cookie_list = self._get_cookie(vlan_id) for cookie, vid in cookie_list: msg = self._set_rule(cookie, rest, waiters, vid) msgs.append(msg) return REST_COMMAND_RESULT, msgs def _set_rule(self, cookie, rest, waiters, vlan_id): priority = int(rest.get(REST_PRIORITY, ACL_FLOW_PRIORITY_MIN)) if (priority < ACL_FLOW_PRIORITY_MIN or ACL_FLOW_PRIORITY_MAX < priority): raise ValueError('Invalid priority value. Set [%d-%d]' % (ACL_FLOW_PRIORITY_MIN, ACL_FLOW_PRIORITY_MAX)) if vlan_id: rest[REST_DL_VLAN] = vlan_id match = Match.to_openflow(rest) if rest.get(REST_ACTION) == REST_ACTION_DENY: result = self.get_log_status(waiters) if result[REST_LOG_STATUS] == REST_STATUS_ENABLE: rest[REST_ACTION] = REST_ACTION_PACKETIN actions = Action.to_openflow(self.dp, rest) flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) cmd = self.dp.ofproto.OFPFC_ADD try: self.ofctl.mod_flow_entry(self.dp, flow, cmd) except: raise ValueError('Invalid rule parameter.') rule_id = Firewall._cookie_to_ruleid(cookie) msg = {'result': 'success', 'details': 'Rule added. : rule_id=%d' % rule_id} if vlan_id != VLANID_NONE: msg.setdefault(REST_VLANID, vlan_id) return msg @rest_command def get_rules(self, waiters, vlan_id): rules = {} msgs = self.ofctl.get_flow_stats(self.dp, waiters) if str(self.dp.id) in msgs: flow_stats = msgs[str(self.dp.id)] for flow_stat in flow_stats: priority = flow_stat[REST_PRIORITY] if (priority != STATUS_FLOW_PRIORITY and priority != ARP_FLOW_PRIORITY and priority != LOG_FLOW_PRIORITY): vid = flow_stat[REST_MATCH].get(REST_DL_VLAN, VLANID_NONE) if vlan_id == REST_ALL or vlan_id == vid: rule = self._to_rest_rule(flow_stat) rules.setdefault(vid, []) rules[vid].append(rule) get_data = [] for vid, rule in rules.items(): if vid == VLANID_NONE: vid_data = {REST_RULES: rule} else: vid_data = {REST_VLANID: vid, REST_RULES: rule} get_data.append(vid_data) return REST_ACL, get_data @rest_command def delete_rule(self, rest, waiters, vlan_id): try: if rest[REST_RULE_ID] == REST_ALL: rule_id = REST_ALL else: rule_id = int(rest[REST_RULE_ID]) except: raise ValueError('Invalid ruleID.') vlan_list = [] delete_list = [] msgs = self.ofctl.get_flow_stats(self.dp, waiters) if str(self.dp.id) in msgs: flow_stats = msgs[str(self.dp.id)] for flow_stat in flow_stats: cookie = flow_stat[REST_COOKIE] ruleid = Firewall._cookie_to_ruleid(cookie) priority = flow_stat[REST_PRIORITY] dl_vlan = flow_stat[REST_MATCH].get(REST_DL_VLAN, VLANID_NONE) if (priority != STATUS_FLOW_PRIORITY and priority != ARP_FLOW_PRIORITY and priority != LOG_FLOW_PRIORITY): if ((rule_id == REST_ALL or rule_id == ruleid) and (vlan_id == dl_vlan or vlan_id == REST_ALL)): match = Match.to_mod_openflow(flow_stat[REST_MATCH]) delete_list.append([cookie, priority, match]) else: if dl_vlan not in vlan_list: vlan_list.append(dl_vlan) self._update_vlan_list(vlan_list) if len(delete_list) == 0: msg_details = 'Rule is not exist.' if rule_id != REST_ALL: msg_details += ' : ruleID=%d' % rule_id msg = {'result': 'failure', 'details': msg_details} else: cmd = self.dp.ofproto.OFPFC_DELETE_STRICT actions = [] delete_ids = {} for cookie, priority, match in delete_list: flow = self._to_of_flow(cookie=cookie, priority=priority, match=match, actions=actions) self.ofctl.mod_flow_entry(self.dp, flow, cmd) vid = match.get(REST_DL_VLAN, VLANID_NONE) rule_id = Firewall._cookie_to_ruleid(cookie) delete_ids.setdefault(vid, '') delete_ids[vid] += (('%d' if delete_ids[vid] == '' else ',%d') % rule_id) msg = [] for vid, rule_ids in delete_ids.items(): del_msg = {'result': 'success', 'details': 'Rule deleted. : ruleID=%s' % rule_ids} if vid != VLANID_NONE: del_msg.setdefault(REST_VLANID, vid) msg.append(del_msg) return REST_COMMAND_RESULT, msg def _to_of_flow(self, cookie, priority, match, actions): flow = {'cookie': cookie, 'priority': priority, 'flags': 0, 'idle_timeout': 0, 'hard_timeout': 0, 'match': match, 'actions': actions} return flow def _to_rest_rule(self, flow): ruleid = Firewall._cookie_to_ruleid(flow[REST_COOKIE]) rule = {REST_RULE_ID: ruleid} rule.update({REST_PRIORITY: flow[REST_PRIORITY]}) rule.update(Match.to_rest(flow)) rule.update(Action.to_rest(self.dp, flow)) return rule class Match(object): _CONVERT = {REST_DL_TYPE: {REST_DL_TYPE_ARP: ether.ETH_TYPE_ARP, REST_DL_TYPE_IPV4: ether.ETH_TYPE_IP, REST_DL_TYPE_IPV6: ether.ETH_TYPE_IPV6}, REST_NW_PROTO: {REST_NW_PROTO_TCP: inet.IPPROTO_TCP, REST_NW_PROTO_UDP: inet.IPPROTO_UDP, REST_NW_PROTO_ICMP: inet.IPPROTO_ICMP, REST_NW_PROTO_ICMPV6: inet.IPPROTO_ICMPV6}} @staticmethod def to_openflow(rest): def __inv_combi(msg): raise ValueError('Invalid combination: [%s]' % msg) def __inv_2and1(*args): __inv_combi('%s=%s and %s' % (args[0], args[1], args[2])) def __inv_2and2(*args): __inv_combi('%s=%s and %s=%s' % ( args[0], args[1], args[2], args[3])) def __inv_1and1(*args): __inv_combi('%s and %s' % (args[0], args[1])) def __inv_1and2(*args): __inv_combi('%s and %s=%s' % (args[0], args[1], args[2])) match = {} # error check dl_type = rest.get(REST_DL_TYPE) nw_proto = rest.get(REST_NW_PROTO) if dl_type is not None: if dl_type == REST_DL_TYPE_ARP: if REST_SRC_IPV6 in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_ARP, REST_SRC_IPV6) if REST_DST_IPV6 in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_ARP, REST_DST_IPV6) if nw_proto: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_ARP, REST_NW_PROTO) elif dl_type == REST_DL_TYPE_IPV4: if REST_SRC_IPV6 in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_IPV4, REST_SRC_IPV6) if REST_DST_IPV6 in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_IPV4, REST_DST_IPV6) if nw_proto == REST_NW_PROTO_ICMPV6: __inv_2and2( REST_DL_TYPE, REST_DL_TYPE_IPV4, REST_NW_PROTO, REST_NW_PROTO_ICMPV6) elif dl_type == REST_DL_TYPE_IPV6: if REST_SRC_IP in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_IPV6, REST_SRC_IP) if REST_DST_IP in rest: __inv_2and1( REST_DL_TYPE, REST_DL_TYPE_IPV6, REST_DST_IP) if nw_proto == REST_NW_PROTO_ICMP: __inv_2and2( REST_DL_TYPE, REST_DL_TYPE_IPV6, REST_NW_PROTO, REST_NW_PROTO_ICMP) else: raise ValueError('Unknown dl_type : %s' % dl_type) else: if REST_SRC_IP in rest: if REST_SRC_IPV6 in rest: __inv_1and1(REST_SRC_IP, REST_SRC_IPV6) if REST_DST_IPV6 in rest: __inv_1and1(REST_SRC_IP, REST_DST_IPV6) if nw_proto == REST_NW_PROTO_ICMPV6: __inv_1and2( REST_SRC_IP, REST_NW_PROTO, REST_NW_PROTO_ICMPV6) rest[REST_DL_TYPE] = REST_DL_TYPE_IPV4 elif REST_DST_IP in rest: if REST_SRC_IPV6 in rest: __inv_1and1(REST_DST_IP, REST_SRC_IPV6) if REST_DST_IPV6 in rest: __inv_1and1(REST_DST_IP, REST_DST_IPV6) if nw_proto == REST_NW_PROTO_ICMPV6: __inv_1and2( REST_DST_IP, REST_NW_PROTO, REST_NW_PROTO_ICMPV6) rest[REST_DL_TYPE] = REST_DL_TYPE_IPV4 elif REST_SRC_IPV6 in rest: if nw_proto == REST_NW_PROTO_ICMP: __inv_1and2( REST_SRC_IPV6, REST_NW_PROTO, REST_NW_PROTO_ICMP) rest[REST_DL_TYPE] = REST_DL_TYPE_IPV6 elif REST_DST_IPV6 in rest: if nw_proto == REST_NW_PROTO_ICMP: __inv_1and2( REST_DST_IPV6, REST_NW_PROTO, REST_NW_PROTO_ICMP) rest[REST_DL_TYPE] = REST_DL_TYPE_IPV6 else: if nw_proto == REST_NW_PROTO_ICMP: rest[REST_DL_TYPE] = REST_DL_TYPE_IPV4 elif nw_proto == REST_NW_PROTO_ICMPV6: rest[REST_DL_TYPE] = REST_DL_TYPE_IPV6 elif nw_proto == REST_NW_PROTO_TCP or \ nw_proto == REST_NW_PROTO_UDP: raise ValueError('no dl_type was specified') else: raise ValueError('Unknown nw_proto: %s' % nw_proto) for key, value in rest.items(): if key in Match._CONVERT: if value in Match._CONVERT[key]: match.setdefault(key, Match._CONVERT[key][value]) else: raise ValueError('Invalid rule parameter. : key=%s' % key) else: match.setdefault(key, value) return match @staticmethod def to_rest(openflow): of_match = openflow[REST_MATCH] mac_dontcare = mac.haddr_to_str(mac.DONTCARE) ip_dontcare = '0.0.0.0' ipv6_dontcare = '::' match = {} for key, value in of_match.items(): if key == REST_SRC_MAC or key == REST_DST_MAC: if value == mac_dontcare: continue elif key == REST_SRC_IP or key == REST_DST_IP: if value == ip_dontcare: continue elif key == REST_SRC_IPV6 or key == REST_DST_IPV6: if value == ipv6_dontcare: continue elif value == 0: continue if key in Match._CONVERT: conv = Match._CONVERT[key] conv = dict((value, key) for key, value in conv.items()) match.setdefault(key, conv[value]) else: match.setdefault(key, value) return match @staticmethod def to_mod_openflow(of_match): mac_dontcare = mac.haddr_to_str(mac.DONTCARE) ip_dontcare = '0.0.0.0' ipv6_dontcare = '::' match = {} for key, value in of_match.items(): if key == REST_SRC_MAC or key == REST_DST_MAC: if value == mac_dontcare: continue elif key == REST_SRC_IP or key == REST_DST_IP: if value == ip_dontcare: continue elif key == REST_SRC_IPV6 or key == REST_DST_IPV6: if value == ipv6_dontcare: continue elif value == 0: continue match.setdefault(key, value) return match class Action(object): @staticmethod def to_openflow(dp, rest): value = rest.get(REST_ACTION, REST_ACTION_ALLOW) if value == REST_ACTION_ALLOW: out_port = dp.ofproto.OFPP_NORMAL action = [{'type': 'OUTPUT', 'port': out_port}] elif value == REST_ACTION_DENY: action = [] elif value == REST_ACTION_PACKETIN: out_port = dp.ofproto.OFPP_CONTROLLER action = [{'type': 'OUTPUT', 'port': out_port, 'max_len': 128}] else: raise ValueError('Invalid action type.') return action @staticmethod def to_rest(dp, openflow): if REST_ACTION in openflow: action_allow = 'OUTPUT:%d' % dp.ofproto.OFPP_NORMAL if openflow[REST_ACTION] == [action_allow]: action = {REST_ACTION: REST_ACTION_ALLOW} else: action = {REST_ACTION: REST_ACTION_DENY} else: action = {REST_ACTION: 'Unknown action type.'} return action
apache-2.0
[ 3, 1898, 334, 35, 9, 6171, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 646, 2050, 199, 646, 2022, 199, 199, 504, 14568, 492, 7232, 199, 199, 504, 25494, 14, 571, 14, 6508, 492, 16282, 1563, 199, 504, 25494, 14, 571, 14, 6508, 492, 9279, 5039, 199, 504, 25494, 14, 1095, 492, 1145, 63, 2609, 199, 504, 25494, 14, 5538, 492, 15643, 63, 1430, 199, 504, 25494, 14, 5538, 492, 12392, 409, 199, 504, 25494, 14, 5538, 14, 2232, 492, 4828, 568, 63, 32550, 540, 199, 504, 25494, 14, 5538, 14, 2232, 492, 663, 63, 6857, 63, 1886, 199, 504, 25494, 14, 1971, 492, 16563, 5912, 3353, 199, 504, 25494, 14, 773, 492, 4497, 199, 504, 25494, 14, 773, 492, 366, 3150, 465, 366, 3150, 63, 773, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 16, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 18, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 19, 199, 504, 25494, 14, 773, 14, 6253, 492, 3644, 199, 504, 25494, 14, 15129, 492, 30201, 199, 504, 25494, 14, 15129, 492, 17260, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 16, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 18, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 18, 63, 2087, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 19, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 19, 63, 2087, 421, 199, 3, 16248, 5769, 199, 3, 3515, 14880, 3261, 199, 3, 16248, 5769, 199, 3, 199, 3, 221, 3390, 26, 4165, 6258, 436, 10119, 1572, 12, 465, 11924, 14, 199, 3, 257, 469, 5656, 13, 344, 93, 520, 283, 452, 7, 503, 6258, 998, 199, 3, 257, 469, 7175, 13, 344, 93, 257, 520, 283, 452, 7, 503, 10119, 998, 199, 3, 199, 3, 199, 199, 3, 3595, 15967, 7567, 2004, 199, 3, 199, 3, 664, 2004, 402, 1006, 12042, 24563, 199, 3, 9576, 1182, 10794, 15, 578, 15, 1205, 199, 3, 199, 3, 663, 4756, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 578, 15, 4296, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 663, 3507, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 578, 15, 5993, 5321, 5656, 13, 344, 93, 199, 3, 199, 199, 3, 3595, 15967, 7567, 9610, 199, 3, 199, 3, 664, 943, 2004, 402, 1006, 12042, 24563, 199, 3, 9576, 1182, 10794, 15, 793, 15, 1205, 199, 3, 199, 3, 663, 943, 4756, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 793, 15, 4296, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 663, 943, 3507, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 793, 15, 5993, 5321, 5656, 13, 344, 93, 199, 3, 199, 199, 3, 3595, 15967, 7567, 4713, 199, 3, 199, 3, 664, 4713, 402, 314, 12042, 24563, 199, 3, 627, 367, 949, 10119, 199, 3, 9576, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 627, 367, 2488, 10119, 1572, 199, 3, 9576, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 16152, 7175, 13, 344, 93, 199, 3, 199, 3, 199, 3, 663, 282, 2332, 370, 314, 12042, 24563, 199, 3, 627, 367, 949, 10119, 199, 3, 8761, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 627, 367, 2488, 10119, 1572, 199, 3, 8761, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 16152, 7175, 13, 344, 93, 199, 3, 199, 3, 221, 1056, 2396, 1475, 26, 199, 3, 257, 2420, 28, 698, 17, 30, 5122, 28, 585, 17, 7166, 3886, 698, 18, 30, 5122, 28, 585, 18, 7166, 1396, 93, 199, 3, 199, 3, 258, 665, 698, 30, 221, 520, 665, 585, 30, 199, 3, 259, 298, 6693, 582, 298, 16, 370, 12633, 1153, 2, 199, 3, 259, 298, 262, 63, 719, 2, 520, 3886, 442, 4335, 199, 3, 259, 298, 5030, 63, 2164, 2, 221, 520, 3886, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 4335, 199, 3, 259, 298, 5030, 63, 5119, 2, 221, 520, 3886, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 4335, 199, 3, 259, 298, 5030, 63, 466, 2, 520, 3886, 23610, 503, 6509, 20, 503, 6509, 22, 4335, 199, 3, 259, 298, 13100, 63, 2164, 2, 221, 520, 3886, 33, 14, 34, 14, 35, 14, 36, 15, 45, 4335, 199, 3, 259, 298, 13100, 63, 5119, 2, 221, 520, 3886, 33, 14, 34, 14, 35, 14, 36, 15, 45, 4335, 199, 3, 259, 298, 4774, 22, 63, 2164, 582, 3886, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 15, 45, 4335, 199, 3, 259, 298, 4774, 22, 63, 5119, 582, 3886, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 15, 45, 4335, 199, 3, 259, 298, 13100, 63, 2625, 582, 3886, 9735, 503, 21802, 503, 473, 23181, 503, 473, 23181, 86, 22, 4335, 199, 3, 259, 298, 683, 63, 2164, 2, 221, 520, 3886, 442, 4335, 199, 3, 259, 298, 683, 63, 5119, 2, 221, 520, 3886, 442, 4335, 199, 3, 259, 298, 3723, 2, 520, 3886, 12231, 503, 577, 742, 57, 4335, 199, 3, 199, 3, 257, 3390, 26, 9176, 22823, 63 ]
[ 1898, 334, 35, 9, 6171, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 646, 2050, 199, 646, 2022, 199, 199, 504, 14568, 492, 7232, 199, 199, 504, 25494, 14, 571, 14, 6508, 492, 16282, 1563, 199, 504, 25494, 14, 571, 14, 6508, 492, 9279, 5039, 199, 504, 25494, 14, 1095, 492, 1145, 63, 2609, 199, 504, 25494, 14, 5538, 492, 15643, 63, 1430, 199, 504, 25494, 14, 5538, 492, 12392, 409, 199, 504, 25494, 14, 5538, 14, 2232, 492, 4828, 568, 63, 32550, 540, 199, 504, 25494, 14, 5538, 14, 2232, 492, 663, 63, 6857, 63, 1886, 199, 504, 25494, 14, 1971, 492, 16563, 5912, 3353, 199, 504, 25494, 14, 773, 492, 4497, 199, 504, 25494, 14, 773, 492, 366, 3150, 465, 366, 3150, 63, 773, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 16, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 18, 199, 504, 25494, 14, 773, 492, 402, 8077, 63, 86, 17, 63, 19, 199, 504, 25494, 14, 773, 14, 6253, 492, 3644, 199, 504, 25494, 14, 15129, 492, 30201, 199, 504, 25494, 14, 15129, 492, 17260, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 16, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 18, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 18, 63, 2087, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 19, 199, 504, 25494, 14, 15129, 492, 14122, 63, 86, 17, 63, 19, 63, 2087, 421, 199, 3, 16248, 5769, 199, 3, 3515, 14880, 3261, 199, 3, 16248, 5769, 199, 3, 199, 3, 221, 3390, 26, 4165, 6258, 436, 10119, 1572, 12, 465, 11924, 14, 199, 3, 257, 469, 5656, 13, 344, 93, 520, 283, 452, 7, 503, 6258, 998, 199, 3, 257, 469, 7175, 13, 344, 93, 257, 520, 283, 452, 7, 503, 10119, 998, 199, 3, 199, 3, 199, 199, 3, 3595, 15967, 7567, 2004, 199, 3, 199, 3, 664, 2004, 402, 1006, 12042, 24563, 199, 3, 9576, 1182, 10794, 15, 578, 15, 1205, 199, 3, 199, 3, 663, 4756, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 578, 15, 4296, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 663, 3507, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 578, 15, 5993, 5321, 5656, 13, 344, 93, 199, 3, 199, 199, 3, 3595, 15967, 7567, 9610, 199, 3, 199, 3, 664, 943, 2004, 402, 1006, 12042, 24563, 199, 3, 9576, 1182, 10794, 15, 793, 15, 1205, 199, 3, 199, 3, 663, 943, 4756, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 793, 15, 4296, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 663, 943, 3507, 314, 12042, 24563, 199, 3, 18337, 1182, 10794, 15, 793, 15, 5993, 5321, 5656, 13, 344, 93, 199, 3, 199, 199, 3, 3595, 15967, 7567, 4713, 199, 3, 199, 3, 664, 4713, 402, 314, 12042, 24563, 199, 3, 627, 367, 949, 10119, 199, 3, 9576, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 627, 367, 2488, 10119, 1572, 199, 3, 9576, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 16152, 7175, 13, 344, 93, 199, 3, 199, 3, 199, 3, 663, 282, 2332, 370, 314, 12042, 24563, 199, 3, 627, 367, 949, 10119, 199, 3, 8761, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 93, 199, 3, 199, 3, 627, 367, 2488, 10119, 1572, 199, 3, 8761, 1182, 10794, 15, 4423, 5321, 5656, 13, 344, 16152, 7175, 13, 344, 93, 199, 3, 199, 3, 221, 1056, 2396, 1475, 26, 199, 3, 257, 2420, 28, 698, 17, 30, 5122, 28, 585, 17, 7166, 3886, 698, 18, 30, 5122, 28, 585, 18, 7166, 1396, 93, 199, 3, 199, 3, 258, 665, 698, 30, 221, 520, 665, 585, 30, 199, 3, 259, 298, 6693, 582, 298, 16, 370, 12633, 1153, 2, 199, 3, 259, 298, 262, 63, 719, 2, 520, 3886, 442, 4335, 199, 3, 259, 298, 5030, 63, 2164, 2, 221, 520, 3886, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 4335, 199, 3, 259, 298, 5030, 63, 5119, 2, 221, 520, 3886, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 26, 2154, 4335, 199, 3, 259, 298, 5030, 63, 466, 2, 520, 3886, 23610, 503, 6509, 20, 503, 6509, 22, 4335, 199, 3, 259, 298, 13100, 63, 2164, 2, 221, 520, 3886, 33, 14, 34, 14, 35, 14, 36, 15, 45, 4335, 199, 3, 259, 298, 13100, 63, 5119, 2, 221, 520, 3886, 33, 14, 34, 14, 35, 14, 36, 15, 45, 4335, 199, 3, 259, 298, 4774, 22, 63, 2164, 582, 3886, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 15, 45, 4335, 199, 3, 259, 298, 4774, 22, 63, 5119, 582, 3886, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 26, 5336, 15, 45, 4335, 199, 3, 259, 298, 13100, 63, 2625, 582, 3886, 9735, 503, 21802, 503, 473, 23181, 503, 473, 23181, 86, 22, 4335, 199, 3, 259, 298, 683, 63, 2164, 2, 221, 520, 3886, 442, 4335, 199, 3, 259, 298, 683, 63, 5119, 2, 221, 520, 3886, 442, 4335, 199, 3, 259, 298, 3723, 2, 520, 3886, 12231, 503, 577, 742, 57, 4335, 199, 3, 199, 3, 257, 3390, 26, 9176, 22823, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
janocat/odoo
addons/l10n_be_intrastat/l10n_be_intrastat.py
258
7828
# -*- encoding: utf-8 -*- ############################################################################## # # Odoo, Open Source Business Applications # Copyright (C) 2014-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.osv import fields, osv class account_invoice(osv.osv): _inherit = "account.invoice" _columns = { 'incoterm_id': fields.many2one( 'stock.incoterms', 'Incoterm', help="International Commercial Terms are a series of predefined commercial terms " "used in international transactions."), 'intrastat_transaction_id': fields.many2one( 'l10n_be_intrastat.transaction', 'Intrastat Transaction Type', help="Intrastat nature of transaction"), 'transport_mode_id': fields.many2one( 'l10n_be_intrastat.transport_mode', 'Intrastat Transport Mode'), 'intrastat_country_id': fields.many2one( 'res.country', 'Intrastat Country', help='Intrastat country, delivery for sales, origin for purchases', domain=[('intrastat','=',True)]), } class intrastat_region(osv.osv): _name = 'l10n_be_intrastat.region' _columns = { 'code': fields.char('Code', required=True), 'country_id': fields.many2one('res.country', 'Country'), 'name': fields.char('Name', translate=True), 'description': fields.char('Description'), } _sql_constraints = [ ('l10n_be_intrastat_regioncodeunique', 'UNIQUE (code)', 'Code must be unique.'), ] class intrastat_transaction(osv.osv): _name = 'l10n_be_intrastat.transaction' _rec_name = 'code' _columns = { 'code': fields.char('Code', required=True, readonly=True), 'description': fields.text('Description', readonly=True), } _sql_constraints = [ ('l10n_be_intrastat_trcodeunique', 'UNIQUE (code)', 'Code must be unique.'), ] class intrastat_transport_mode(osv.osv): _name = 'l10n_be_intrastat.transport_mode' _columns = { 'code': fields.char('Code', required=True, readonly=True), 'name': fields.char('Description', readonly=True), } _sql_constraints = [ ('l10n_be_intrastat_trmodecodeunique', 'UNIQUE (code)', 'Code must be unique.'), ] class product_category(osv.osv): _name = "product.category" _inherit = "product.category" _columns = { 'intrastat_id': fields.many2one('report.intrastat.code', 'Intrastat Code'), } def get_intrastat_recursively(self, cr, uid, category, context=None): """ Recursively search in categories to find an intrastat code id :param category : Browse record of a category """ if category.intrastat_id: res = category.intrastat_id.id elif category.parent_id: res = self.get_intrastat_recursively(cr, uid, category.parent_id, context=context) else: res = None return res class product_product(osv.osv): _name = "product.product" _inherit = "product.product" def get_intrastat_recursively(self, cr, uid, id, context=None): """ Recursively search in categories to find an intrastat code id """ product = self.browse(cr, uid, id, context=context) if product.intrastat_id: res = product.intrastat_id.id elif product.categ_id: res = self.pool['product.category'].get_intrastat_recursively( cr, uid, product.categ_id, context=context) else: res = None return res class purchase_order(osv.osv): _inherit = "purchase.order" def _prepare_invoice(self, cr, uid, order, line_ids, context=None): """ copy incoterm from purchase order to invoice """ invoice = super(purchase_order, self)._prepare_invoice( cr, uid, order, line_ids, context=context) if order.incoterm_id: invoice['incoterm_id'] = order.incoterm_id.id #Try to determine products origin if order.partner_id.country_id: #It comes from supplier invoice['intrastat_country_id'] = order.partner_id.country_id.id return invoice class report_intrastat_code(osv.osv): _inherit = "report.intrastat.code" _columns = { 'description': fields.text('Description', translate=True), } class res_company(osv.osv): _inherit = "res.company" _columns = { 'region_id': fields.many2one('l10n_be_intrastat.region', 'Intrastat region'), 'transport_mode_id': fields.many2one('l10n_be_intrastat.transport_mode', 'Default transport mode'), 'incoterm_id': fields.many2one('stock.incoterms', 'Default incoterm for Intrastat', help="International Commercial Terms are a series of " "predefined commercial terms used in international " "transactions."), } class sale_order(osv.osv): _inherit = "sale.order" def _prepare_invoice(self, cr, uid, saleorder, lines, context=None): """ copy incoterm from sale order to invoice """ invoice = super(sale_order, self)._prepare_invoice( cr, uid, saleorder, lines, context=context) if saleorder.incoterm: invoice['incoterm_id'] = saleorder.incoterm.id # Guess products destination if saleorder.partner_shipping_id.country_id: invoice['intrastat_country_id'] = saleorder.partner_shipping_id.country_id.id elif saleorder.partner_id.country_id: invoice['intrastat_country_id'] = saleorder.partner_id.country_id.id elif saleorder.partner_invoice_id.country_id: invoice['intrastat_country_id'] = saleorder.partner_invoice_id.country_id.id return invoice class stock_warehouse(osv.osv): _inherit = "stock.warehouse" _columns = { 'region_id': fields.many2one('l10n_be_intrastat.region', 'Intrastat region'), } def get_regionid_from_locationid(self, cr, uid, location_id, context=None): location_model = self.pool['stock.location'] location = location_model.browse(cr, uid, location_id, context=context) location_ids = location_model.search(cr, uid, [('parent_left', '<=', location.parent_left), ('parent_right', '>=', location.parent_right)], context=context) warehouse_ids = self.search(cr, uid, [('lot_stock_id', 'in', location_ids), ('region_id', '!=', False)], context=context) warehouses = self.browse(cr, uid, warehouse_ids, context=context) if warehouses and warehouses[0]: return warehouses[0].region_id.id return None
agpl-3.0
[ 3, 1882, 2644, 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, 6927, 13, 7806, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 2048, 14, 5404, 2, 272, 485, 3406, 275, 469, 267, 283, 262, 331, 5125, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 6088, 14, 262, 331, 9187, 297, 283, 607, 331, 5125, 297, 288, 1720, 628, 30886, 5429, 23012, 13861, 706, 787, 282, 6779, 402, 27684, 2414, 23012, 2895, 298, 326, 298, 2972, 315, 10757, 6279, 15809, 7651, 267, 283, 442, 345, 3736, 63, 5945, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5945, 297, 283, 3241, 345, 3736, 18244, 2434, 297, 288, 1720, 628, 3241, 345, 3736, 302, 1463, 402, 6008, 1288, 267, 283, 5545, 63, 632, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5545, 63, 632, 297, 283, 3241, 345, 3736, 27018, 4900, 659, 267, 283, 442, 345, 3736, 63, 6063, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 470, 14, 6063, 297, 283, 3241, 345, 3736, 19453, 297, 288, 1720, 534, 3241, 345, 3736, 9023, 12, 18719, 367, 21702, 12, 6330, 367, 5861, 335, 3274, 297, 288, 2881, 11699, 442, 345, 3736, 18937, 549, 16636, 272, 789, 421, 199, 533, 1109, 345, 3736, 63, 4551, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 4551, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 395, 267, 283, 6063, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 6063, 297, 283, 17393, 659, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 9028, 29, 549, 395, 267, 283, 1802, 356, 1504, 14, 1560, 360, 5831, 659, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 4551, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 1109, 345, 3736, 63, 5945, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5945, 7, 272, 485, 2761, 63, 354, 275, 283, 600, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 1802, 356, 1504, 14, 505, 360, 5831, 297, 6863, 29, 549, 395, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 454, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 1109, 345, 3736, 63, 5545, 63, 632, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5545, 63, 632, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 1560, 360, 5831, 297, 6863, 29, 549, 395, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 454, 632, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 3336, 63, 3710, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2558, 14, 3710, 2, 272, 485, 6486, 275, 298, 2558, 14, 3710, 2, 339, 485, 3406, 275, 469, 267, 283, 442, 345, 3736, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 3070, 14, 442, 345, 3736, 14, 600, 297, 283, 3241, 345, 3736, 5495, 659, 272, 789, 339, 347, 664, 63, 442, 345, 3736, 63, 6794, 9840, 8, 277, 12, 2467, 12, 1747, 12, 4637, 12, 1067, 29, 403, 304, 267, 408, 18306, 9840, 2754, 315, 9695, 370, 2342, 376, 1109, 345, 3736, 1233, 1305, 398, 520, 635, 4637, 520, 699, 13300, 2777, 402, 282, 4637, 267, 408, 267, 340, 4637, 14, 442, 345, 3736, 63, 344, 26, 288, 522, 275, 4637, 14, 442, 345, 3736, 63, 344, 14, 344, 267, 916, 4637, 14, 1708, 63, 344, 26, 288, 522, 275, 291, 14, 362, 63, 442, 345, 3736, 63, 6794, 9840, 8, 1556, 12, 1747, 12, 4637, 14, 1708, 63, 344, 12, 1067, 29, 1100, 9, 267, 587, 26, 288, 522, 275, 488, 267, 372, 522, 421, 199, 533, 3336, 63, 2558, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2558, 14, 2558, 2, 272, 485, 6486, 275, 298, 2558, 14, 2558, 2, 339, 347, 664, 63, 442, 345, 3736, 63, 6794, 9840, 8, 277, 12, 2467, 12, 1747, 12 ]
[ 1882, 2644, 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, 6927, 13, 7806, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 2048, 14, 5404, 2, 272, 485, 3406, 275, 469, 267, 283, 262, 331, 5125, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 6088, 14, 262, 331, 9187, 297, 283, 607, 331, 5125, 297, 288, 1720, 628, 30886, 5429, 23012, 13861, 706, 787, 282, 6779, 402, 27684, 2414, 23012, 2895, 298, 326, 298, 2972, 315, 10757, 6279, 15809, 7651, 267, 283, 442, 345, 3736, 63, 5945, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5945, 297, 283, 3241, 345, 3736, 18244, 2434, 297, 288, 1720, 628, 3241, 345, 3736, 302, 1463, 402, 6008, 1288, 267, 283, 5545, 63, 632, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5545, 63, 632, 297, 283, 3241, 345, 3736, 27018, 4900, 659, 267, 283, 442, 345, 3736, 63, 6063, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 470, 14, 6063, 297, 283, 3241, 345, 3736, 19453, 297, 288, 1720, 534, 3241, 345, 3736, 9023, 12, 18719, 367, 21702, 12, 6330, 367, 5861, 335, 3274, 297, 288, 2881, 11699, 442, 345, 3736, 18937, 549, 16636, 272, 789, 421, 199, 533, 1109, 345, 3736, 63, 4551, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 4551, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 395, 267, 283, 6063, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 6063, 297, 283, 17393, 659, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 9028, 29, 549, 395, 267, 283, 1802, 356, 1504, 14, 1560, 360, 5831, 659, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 4551, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 1109, 345, 3736, 63, 5945, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5945, 7, 272, 485, 2761, 63, 354, 275, 283, 600, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 1802, 356, 1504, 14, 505, 360, 5831, 297, 6863, 29, 549, 395, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 454, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 1109, 345, 3736, 63, 5545, 63, 632, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 14, 5545, 63, 632, 7, 272, 485, 3406, 275, 469, 267, 283, 600, 356, 1504, 14, 1560, 360, 3034, 297, 1415, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 1560, 360, 5831, 297, 6863, 29, 549, 395, 272, 789, 339, 485, 3009, 63, 9882, 275, 359, 267, 661, 76, 709, 78, 63, 1235, 63, 442, 345, 3736, 63, 454, 632, 600, 3235, 297, 283, 28060, 334, 600, 3196, 283, 3034, 1471, 506, 3747, 8038, 272, 1622, 421, 199, 533, 3336, 63, 3710, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2558, 14, 3710, 2, 272, 485, 6486, 275, 298, 2558, 14, 3710, 2, 339, 485, 3406, 275, 469, 267, 283, 442, 345, 3736, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 3070, 14, 442, 345, 3736, 14, 600, 297, 283, 3241, 345, 3736, 5495, 659, 272, 789, 339, 347, 664, 63, 442, 345, 3736, 63, 6794, 9840, 8, 277, 12, 2467, 12, 1747, 12, 4637, 12, 1067, 29, 403, 304, 267, 408, 18306, 9840, 2754, 315, 9695, 370, 2342, 376, 1109, 345, 3736, 1233, 1305, 398, 520, 635, 4637, 520, 699, 13300, 2777, 402, 282, 4637, 267, 408, 267, 340, 4637, 14, 442, 345, 3736, 63, 344, 26, 288, 522, 275, 4637, 14, 442, 345, 3736, 63, 344, 14, 344, 267, 916, 4637, 14, 1708, 63, 344, 26, 288, 522, 275, 291, 14, 362, 63, 442, 345, 3736, 63, 6794, 9840, 8, 1556, 12, 1747, 12, 4637, 14, 1708, 63, 344, 12, 1067, 29, 1100, 9, 267, 587, 26, 288, 522, 275, 488, 267, 372, 522, 421, 199, 533, 3336, 63, 2558, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2558, 14, 2558, 2, 272, 485, 6486, 275, 298, 2558, 14, 2558, 2, 339, 347, 664, 63, 442, 345, 3736, 63, 6794, 9840, 8, 277, 12, 2467, 12, 1747, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nkhuyu/seizure-prediction
ensemble.py
2
9703
#!/usr/bin/env python2.7 from multiprocessing import Pool import sys import numpy as np from sklearn.metrics import roc_auc_score from seizure_prediction.classifiers import make_svm, make_simple_lr, make_lr from seizure_prediction.feature_selection import generate_feature_masks from seizure_prediction.fft_bins import * from seizure_prediction.pipeline import Pipeline, FeatureConcatPipeline, InputSource from seizure_prediction.scores import get_score_summary, print_results from seizure_prediction.tasks import make_csv_for_target_predictions, write_submission_file, \ cross_validation_score, check_training_data_loaded, check_test_data_loaded, make_submission_predictions from seizure_prediction.transforms import Windower, Correlation, FreqCorrelation, FFT, \ Magnitude, PIBSpectralEntropy, Log10, FreqBinning, FlattenChannels, Preprocess, HFD, PFD, Hurst from seizure_prediction.settings import load_settings from main import run_prepare_data_for_cross_validation def run_make_submission(settings, targets_and_pipelines, split_ratio): pool = Pool(settings.N_jobs) for i, (target, pipeline, feature_masks, classifier, classifier_name) in enumerate(targets_and_pipelines): for j, feature_mask in enumerate(feature_masks): progress_str = 'T=%d/%d M=%d/%d' % (i+1, len(targets_and_pipelines), j+1, len(feature_masks)) pool.apply_async(make_submission_predictions, [settings, target, pipeline, classifier, classifier_name], {'feature_mask': feature_mask, 'progress_str': progress_str, 'quiet': True}) pool.close() pool.join() guesses = ['clip,preictal'] num_masks = None classifier_names = [] for target, pipeline, feature_masks, classifier, classifier_name in targets_and_pipelines: classifier_names.append(classifier_name) if num_masks is None: num_masks = len(feature_masks) else: assert num_masks == len(feature_masks) test_predictions = [] for feature_mask in feature_masks: data = make_submission_predictions(settings, target, pipeline, classifier, classifier_name, feature_mask=feature_mask) test_predictions.append(data.mean_predictions) predictions = np.mean(test_predictions, axis=0) guesses += make_csv_for_target_predictions(target, predictions) output = '\n'.join(guesses) write_submission_file(settings, output, 'ensemble n=%d split_ratio=%s' % (num_masks, split_ratio), None, str(classifier_names), targets_and_pipelines) def run_prepare_data(settings, targets, pipelines, train=True, test=False, quiet=False): for pipeline in pipelines: for target in targets: print 'Preparing data for', target if train: check_training_data_loaded(settings, target, pipeline, quiet=quiet) if test: check_test_data_loaded(settings, target, pipeline, quiet=quiet) def run_cross_validation(settings, targets, pipelines, mask_range, split_ratios, classifiers): pool = Pool(settings.N_jobs) for i, pipeline in enumerate(pipelines): for j, (classifier, classifier_name) in enumerate(classifiers): for k, target in enumerate(targets): pool.apply_async(cross_validation_score, [settings, target, pipeline, classifier, classifier_name], {'quiet': True}) for split_num, split_ratio in enumerate(split_ratios): masks = generate_feature_masks(settings, target, pipeline, np.max(mask_range), split_ratio, random_state=0, quiet=True) for mask_num, mask in enumerate(masks): progress_str = 'P=%d/%d C=%d/%d T=%d/%d S=%d/%d M=%d/%d' % (i+1, len(pipelines), j+1, len(classifiers), k+1, len(targets), split_num+1, len(split_ratios), mask_num+1, len(masks)) cross_validation_score(settings, target, pipeline, classifier, classifier_name, feature_mask=mask, quiet=True, return_data=False, pool=pool, progress_str=progress_str) pool.close() pool.join() print 'Finished cross validation mp' summaries = [] for p_num, pipeline in enumerate(pipelines): for classifier, classifier_name in classifiers: scores_full = [] scores_masked = [[[] for y in mask_range] for x in split_ratios] for i, target in enumerate(targets): run_prepare_data_for_cross_validation(settings, [target], [pipeline], quiet=True) data = cross_validation_score(settings, target, pipeline, classifier, classifier_name, pool=None, quiet=True) scores_full.append(data.mean_score) for split_index, split_ratio in enumerate(split_ratios): masks = generate_feature_masks(settings, target, pipeline, np.max(mask_range), split_ratio, random_state=0, quiet=True) for mask_index, num_masks in enumerate(mask_range): predictions = [] y_cvs = None for mask in masks[0:num_masks]: data = cross_validation_score(settings, target, pipeline, classifier, classifier_name, feature_mask=mask, pool=None, quiet=True) predictions.append(data.mean_predictions) if y_cvs is None: y_cvs = data.y_cvs else: for y_cv_1, y_cv_2 in zip(y_cvs, data.y_cvs): assert np.alltrue(y_cv_1 == y_cv_2) predictions = np.mean(predictions, axis=0) scores = [roc_auc_score(y_cv, p) for p, y_cv in zip(predictions, y_cvs)] score = np.mean(scores) scores_masked[split_index][mask_index].append(score) summary = get_score_summary('%s p=%d full' % (classifier_name, p_num), scores_full) summaries.append((summary, np.mean(scores_full))) for split_index, split_ratio in enumerate(split_ratios): for mask_index, num_masks in enumerate(mask_range): scores = scores_masked[split_index][mask_index] summary = get_score_summary('%s p=%d split_ratio=%s masks=%d' % (classifier_name, p_num, split_ratio, num_masks), scores) summaries.append((summary, np.mean(scores))) print summary print_results(summaries) def main(): settings = load_settings() pipelines = [ FeatureConcatPipeline( Pipeline(InputSource(), Preprocess(), Windower(75), Correlation('none')), Pipeline(InputSource(), Preprocess(), Windower(75), FreqCorrelation(1, None, 'none')), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), FreqBinning(winning_bins, 'mean'), Log10(), FlattenChannels()), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([0.25, 1, 1.75, 2.5, 3.25, 4, 5, 8.5, 12, 15.5, 19.5, 24])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([0.25, 2, 3.5, 6, 15, 24])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([0.25, 2, 3.5, 6, 15])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([0.25, 2, 3.5])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([6, 15, 24])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([2, 3.5, 6])), Pipeline(InputSource(Preprocess(), Windower(75), FFT(), Magnitude()), PIBSpectralEntropy([3.5, 6, 15])), Pipeline(InputSource(), Preprocess(), Windower(75), HFD(2)), Pipeline(InputSource(), Preprocess(), Windower(75), PFD()), Pipeline(InputSource(), Preprocess(), Windower(75), Hurst()), ), ] targets = [ 'Dog_1', 'Dog_2', 'Dog_3', 'Dog_4', 'Dog_5', 'Patient_1', 'Patient_2' ] classifiers = [ make_svm(gamma=0.0079, C=2.7), make_svm(gamma=0.0068, C=2.0), make_svm(gamma=0.003, C=150.0), make_lr(C=0.04), make_simple_lr(), ] make_submission = len(sys.argv) >= 2 and sys.argv[1] == 'submission' do_cv = not make_submission if do_cv: mask_range = [3] split_ratios = [0.4, 0.525, 0.6] run_prepare_data_for_cross_validation(settings, targets, pipelines) run_cross_validation(settings, targets, pipelines, mask_range, split_ratios, classifiers) if make_submission: num_masks = 10 split_ratio = 0.525 classifiers = [ # make_svm(gamma=0.0079, C=2.7), make_svm(gamma=0.0068, C=2.0), # make_svm(gamma=0.003, C=150.0), # make_lr(C=0.04), # make_simple_lr(), ] targets_and_pipelines = [] pipeline = pipelines[0] for classifier, classifier_name in classifiers: for i, target in enumerate(targets): run_prepare_data(settings, [target], [pipeline], test=True) feature_masks = generate_feature_masks(settings, target, pipeline, num_masks, split_ratio, random_state=0, quiet=True) targets_and_pipelines.append((target, pipeline, feature_masks, classifier, classifier_name)) run_make_submission(settings, targets_and_pipelines, split_ratio) if __name__ == "__main__": main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 504, 12866, 492, 15553, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 504, 6357, 14, 6759, 492, 882, 67, 63, 19129, 63, 3397, 199, 199, 504, 542, 565, 608, 63, 14845, 14, 27628, 492, 1852, 63, 16820, 12, 1852, 63, 4129, 63, 7493, 12, 1852, 63, 7493, 199, 504, 542, 565, 608, 63, 14845, 14, 4445, 63, 5592, 492, 3550, 63, 4445, 63, 25768, 199, 504, 542, 565, 608, 63, 14845, 14, 9996, 63, 11329, 492, 627, 199, 504, 542, 565, 608, 63, 14845, 14, 7379, 492, 19090, 12, 13407, 25536, 17562, 12, 6924, 2980, 199, 504, 542, 565, 608, 63, 14845, 14, 7107, 492, 664, 63, 3397, 63, 4705, 12, 870, 63, 2604, 199, 504, 542, 565, 608, 63, 14845, 14, 5054, 492, 1852, 63, 4737, 63, 509, 63, 1375, 63, 9869, 12, 2218, 63, 12542, 63, 493, 12, 971, 272, 8059, 63, 6136, 63, 3397, 12, 1104, 63, 7588, 63, 576, 63, 4591, 12, 1104, 63, 396, 63, 576, 63, 4591, 12, 1852, 63, 12542, 63, 9869, 199, 504, 542, 565, 608, 63, 14845, 14, 15133, 492, 15689, 281, 12, 7499, 5690, 12, 481, 2103, 8380, 5690, 12, 29484, 12, 971, 272, 603, 643, 78, 7779, 12, 510, 2100, 51, 15832, 31224, 12, 5297, 709, 12, 481, 2103, 13394, 1835, 12, 19005, 724, 27138, 12, 5543, 1412, 12, 869, 7902, 12, 510, 7902, 12, 869, 13305, 199, 504, 542, 565, 608, 63, 14845, 14, 1751, 492, 2248, 63, 1751, 199, 504, 2446, 492, 1255, 63, 6726, 63, 576, 63, 509, 63, 7925, 63, 6136, 421, 199, 318, 1255, 63, 1875, 63, 12542, 8, 1751, 12, 4545, 63, 460, 63, 4990, 1278, 12, 3715, 63, 6884, 304, 272, 4203, 275, 15553, 8, 1751, 14, 46, 63, 6920, 9, 272, 367, 284, 12, 334, 1375, 12, 7679, 12, 3878, 63, 25768, 12, 12429, 12, 12429, 63, 354, 9, 315, 3874, 8, 4684, 63, 460, 63, 4990, 1278, 304, 267, 367, 1335, 12, 3878, 63, 2629, 315, 3874, 8, 4445, 63, 25768, 304, 288, 6696, 63, 495, 275, 283, 52, 2458, 68, 3149, 68, 603, 2458, 68, 3149, 68, 7, 450, 334, 73, 11, 17, 12, 822, 8, 4684, 63, 460, 63, 4990, 1278, 395, 1335, 11, 17, 12, 822, 8, 4445, 63, 25768, 430, 288, 4203, 14, 4998, 63, 4146, 8, 1875, 63, 12542, 63, 9869, 12, 359, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 467, 355, 791, 4445, 63, 2629, 356, 3878, 63, 2629, 12, 283, 5734, 63, 495, 356, 6696, 63, 495, 12, 283, 10243, 356, 715, 1552, 272, 4203, 14, 1600, 342, 272, 4203, 14, 904, 342, 339, 19977, 874, 275, 788, 7548, 12, 657, 73, 319, 279, 418, 272, 1967, 63, 25768, 275, 488, 272, 12429, 63, 1247, 275, 942, 272, 367, 1347, 12, 7679, 12, 3878, 63, 25768, 12, 12429, 12, 12429, 63, 354, 315, 4545, 63, 460, 63, 4990, 1278, 26, 267, 12429, 63, 1247, 14, 740, 8, 14720, 63, 354, 9, 267, 340, 1967, 63, 25768, 365, 488, 26, 288, 1967, 63, 25768, 275, 822, 8, 4445, 63, 25768, 9, 267, 587, 26, 288, 702, 1967, 63, 25768, 508, 822, 8, 4445, 63, 25768, 9, 398, 511, 63, 9869, 275, 942, 398, 367, 3878, 63, 2629, 315, 3878, 63, 25768, 26, 288, 666, 275, 1852, 63, 12542, 63, 9869, 8, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 12, 3878, 63, 2629, 29, 4445, 63, 2629, 9, 288, 511, 63, 9869, 14, 740, 8, 576, 14, 3670, 63, 9869, 9, 398, 7914, 275, 980, 14, 3670, 8, 396, 63, 9869, 12, 3114, 29, 16, 9, 267, 19977, 874, 847, 1852, 63, 4737, 63, 509, 63, 1375, 63, 9869, 8, 1375, 12, 7914, 9, 339, 1072, 275, 1557, 78, 1370, 904, 8, 71, 10138, 874, 9, 272, 2218, 63, 12542, 63, 493, 8, 1751, 12, 1072, 12, 283, 15628, 302, 2458, 68, 3715, 63, 6884, 2458, 83, 7, 450, 334, 1507, 63, 25768, 12, 3715, 63, 6884, 395, 488, 12, 620, 8, 14720, 63, 1247, 395, 4545, 63, 460, 63, 4990, 1278, 9, 421, 199, 318, 1255, 63, 6726, 63, 576, 8, 1751, 12, 4545, 12, 5200, 1278, 12, 3560, 29, 549, 12, 511, 29, 797, 12, 11971, 29, 797, 304, 272, 367, 7679, 315, 5200, 1278, 26, 267, 367, 1347, 315, 4545, 26, 288, 870, 283, 2398, 462, 316, 666, 367, 297, 1347, 288, 340, 3560, 26, 355, 1104, 63, 7588, 63, 576, 63, 4591, 8, 1751, 12, 1347, 12, 7679, 12, 11971, 29, 10243, 9, 288, 340, 511, 26, 355, 1104, 63, 396, 63, 576, 63, 4591, 8, 1751, 12, 1347, 12, 7679, 12, 11971, 29, 10243, 9, 421, 199, 318, 1255, 63, 7925, 63, 6136, 8, 1751, 12, 4545, 12, 5200, 1278, 12, 3656, 63, 1842, 12, 3715, 63, 345, 9636, 12, 19137, 304, 272, 4203, 275, 15553, 8, 1751, 14, 46, 63, 6920, 9, 272, 367, 284, 12, 7679, 315, 3874, 8, 4990, 1278, 304, 267, 367, 1335, 12, 334, 14720, 12, 12429, 63, 354, 9, 315, 3874, 8, 27628, 304, 288, 367, 1022, 12, 1347, 315, 3874, 8, 4684, 304, 355, 4203, 14, 4998, 63, 4146, 8, 7925, 63, 6136, 63, 3397, 12, 359, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 467, 791, 10243, 356, 715, 1552, 355, 367, 3715, 63, 1507, 12, 3715, 63, 6884, 315, 3874, 8, 1294, 63, 345, 9636, 304, 490, 27996, 275, 3550, 63, 4445, 63, 25768, 8, 1751, 12, 1347, 12, 7679, 12, 980, 14, 988, 8, 2629, 63, 1842, 395, 3715, 63, 6884, 12, 2196, 63, 929, 29, 16, 12, 11971, 29, 549, 9, 490, 367, 3656, 63, 1507, 12, 3656, 315, 3874, 8, 25768, 304, 717, 6696, 63, 495, 275, 283, 48, 2458, 68, 3149, 68, 445, 2458, 68, 3149, 68, 377, 2458, 68, 3149, 68, 428, 2458, 68, 3149, 68, 603, 2458, 68, 3149, 68, 7, 450, 334, 73, 11, 17, 12, 822, 8, 4990, 1278, 395, 1335, 11, 17, 12, 822, 8, 27628, 395, 1022, 11, 17, 12, 822, 8, 4684, 395, 3715, 63, 1507, 11, 17, 12 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 199, 504, 12866, 492, 15553, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 504, 6357, 14, 6759, 492, 882, 67, 63, 19129, 63, 3397, 199, 199, 504, 542, 565, 608, 63, 14845, 14, 27628, 492, 1852, 63, 16820, 12, 1852, 63, 4129, 63, 7493, 12, 1852, 63, 7493, 199, 504, 542, 565, 608, 63, 14845, 14, 4445, 63, 5592, 492, 3550, 63, 4445, 63, 25768, 199, 504, 542, 565, 608, 63, 14845, 14, 9996, 63, 11329, 492, 627, 199, 504, 542, 565, 608, 63, 14845, 14, 7379, 492, 19090, 12, 13407, 25536, 17562, 12, 6924, 2980, 199, 504, 542, 565, 608, 63, 14845, 14, 7107, 492, 664, 63, 3397, 63, 4705, 12, 870, 63, 2604, 199, 504, 542, 565, 608, 63, 14845, 14, 5054, 492, 1852, 63, 4737, 63, 509, 63, 1375, 63, 9869, 12, 2218, 63, 12542, 63, 493, 12, 971, 272, 8059, 63, 6136, 63, 3397, 12, 1104, 63, 7588, 63, 576, 63, 4591, 12, 1104, 63, 396, 63, 576, 63, 4591, 12, 1852, 63, 12542, 63, 9869, 199, 504, 542, 565, 608, 63, 14845, 14, 15133, 492, 15689, 281, 12, 7499, 5690, 12, 481, 2103, 8380, 5690, 12, 29484, 12, 971, 272, 603, 643, 78, 7779, 12, 510, 2100, 51, 15832, 31224, 12, 5297, 709, 12, 481, 2103, 13394, 1835, 12, 19005, 724, 27138, 12, 5543, 1412, 12, 869, 7902, 12, 510, 7902, 12, 869, 13305, 199, 504, 542, 565, 608, 63, 14845, 14, 1751, 492, 2248, 63, 1751, 199, 504, 2446, 492, 1255, 63, 6726, 63, 576, 63, 509, 63, 7925, 63, 6136, 421, 199, 318, 1255, 63, 1875, 63, 12542, 8, 1751, 12, 4545, 63, 460, 63, 4990, 1278, 12, 3715, 63, 6884, 304, 272, 4203, 275, 15553, 8, 1751, 14, 46, 63, 6920, 9, 272, 367, 284, 12, 334, 1375, 12, 7679, 12, 3878, 63, 25768, 12, 12429, 12, 12429, 63, 354, 9, 315, 3874, 8, 4684, 63, 460, 63, 4990, 1278, 304, 267, 367, 1335, 12, 3878, 63, 2629, 315, 3874, 8, 4445, 63, 25768, 304, 288, 6696, 63, 495, 275, 283, 52, 2458, 68, 3149, 68, 603, 2458, 68, 3149, 68, 7, 450, 334, 73, 11, 17, 12, 822, 8, 4684, 63, 460, 63, 4990, 1278, 395, 1335, 11, 17, 12, 822, 8, 4445, 63, 25768, 430, 288, 4203, 14, 4998, 63, 4146, 8, 1875, 63, 12542, 63, 9869, 12, 359, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 467, 355, 791, 4445, 63, 2629, 356, 3878, 63, 2629, 12, 283, 5734, 63, 495, 356, 6696, 63, 495, 12, 283, 10243, 356, 715, 1552, 272, 4203, 14, 1600, 342, 272, 4203, 14, 904, 342, 339, 19977, 874, 275, 788, 7548, 12, 657, 73, 319, 279, 418, 272, 1967, 63, 25768, 275, 488, 272, 12429, 63, 1247, 275, 942, 272, 367, 1347, 12, 7679, 12, 3878, 63, 25768, 12, 12429, 12, 12429, 63, 354, 315, 4545, 63, 460, 63, 4990, 1278, 26, 267, 12429, 63, 1247, 14, 740, 8, 14720, 63, 354, 9, 267, 340, 1967, 63, 25768, 365, 488, 26, 288, 1967, 63, 25768, 275, 822, 8, 4445, 63, 25768, 9, 267, 587, 26, 288, 702, 1967, 63, 25768, 508, 822, 8, 4445, 63, 25768, 9, 398, 511, 63, 9869, 275, 942, 398, 367, 3878, 63, 2629, 315, 3878, 63, 25768, 26, 288, 666, 275, 1852, 63, 12542, 63, 9869, 8, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 12, 3878, 63, 2629, 29, 4445, 63, 2629, 9, 288, 511, 63, 9869, 14, 740, 8, 576, 14, 3670, 63, 9869, 9, 398, 7914, 275, 980, 14, 3670, 8, 396, 63, 9869, 12, 3114, 29, 16, 9, 267, 19977, 874, 847, 1852, 63, 4737, 63, 509, 63, 1375, 63, 9869, 8, 1375, 12, 7914, 9, 339, 1072, 275, 1557, 78, 1370, 904, 8, 71, 10138, 874, 9, 272, 2218, 63, 12542, 63, 493, 8, 1751, 12, 1072, 12, 283, 15628, 302, 2458, 68, 3715, 63, 6884, 2458, 83, 7, 450, 334, 1507, 63, 25768, 12, 3715, 63, 6884, 395, 488, 12, 620, 8, 14720, 63, 1247, 395, 4545, 63, 460, 63, 4990, 1278, 9, 421, 199, 318, 1255, 63, 6726, 63, 576, 8, 1751, 12, 4545, 12, 5200, 1278, 12, 3560, 29, 549, 12, 511, 29, 797, 12, 11971, 29, 797, 304, 272, 367, 7679, 315, 5200, 1278, 26, 267, 367, 1347, 315, 4545, 26, 288, 870, 283, 2398, 462, 316, 666, 367, 297, 1347, 288, 340, 3560, 26, 355, 1104, 63, 7588, 63, 576, 63, 4591, 8, 1751, 12, 1347, 12, 7679, 12, 11971, 29, 10243, 9, 288, 340, 511, 26, 355, 1104, 63, 396, 63, 576, 63, 4591, 8, 1751, 12, 1347, 12, 7679, 12, 11971, 29, 10243, 9, 421, 199, 318, 1255, 63, 7925, 63, 6136, 8, 1751, 12, 4545, 12, 5200, 1278, 12, 3656, 63, 1842, 12, 3715, 63, 345, 9636, 12, 19137, 304, 272, 4203, 275, 15553, 8, 1751, 14, 46, 63, 6920, 9, 272, 367, 284, 12, 7679, 315, 3874, 8, 4990, 1278, 304, 267, 367, 1335, 12, 334, 14720, 12, 12429, 63, 354, 9, 315, 3874, 8, 27628, 304, 288, 367, 1022, 12, 1347, 315, 3874, 8, 4684, 304, 355, 4203, 14, 4998, 63, 4146, 8, 7925, 63, 6136, 63, 3397, 12, 359, 1751, 12, 1347, 12, 7679, 12, 12429, 12, 12429, 63, 354, 467, 791, 10243, 356, 715, 1552, 355, 367, 3715, 63, 1507, 12, 3715, 63, 6884, 315, 3874, 8, 1294, 63, 345, 9636, 304, 490, 27996, 275, 3550, 63, 4445, 63, 25768, 8, 1751, 12, 1347, 12, 7679, 12, 980, 14, 988, 8, 2629, 63, 1842, 395, 3715, 63, 6884, 12, 2196, 63, 929, 29, 16, 12, 11971, 29, 549, 9, 490, 367, 3656, 63, 1507, 12, 3656, 315, 3874, 8, 25768, 304, 717, 6696, 63, 495, 275, 283, 48, 2458, 68, 3149, 68, 445, 2458, 68, 3149, 68, 377, 2458, 68, 3149, 68, 428, 2458, 68, 3149, 68, 603, 2458, 68, 3149, 68, 7, 450, 334, 73, 11, 17, 12, 822, 8, 4990, 1278, 395, 1335, 11, 17, 12, 822, 8, 27628, 395, 1022, 11, 17, 12, 822, 8, 4684, 395, 3715, 63, 1507, 11, 17, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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rics.py
131
2392
#!/usr/bin/python # # generate pyschometrics data from tracking logs and student module data import json from courseware.models import StudentModule from track.models import TrackingLog from psychometrics.models import PsychometricData from django.conf import settings from django.core.management.base import BaseCommand #db = "ocwtutor" # for debugging #db = "default" db = getattr(settings, 'DATABASE_FOR_PSYCHOMETRICS', 'default') class Command(BaseCommand): help = "initialize PsychometricData tables from StudentModule instances (and tracking data, if in SQL)." help += "Note this is done for all courses for which StudentModule instances exist." def handle(self, *args, **options): # delete all pmd #PsychometricData.objects.all().delete() #PsychometricData.objects.using(db).all().delete() smset = StudentModule.objects.using(db).exclude(max_grade=None) for sm in smset: usage_key = sm.module_state_key if not usage_key.block_type == "problem": continue try: state = json.loads(sm.state) done = state['done'] except: print "Oops, failed to eval state for %s (state=%s)" % (sm, sm.state) continue if done: # only keep if problem completed try: pmd = PsychometricData.objects.using(db).get(studentmodule=sm) except PsychometricData.DoesNotExist: pmd = PsychometricData(studentmodule=sm) pmd.done = done pmd.attempts = state['attempts'] # get attempt times from tracking log uname = sm.student.username tset = TrackingLog.objects.using(db).filter(username=uname, event_type__contains='problem_check') tset = tset.filter(event_source='server') tset = tset.filter(event__contains="'%s'" % usage_key) checktimes = [x.dtcreated for x in tset] pmd.checktimes = checktimes if not len(checktimes) == pmd.attempts: print "Oops, mismatch in number of attempts and check times for %s" % pmd #print pmd pmd.save(using=db) print "%d PMD entries" % PsychometricData.objects.using(db).all().count()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 3550, 10382, 335, 1377, 599, 1259, 666, 687, 15161, 9610, 436, 6474, 859, 666, 199, 199, 646, 2022, 199, 199, 504, 20736, 14, 992, 492, 17246, 2377, 199, 504, 4426, 14, 992, 492, 17507, 316, 2445, 199, 504, 14177, 335, 1377, 599, 1259, 14, 992, 492, 510, 1786, 335, 15890, 1451, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 3, 697, 275, 298, 679, 9115, 4139, 2, 198, 3, 367, 10201, 199, 3, 697, 275, 298, 885, 2, 199, 199, 697, 275, 2519, 8, 1751, 12, 283, 17873, 63, 2707, 63, 48, 4669, 10465, 30476, 297, 283, 885, 358, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 8489, 510, 1786, 335, 15890, 1451, 6716, 687, 17246, 2377, 4454, 334, 460, 15161, 666, 12, 340, 315, 5385, 17617, 272, 1720, 847, 298, 7443, 642, 365, 4224, 367, 1006, 13588, 367, 1314, 17246, 2377, 4454, 2187, 2122, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 327, 3145, 1006, 299, 1064, 398, 327, 48, 1786, 335, 15890, 1451, 14, 1462, 14, 452, 1252, 1807, 342, 267, 327, 48, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 452, 1252, 1807, 342, 398, 4383, 409, 275, 17246, 2377, 14, 1462, 14, 4941, 8, 697, 680, 5473, 8, 988, 63, 4523, 29, 403, 9, 398, 367, 4383, 315, 4383, 409, 26, 288, 4503, 63, 498, 275, 4383, 14, 578, 63, 929, 63, 498, 288, 340, 440, 4503, 63, 498, 14, 1457, 63, 466, 508, 298, 6462, 582, 355, 1980, 288, 862, 26, 355, 1174, 275, 2022, 14, 3640, 8, 3300, 14, 929, 9, 355, 4224, 275, 1174, 459, 4456, 418, 288, 871, 26, 355, 870, 298, 47, 1483, 12, 3405, 370, 3468, 1174, 367, 450, 83, 334, 929, 2458, 83, 2924, 450, 334, 3300, 12, 4383, 14, 929, 9, 355, 1980, 953, 340, 4224, 26, 1057, 198, 3, 1454, 4215, 340, 5160, 9709, 355, 862, 26, 490, 299, 1064, 275, 510, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 362, 8, 5500, 578, 29, 3300, 9, 355, 871, 510, 1786, 335, 15890, 1451, 14, 7400, 26, 490, 299, 1064, 275, 510, 1786, 335, 15890, 1451, 8, 5500, 578, 29, 3300, 9, 2234, 299, 1064, 14, 4456, 275, 4224, 355, 299, 1064, 14, 13143, 275, 1174, 459, 13143, 418, 2234, 327, 664, 7427, 5431, 687, 15161, 943, 355, 28179, 275, 4383, 14, 5500, 14, 2473, 355, 307, 409, 275, 17507, 316, 2445, 14, 1462, 14, 4941, 8, 697, 680, 1541, 8, 2473, 29, 16040, 12, 1566, 63, 466, 363, 6134, 534, 6462, 63, 1074, 358, 355, 307, 409, 275, 307, 409, 14, 1541, 8, 1430, 63, 1365, 534, 1000, 358, 355, 307, 409, 275, 307, 409, 14, 1541, 8, 1430, 363, 6134, 628, 5956, 83, 4065, 450, 4503, 63, 498, 9, 355, 1104, 4508, 275, 359, 88, 14, 3583, 3966, 367, 671, 315, 307, 409, 61, 355, 299, 1064, 14, 1074, 4508, 275, 1104, 4508, 355, 340, 440, 822, 8, 1074, 4508, 9, 508, 299, 1064, 14, 13143, 26, 490, 870, 298, 47, 1483, 12, 15015, 315, 1329, 402, 12454, 436, 1104, 5431, 367, 450, 83, 2, 450, 299, 1064, 2234, 327, 1361, 299, 1064, 355, 299, 1064, 14, 2117, 8, 4941, 29, 697, 9, 398, 870, 2071, 68, 510, 5127, 4811, 2, 450, 510, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 452, 1252, 835, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 3550, 10382, 335, 1377, 599, 1259, 666, 687, 15161, 9610, 436, 6474, 859, 666, 199, 199, 646, 2022, 199, 199, 504, 20736, 14, 992, 492, 17246, 2377, 199, 504, 4426, 14, 992, 492, 17507, 316, 2445, 199, 504, 14177, 335, 1377, 599, 1259, 14, 992, 492, 510, 1786, 335, 15890, 1451, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 3, 697, 275, 298, 679, 9115, 4139, 2, 198, 3, 367, 10201, 199, 3, 697, 275, 298, 885, 2, 199, 199, 697, 275, 2519, 8, 1751, 12, 283, 17873, 63, 2707, 63, 48, 4669, 10465, 30476, 297, 283, 885, 358, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 298, 8489, 510, 1786, 335, 15890, 1451, 6716, 687, 17246, 2377, 4454, 334, 460, 15161, 666, 12, 340, 315, 5385, 17617, 272, 1720, 847, 298, 7443, 642, 365, 4224, 367, 1006, 13588, 367, 1314, 17246, 2377, 4454, 2187, 2122, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 327, 3145, 1006, 299, 1064, 398, 327, 48, 1786, 335, 15890, 1451, 14, 1462, 14, 452, 1252, 1807, 342, 267, 327, 48, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 452, 1252, 1807, 342, 398, 4383, 409, 275, 17246, 2377, 14, 1462, 14, 4941, 8, 697, 680, 5473, 8, 988, 63, 4523, 29, 403, 9, 398, 367, 4383, 315, 4383, 409, 26, 288, 4503, 63, 498, 275, 4383, 14, 578, 63, 929, 63, 498, 288, 340, 440, 4503, 63, 498, 14, 1457, 63, 466, 508, 298, 6462, 582, 355, 1980, 288, 862, 26, 355, 1174, 275, 2022, 14, 3640, 8, 3300, 14, 929, 9, 355, 4224, 275, 1174, 459, 4456, 418, 288, 871, 26, 355, 870, 298, 47, 1483, 12, 3405, 370, 3468, 1174, 367, 450, 83, 334, 929, 2458, 83, 2924, 450, 334, 3300, 12, 4383, 14, 929, 9, 355, 1980, 953, 340, 4224, 26, 1057, 198, 3, 1454, 4215, 340, 5160, 9709, 355, 862, 26, 490, 299, 1064, 275, 510, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 362, 8, 5500, 578, 29, 3300, 9, 355, 871, 510, 1786, 335, 15890, 1451, 14, 7400, 26, 490, 299, 1064, 275, 510, 1786, 335, 15890, 1451, 8, 5500, 578, 29, 3300, 9, 2234, 299, 1064, 14, 4456, 275, 4224, 355, 299, 1064, 14, 13143, 275, 1174, 459, 13143, 418, 2234, 327, 664, 7427, 5431, 687, 15161, 943, 355, 28179, 275, 4383, 14, 5500, 14, 2473, 355, 307, 409, 275, 17507, 316, 2445, 14, 1462, 14, 4941, 8, 697, 680, 1541, 8, 2473, 29, 16040, 12, 1566, 63, 466, 363, 6134, 534, 6462, 63, 1074, 358, 355, 307, 409, 275, 307, 409, 14, 1541, 8, 1430, 63, 1365, 534, 1000, 358, 355, 307, 409, 275, 307, 409, 14, 1541, 8, 1430, 363, 6134, 628, 5956, 83, 4065, 450, 4503, 63, 498, 9, 355, 1104, 4508, 275, 359, 88, 14, 3583, 3966, 367, 671, 315, 307, 409, 61, 355, 299, 1064, 14, 1074, 4508, 275, 1104, 4508, 355, 340, 440, 822, 8, 1074, 4508, 9, 508, 299, 1064, 14, 13143, 26, 490, 870, 298, 47, 1483, 12, 15015, 315, 1329, 402, 12454, 436, 1104, 5431, 367, 450, 83, 2, 450, 299, 1064, 2234, 327, 1361, 299, 1064, 355, 299, 1064, 14, 2117, 8, 4941, 29, 697, 9, 398, 870, 2071, 68, 510, 5127, 4811, 2, 450, 510, 1786, 335, 15890, 1451, 14, 1462, 14, 4941, 8, 697, 680, 452, 1252, 835, 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, 0 ]
[ 1, 1, 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django-startup
{{cookiecutter.project_slug}}/app/accounts/migrations/0001_initial.py
2
2936
# Generated by Django 2.0.2 on 2018-03-01 13:26 import django.contrib.auth.models import django.contrib.auth.validators from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0009_alter_user_last_name_max_length'), ] operations = [ migrations.CreateModel( name='User', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('display_name', models.CharField(max_length=150)), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ 'verbose_name': 'user', 'verbose_name_plural': 'users', 'abstract': False, }, managers=[ ('objects', django.contrib.auth.models.UserManager()), ], ), ]
mit
[ 3, 17065, 701, 5634, 499, 14, 16, 14, 18, 641, 14894, 13, 1644, 13, 614, 4944, 26, 1479, 199, 199, 646, 1639, 14, 2828, 14, 1178, 14, 992, 199, 646, 1639, 14, 2828, 14, 1178, 14, 11346, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 661, 1178, 297, 283, 21144, 63, 11858, 63, 751, 63, 2019, 63, 354, 63, 988, 63, 1267, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 1899, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 2060, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 3933, 12, 3376, 63, 354, 534, 2060, 3855, 355, 661, 2019, 63, 2886, 297, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 2019, 4676, 3855, 355, 661, 374, 63, 11434, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 1720, 63, 505, 534, 20924, 2335, 626, 642, 922, 965, 1006, 3443, 1928, 7662, 26694, 3062, 3130, 3376, 63, 354, 534, 11434, 2004, 3855, 355, 661, 2473, 297, 1709, 14, 2183, 8, 705, 63, 3431, 3713, 3235, 356, 283, 33, 922, 543, 626, 3434, 2575, 3495, 14, 2267, 1720, 63, 505, 534, 8030, 14, 14711, 4110, 503, 27392, 14, 12230, 878, 12, 7576, 436, 768, 8083, 15, 19616, 13, 15607, 1454, 3130, 1390, 63, 1267, 29, 8251, 12, 3747, 29, 549, 12, 14370, 1524, 1176, 14, 2828, 14, 1178, 14, 11346, 14, 7087, 13355, 8640, 15618, 3376, 63, 354, 534, 2473, 3855, 355, 661, 2246, 63, 354, 297, 1709, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 1216, 12, 3376, 63, 354, 534, 2246, 536, 3855, 355, 661, 2019, 63, 354, 297, 1709, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 8251, 12, 3376, 63, 354, 534, 2019, 536, 3855, 355, 661, 2123, 297, 1709, 14, 16577, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 8306, 12, 3376, 63, 354, 534, 2123, 2287, 3855, 355, 661, 374, 63, 7018, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 1720, 63, 505, 534, 20924, 2335, 3775, 314, 922, 883, 943, 1901, 642, 4628, 4770, 3130, 3376, 63, 354, 534, 7018, 2004, 3855, 355, 661, 374, 63, 2682, 297, 1709, 14, 5036, 8, 885, 29, 549, 12, 1720, 63, 505, 534, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 4702, 14, 1910, 2416, 642, 3140, 402, 13794, 12639, 3130, 3376, 63, 354, 534, 2682, 3855, 355, 661, 602, 63, 11806, 297, 1709, 14, 4626, 8, 885, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 12, 3376, 63, 354, 534, 602, 16538, 3855, 355, 661, 2918, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 1826, 355, 661, 2634, 297, 1709, 14, 7624, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 1918, 4652, 642, 922, 15006, 370, 14, 437, 922, 911, 664, 1006, 3443, 10009, 370, 1924, 402, 3932, 4652, 3130, 4048, 63, 354, 534, 751, 63, 409, 297, 4048, 63, 1131, 63, 354, 534, 751, 297, 370, 534, 1178, 14, 2448, 297, 3376, 63, 354, 534, 2634, 3855, 355, 661, 751, 63, 6060, 297, 1709, 14, 7624, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 16786, 3443, 367, 642, 922, 3130, 4048, 63, 354, 534, 751, 63, 409, 297, 4048, 63, 1131, 63, 354, 534, 751, 297, 370, 534, 1178, 14, 7980, 297, 3376, 63, 354, 534, 751, 3443, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 751, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 3707, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 19680, 1524, 355, 661, 1462, 297, 1639, 14, 2828, 14, 1178, 14, 992, 14, 1899, 2988, 4000, 288, 2156, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17065, 701, 5634, 499, 14, 16, 14, 18, 641, 14894, 13, 1644, 13, 614, 4944, 26, 1479, 199, 199, 646, 1639, 14, 2828, 14, 1178, 14, 992, 199, 646, 1639, 14, 2828, 14, 1178, 14, 11346, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 661, 1178, 297, 283, 21144, 63, 11858, 63, 751, 63, 2019, 63, 354, 63, 988, 63, 1267, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 1899, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 2060, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 3933, 12, 3376, 63, 354, 534, 2060, 3855, 355, 661, 2019, 63, 2886, 297, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 2019, 4676, 3855, 355, 661, 374, 63, 11434, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 1720, 63, 505, 534, 20924, 2335, 626, 642, 922, 965, 1006, 3443, 1928, 7662, 26694, 3062, 3130, 3376, 63, 354, 534, 11434, 2004, 3855, 355, 661, 2473, 297, 1709, 14, 2183, 8, 705, 63, 3431, 3713, 3235, 356, 283, 33, 922, 543, 626, 3434, 2575, 3495, 14, 2267, 1720, 63, 505, 534, 8030, 14, 14711, 4110, 503, 27392, 14, 12230, 878, 12, 7576, 436, 768, 8083, 15, 19616, 13, 15607, 1454, 3130, 1390, 63, 1267, 29, 8251, 12, 3747, 29, 549, 12, 14370, 1524, 1176, 14, 2828, 14, 1178, 14, 11346, 14, 7087, 13355, 8640, 15618, 3376, 63, 354, 534, 2473, 3855, 355, 661, 2246, 63, 354, 297, 1709, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 1216, 12, 3376, 63, 354, 534, 2246, 536, 3855, 355, 661, 2019, 63, 354, 297, 1709, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 8251, 12, 3376, 63, 354, 534, 2019, 536, 3855, 355, 661, 2123, 297, 1709, 14, 16577, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 8306, 12, 3376, 63, 354, 534, 2123, 2287, 3855, 355, 661, 374, 63, 7018, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 1720, 63, 505, 534, 20924, 2335, 3775, 314, 922, 883, 943, 1901, 642, 4628, 4770, 3130, 3376, 63, 354, 534, 7018, 2004, 3855, 355, 661, 374, 63, 2682, 297, 1709, 14, 5036, 8, 885, 29, 549, 12, 1720, 63, 505, 534, 20924, 2335, 3775, 642, 922, 1077, 506, 10184, 465, 4702, 14, 1910, 2416, 642, 3140, 402, 13794, 12639, 3130, 3376, 63, 354, 534, 2682, 3855, 355, 661, 602, 63, 11806, 297, 1709, 14, 4626, 8, 885, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 12, 3376, 63, 354, 534, 602, 16538, 3855, 355, 661, 2918, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 8251, 1826, 355, 661, 2634, 297, 1709, 14, 7624, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 1918, 4652, 642, 922, 15006, 370, 14, 437, 922, 911, 664, 1006, 3443, 10009, 370, 1924, 402, 3932, 4652, 3130, 4048, 63, 354, 534, 751, 63, 409, 297, 4048, 63, 1131, 63, 354, 534, 751, 297, 370, 534, 1178, 14, 2448, 297, 3376, 63, 354, 534, 2634, 3855, 355, 661, 751, 63, 6060, 297, 1709, 14, 7624, 8, 2500, 29, 549, 12, 1720, 63, 505, 534, 16786, 3443, 367, 642, 922, 3130, 4048, 63, 354, 534, 751, 63, 409, 297, 4048, 63, 1131, 63, 354, 534, 751, 297, 370, 534, 1178, 14, 7980, 297, 3376, 63, 354, 534, 751, 3443, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 751, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 3707, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 19680, 1524, 355, 661, 1462, 297, 1639, 14, 2828, 14, 1178, 14, 992, 14, 1899, 2988, 4000, 288, 2156, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hwfwgrp/project_generator
tests/test_pgenworkspace.py
2
2110
# Copyright 2015 0xc0170 # # 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 os import shutil import yaml from unittest import TestCase from project_generator.generate import Generator project_1_yaml = { 'common': { 'sources': ['sources/main.cpp'], 'includes': ['includes/header1.h'] } } projects_yaml = { 'projects': { 'project_1' : ['test_workspace/project_1.yaml'] }, 'settings' : { 'definitions_dir': ['notpg/path/somewhere'], 'export_dir': ['not_generated_projects'] } } class TestPgenWorkspace(TestCase): """test things related to the PgenWorkspace class""" def setUp(self): if not os.path.exists('test_workspace'): os.makedirs('test_workspace') # write project file with open(os.path.join(os.getcwd(), 'test_workspace/project_1.yaml'), 'wt') as f: f.write(yaml.dump(project_1_yaml, default_flow_style=False)) # write projects file with open(os.path.join(os.getcwd(), 'test_workspace/projects.yaml'), 'wt') as f: f.write(yaml.dump(projects_yaml, default_flow_style=False)) self.workspace = Generator('test_workspace/projects.yaml') def tearDown(self): # remove created directory shutil.rmtree('test_workspace', ignore_errors=True) def test_settings(self): # only check things which are affected by projects.yaml assert self.workspace.settings.paths['definitions'] == os.path.normpath('notpg/path/somewhere') assert self.workspace.settings.export_location_format == 'not_generated_projects'
apache-2.0
[ 3, 1898, 6900, 378, 1812, 614, 2760, 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, 646, 747, 199, 646, 5145, 199, 199, 646, 8864, 199, 504, 2882, 492, 7640, 199, 199, 504, 2199, 63, 4679, 14, 4208, 492, 15042, 199, 199, 1715, 63, 17, 63, 5963, 275, 469, 272, 283, 2330, 356, 469, 267, 283, 4553, 356, 788, 4553, 15, 973, 14, 5910, 995, 267, 283, 9441, 356, 788, 9441, 15, 1291, 17, 14, 72, 418, 272, 789, 199, 93, 199, 199, 6776, 63, 5963, 275, 469, 272, 283, 6776, 356, 469, 267, 283, 1715, 63, 17, 7, 520, 788, 396, 63, 13249, 15, 1715, 63, 17, 14, 5963, 418, 272, 1660, 272, 283, 1751, 7, 520, 469, 267, 283, 15388, 63, 694, 356, 788, 1397, 4198, 15, 515, 15, 3972, 4509, 995, 267, 283, 3790, 63, 694, 356, 788, 1397, 63, 10176, 63, 6776, 418, 272, 789, 199, 93, 199, 199, 533, 1379, 48, 2268, 21058, 8, 1746, 304, 339, 408, 396, 7645, 4048, 370, 314, 510, 2268, 21058, 1021, 624, 339, 347, 3613, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 360, 396, 63, 13249, 735, 288, 747, 14, 8347, 360, 396, 63, 13249, 358, 267, 327, 2218, 2199, 570, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 283, 396, 63, 13249, 15, 1715, 63, 17, 14, 5963, 659, 283, 9115, 358, 465, 289, 26, 288, 289, 14, 952, 8, 5963, 14, 2724, 8, 1715, 63, 17, 63, 5963, 12, 849, 63, 1659, 63, 2487, 29, 797, 430, 267, 327, 2218, 11336, 570, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 283, 396, 63, 13249, 15, 6776, 14, 5963, 659, 283, 9115, 358, 465, 289, 26, 288, 289, 14, 952, 8, 5963, 14, 2724, 8, 6776, 63, 5963, 12, 849, 63, 1659, 63, 2487, 29, 797, 430, 267, 291, 14, 13249, 275, 15042, 360, 396, 63, 13249, 15, 6776, 14, 5963, 358, 339, 347, 6766, 8, 277, 304, 267, 327, 2813, 2737, 2082, 267, 5145, 14, 9242, 360, 396, 63, 13249, 297, 3686, 63, 2550, 29, 549, 9, 339, 347, 511, 63, 1751, 8, 277, 304, 267, 327, 1454, 1104, 7645, 1314, 787, 16955, 701, 11336, 14, 5963, 267, 702, 291, 14, 13249, 14, 1751, 14, 3771, 459, 15388, 418, 508, 747, 14, 515, 14, 9267, 360, 1397, 4198, 15, 515, 15, 3972, 4509, 358, 267, 702, 291, 14, 13249, 14, 1751, 14, 3790, 63, 1985, 63, 908, 508, 283, 1397, 63, 10176, 63, 6776, 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 ]
[ 1898, 6900, 378, 1812, 614, 2760, 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, 646, 747, 199, 646, 5145, 199, 199, 646, 8864, 199, 504, 2882, 492, 7640, 199, 199, 504, 2199, 63, 4679, 14, 4208, 492, 15042, 199, 199, 1715, 63, 17, 63, 5963, 275, 469, 272, 283, 2330, 356, 469, 267, 283, 4553, 356, 788, 4553, 15, 973, 14, 5910, 995, 267, 283, 9441, 356, 788, 9441, 15, 1291, 17, 14, 72, 418, 272, 789, 199, 93, 199, 199, 6776, 63, 5963, 275, 469, 272, 283, 6776, 356, 469, 267, 283, 1715, 63, 17, 7, 520, 788, 396, 63, 13249, 15, 1715, 63, 17, 14, 5963, 418, 272, 1660, 272, 283, 1751, 7, 520, 469, 267, 283, 15388, 63, 694, 356, 788, 1397, 4198, 15, 515, 15, 3972, 4509, 995, 267, 283, 3790, 63, 694, 356, 788, 1397, 63, 10176, 63, 6776, 418, 272, 789, 199, 93, 199, 199, 533, 1379, 48, 2268, 21058, 8, 1746, 304, 339, 408, 396, 7645, 4048, 370, 314, 510, 2268, 21058, 1021, 624, 339, 347, 3613, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 360, 396, 63, 13249, 735, 288, 747, 14, 8347, 360, 396, 63, 13249, 358, 267, 327, 2218, 2199, 570, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 283, 396, 63, 13249, 15, 1715, 63, 17, 14, 5963, 659, 283, 9115, 358, 465, 289, 26, 288, 289, 14, 952, 8, 5963, 14, 2724, 8, 1715, 63, 17, 63, 5963, 12, 849, 63, 1659, 63, 2487, 29, 797, 430, 267, 327, 2218, 11336, 570, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 283, 396, 63, 13249, 15, 6776, 14, 5963, 659, 283, 9115, 358, 465, 289, 26, 288, 289, 14, 952, 8, 5963, 14, 2724, 8, 6776, 63, 5963, 12, 849, 63, 1659, 63, 2487, 29, 797, 430, 267, 291, 14, 13249, 275, 15042, 360, 396, 63, 13249, 15, 6776, 14, 5963, 358, 339, 347, 6766, 8, 277, 304, 267, 327, 2813, 2737, 2082, 267, 5145, 14, 9242, 360, 396, 63, 13249, 297, 3686, 63, 2550, 29, 549, 9, 339, 347, 511, 63, 1751, 8, 277, 304, 267, 327, 1454, 1104, 7645, 1314, 787, 16955, 701, 11336, 14, 5963, 267, 702, 291, 14, 13249, 14, 1751, 14, 3771, 459, 15388, 418, 508, 747, 14, 515, 14, 9267, 360, 1397, 4198, 15, 515, 15, 3972, 4509, 358, 267, 702, 291, 14, 13249, 14, 1751, 14, 3790, 63, 1985, 63, 908, 508, 283, 1397, 63, 10176, 63, 6776, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ioannistsanaktsidis/invenio
modules/websubmit/lib/functions/Insert_Modify_Record.py
26
2500
## This file is part of Invenio. ## Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. __revision__ = "$Id$" import os import shutil import time import tempfile from invenio.config import \ CFG_TMPDIR from invenio.websubmit_config import InvenioWebSubmitFunctionError from invenio.websubmit_functions.Shared_Functions import ParamFromFile from invenio.bibtask import task_low_level_submission, bibtask_allocate_sequenceid def Insert_Modify_Record(parameters, curdir, form, user_info=None): """ Modify existing record using 'curdir/recmysql' and BibUpload correct mode. The file must therefore already have been created prior to this execution of this function, for eg. using "Make_Modify_Record". This function gets the output of BibConvert and uploads it into the MySQL bibliographical database. """ global rn sequence_id = bibtask_allocate_sequenceid(curdir) if os.path.exists(os.path.join(curdir, "recmysqlfmt")): recfile = "recmysqlfmt" elif os.path.exists(os.path.join(curdir, "recmysql")): recfile = "recmysql" else: raise InvenioWebSubmitFunctionError("Could not find record file") initial_file = os.path.join(curdir, recfile) tmp_fd, final_file = tempfile.mkstemp(dir=CFG_TMPDIR, prefix="%s_%s" % \ (rn.replace('/', '_'), time.strftime("%Y-%m-%d_%H:%M:%S"))) os.close(tmp_fd) shutil.copy(initial_file, final_file) bibupload_id = task_low_level_submission('bibupload', 'websubmit.Insert_Modify_Record', '-c', final_file, '-P', '3', '-I', str(sequence_id)) open(os.path.join(curdir, 'bibupload_id'), 'w').write(str(bibupload_id)) return ""
gpl-2.0
[ 309, 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 900, 199, 646, 5549, 199, 199, 504, 13640, 14, 888, 492, 971, 1362, 10974, 63, 17983, 3022, 199, 504, 13640, 14, 2520, 7275, 63, 888, 492, 12235, 5926, 17187, 3481, 547, 199, 504, 13640, 14, 2520, 7275, 63, 5777, 14, 12197, 63, 13967, 492, 12608, 26637, 199, 504, 13640, 14, 8804, 1765, 492, 2120, 63, 674, 63, 1896, 63, 12542, 12, 11314, 1765, 63, 12991, 63, 4041, 344, 199, 199, 318, 15496, 63, 18357, 63, 5433, 8, 3214, 12, 1094, 694, 12, 1824, 12, 922, 63, 815, 29, 403, 304, 272, 408, 272, 22520, 3411, 2777, 1808, 283, 15594, 15, 2761, 8644, 7, 436, 21949, 10301, 3211, 272, 818, 14, 710, 570, 1471, 16119, 2575, 1172, 2757, 2737, 6791, 370, 642, 272, 6451, 402, 642, 805, 12, 367, 11837, 14, 1808, 298, 5483, 63, 18357, 63, 5433, 1674, 339, 961, 805, 7545, 314, 1072, 402, 21949, 7306, 436, 26598, 652, 1901, 272, 314, 11200, 11314, 14437, 2180, 2652, 3050, 14, 272, 408, 272, 2288, 519, 78, 272, 3414, 63, 344, 275, 11314, 1765, 63, 12991, 63, 4041, 344, 8, 15594, 9, 272, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 298, 2761, 23726, 81, 276, 2037, 14150, 267, 6488, 493, 275, 298, 2761, 23726, 81, 276, 2037, 2, 272, 916, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 298, 2761, 8644, 14150, 267, 6488, 493, 275, 298, 2761, 8644, 2, 272, 587, 26, 267, 746, 12235, 5926, 17187, 3481, 547, 480, 6531, 440, 2342, 2777, 570, 531, 272, 2536, 63, 493, 275, 747, 14, 515, 14, 904, 8, 15594, 12, 6488, 493, 9, 272, 3529, 63, 2592, 12, 4242, 63, 493, 275, 5549, 14, 17721, 8, 694, 29, 10118, 63, 17983, 3022, 12, 5101, 2403, 5961, 83, 4970, 83, 2, 450, 971, 5101, 334, 11641, 14, 1814, 10998, 2513, 659, 5644, 900, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 4970, 40, 2689, 45, 2689, 51, 13324, 272, 747, 14, 1600, 8, 2791, 63, 2592, 9, 272, 5145, 14, 1574, 8, 2747, 63, 493, 12, 4242, 63, 493, 9, 272, 11314, 5064, 63, 344, 275, 2120, 63, 674, 63, 1896, 63, 12542, 360, 8804, 5064, 297, 283, 2520, 7275, 14, 9971, 63, 18357, 63, 5433, 297, 2475, 67, 297, 4242, 63, 493, 12, 2475, 48, 297, 283, 19, 297, 2475, 41, 297, 620, 8, 4041, 63, 344, 430, 272, 1551, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 283, 8804, 5064, 63, 344, 659, 283, 87, 1959, 952, 8, 495, 8, 8804, 5064, 63, 344, 430, 272, 372, 3087, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 900, 199, 646, 5549, 199, 199, 504, 13640, 14, 888, 492, 971, 1362, 10974, 63, 17983, 3022, 199, 504, 13640, 14, 2520, 7275, 63, 888, 492, 12235, 5926, 17187, 3481, 547, 199, 504, 13640, 14, 2520, 7275, 63, 5777, 14, 12197, 63, 13967, 492, 12608, 26637, 199, 504, 13640, 14, 8804, 1765, 492, 2120, 63, 674, 63, 1896, 63, 12542, 12, 11314, 1765, 63, 12991, 63, 4041, 344, 199, 199, 318, 15496, 63, 18357, 63, 5433, 8, 3214, 12, 1094, 694, 12, 1824, 12, 922, 63, 815, 29, 403, 304, 272, 408, 272, 22520, 3411, 2777, 1808, 283, 15594, 15, 2761, 8644, 7, 436, 21949, 10301, 3211, 272, 818, 14, 710, 570, 1471, 16119, 2575, 1172, 2757, 2737, 6791, 370, 642, 272, 6451, 402, 642, 805, 12, 367, 11837, 14, 1808, 298, 5483, 63, 18357, 63, 5433, 1674, 339, 961, 805, 7545, 314, 1072, 402, 21949, 7306, 436, 26598, 652, 1901, 272, 314, 11200, 11314, 14437, 2180, 2652, 3050, 14, 272, 408, 272, 2288, 519, 78, 272, 3414, 63, 344, 275, 11314, 1765, 63, 12991, 63, 4041, 344, 8, 15594, 9, 272, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 298, 2761, 23726, 81, 276, 2037, 14150, 267, 6488, 493, 275, 298, 2761, 23726, 81, 276, 2037, 2, 272, 916, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 298, 2761, 8644, 14150, 267, 6488, 493, 275, 298, 2761, 8644, 2, 272, 587, 26, 267, 746, 12235, 5926, 17187, 3481, 547, 480, 6531, 440, 2342, 2777, 570, 531, 272, 2536, 63, 493, 275, 747, 14, 515, 14, 904, 8, 15594, 12, 6488, 493, 9, 272, 3529, 63, 2592, 12, 4242, 63, 493, 275, 5549, 14, 17721, 8, 694, 29, 10118, 63, 17983, 3022, 12, 5101, 2403, 5961, 83, 4970, 83, 2, 450, 971, 5101, 334, 11641, 14, 1814, 10998, 2513, 659, 5644, 900, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 4970, 40, 2689, 45, 2689, 51, 13324, 272, 747, 14, 1600, 8, 2791, 63, 2592, 9, 272, 5145, 14, 1574, 8, 2747, 63, 493, 12, 4242, 63, 493, 9, 272, 11314, 5064, 63, 344, 275, 2120, 63, 674, 63, 1896, 63, 12542, 360, 8804, 5064, 297, 283, 2520, 7275, 14, 9971, 63, 18357, 63, 5433, 297, 2475, 67, 297, 4242, 63, 493, 12, 2475, 48, 297, 283, 19, 297, 2475, 41, 297, 620, 8, 4041, 63, 344, 430, 272, 1551, 8, 736, 14, 515, 14, 904, 8, 15594, 12, 283, 8804, 5064, 63, 344, 659, 283, 87, 1959, 952, 8, 495, 8, 8804, 5064, 63, 344, 430, 272, 372, 3087, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
jmelett/pyFxTrader
setup.py
2
4026
#!/usr/bin/env python import io import os import re import sys from setuptools import setup, find_packages PACKAGE = 'trader' if sys.argv[-1] == 'publish': os.system('python setup.py sdist bdist_wheel upload') sys.exit() class Setup(object): @staticmethod def read(fname, fail_silently=False): """ Read the content of the given file. The path is evaluated from the directory containing this file. """ try: filepath = os.path.join(os.path.dirname(__file__), fname) with io.open(filepath, 'rt', encoding='utf8') as f: return f.read() except: if not fail_silently: raise return '' @staticmethod def requirements(fname): """ Create a list of requirements from the output of the pip freeze command saved in a text file. """ packages = Setup.read(fname, fail_silently=True).split('\n') packages = (p.strip() for p in packages) packages = (p for p in packages if p and not p.startswith('#')) packages = (p for p in packages if p and not p.startswith('https://')) return list(packages) @staticmethod def get_files(*bases): """ List all files in a data directory. """ for base in bases: basedir, _ = base.split('.', 1) base = os.path.join(os.path.dirname(__file__), *base.split('.')) rem = len(os.path.dirname(base)) + len(basedir) + 2 for root, dirs, files in os.walk(base): for name in files: yield os.path.join(basedir, root, name)[rem:] @staticmethod def parse_key(key): data = Setup.read(os.path.join(PACKAGE, '__init__.py')) value = (re.search(ur"{}\s*=\s*u?'([^']+)'".format(key), data) .group(1).strip()) return value @classmethod def version(cls): return cls.parse_key('__version__') @classmethod def url(cls): return cls.parse_key('__url__') @classmethod def author(cls): return cls.parse_key('__author__') @classmethod def email(cls): return cls.parse_key('__email__') @classmethod def license(cls): return cls.parse_key('__license__') @staticmethod def longdesc(): return Setup.read('README.rst') + '\n\n' + Setup.read('HISTORY.rst') @staticmethod def test_links(): # Test if hardlinks work. This is a workaround until # http://bugs.python.org/issue8876 is solved if hasattr(os, 'link'): tempfile = __file__ + '.tmp' try: os.link(__file__, tempfile) except OSError as e: if e.errno == 1: # Operation not permitted del os.link else: raise finally: if os.path.exists(tempfile): os.remove(tempfile) Setup.test_links() setup(name=PACKAGE, version=Setup.version(), author=Setup.author(), author_email=Setup.email(), include_package_data=True, zip_safe=False, url=Setup.url(), license=Setup.license(), packages=find_packages(), package_dir={PACKAGE: PACKAGE}, description='Algortihmic trading tool', install_requires=Setup.requirements('requirements.txt'), long_description=Setup.longdesc(), entry_points=Setup.read('entry-points.ini', True), classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: {} License'.format(Setup.license()), 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', ])
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 5890, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 421, 199, 19265, 275, 283, 1239, 424, 7, 421, 199, 692, 984, 14, 3020, 1988, 17, 61, 508, 283, 4763, 356, 272, 747, 14, 2253, 360, 1548, 3272, 14, 647, 26644, 26308, 63, 11798, 5802, 358, 272, 984, 14, 2224, 342, 421, 199, 533, 12439, 8, 785, 304, 272, 768, 4639, 272, 347, 1586, 8, 5252, 12, 2449, 63, 25163, 29, 797, 304, 267, 408, 267, 5574, 314, 1564, 402, 314, 1627, 570, 14, 710, 931, 365, 13006, 687, 314, 267, 2082, 3035, 642, 570, 14, 267, 408, 267, 862, 26, 288, 9911, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 9, 288, 543, 5890, 14, 1490, 8, 7218, 12, 283, 2591, 297, 2644, 534, 1624, 24, 358, 465, 289, 26, 355, 372, 289, 14, 739, 342, 267, 871, 26, 288, 340, 440, 2449, 63, 25163, 26, 355, 746, 288, 372, 2125, 339, 768, 4639, 272, 347, 9760, 8, 5252, 304, 267, 408, 267, 2790, 282, 769, 402, 9760, 687, 314, 1072, 402, 314, 7305, 22778, 1414, 267, 6290, 315, 282, 1318, 570, 14, 267, 408, 267, 6117, 275, 12439, 14, 739, 8, 5252, 12, 2449, 63, 25163, 29, 549, 680, 1294, 2258, 78, 358, 267, 6117, 275, 334, 80, 14, 1913, 342, 367, 299, 315, 6117, 9, 267, 6117, 275, 334, 80, 367, 299, 315, 6117, 340, 299, 436, 440, 299, 14, 2460, 7863, 1333, 267, 6117, 275, 334, 80, 367, 299, 315, 6117, 340, 299, 436, 440, 299, 14, 2460, 360, 2859, 921, 1333, 267, 372, 769, 8, 5154, 9, 339, 768, 4639, 272, 347, 664, 63, 1725, 2031, 12087, 304, 267, 408, 267, 3820, 1006, 1584, 315, 282, 666, 2082, 14, 267, 408, 267, 367, 1300, 315, 9768, 26, 288, 19380, 12, 485, 275, 1300, 14, 1294, 14078, 413, 9, 288, 1300, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 627, 1095, 14, 1294, 24535, 953, 18798, 275, 822, 8, 736, 14, 515, 14, 3475, 8, 1095, 430, 435, 822, 8, 12484, 9, 435, 499, 953, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1095, 304, 355, 367, 536, 315, 1584, 26, 490, 1995, 747, 14, 515, 14, 904, 8, 12484, 12, 1738, 12, 536, 2788, 13179, 2938, 339, 768, 4639, 272, 347, 2198, 63, 498, 8, 498, 304, 267, 666, 275, 12439, 14, 739, 8, 736, 14, 515, 14, 904, 8, 19265, 12, 2560, 826, 4343, 647, 1333, 267, 574, 275, 334, 264, 14, 1733, 8, 300, 2, 24423, 83, 23440, 83, 10, 85, 14069, 7059, 21899, 3171, 1674, 908, 8, 498, 395, 666, 9, 326, 1275, 923, 8, 17, 680, 1913, 1012, 267, 372, 574, 339, 768, 3744, 272, 347, 1015, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 1023, 13766, 339, 768, 3744, 272, 347, 1166, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 633, 13766, 339, 768, 3744, 272, 347, 4132, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 2502, 13766, 339, 768, 3744, 272, 347, 3031, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 2123, 13766, 339, 768, 3744, 272, 347, 4190, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 1682, 13766, 339, 768, 4639, 272, 347, 1846, 3257, 837, 267, 372, 12439, 14, 739, 360, 18195, 14, 8332, 358, 435, 1557, 78, 60, 78, 7, 435, 12439, 14, 739, 360, 30895, 14, 8332, 358, 339, 768, 4639, 272, 347, 511, 63, 4614, 837, 267, 327, 1379, 340, 7508, 4614, 1736, 14, 961, 365, 282, 18092, 5133, 267, 327, 1455, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 1299, 2114, 365, 308, 7064, 267, 340, 2688, 8, 736, 12, 283, 1073, 735, 288, 5549, 275, 636, 493, 363, 435, 1987, 2791, 7, 288, 862, 26, 355, 747, 14, 1073, 3460, 493, 3108, 5549, 9, 288, 871, 6440, 465, 325, 26, 355, 340, 325, 14, 7931, 508, 413, 26, 221, 327, 17954, 440, 8211, 490, 2150, 747, 14, 1073, 355, 587, 26, 490, 746, 288, 3753, 26, 355, 340, 747, 14, 515, 14, 2444, 8, 17336, 304, 490, 747, 14, 2168, 8, 17336, 9, 421, 199, 8555, 14, 396, 63, 4614, 342, 199, 199, 2758, 8, 354, 29, 19265, 12, 489, 1015, 29, 8555, 14, 1023, 1062, 489, 4132, 29, 8555, 14, 2502, 1062, 489, 4132, 63, 2123, 29, 8555, 14, 2123, 1062, 489, 2387, 63, 2491, 63, 576, 29, 549, 12, 489, 3482, 63, 3489, 29, 797, 12, 489, 1166, 29, 8555, 14, 633, 1062, 489, 4190, 29, 8555, 14, 1682, 1062, 489, 6117, 29, 1623, 63, 5154, 1062, 489, 2559, 63, 694, 3126, 19265, 26, 510, 3099, 2962, 1386, 489, 1369, 534, 2439, 2904, 280, 14038, 530, 1468, 1098, 4744, 297, 489, 3907, 63, 6537, 29, 8555, 14, 7538, 360, 7538, 14, 2424, 659, 489, 1846, 63, 1802, 29, 8555, 14, 2809, 3257, 1062, 489, 2397, 63, 3438, 29, 8555, 14, 739, 360, 2373, 13, 3438, 14, 2730, 297, 715, 395, 489, 19137, 1524, 881, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 1052, 844, 1370, 908, 8, 8555, 14, 1682, 4000, 881, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 489, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 5890, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 421, 199, 19265, 275, 283, 1239, 424, 7, 421, 199, 692, 984, 14, 3020, 1988, 17, 61, 508, 283, 4763, 356, 272, 747, 14, 2253, 360, 1548, 3272, 14, 647, 26644, 26308, 63, 11798, 5802, 358, 272, 984, 14, 2224, 342, 421, 199, 533, 12439, 8, 785, 304, 272, 768, 4639, 272, 347, 1586, 8, 5252, 12, 2449, 63, 25163, 29, 797, 304, 267, 408, 267, 5574, 314, 1564, 402, 314, 1627, 570, 14, 710, 931, 365, 13006, 687, 314, 267, 2082, 3035, 642, 570, 14, 267, 408, 267, 862, 26, 288, 9911, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 9, 288, 543, 5890, 14, 1490, 8, 7218, 12, 283, 2591, 297, 2644, 534, 1624, 24, 358, 465, 289, 26, 355, 372, 289, 14, 739, 342, 267, 871, 26, 288, 340, 440, 2449, 63, 25163, 26, 355, 746, 288, 372, 2125, 339, 768, 4639, 272, 347, 9760, 8, 5252, 304, 267, 408, 267, 2790, 282, 769, 402, 9760, 687, 314, 1072, 402, 314, 7305, 22778, 1414, 267, 6290, 315, 282, 1318, 570, 14, 267, 408, 267, 6117, 275, 12439, 14, 739, 8, 5252, 12, 2449, 63, 25163, 29, 549, 680, 1294, 2258, 78, 358, 267, 6117, 275, 334, 80, 14, 1913, 342, 367, 299, 315, 6117, 9, 267, 6117, 275, 334, 80, 367, 299, 315, 6117, 340, 299, 436, 440, 299, 14, 2460, 7863, 1333, 267, 6117, 275, 334, 80, 367, 299, 315, 6117, 340, 299, 436, 440, 299, 14, 2460, 360, 2859, 921, 1333, 267, 372, 769, 8, 5154, 9, 339, 768, 4639, 272, 347, 664, 63, 1725, 2031, 12087, 304, 267, 408, 267, 3820, 1006, 1584, 315, 282, 666, 2082, 14, 267, 408, 267, 367, 1300, 315, 9768, 26, 288, 19380, 12, 485, 275, 1300, 14, 1294, 14078, 413, 9, 288, 1300, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 627, 1095, 14, 1294, 24535, 953, 18798, 275, 822, 8, 736, 14, 515, 14, 3475, 8, 1095, 430, 435, 822, 8, 12484, 9, 435, 499, 953, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 1095, 304, 355, 367, 536, 315, 1584, 26, 490, 1995, 747, 14, 515, 14, 904, 8, 12484, 12, 1738, 12, 536, 2788, 13179, 2938, 339, 768, 4639, 272, 347, 2198, 63, 498, 8, 498, 304, 267, 666, 275, 12439, 14, 739, 8, 736, 14, 515, 14, 904, 8, 19265, 12, 2560, 826, 4343, 647, 1333, 267, 574, 275, 334, 264, 14, 1733, 8, 300, 2, 24423, 83, 23440, 83, 10, 85, 14069, 7059, 21899, 3171, 1674, 908, 8, 498, 395, 666, 9, 326, 1275, 923, 8, 17, 680, 1913, 1012, 267, 372, 574, 339, 768, 3744, 272, 347, 1015, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 1023, 13766, 339, 768, 3744, 272, 347, 1166, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 633, 13766, 339, 768, 3744, 272, 347, 4132, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 2502, 13766, 339, 768, 3744, 272, 347, 3031, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 2123, 13766, 339, 768, 3744, 272, 347, 4190, 8, 1886, 304, 267, 372, 843, 14, 1122, 63, 498, 10714, 1682, 13766, 339, 768, 4639, 272, 347, 1846, 3257, 837, 267, 372, 12439, 14, 739, 360, 18195, 14, 8332, 358, 435, 1557, 78, 60, 78, 7, 435, 12439, 14, 739, 360, 30895, 14, 8332, 358, 339, 768, 4639, 272, 347, 511, 63, 4614, 837, 267, 327, 1379, 340, 7508, 4614, 1736, 14, 961, 365, 282, 18092, 5133, 267, 327, 1455, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 1299, 2114, 365, 308, 7064, 267, 340, 2688, 8, 736, 12, 283, 1073, 735, 288, 5549, 275, 636, 493, 363, 435, 1987, 2791, 7, 288, 862, 26, 355, 747, 14, 1073, 3460, 493, 3108, 5549, 9, 288, 871, 6440, 465, 325, 26, 355, 340, 325, 14, 7931, 508, 413, 26, 221, 327, 17954, 440, 8211, 490, 2150, 747, 14, 1073, 355, 587, 26, 490, 746, 288, 3753, 26, 355, 340, 747, 14, 515, 14, 2444, 8, 17336, 304, 490, 747, 14, 2168, 8, 17336, 9, 421, 199, 8555, 14, 396, 63, 4614, 342, 199, 199, 2758, 8, 354, 29, 19265, 12, 489, 1015, 29, 8555, 14, 1023, 1062, 489, 4132, 29, 8555, 14, 2502, 1062, 489, 4132, 63, 2123, 29, 8555, 14, 2123, 1062, 489, 2387, 63, 2491, 63, 576, 29, 549, 12, 489, 3482, 63, 3489, 29, 797, 12, 489, 1166, 29, 8555, 14, 633, 1062, 489, 4190, 29, 8555, 14, 1682, 1062, 489, 6117, 29, 1623, 63, 5154, 1062, 489, 2559, 63, 694, 3126, 19265, 26, 510, 3099, 2962, 1386, 489, 1369, 534, 2439, 2904, 280, 14038, 530, 1468, 1098, 4744, 297, 489, 3907, 63, 6537, 29, 8555, 14, 7538, 360, 7538, 14, 2424, 659, 489, 1846, 63, 1802, 29, 8555, 14, 2809, 3257, 1062, 489, 2397, 63, 3438, 29, 8555, 14, 739, 360, 2373, 13, 3438, 14, 2730, 297, 715, 395, 489, 19137, 1524, 881, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 1052, 844, 1370, 908, 8, 8555, 14, 1682, 4000, 881, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 489, 4794, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wuhengzhi/chromium-crosswalk
third_party/closure_linter/closure_linter/common/simplefileflags.py
285
5107
#!/usr/bin/env python # # Copyright 2008 The Closure Linter 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. """Determines the list of files to be checked from command line arguments.""" __author__ = ('robbyw@google.com (Robert Walker)', 'ajp@google.com (Andy Perelson)') import glob import os import re import gflags as flags FLAGS = flags.FLAGS flags.DEFINE_multistring( 'recurse', None, 'Recurse in to the subdirectories of the given path', short_name='r') flags.DEFINE_list( 'exclude_directories', ('_demos'), 'Exclude the specified directories (only applicable along with -r or ' '--presubmit)', short_name='e') flags.DEFINE_list( 'exclude_files', ('deps.js'), 'Exclude the specified files', short_name='x') def MatchesSuffixes(filename, suffixes): """Returns whether the given filename matches one of the given suffixes. Args: filename: Filename to check. suffixes: Sequence of suffixes to check. Returns: Whether the given filename matches one of the given suffixes. """ suffix = filename[filename.rfind('.'):] return suffix in suffixes def _GetUserSpecifiedFiles(argv, suffixes): """Returns files to be linted, specified directly on the command line. Can handle the '*' wildcard in filenames, but no other wildcards. Args: argv: Sequence of command line arguments. The second and following arguments are assumed to be files that should be linted. suffixes: Expected suffixes for the file type being checked. Returns: A sequence of files to be linted. """ files = argv[1:] or [] all_files = [] lint_files = [] # Perform any necessary globs. for f in files: if f.find('*') != -1: for result in glob.glob(f): all_files.append(result) else: all_files.append(f) for f in all_files: if MatchesSuffixes(f, suffixes): lint_files.append(f) return lint_files def _GetRecursiveFiles(suffixes): """Returns files to be checked specified by the --recurse flag. Args: suffixes: Expected suffixes for the file type being checked. Returns: A list of files to be checked. """ lint_files = [] # Perform any request recursion if FLAGS.recurse: for start in FLAGS.recurse: for root, subdirs, files in os.walk(start): for f in files: if MatchesSuffixes(f, suffixes): lint_files.append(os.path.join(root, f)) return lint_files def GetAllSpecifiedFiles(argv, suffixes): """Returns all files specified by the user on the commandline. Args: argv: Sequence of command line arguments. The second and following arguments are assumed to be files that should be linted. suffixes: Expected suffixes for the file type Returns: A list of all files specified directly or indirectly (via flags) on the command line by the user. """ files = _GetUserSpecifiedFiles(argv, suffixes) if FLAGS.recurse: files += _GetRecursiveFiles(suffixes) return FilterFiles(files) def FilterFiles(files): """Filters the list of files to be linted be removing any excluded files. Filters out files excluded using --exclude_files and --exclude_directories. Args: files: Sequence of files that needs filtering. Returns: Filtered list of files to be linted. """ num_files = len(files) ignore_dirs_regexs = [] for ignore in FLAGS.exclude_directories: ignore_dirs_regexs.append(re.compile(r'(^|[\\/])%s[\\/]' % ignore)) result_files = [] for f in files: add_file = True for exclude in FLAGS.exclude_files: if f.endswith('/' + exclude) or f == exclude: add_file = False break for ignore in ignore_dirs_regexs: if ignore.search(f): # Break out of ignore loop so we don't add to # filtered files. add_file = False break if add_file: # Convert everything to absolute paths so we can easily remove duplicates # using a set. result_files.append(os.path.abspath(f)) skipped = num_files - len(result_files) if skipped: print 'Skipping %d file(s).' % skipped return set(result_files) def GetFileList(argv, file_type, suffixes): """Parse the flags and return the list of files to check. Args: argv: Sequence of command line arguments. suffixes: Sequence of acceptable suffixes for the file type. Returns: The list of files to check. """ return sorted(GetAllSpecifiedFiles(argv, suffixes)) def IsEmptyArgumentList(argv): return not (len(argv[1:]) or FLAGS.recurse)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 710, 5980, 3253, 491, 1058, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 872, 18454, 314, 769, 402, 1584, 370, 506, 7923, 687, 1414, 1004, 2368, 1041, 199, 199, 363, 2502, 363, 275, 661, 29891, 991, 87, 32, 3098, 14, 957, 334, 3863, 12504, 644, 14976, 3196, 1598, 283, 9091, 80, 32, 3098, 14, 957, 334, 3325, 89, 11379, 264, 478, 265, 5942, 199, 199, 646, 5739, 199, 646, 747, 199, 646, 295, 199, 199, 646, 486, 2469, 465, 3285, 421, 199, 4831, 275, 3285, 14, 4831, 199, 199, 2469, 14, 14603, 63, 3029, 875, 8, 272, 283, 25786, 297, 272, 488, 12, 272, 283, 14244, 261, 315, 370, 314, 24799, 402, 314, 1627, 931, 297, 272, 3974, 63, 354, 534, 82, 358, 199, 2469, 14, 14603, 63, 513, 8, 272, 283, 5473, 63, 12629, 297, 272, 12331, 8768, 83, 659, 272, 283, 29448, 314, 2013, 6602, 334, 2118, 3964, 3180, 543, 446, 82, 503, 283, 272, 2850, 80, 15527, 3196, 272, 3974, 63, 354, 534, 69, 358, 199, 2469, 14, 14603, 63, 513, 8, 272, 283, 5473, 63, 1725, 297, 272, 661, 5846, 14, 3596, 659, 272, 283, 29448, 314, 2013, 1584, 297, 272, 3974, 63, 354, 534, 88, 358, 421, 199, 318, 21682, 20126, 397, 8, 1501, 12, 19475, 304, 523, 408, 3407, 3775, 314, 1627, 1788, 4450, 1373, 402, 314, 1627, 19475, 14, 819, 3033, 26, 272, 1788, 26, 31167, 370, 1104, 14, 272, 19475, 26, 10975, 402, 19475, 370, 1104, 14, 819, 1803, 26, 272, 7480, 314, 1627, 1788, 4450, 1373, 402, 314, 1627, 19475, 14, 523, 408, 523, 4739, 275, 1788, 59, 1501, 14, 14542, 26461, 61, 523, 372, 4739, 315, 19475, 421, 199, 318, 485, 1002, 1899, 6154, 1290, 5535, 8, 3020, 12, 19475, 304, 523, 408, 3407, 1584, 370, 506, 7403, 471, 12, 2013, 5370, 641, 314, 1414, 1004, 14, 819, 6855, 2429, 314, 13626, 16792, 315, 6203, 12, 1325, 949, 1163, 24952, 14, 819, 3033, 26, 272, 9238, 26, 10975, 402, 1414, 1004, 2368, 14, 710, 3499, 436, 2569, 2368, 489, 787, 10826, 370, 506, 1584, 626, 1077, 506, 7403, 471, 14, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 3769, 7923, 14, 819, 1803, 26, 272, 437, 3414, 402, 1584, 370, 506, 7403, 471, 14, 523, 408, 523, 1584, 275, 9238, 59, 17, 2938, 503, 942, 523, 1006, 63, 1725, 275, 942, 523, 24620, 63, 1725, 275, 942, 8410, 327, 14795, 1263, 5784, 13977, 14, 523, 367, 289, 315, 1584, 26, 272, 340, 289, 14, 1623, 360, 13418, 1137, 446, 17, 26, 489, 367, 754, 315, 5739, 14, 6463, 8, 70, 304, 267, 1006, 63, 1725, 14, 740, 8, 1099, 9, 272, 587, 26, 489, 1006, 63, 1725, 14, 740, 8, 70, 9, 819, 367, 289, 315, 1006, 63, 1725, 26, 272, 340, 21682, 20126, 397, 8, 70, 12, 19475, 304, 489, 24620, 63, 1725, 14, 740, 8, 70, 9, 523, 372, 24620, 63, 1725, 421, 199, 318, 485, 1002, 25122, 5535, 8, 16097, 304, 523, 408, 3407, 1584, 370, 506, 7923, 2013, 701, 314, 1553, 25786, 3305, 14, 819, 3033, 26, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 3769, 7923, 14, 819, 1803, 26, 272, 437, 769, 402, 1584, 370, 506, 7923, 14, 523, 408, 523, 24620, 63, 1725, 275, 942, 523, 327, 14795, 1263, 1056, 16189, 523, 340, 12846, 14, 25786, 26, 272, 367, 1343, 315, 12846, 14, 25786, 26, 489, 367, 1738, 12, 31396, 12, 1584, 315, 747, 14, 7757, 8, 928, 304, 267, 367, 289, 315, 1584, 26, 881, 340, 21682, 20126, 397, 8, 70, 12, 19475, 304, 288, 24620, 63, 1725, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 430, 523, 372, 24620, 63, 1725, 421, 199, 318, 2372, 2422, 6154, 1290, 5535, 8, 3020, 12, 19475, 304, 523, 408, 3407, 1006, 1584, 2013, 701, 314, 922, 641, 314, 28279, 14, 819, 3033, 26, 272, 9238, 26, 10975, 402, 1414, 1004, 2368, 14, 710, 3499, 436, 2569, 2368, 489, 787, 10826, 370, 506, 1584, 626, 1077, 506, 7403, 471, 14, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 819, 1803, 26, 272, 437, 769, 402, 1006, 1584, 2013, 5370, 503, 19458, 590, 334, 12897, 3285, 9, 641, 314, 272, 1414, 1004, 701, 314, 922, 14, 523, 408, 523, 1584, 275, 485, 1002, 1899, 6154, 1290, 5535, 8, 3020, 12, 19475, 9, 819, 340, 12846, 14, 25786, 26, 272, 1584, 847, 485, 1002, 25122, 5535, 8, 16097, 9, 819, 372, 9388, 5535, 8, 1725, 9, 421, 199, 318, 9388, 5535, 8, 1725, 304, 523, 408, 18053, 314, 769, 402, 1584, 370, 506, 7403, 471, 506, 12881, 1263, 8789, 1584, 14, 819, 21240, 734, 1584, 8789, 1808, 1553, 5473, 63, 1725, 436, 221, 1553, 5473, 63, 12629, 14, 819, 3033, 26, 272, 1584, 26, 10975, 402, 1584, 626, 4839, 14545, 14, 819, 1803, 26, 272, 17887, 3014, 769, 402, 1584, 370, 506, 7403, 471, 14, 523, 408, 523, 1967, 63, 1725, 275, 822, 8, 1725, 9, 819, 3686, 63, 3220, 63, 3821, 83, 275, 942, 523, 367, 3686, 315, 12846, 14, 5473, 63, 12629, 26, 272, 3686, 63, 3220, 63, 3821, 83, 14, 740, 8, 264, 14, 2014, 8, 82, 6774, 62, 17884, 1103, 15, 566, 5, 83, 59, 1103, 15, 6616, 450, 3686, 430, 819, 754, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 710, 5980, 3253, 491, 1058, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 872, 18454, 314, 769, 402, 1584, 370, 506, 7923, 687, 1414, 1004, 2368, 1041, 199, 199, 363, 2502, 363, 275, 661, 29891, 991, 87, 32, 3098, 14, 957, 334, 3863, 12504, 644, 14976, 3196, 1598, 283, 9091, 80, 32, 3098, 14, 957, 334, 3325, 89, 11379, 264, 478, 265, 5942, 199, 199, 646, 5739, 199, 646, 747, 199, 646, 295, 199, 199, 646, 486, 2469, 465, 3285, 421, 199, 4831, 275, 3285, 14, 4831, 199, 199, 2469, 14, 14603, 63, 3029, 875, 8, 272, 283, 25786, 297, 272, 488, 12, 272, 283, 14244, 261, 315, 370, 314, 24799, 402, 314, 1627, 931, 297, 272, 3974, 63, 354, 534, 82, 358, 199, 2469, 14, 14603, 63, 513, 8, 272, 283, 5473, 63, 12629, 297, 272, 12331, 8768, 83, 659, 272, 283, 29448, 314, 2013, 6602, 334, 2118, 3964, 3180, 543, 446, 82, 503, 283, 272, 2850, 80, 15527, 3196, 272, 3974, 63, 354, 534, 69, 358, 199, 2469, 14, 14603, 63, 513, 8, 272, 283, 5473, 63, 1725, 297, 272, 661, 5846, 14, 3596, 659, 272, 283, 29448, 314, 2013, 1584, 297, 272, 3974, 63, 354, 534, 88, 358, 421, 199, 318, 21682, 20126, 397, 8, 1501, 12, 19475, 304, 523, 408, 3407, 3775, 314, 1627, 1788, 4450, 1373, 402, 314, 1627, 19475, 14, 819, 3033, 26, 272, 1788, 26, 31167, 370, 1104, 14, 272, 19475, 26, 10975, 402, 19475, 370, 1104, 14, 819, 1803, 26, 272, 7480, 314, 1627, 1788, 4450, 1373, 402, 314, 1627, 19475, 14, 523, 408, 523, 4739, 275, 1788, 59, 1501, 14, 14542, 26461, 61, 523, 372, 4739, 315, 19475, 421, 199, 318, 485, 1002, 1899, 6154, 1290, 5535, 8, 3020, 12, 19475, 304, 523, 408, 3407, 1584, 370, 506, 7403, 471, 12, 2013, 5370, 641, 314, 1414, 1004, 14, 819, 6855, 2429, 314, 13626, 16792, 315, 6203, 12, 1325, 949, 1163, 24952, 14, 819, 3033, 26, 272, 9238, 26, 10975, 402, 1414, 1004, 2368, 14, 710, 3499, 436, 2569, 2368, 489, 787, 10826, 370, 506, 1584, 626, 1077, 506, 7403, 471, 14, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 3769, 7923, 14, 819, 1803, 26, 272, 437, 3414, 402, 1584, 370, 506, 7403, 471, 14, 523, 408, 523, 1584, 275, 9238, 59, 17, 2938, 503, 942, 523, 1006, 63, 1725, 275, 942, 523, 24620, 63, 1725, 275, 942, 8410, 327, 14795, 1263, 5784, 13977, 14, 523, 367, 289, 315, 1584, 26, 272, 340, 289, 14, 1623, 360, 13418, 1137, 446, 17, 26, 489, 367, 754, 315, 5739, 14, 6463, 8, 70, 304, 267, 1006, 63, 1725, 14, 740, 8, 1099, 9, 272, 587, 26, 489, 1006, 63, 1725, 14, 740, 8, 70, 9, 819, 367, 289, 315, 1006, 63, 1725, 26, 272, 340, 21682, 20126, 397, 8, 70, 12, 19475, 304, 489, 24620, 63, 1725, 14, 740, 8, 70, 9, 523, 372, 24620, 63, 1725, 421, 199, 318, 485, 1002, 25122, 5535, 8, 16097, 304, 523, 408, 3407, 1584, 370, 506, 7923, 2013, 701, 314, 1553, 25786, 3305, 14, 819, 3033, 26, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 3769, 7923, 14, 819, 1803, 26, 272, 437, 769, 402, 1584, 370, 506, 7923, 14, 523, 408, 523, 24620, 63, 1725, 275, 942, 523, 327, 14795, 1263, 1056, 16189, 523, 340, 12846, 14, 25786, 26, 272, 367, 1343, 315, 12846, 14, 25786, 26, 489, 367, 1738, 12, 31396, 12, 1584, 315, 747, 14, 7757, 8, 928, 304, 267, 367, 289, 315, 1584, 26, 881, 340, 21682, 20126, 397, 8, 70, 12, 19475, 304, 288, 24620, 63, 1725, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 430, 523, 372, 24620, 63, 1725, 421, 199, 318, 2372, 2422, 6154, 1290, 5535, 8, 3020, 12, 19475, 304, 523, 408, 3407, 1006, 1584, 2013, 701, 314, 922, 641, 314, 28279, 14, 819, 3033, 26, 272, 9238, 26, 10975, 402, 1414, 1004, 2368, 14, 710, 3499, 436, 2569, 2368, 489, 787, 10826, 370, 506, 1584, 626, 1077, 506, 7403, 471, 14, 272, 19475, 26, 13796, 19475, 367, 314, 570, 730, 819, 1803, 26, 272, 437, 769, 402, 1006, 1584, 2013, 5370, 503, 19458, 590, 334, 12897, 3285, 9, 641, 314, 272, 1414, 1004, 701, 314, 922, 14, 523, 408, 523, 1584, 275, 485, 1002, 1899, 6154, 1290, 5535, 8, 3020, 12, 19475, 9, 819, 340, 12846, 14, 25786, 26, 272, 1584, 847, 485, 1002, 25122, 5535, 8, 16097, 9, 819, 372, 9388, 5535, 8, 1725, 9, 421, 199, 318, 9388, 5535, 8, 1725, 304, 523, 408, 18053, 314, 769, 402, 1584, 370, 506, 7403, 471, 506, 12881, 1263, 8789, 1584, 14, 819, 21240, 734, 1584, 8789, 1808, 1553, 5473, 63, 1725, 436, 221, 1553, 5473, 63, 12629, 14, 819, 3033, 26, 272, 1584, 26, 10975, 402, 1584, 626, 4839, 14545, 14, 819, 1803, 26, 272, 17887, 3014, 769, 402, 1584, 370, 506, 7403, 471, 14, 523, 408, 523, 1967, 63, 1725, 275, 822, 8, 1725, 9, 819, 3686, 63, 3220, 63, 3821, 83, 275, 942, 523, 367, 3686, 315, 12846, 14, 5473, 63, 12629, 26, 272, 3686, 63, 3220, 63, 3821, 83, 14, 740, 8, 264, 14, 2014, 8, 82, 6774, 62, 17884, 1103, 15, 566, 5, 83, 59, 1103, 15, 6616, 450, 3686, 430, 819, 754, 63, 0 ]
[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 ]
gangadhar-kadam/mtn-erpnext
manufacturing/doctype/bom/test_bom.py
6
1356
# ERPNext - web based ERP (http://erpnext.com) # Copyright (C) 2012 Web Notes Technologies Pvt Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import unicode_literals import unittest import webnotes test_records = [ [ { "doctype": "BOM", "item": "_Test FG Item", "quantity": 1.0, "is_active": 1, "is_default": 1, "docstatus": 1 }, { "doctype": "BOM Item", "item_code": "_Test Item", "parentfield": "bom_materials", "qty": 1.0, "rate": 5000.0, "amount": 5000.0, "stock_uom": "No." }, { "doctype": "BOM Item", "item_code": "_Test Item Home Desktop 100", "parentfield": "bom_materials", "qty": 2.0, "rate": 1000.0, "amount": 2000.0, "stock_uom": "No." } ] ]
agpl-3.0
[ 3, 221, 6758, 5765, 446, 3330, 4079, 221, 6758, 334, 1014, 921, 281, 23416, 14, 957, 9, 199, 3, 1898, 334, 35, 9, 6029, 6001, 8144, 19215, 29053, 12126, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 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, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2882, 199, 646, 23154, 199, 199, 396, 63, 6502, 275, 359, 199, 198, 59, 507, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 401, 20866, 198, 2, 1053, 582, 2668, 774, 481, 39, 7020, 401, 20866, 198, 2, 10577, 582, 413, 14, 16, 12, 686, 198, 2, 374, 63, 2682, 582, 413, 12, 686, 198, 2, 374, 63, 885, 582, 413, 12, 686, 198, 2, 30461, 582, 413, 507, 198, 1386, 11083, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 7020, 401, 20866, 198, 2, 1053, 63, 600, 582, 2668, 774, 7020, 401, 20866, 198, 2, 1708, 698, 582, 298, 16302, 63, 23231, 401, 20866, 198, 2, 5643, 582, 413, 14, 16, 12, 20866, 198, 2, 1866, 582, 22369, 14, 16, 12, 20866, 198, 2, 4606, 582, 22369, 14, 16, 12, 20866, 198, 2, 6088, 63, 7519, 582, 298, 1944, 2122, 507, 198, 1386, 11083, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 7020, 401, 20866, 198, 2, 1053, 63, 600, 582, 2668, 774, 7020, 14621, 8055, 17827, 2948, 401, 20866, 198, 2, 1708, 698, 582, 298, 16302, 63, 23231, 401, 20866, 198, 2, 5643, 582, 499, 14, 16, 12, 20866, 198, 2, 1866, 582, 5198, 14, 16, 12, 686, 198, 2, 4606, 582, 12293, 14, 16, 12, 686, 198, 2, 6088, 63, 7519, 582, 298, 1944, 2122, 507, 198, 93, 199, 198, 61, 199, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 221, 6758, 5765, 446, 3330, 4079, 221, 6758, 334, 1014, 921, 281, 23416, 14, 957, 9, 199, 3, 1898, 334, 35, 9, 6029, 6001, 8144, 19215, 29053, 12126, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 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, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2882, 199, 646, 23154, 199, 199, 396, 63, 6502, 275, 359, 199, 198, 59, 507, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 401, 20866, 198, 2, 1053, 582, 2668, 774, 481, 39, 7020, 401, 20866, 198, 2, 10577, 582, 413, 14, 16, 12, 686, 198, 2, 374, 63, 2682, 582, 413, 12, 686, 198, 2, 374, 63, 885, 582, 413, 12, 686, 198, 2, 30461, 582, 413, 507, 198, 1386, 11083, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 7020, 401, 20866, 198, 2, 1053, 63, 600, 582, 2668, 774, 7020, 401, 20866, 198, 2, 1708, 698, 582, 298, 16302, 63, 23231, 401, 20866, 198, 2, 5643, 582, 413, 14, 16, 12, 20866, 198, 2, 1866, 582, 22369, 14, 16, 12, 20866, 198, 2, 4606, 582, 22369, 14, 16, 12, 20866, 198, 2, 6088, 63, 7519, 582, 298, 1944, 2122, 507, 198, 1386, 11083, 198, 91, 686, 198, 2, 6356, 582, 298, 19550, 7020, 401, 20866, 198, 2, 1053, 63, 600, 582, 2668, 774, 7020, 14621, 8055, 17827, 2948, 401, 20866, 198, 2, 1708, 698, 582, 298, 16302, 63, 23231, 401, 20866, 198, 2, 5643, 582, 499, 14, 16, 12, 20866, 198, 2, 1866, 582, 5198, 14, 16, 12, 686, 198, 2, 4606, 582, 12293, 14, 16, 12, 686, 198, 2, 6088, 63, 7519, 582, 298, 1944, 2122, 507, 198, 93, 199, 198, 61, 199, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
gautam1858/tensorflow
tensorflow/python/framework/common_shapes_test.py
76
9343
# 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 common shapes.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.framework import common_shapes from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import test_util from tensorflow.python.platform import googletest class CommonShapesTest(test_util.TensorFlowTestCase): # Asserts that we get the same result with numpy (for known shapes), and that # the order of arguments does not matter (i.e., broadcasting is reflexive). def _assert_incompatible_broadcast(self, shape1, shape2): if shape1.dims is not None and shape2.dims is not None: zeros1 = np.zeros(shape1.as_list()) zeros2 = np.zeros(shape2.as_list()) with self.assertRaises(ValueError): np.broadcast(zeros1, zeros2) with self.assertRaises(ValueError): np.broadcast(zeros2, zeros1) self.assertFalse(common_shapes.is_broadcast_compatible(shape1, shape2)) self.assertFalse(common_shapes.is_broadcast_compatible(shape2, shape1)) with self.assertRaises(ValueError): common_shapes.broadcast_shape(shape1, shape2) with self.assertRaises(ValueError): common_shapes.broadcast_shape(shape2, shape1) # Asserts that we get the same result with numpy (for known shapes), and that # the order of arguments does not matter (i.e., broadcasting is reflexive). def _assert_broadcast(self, expected, shape1, shape2): if shape1.dims is not None and shape2.dims is not None: expected_np = expected.as_list() zeros1 = np.zeros(shape1.as_list()) zeros2 = np.zeros(shape2.as_list()) self.assertAllEqual(expected_np, np.broadcast(zeros1, zeros2).shape) self.assertAllEqual(expected_np, np.broadcast(zeros2, zeros1).shape) self.assertEqual( expected, common_shapes.broadcast_shape(shape1, shape2)) self.assertEqual( expected, common_shapes.broadcast_shape(shape2, shape1)) else: self.assertEqual(expected, common_shapes.broadcast_shape(shape1, shape2)) self.assertEqual(expected, common_shapes.broadcast_shape(shape2, shape1)) def testBroadcast_one_dimension(self): s1 = tensor_shape.vector(5) s2 = tensor_shape.vector(7) unknown = tensor_shape.unknown_shape() scalar = tensor_shape.scalar() expanded_scalar = tensor_shape.TensorShape([1]) # Tensors with same shape should have the same broadcast result. for shape in (s1, s2, unknown, scalar, expanded_scalar): self._assert_broadcast(expected=shape, shape1=shape, shape2=shape) # [] and [1] act like identity. self._assert_broadcast(expected=s1, shape1=s1, shape2=scalar) self._assert_broadcast(expected=s2, shape1=s2, shape2=scalar) self._assert_broadcast(expected=s1, shape1=s1, shape2=expanded_scalar) self._assert_broadcast(expected=s2, shape1=s2, shape2=expanded_scalar) self._assert_broadcast(expected=unknown, shape1=s1, shape2=unknown) self._assert_broadcast(expected=unknown, shape1=s2, shape2=unknown) self._assert_broadcast( expected=expanded_scalar, shape1=scalar, shape2=expanded_scalar) self._assert_incompatible_broadcast(shape1=s1, shape2=s2) def testBroadcast_many_dimensions(self): unknown = tensor_shape.unknown_shape() shape_0 = tensor_shape.scalar() shape_1 = tensor_shape.vector(1) shape_4 = tensor_shape.vector(4) shape_1x4 = tensor_shape.matrix(1, 4) shape_4x1 = tensor_shape.matrix(4, 1) shape_3x4 = tensor_shape.matrix(3, 4) shape_4x3 = tensor_shape.matrix(4, 3) # Tensors with same shape should have the same broadcast result. for shape in ( shape_0, shape_1, shape_4, shape_1x4, shape_4x1, shape_3x4, shape_4x3): self._assert_broadcast(expected=shape, shape1=shape, shape2=shape) # [] and [1] act like identity. for identity in (shape_0, shape_1): for shape in (shape_4, shape_1x4, shape_4x1, shape_3x4, shape_4x3): self._assert_broadcast(expected=shape, shape1=identity, shape2=shape) # Unknown in, unknown out. for shape in (shape_4, shape_1x4, shape_4x1, shape_3x4, shape_4x3): self._assert_broadcast(expected=unknown, shape1=shape, shape2=unknown) self._assert_broadcast(expected=shape_1x4, shape1=shape_4, shape2=shape_1x4) shape_4x4 = tensor_shape.matrix(4, 4) self._assert_broadcast(expected=shape_4x4, shape1=shape_4, shape2=shape_4x1) self._assert_broadcast(expected=shape_3x4, shape1=shape_4, shape2=shape_3x4) self._assert_incompatible_broadcast(shape1=shape_4, shape2=shape_4x3) self._assert_broadcast( expected=shape_4x4, shape1=shape_1x4, shape2=shape_4x1) self._assert_broadcast( expected=shape_3x4, shape1=shape_1x4, shape2=shape_3x4) self._assert_incompatible_broadcast(shape1=shape_1x4, shape2=shape_4x3) self._assert_incompatible_broadcast(shape1=shape_4x1, shape2=shape_3x4) self._assert_broadcast( expected=shape_4x3, shape1=shape_4x1, shape2=shape_4x3) self._assert_incompatible_broadcast(shape1=shape_3x4, shape2=shape_4x3) # Asserts that the order of arguments does not matter (i.e., broadcasting is # reflexive). def _assert_broadcast_with_unknown_dims(self, expected, shape1, shape2): actual_dims = common_shapes.broadcast_shape(shape1, shape2).dims reflexive_actual_dims = common_shapes.broadcast_shape(shape2, shape1).dims if actual_dims is None: self.assertIsNone(reflexive_actual_dims) elif reflexive_actual_dims is None: self.assertIsNone(actual_dims) else: self.assertEqual(len(actual_dims), len(reflexive_actual_dims)) for actual_dim, reflexive_actual_dim in zip( actual_dims, reflexive_actual_dims): self.assertEqual(actual_dim.value, reflexive_actual_dim.value) expected_dims = expected.dims if expected_dims is None: self.assertIsNone(actual_dims) elif actual_dims is None: self.assertIsNone(expected_dims) else: self.assertEqual(len(expected_dims), len(actual_dims)) for expected_dim, actual_dim in zip(expected_dims, actual_dims): self.assertEqual(expected_dim.value, actual_dim.value) def testBroadcast_unknown_dims(self): unknown = tensor_shape.unknown_shape() shape_0 = tensor_shape.scalar() shape_1 = tensor_shape.vector(1) # pylint: disable=invalid-name shape_U = tensor_shape.vector(None) shape_1xU = tensor_shape.matrix(1, None) shape_Ux1 = tensor_shape.matrix(None, 1) shape_4xU = tensor_shape.matrix(4, None) shape_Ux4 = tensor_shape.matrix(None, 4) # pylint: enable=invalid-name # Tensors with same shape should have the same broadcast result. for shape in (shape_U, shape_1xU, shape_Ux1, shape_4xU, shape_Ux4): self._assert_broadcast_with_unknown_dims( expected=shape, shape1=shape, shape2=shape) # [] and [1] act like identity. for identity in (shape_0, shape_1): for shape in (shape_U, shape_1xU, shape_Ux1, shape_4xU, shape_Ux4): self._assert_broadcast_with_unknown_dims( expected=shape, shape1=identity, shape2=shape) # Unknown in, unknown out. for shape in (shape_U, shape_1xU, shape_Ux1, shape_4xU, shape_Ux4): self._assert_broadcast_with_unknown_dims( expected=unknown, shape1=shape, shape2=unknown) self._assert_broadcast_with_unknown_dims( expected=shape_1xU, shape1=shape_U, shape2=shape_1xU) shape_UxU = tensor_shape.matrix(None, None) # pylint: disable=invalid-name self._assert_broadcast_with_unknown_dims( expected=shape_UxU, shape1=shape_U, shape2=shape_Ux1) self._assert_broadcast_with_unknown_dims( expected=shape_4xU, shape1=shape_U, shape2=shape_4xU) self._assert_broadcast_with_unknown_dims( expected=shape_Ux4, shape1=shape_U, shape2=shape_Ux4) self._assert_broadcast_with_unknown_dims( expected=shape_UxU, shape1=shape_1xU, shape2=shape_Ux1) self._assert_broadcast_with_unknown_dims( expected=shape_4xU, shape1=shape_1xU, shape2=shape_4xU) self._assert_broadcast_with_unknown_dims( expected=shape_Ux4, shape1=shape_1xU, shape2=shape_Ux4) self._assert_broadcast_with_unknown_dims( expected=shape_4xU, shape1=shape_Ux1, shape2=shape_4xU) self._assert_broadcast_with_unknown_dims( expected=shape_Ux4, shape1=shape_Ux1, shape2=shape_Ux4) shape_4x4 = tensor_shape.matrix(4, 4) self._assert_broadcast_with_unknown_dims( expected=shape_4x4, shape1=shape_4xU, shape2=shape_Ux4) 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, 199, 624, 2925, 367, 2863, 11751, 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, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2863, 63, 9069, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 13964, 7238, 26935, 8, 396, 63, 1974, 14, 26998, 1746, 304, 819, 327, 10716, 83, 626, 781, 664, 314, 2011, 754, 543, 2680, 334, 509, 6040, 11751, 395, 436, 626, 523, 327, 314, 1865, 402, 2368, 1630, 440, 17247, 334, 73, 14, 69, 2020, 32001, 365, 2984, 3113, 1912, 680, 523, 347, 485, 479, 63, 31787, 63, 10786, 8, 277, 12, 2215, 17, 12, 2215, 18, 304, 272, 340, 2215, 17, 14, 5380, 365, 440, 488, 436, 2215, 18, 14, 5380, 365, 440, 488, 26, 489, 10136, 17, 275, 980, 14, 4250, 8, 1392, 17, 14, 305, 63, 513, 1012, 489, 10136, 18, 275, 980, 14, 4250, 8, 1392, 18, 14, 305, 63, 513, 1012, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 980, 14, 10786, 8, 4250, 17, 12, 10136, 18, 9, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 980, 14, 10786, 8, 4250, 18, 12, 10136, 17, 9, 272, 291, 14, 3334, 8, 2330, 63, 9069, 14, 374, 63, 10786, 63, 6490, 8, 1392, 17, 12, 2215, 18, 430, 272, 291, 14, 3334, 8, 2330, 63, 9069, 14, 374, 63, 10786, 63, 6490, 8, 1392, 18, 12, 2215, 17, 430, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 9, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 9, 819, 327, 10716, 83, 626, 781, 664, 314, 2011, 754, 543, 2680, 334, 509, 6040, 11751, 395, 436, 626, 523, 327, 314, 1865, 402, 2368, 1630, 440, 17247, 334, 73, 14, 69, 2020, 32001, 365, 2984, 3113, 1912, 680, 523, 347, 485, 479, 63, 10786, 8, 277, 12, 1420, 12, 2215, 17, 12, 2215, 18, 304, 272, 340, 2215, 17, 14, 5380, 365, 440, 488, 436, 2215, 18, 14, 5380, 365, 440, 488, 26, 489, 1420, 63, 1590, 275, 1420, 14, 305, 63, 513, 342, 489, 10136, 17, 275, 980, 14, 4250, 8, 1392, 17, 14, 305, 63, 513, 1012, 489, 10136, 18, 275, 980, 14, 4250, 8, 1392, 18, 14, 305, 63, 513, 1012, 489, 291, 14, 7069, 8, 2062, 63, 1590, 12, 980, 14, 10786, 8, 4250, 17, 12, 10136, 18, 680, 1392, 9, 489, 291, 14, 7069, 8, 2062, 63, 1590, 12, 980, 14, 10786, 8, 4250, 18, 12, 10136, 17, 680, 1392, 9, 489, 291, 14, 629, 8, 881, 1420, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 430, 489, 291, 14, 629, 8, 881, 1420, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 430, 272, 587, 26, 489, 291, 14, 629, 8, 2062, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 430, 489, 291, 14, 629, 8, 2062, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 430, 819, 347, 511, 12105, 63, 368, 63, 7430, 8, 277, 304, 272, 308, 17, 275, 2345, 63, 1392, 14, 4106, 8, 21, 9, 272, 308, 18, 275, 2345, 63, 1392, 14, 4106, 8, 23, 9, 339, 5809, 275, 2345, 63, 1392, 14, 5187, 63, 1392, 342, 272, 6917, 275, 2345, 63, 1392, 14, 7033, 342, 272, 11507, 63, 7033, 275, 2345, 63, 1392, 14, 18592, 779, 17, 566, 339, 327, 28373, 543, 2011, 2215, 1077, 1172, 314, 2011, 11180, 754, 14, 272, 367, 2215, 315, 334, 83, 17, 12, 308, 18, 12, 5809, 12, 6917, 12, 11507, 63, 7033, 304, 489, 291, 423, 479, 63, 10786, 8, 2062, 29, 1392, 12, 2215, 17, 29, 1392, 12, 2215, 18, 29, 1392, 9, 339, 327, 942, 436, 359, 17, 61, 2454, 2839, 8503, 14, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 17, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 18, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 17, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 15645, 63, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 18, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 15645, 63, 7033, 9, 339, 291, 423, 479, 63, 10786, 8, 2062, 29, 5187, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 5187, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 5187, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 5187, 9, 339, 291, 423, 479, 63, 10786, 8, 267, 1420, 29, 15645, 63, 7033, 12, 2215, 17, 29, 7033, 12, 2215, 18, 29, 15645, 63, 7033, 9, 339, 291, 423, 479, 63, 31787, 63, 10786, 8 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 2863, 11751, 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, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2863, 63, 9069, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 13964, 7238, 26935, 8, 396, 63, 1974, 14, 26998, 1746, 304, 819, 327, 10716, 83, 626, 781, 664, 314, 2011, 754, 543, 2680, 334, 509, 6040, 11751, 395, 436, 626, 523, 327, 314, 1865, 402, 2368, 1630, 440, 17247, 334, 73, 14, 69, 2020, 32001, 365, 2984, 3113, 1912, 680, 523, 347, 485, 479, 63, 31787, 63, 10786, 8, 277, 12, 2215, 17, 12, 2215, 18, 304, 272, 340, 2215, 17, 14, 5380, 365, 440, 488, 436, 2215, 18, 14, 5380, 365, 440, 488, 26, 489, 10136, 17, 275, 980, 14, 4250, 8, 1392, 17, 14, 305, 63, 513, 1012, 489, 10136, 18, 275, 980, 14, 4250, 8, 1392, 18, 14, 305, 63, 513, 1012, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 980, 14, 10786, 8, 4250, 17, 12, 10136, 18, 9, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 980, 14, 10786, 8, 4250, 18, 12, 10136, 17, 9, 272, 291, 14, 3334, 8, 2330, 63, 9069, 14, 374, 63, 10786, 63, 6490, 8, 1392, 17, 12, 2215, 18, 430, 272, 291, 14, 3334, 8, 2330, 63, 9069, 14, 374, 63, 10786, 63, 6490, 8, 1392, 18, 12, 2215, 17, 430, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 9, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 9, 819, 327, 10716, 83, 626, 781, 664, 314, 2011, 754, 543, 2680, 334, 509, 6040, 11751, 395, 436, 626, 523, 327, 314, 1865, 402, 2368, 1630, 440, 17247, 334, 73, 14, 69, 2020, 32001, 365, 2984, 3113, 1912, 680, 523, 347, 485, 479, 63, 10786, 8, 277, 12, 1420, 12, 2215, 17, 12, 2215, 18, 304, 272, 340, 2215, 17, 14, 5380, 365, 440, 488, 436, 2215, 18, 14, 5380, 365, 440, 488, 26, 489, 1420, 63, 1590, 275, 1420, 14, 305, 63, 513, 342, 489, 10136, 17, 275, 980, 14, 4250, 8, 1392, 17, 14, 305, 63, 513, 1012, 489, 10136, 18, 275, 980, 14, 4250, 8, 1392, 18, 14, 305, 63, 513, 1012, 489, 291, 14, 7069, 8, 2062, 63, 1590, 12, 980, 14, 10786, 8, 4250, 17, 12, 10136, 18, 680, 1392, 9, 489, 291, 14, 7069, 8, 2062, 63, 1590, 12, 980, 14, 10786, 8, 4250, 18, 12, 10136, 17, 680, 1392, 9, 489, 291, 14, 629, 8, 881, 1420, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 430, 489, 291, 14, 629, 8, 881, 1420, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 430, 272, 587, 26, 489, 291, 14, 629, 8, 2062, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 17, 12, 2215, 18, 430, 489, 291, 14, 629, 8, 2062, 12, 2863, 63, 9069, 14, 10786, 63, 1392, 8, 1392, 18, 12, 2215, 17, 430, 819, 347, 511, 12105, 63, 368, 63, 7430, 8, 277, 304, 272, 308, 17, 275, 2345, 63, 1392, 14, 4106, 8, 21, 9, 272, 308, 18, 275, 2345, 63, 1392, 14, 4106, 8, 23, 9, 339, 5809, 275, 2345, 63, 1392, 14, 5187, 63, 1392, 342, 272, 6917, 275, 2345, 63, 1392, 14, 7033, 342, 272, 11507, 63, 7033, 275, 2345, 63, 1392, 14, 18592, 779, 17, 566, 339, 327, 28373, 543, 2011, 2215, 1077, 1172, 314, 2011, 11180, 754, 14, 272, 367, 2215, 315, 334, 83, 17, 12, 308, 18, 12, 5809, 12, 6917, 12, 11507, 63, 7033, 304, 489, 291, 423, 479, 63, 10786, 8, 2062, 29, 1392, 12, 2215, 17, 29, 1392, 12, 2215, 18, 29, 1392, 9, 339, 327, 942, 436, 359, 17, 61, 2454, 2839, 8503, 14, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 17, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 18, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 17, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 15645, 63, 7033, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 83, 18, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 15645, 63, 7033, 9, 339, 291, 423, 479, 63, 10786, 8, 2062, 29, 5187, 12, 2215, 17, 29, 83, 17, 12, 2215, 18, 29, 5187, 9, 272, 291, 423, 479, 63, 10786, 8, 2062, 29, 5187, 12, 2215, 17, 29, 83, 18, 12, 2215, 18, 29, 5187, 9, 339, 291, 423, 479, 63, 10786, 8, 267, 1420, 29, 15645, 63, 7033, 12, 2215, 17, 29, 7033, 12, 2215, 18, 29, 15645, 63, 7033, 9, 339, 291, 423, 479, 63, 31787, 63, 10786, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
assamite/TwatBot
tweets/reasoning.py
1
4674
''' .. py:module:: reasoning :platform: Unix Reasoning object for the tweets. ''' import logging import traceback logger = logging.getLogger('tweets.default') class Reasoning(): '''Reasoning for the tweets. Class is used to hold information about the tweet's construction, and contains few utility functions for convenience. After the tweet has been constructed, the class should hold at least following attributes: * color_code (str or unicode): color of the tweet in html-format. * color_name (str or unicode: name constructed for the color code * tweet (str or unicode): text of the tweet * tweeted (bool): Was the constructed tweet send to twitter * retweet (bool): is the tweet a retweet * retweet_url (str or unicode): URL for the retweet (if any) * original_tweet (str or unicode): Original tweet if this is a retweet * muse: class instance of the used Muse * context: class instance of the used Context * color_semantics: class instance of the used ColorSemantics. * values (dict): dictionary of the appreciation values generated during the tweet's construction. ''' def __init__(self, **kwargs): self.color_code = "" self.color_name = "" self.tweet = "" self.tweeted = False self.retweet = False self.retweet_url = "" self.original_tweet = "" self.muse = None self.context = None self.color_semantics = None self.muse_classname = "" self.color_semantics_classname = "" self.context_classname = "" self.values = {} self.media = None self.appreciation = 0.0 for k, v in kwargs.items(): setattr(self, k, v) def __repr__(self): ret = "" for k, v in self.__dict__.items(): ret = ret + k + ": " + str(v) + "\n" return ret def set_attr(self, name, value): '''Define new or change old attribute value. Caller should take care of the possible conflicts when changing existing attribute values. :param name: Name of the attribute :type name: str :param value: New attribute value :type value: Object ''' setattr(self, name, value) if name == 'muse': setattr(self, 'muse_classname', value.__class__.__name__) if name == 'context': setattr(self, 'context_classname', value.__class__.__name__) if name == 'color_semantics': setattr(self, 'color_semantics_classname', value.__class__.__name__) def set_attrs(self, mappings): '''Define new or change old attribute values in a patch. Caller should take care of the possible conflicts when changing existing attribute values. :param mappings: Attribute mappings :type mappings: dict ''' for k, v in mappings.items(): self.set_attr(k, v) def save(self): '''Save tweet to database. :returns: bool -- True is the save was made, False if not exceptions happened during the save ''' from models import EveryColorBotTweet, Tweet, ReTweet if self.tweet == "": logger.info("Saving called for empty tweet. Skipping.") return False try: twinst = Tweet(message = self.tweet, value = self.appreciation,\ muse = self.muse_classname,\ context = self.context_classname,\ color_code = self.color_code,\ color_name = self.color_name) twinst.save() if self.retweet: screen_name = self.screen_name if screen_name == 'everycolorbot': inst = EveryColorBotTweet.objects.get_or_none(url = self.retweet_url) if inst: inst.tweeted = True inst.save() reinst = ReTweet(tweet_url = self.retweet_url,\ screen_name = screen_name, tweet = twinst) reinst.save() logger.info("Tweet saved to database: {}".format(self.tweet)) except Exception: e = traceback.format_exc() logger.error("Could not save tweet to database, because of error: {}".format(e)) return False return True
mit
[ 2344, 199, 703, 1134, 26, 578, 447, 4499, 316, 272, 520, 3246, 26, 13074, 1362, 199, 16148, 316, 909, 367, 314, 307, 18588, 14, 199, 2344, 199, 646, 2050, 199, 646, 5190, 199, 199, 2921, 275, 2050, 14, 5572, 360, 84, 18588, 14, 885, 358, 199, 199, 533, 799, 2660, 316, 837, 272, 1449, 16148, 316, 367, 314, 307, 18588, 14, 2286, 8089, 365, 1202, 370, 10266, 2556, 3595, 314, 21217, 1159, 14538, 12, 436, 3509, 5591, 9284, 11420, 3423, 367, 16777, 14, 2286, 12836, 314, 21217, 965, 2757, 14701, 12, 314, 1021, 1077, 10266, 737, 5210, 5591, 2569, 3004, 26, 2286, 627, 3164, 63, 600, 334, 495, 503, 2649, 304, 3164, 402, 314, 21217, 315, 3517, 13, 908, 14, 272, 627, 3164, 63, 354, 334, 495, 503, 2649, 26, 536, 14701, 367, 314, 3164, 1233, 272, 627, 21217, 334, 495, 503, 2649, 304, 1318, 402, 314, 21217, 5591, 627, 8900, 1024, 471, 334, 2245, 304, 644, 305, 314, 14701, 21217, 3222, 370, 15811, 272, 627, 2203, 11554, 334, 2245, 304, 365, 314, 21217, 282, 2203, 11554, 5591, 627, 2203, 11554, 63, 633, 334, 495, 503, 2649, 304, 2851, 367, 314, 2203, 11554, 334, 692, 1263, 9, 272, 627, 3379, 63, 23508, 334, 495, 503, 2649, 304, 12769, 21217, 340, 642, 365, 282, 2203, 11554, 272, 627, 333, 1180, 26, 1021, 1256, 402, 314, 1202, 603, 1180, 272, 627, 1067, 26, 1021, 1256, 402, 314, 1202, 9470, 272, 627, 3164, 63, 261, 1237, 7769, 26, 1021, 1256, 402, 314, 1202, 11581, 1513, 1237, 7769, 14, 272, 627, 1338, 334, 807, 304, 2600, 402, 314, 2771, 29804, 1338, 4046, 5309, 314, 21217, 1159, 14538, 14, 259, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 291, 14, 2326, 63, 600, 275, 3087, 267, 291, 14, 2326, 63, 354, 275, 3087, 267, 291, 14, 23508, 275, 3087, 267, 291, 14, 8122, 1024, 471, 275, 756, 267, 291, 14, 3292, 11554, 275, 756, 267, 291, 14, 3292, 11554, 63, 633, 275, 3087, 267, 291, 14, 5043, 63, 23508, 275, 3087, 267, 291, 14, 77, 1180, 275, 488, 267, 291, 14, 1100, 275, 488, 267, 291, 14, 2326, 63, 261, 1237, 7769, 275, 488, 267, 291, 14, 77, 1180, 63, 19851, 275, 3087, 267, 291, 14, 2326, 63, 261, 1237, 7769, 63, 19851, 275, 3087, 267, 291, 14, 1100, 63, 19851, 275, 3087, 267, 291, 14, 1459, 275, 1052, 267, 291, 14, 4603, 275, 488, 267, 291, 14, 571, 264, 559, 425, 275, 378, 14, 16, 268, 1362, 2728, 367, 1022, 12, 373, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 1022, 12, 373, 9, 15567, 347, 636, 2722, 721, 277, 304, 267, 2203, 275, 3087, 267, 367, 1022, 12, 373, 315, 291, 855, 807, 4343, 1744, 837, 288, 2203, 275, 2203, 435, 1022, 435, 7244, 298, 435, 620, 8, 86, 9, 435, 1867, 78, 2, 267, 372, 2203, 221, 1467, 15567, 347, 663, 63, 962, 8, 277, 12, 536, 12, 574, 304, 267, 1449, 16213, 892, 503, 1570, 2269, 2225, 574, 14, 221, 2728, 8256, 1435, 1077, 5452, 10296, 402, 314, 3962, 18511, 1380, 13729, 3411, 267, 2225, 1338, 14, 2728, 520, 635, 536, 26, 2812, 402, 314, 2225, 267, 520, 466, 536, 26, 620, 267, 520, 635, 574, 26, 7053, 2225, 574, 267, 520, 466, 574, 26, 6935, 267, 1449, 267, 5371, 8, 277, 12, 536, 12, 574, 9, 267, 340, 536, 508, 283, 77, 1180, 356, 288, 5371, 8, 277, 12, 283, 77, 1180, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 267, 340, 536, 508, 283, 1100, 356, 288, 5371, 8, 277, 12, 283, 1100, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 267, 340, 536, 508, 283, 2326, 63, 261, 1237, 7769, 356, 288, 5371, 8, 277, 12, 283, 2326, 63, 261, 1237, 7769, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 268, 5493, 347, 663, 63, 3288, 8, 277, 12, 13546, 304, 267, 1449, 16213, 892, 503, 1570, 2269, 2225, 1338, 315, 282, 3371, 14, 2728, 8256, 1435, 1077, 5452, 10296, 402, 314, 3962, 18511, 1380, 13729, 3411, 267, 2225, 1338, 14, 2728, 520, 635, 13546, 26, 3882, 13546, 267, 520, 466, 13546, 26, 1211, 267, 1449, 267, 367, 1022, 12, 373, 315, 13546, 14, 1744, 837, 288, 291, 14, 409, 63, 962, 8, 75, 12, 373, 9, 326, 15567, 347, 3354, 8, 277, 304, 267, 1449, 8229, 21217, 370, 3050, 14, 2728, 520, 5808, 26, 2155, 1553, 715, 365, 314, 3354, 1990, 6326, 12, 756, 340, 440, 4967, 21056, 5309, 314, 3354, 267, 1449, 267, 687, 1709, 492, 18414, 4117, 14026, 52, 11554, 12, 377, 11554, 12, 799, 52, 11554, 2728, 340, 291, 14, 23508, 508, 10812, 288, 2512, 14, 815, 480, 30125, 2797, 367, 2701, 21217, 14, 8232, 4073, 2685, 288, 372, 756, 2728, 862, 26, 7205, 307, 2676, 270, 275, 377, 11554, 8, 1188, 275, 291, 14, 23508, 12, 574, 275, 291, 14, 571, 264, 559, 425, 4202, 2574, 333, 1180, 275, 291, 14, 77, 1180, 63, 19851, 4202, 2574, 1067, 275, 291, 14, 1100, 63, 19851, 4202, 2574, 3164, 63, 600, 275, 291, 14, 2326, 63, 600, 4202, 2574, 3164, 63, 354, 275, 291, 14, 2326, 63, 354, 9, 288, 307, 2676, 270, 14, 2117, 342, 7846, 340, 291, 14, 3292, 11554, 26, 355, 6426, 63, 354, 275, 291, 14, 5410, 63, 354, 355, 340, 6426, 63, 354, 508, 283, 14287, 2326, 3018, 356, 490, 2727, 275, 18414, 4117, 14026, 52, 11554, 14, 1462, 14, 362, 63, 269, 63, 3592, 8, 633, 275, 291, 14, 3292, 11554, 63, 633, 9, 490, 340, 2727, 26, 717, 2727, 14, 8122, 1024, 471, 275, 715, 717, 2727, 14, 2117, 342, 586, 355, 295, 3615, 275, 799, 52, 11554, 8, 23508, 63, 633, 275, 291, 14, 3292, 11554, 63, 633, 4202, 639, 6426, 63, 354, 275, 6426, 63, 354, 12, 21217, 275, 307, 2676, 270, 9, 355, 295, 3615, 14, 2117, 342, 288, 2512, 14, 815, 480, 52, 11554, 6290, 370, 3050, 26, 8352, 908, 8, 277, 14, 23508, 430, 267, 871, 2186, 26, 288, 325, 275, 5190, 14, 908, 63, 2804, 342, 288, 2512, 14, 705, 480, 6531, 440, 3354, 21217, 370 ]
[ 199, 703, 1134, 26, 578, 447, 4499, 316, 272, 520, 3246, 26, 13074, 1362, 199, 16148, 316, 909, 367, 314, 307, 18588, 14, 199, 2344, 199, 646, 2050, 199, 646, 5190, 199, 199, 2921, 275, 2050, 14, 5572, 360, 84, 18588, 14, 885, 358, 199, 199, 533, 799, 2660, 316, 837, 272, 1449, 16148, 316, 367, 314, 307, 18588, 14, 2286, 8089, 365, 1202, 370, 10266, 2556, 3595, 314, 21217, 1159, 14538, 12, 436, 3509, 5591, 9284, 11420, 3423, 367, 16777, 14, 2286, 12836, 314, 21217, 965, 2757, 14701, 12, 314, 1021, 1077, 10266, 737, 5210, 5591, 2569, 3004, 26, 2286, 627, 3164, 63, 600, 334, 495, 503, 2649, 304, 3164, 402, 314, 21217, 315, 3517, 13, 908, 14, 272, 627, 3164, 63, 354, 334, 495, 503, 2649, 26, 536, 14701, 367, 314, 3164, 1233, 272, 627, 21217, 334, 495, 503, 2649, 304, 1318, 402, 314, 21217, 5591, 627, 8900, 1024, 471, 334, 2245, 304, 644, 305, 314, 14701, 21217, 3222, 370, 15811, 272, 627, 2203, 11554, 334, 2245, 304, 365, 314, 21217, 282, 2203, 11554, 5591, 627, 2203, 11554, 63, 633, 334, 495, 503, 2649, 304, 2851, 367, 314, 2203, 11554, 334, 692, 1263, 9, 272, 627, 3379, 63, 23508, 334, 495, 503, 2649, 304, 12769, 21217, 340, 642, 365, 282, 2203, 11554, 272, 627, 333, 1180, 26, 1021, 1256, 402, 314, 1202, 603, 1180, 272, 627, 1067, 26, 1021, 1256, 402, 314, 1202, 9470, 272, 627, 3164, 63, 261, 1237, 7769, 26, 1021, 1256, 402, 314, 1202, 11581, 1513, 1237, 7769, 14, 272, 627, 1338, 334, 807, 304, 2600, 402, 314, 2771, 29804, 1338, 4046, 5309, 314, 21217, 1159, 14538, 14, 259, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 291, 14, 2326, 63, 600, 275, 3087, 267, 291, 14, 2326, 63, 354, 275, 3087, 267, 291, 14, 23508, 275, 3087, 267, 291, 14, 8122, 1024, 471, 275, 756, 267, 291, 14, 3292, 11554, 275, 756, 267, 291, 14, 3292, 11554, 63, 633, 275, 3087, 267, 291, 14, 5043, 63, 23508, 275, 3087, 267, 291, 14, 77, 1180, 275, 488, 267, 291, 14, 1100, 275, 488, 267, 291, 14, 2326, 63, 261, 1237, 7769, 275, 488, 267, 291, 14, 77, 1180, 63, 19851, 275, 3087, 267, 291, 14, 2326, 63, 261, 1237, 7769, 63, 19851, 275, 3087, 267, 291, 14, 1100, 63, 19851, 275, 3087, 267, 291, 14, 1459, 275, 1052, 267, 291, 14, 4603, 275, 488, 267, 291, 14, 571, 264, 559, 425, 275, 378, 14, 16, 268, 1362, 2728, 367, 1022, 12, 373, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 1022, 12, 373, 9, 15567, 347, 636, 2722, 721, 277, 304, 267, 2203, 275, 3087, 267, 367, 1022, 12, 373, 315, 291, 855, 807, 4343, 1744, 837, 288, 2203, 275, 2203, 435, 1022, 435, 7244, 298, 435, 620, 8, 86, 9, 435, 1867, 78, 2, 267, 372, 2203, 221, 1467, 15567, 347, 663, 63, 962, 8, 277, 12, 536, 12, 574, 304, 267, 1449, 16213, 892, 503, 1570, 2269, 2225, 574, 14, 221, 2728, 8256, 1435, 1077, 5452, 10296, 402, 314, 3962, 18511, 1380, 13729, 3411, 267, 2225, 1338, 14, 2728, 520, 635, 536, 26, 2812, 402, 314, 2225, 267, 520, 466, 536, 26, 620, 267, 520, 635, 574, 26, 7053, 2225, 574, 267, 520, 466, 574, 26, 6935, 267, 1449, 267, 5371, 8, 277, 12, 536, 12, 574, 9, 267, 340, 536, 508, 283, 77, 1180, 356, 288, 5371, 8, 277, 12, 283, 77, 1180, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 267, 340, 536, 508, 283, 1100, 356, 288, 5371, 8, 277, 12, 283, 1100, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 267, 340, 536, 508, 283, 2326, 63, 261, 1237, 7769, 356, 288, 5371, 8, 277, 12, 283, 2326, 63, 261, 1237, 7769, 63, 19851, 297, 574, 855, 533, 4914, 354, 3368, 268, 5493, 347, 663, 63, 3288, 8, 277, 12, 13546, 304, 267, 1449, 16213, 892, 503, 1570, 2269, 2225, 1338, 315, 282, 3371, 14, 2728, 8256, 1435, 1077, 5452, 10296, 402, 314, 3962, 18511, 1380, 13729, 3411, 267, 2225, 1338, 14, 2728, 520, 635, 13546, 26, 3882, 13546, 267, 520, 466, 13546, 26, 1211, 267, 1449, 267, 367, 1022, 12, 373, 315, 13546, 14, 1744, 837, 288, 291, 14, 409, 63, 962, 8, 75, 12, 373, 9, 326, 15567, 347, 3354, 8, 277, 304, 267, 1449, 8229, 21217, 370, 3050, 14, 2728, 520, 5808, 26, 2155, 1553, 715, 365, 314, 3354, 1990, 6326, 12, 756, 340, 440, 4967, 21056, 5309, 314, 3354, 267, 1449, 267, 687, 1709, 492, 18414, 4117, 14026, 52, 11554, 12, 377, 11554, 12, 799, 52, 11554, 2728, 340, 291, 14, 23508, 508, 10812, 288, 2512, 14, 815, 480, 30125, 2797, 367, 2701, 21217, 14, 8232, 4073, 2685, 288, 372, 756, 2728, 862, 26, 7205, 307, 2676, 270, 275, 377, 11554, 8, 1188, 275, 291, 14, 23508, 12, 574, 275, 291, 14, 571, 264, 559, 425, 4202, 2574, 333, 1180, 275, 291, 14, 77, 1180, 63, 19851, 4202, 2574, 1067, 275, 291, 14, 1100, 63, 19851, 4202, 2574, 3164, 63, 600, 275, 291, 14, 2326, 63, 600, 4202, 2574, 3164, 63, 354, 275, 291, 14, 2326, 63, 354, 9, 288, 307, 2676, 270, 14, 2117, 342, 7846, 340, 291, 14, 3292, 11554, 26, 355, 6426, 63, 354, 275, 291, 14, 5410, 63, 354, 355, 340, 6426, 63, 354, 508, 283, 14287, 2326, 3018, 356, 490, 2727, 275, 18414, 4117, 14026, 52, 11554, 14, 1462, 14, 362, 63, 269, 63, 3592, 8, 633, 275, 291, 14, 3292, 11554, 63, 633, 9, 490, 340, 2727, 26, 717, 2727, 14, 8122, 1024, 471, 275, 715, 717, 2727, 14, 2117, 342, 586, 355, 295, 3615, 275, 799, 52, 11554, 8, 23508, 63, 633, 275, 291, 14, 3292, 11554, 63, 633, 4202, 639, 6426, 63, 354, 275, 6426, 63, 354, 12, 21217, 275, 307, 2676, 270, 9, 355, 295, 3615, 14, 2117, 342, 288, 2512, 14, 815, 480, 52, 11554, 6290, 370, 3050, 26, 8352, 908, 8, 277, 14, 23508, 430, 267, 871, 2186, 26, 288, 325, 275, 5190, 14, 908, 63, 2804, 342, 288, 2512, 14, 705, 480, 6531, 440, 3354, 21217, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tiagofrepereira2012/tensorflow
tensorflow/compiler/tests/concat_ops_test.py
107
12661
# Copyright 2017 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. # ============================================================================== """Functional tests for XLA Concat Op.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.compiler.tests.xla_test import XLATestCase from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops from tensorflow.python.platform import googletest class ConcatTest(XLATestCase): def testHStack(self): with self.test_session(): p1 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) p2 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) with self.test_scope(): c = array_ops.concat([p1, p2], 0) params = { p1: np.random.rand(4, 4).astype("f"), p2: np.random.rand(4, 4).astype("f") } result = c.eval(feed_dict=params) self.assertEqual(result.shape, c.get_shape()) self.assertAllEqual(result[:4, :], params[p1]) self.assertAllEqual(result[4:, :], params[p2]) def testVStack(self): with self.test_session(): p1 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) p2 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) with self.test_scope(): c = array_ops.concat([p1, p2], 1) params = { p1: np.random.rand(4, 4).astype("f"), p2: np.random.rand(4, 4).astype("f") } result = c.eval(feed_dict=params) self.assertEqual(result.shape, c.get_shape()) self.assertAllEqual(result[:, :4], params[p1]) self.assertAllEqual(result[:, 4:], params[p2]) def testInt32(self): with self.test_session(): p1 = np.random.rand(2, 3).astype("i") p2 = np.random.rand(2, 3).astype("i") x1 = constant_op.constant(p1) x2 = constant_op.constant(p2) with self.test_scope(): c = array_ops.concat([x1, x2], 0) result = c.eval() self.assertAllEqual(result[:2, :], p1) self.assertAllEqual(result[2:, :], p2) def _testRandom(self, dtype): # Random dims of rank 5 shape = np.random.randint(1, 5, size=5) # Random number of tensors, but always > 1. num_tensors = np.random.randint(2, 10) # Random dim to concat on concat_dim = np.random.randint(5) params = {} if dtype == dtypes.bfloat16: dtype_feed = dtypes.float32 else: dtype_feed = dtype with self.test_session(): p = [] for i in np.arange(num_tensors): input_shape = shape input_shape[concat_dim] = np.random.randint(1, 5) placeholder = array_ops.placeholder(dtype_feed, shape=input_shape) p.append(placeholder) t = dtype_feed.as_numpy_dtype params[placeholder] = np.random.rand(*input_shape).astype(t) if dtype != dtype_feed: concat_inputs = [math_ops.cast(p_i, dtype) for p_i in p] else: concat_inputs = p with self.test_scope(): c = array_ops.concat(concat_inputs, concat_dim) if dtype != dtype_feed: c = math_ops.cast(c, dtype_feed) result = c.eval(feed_dict=params) self.assertEqual(result.shape, c.get_shape()) cur_offset = 0 for i in np.arange(num_tensors): # The index into the result is the ':' along all dimensions # except the concat_dim. slice(0, size) is used for ':', and # a list of slices is used to index into result. ind = [slice(0, params[p[i]].shape[j]) for j in np.arange(5)] ind[concat_dim] = slice(cur_offset, cur_offset + params[p[i]].shape[concat_dim]) cur_offset += params[p[i]].shape[concat_dim] if dtype == dtype_feed: self.assertAllEqual(result[ind], params[p[i]]) else: self.assertAllClose(result[ind], params[p[i]], 0.01) def testRandom(self): self._testRandom(dtypes.float32) self._testRandom(dtypes.int32) def _testGradientsSimple(self): with self.test_session(): inp = [] inp_tensors = [] with self.test_scope(): for x in [1, 2, 6]: shape = [10, x, 2] t = np.random.rand(*shape).astype("f") inp.append(t) inp_tensors.append( constant_op.constant( [float(y) for y in t.flatten()], shape=shape, dtype=dtypes.float32)) c = array_ops.concat(inp_tensors, 1) output_shape = [10, 9, 2] grad_inp = np.random.rand(*output_shape).astype("f") grad_tensor = constant_op.constant( [float(x) for x in grad_inp.flatten()], shape=output_shape) grad = gradients_impl.gradients([c], inp_tensors, [grad_tensor]) concated_grad = array_ops.concat(grad, 1) result = concated_grad.eval() self.assertAllEqual(result, grad_inp) def testGradientsSimpleAll(self): self._testGradientsSimple() def _testGradientsFirstDim(self): with self.test_session(): inp = [] inp_tensors = [] with self.test_scope(): for x in [1, 2, 6]: shape = [x, 10, 2] t = np.random.rand(*shape).astype("f") inp.append(t) inp_tensors.append( constant_op.constant( [float(y) for y in t.flatten()], shape=shape, dtype=dtypes.float32)) c = array_ops.concat(inp_tensors, 0) output_shape = [9, 10, 2] grad_inp = np.random.rand(*output_shape).astype("f") grad_tensor = constant_op.constant( [float(x) for x in grad_inp.flatten()], shape=output_shape) grad = gradients_impl.gradients([c], inp_tensors, [grad_tensor]) concated_grad = array_ops.concat(grad, 0) result = concated_grad.eval() self.assertAllEqual(result, grad_inp) def testGradientsFirstDimAll(self): self._testGradientsFirstDim() def _testGradientsLastDim(self): with self.test_session(): inp = [] inp_tensors = [] with self.test_scope(): for x in [1, 2, 6]: shape = [10, 2, x] t = np.random.rand(*shape).astype("f") inp.append(t) inp_tensors.append( constant_op.constant( [float(y) for y in t.flatten()], shape=shape, dtype=dtypes.float32)) c = array_ops.concat(inp_tensors, 2) output_shape = [10, 2, 9] grad_inp = np.random.rand(*output_shape).astype("f") grad_tensor = constant_op.constant( [float(x) for x in grad_inp.flatten()], shape=output_shape) grad = gradients_impl.gradients([c], inp_tensors, [grad_tensor]) concated_grad = array_ops.concat(grad, 2) result = concated_grad.eval() self.assertAllEqual(result, grad_inp) def testGradientsLastDimAll(self): self._testGradientsLastDim() def _RunAndVerifyGradientsRandom(self): # Random dims of rank 5 input_shape = np.random.randint(1, 5, size=5) # Random number of tensors num_tensors = np.random.randint(1, 10) # Random dim to concat on concat_dim = np.random.randint(5) concat_dim_sizes = np.random.randint(1, 5, size=num_tensors) with self.test_session(): inp = [] inp_tensors = [] with self.test_scope(): for x in concat_dim_sizes: shape = input_shape shape[concat_dim] = x t = np.random.rand(*shape).astype("f") inp.append(t) inp_tensors.append( constant_op.constant( [float(y) for y in t.flatten()], shape=shape, dtype=dtypes.float32)) c = array_ops.concat(inp_tensors, concat_dim) output_shape = input_shape output_shape[concat_dim] = concat_dim_sizes.sum() grad_inp = np.random.rand(*output_shape).astype("f") grad_tensor = constant_op.constant( [float(x) for x in grad_inp.flatten()], shape=output_shape) grad = gradients_impl.gradients([c], inp_tensors, [grad_tensor]) concated_grad = array_ops.concat(grad, concat_dim) result = concated_grad.eval() self.assertAllEqual(result, grad_inp) def testGradientsRandom(self): for _ in range(5): self._RunAndVerifyGradientsRandom() # Re-enable once zero-element Retvals are handled correctly. def DISABLED_testZeroSize(self): # Verify that concat doesn't crash and burn for zero size inputs np.random.seed(7) with self.test_session() as sess: with self.test_scope(): for shape0 in (), (2,): axis = len(shape0) for shape1 in (), (3,): for n0 in 0, 1, 2: for n1 in 0, 1, 2: x0 = np.random.randn(*(shape0 + (n0,) + shape1)) x1 = np.random.randn(*(shape0 + (n1,) + shape1)) correct = np.concatenate([x0, x1], axis=axis) # TODO(irving): Make tf.concat handle map, then drop list(). xs = list(map(constant_op.constant, [x0, x1])) c = array_ops.concat(xs, axis) self.assertAllEqual(c.eval(), correct) # Check gradients dc = np.random.randn(*c.get_shape().as_list()) dxs = sess.run(gradients_impl.gradients(c, xs, dc)) self.assertAllEqual(dc, np.concatenate(dxs, axis=axis)) def testConcatTuple(self): c1 = np.random.rand(4, 4).astype(np.float32) c2 = np.random.rand(4, 4).astype(np.float32) with self.test_session(): with self.test_scope(): concat_list_t = array_ops.concat([c1, c2], 0) concat_tuple_t = array_ops.concat((c1, c2), 0) self.assertAllEqual(concat_list_t.eval(), concat_tuple_t.eval()) def testConcatNoScalars(self): with self.test_session(): with self.test_scope(): scalar = constant_op.constant(7) dim = array_ops.placeholder(dtypes.int32) with self.assertRaisesRegexp( ValueError, r"Can't concatenate scalars \(use tf\.stack instead\)"): array_ops.concat([scalar, scalar, scalar], dim) class ConcatOffsetTest(XLATestCase): def testBasic(self): with self.test_session() as sess: with self.test_scope(): cdim = constant_op.constant(1, dtypes.int32) s0 = constant_op.constant([2, 3, 5], dtypes.int32) s1 = constant_op.constant([2, 7, 5], dtypes.int32) s2 = constant_op.constant([2, 20, 5], dtypes.int32) off = gen_array_ops._concat_offset(cdim, [s0, s1, s2]) ans = sess.run(off) self.assertAllEqual(ans, [[0, 0, 0], [0, 3, 0], [0, 10, 0]]) class PackTest(XLATestCase): def testBasic(self): with self.test_session() as sess: with self.test_scope(): s0 = constant_op.constant([2, 3, 5], dtypes.int32) s1 = constant_op.constant([2, 7, 5], dtypes.int32) s2 = constant_op.constant([2, 20, 5], dtypes.int32) packed = array_ops.stack([s0, s1, s2]) ans = sess.run(packed) self.assertAllEqual(ans, [[2, 3, 5], [2, 7, 5], [2, 20, 5]]) def testScalars(self): with self.test_session() as sess: with self.test_scope(): s0 = constant_op.constant(2, dtypes.int32) s1 = constant_op.constant(3, dtypes.int32) s2 = constant_op.constant(5, dtypes.int32) packed = array_ops.stack([s0, s1, s2]) ans = sess.run(packed) self.assertAllEqual(ans, [2, 3, 5]) def testEmpty(self): with self.test_session() as sess: with self.test_scope(): s0 = constant_op.constant([[]], dtypes.int32) s1 = constant_op.constant([[]], dtypes.int32) s2 = constant_op.constant([[]], dtypes.int32) packed = array_ops.stack([s0, s1, s2]) ans = sess.run(packed) self.assertAllEqual(ans, [[[]], [[]], [[]]]) if __name__ == "__main__": googletest.main()
apache-2.0
[ 3, 1898, 9708, 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, 3481, 279, 2295, 367, 1323, 5837, 1448, 3385, 9319, 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, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 1448, 3385, 774, 8, 56, 20307, 27309, 304, 819, 347, 511, 40, 4851, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 299, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 80, 17, 12, 299, 18, 467, 378, 9, 489, 1862, 275, 469, 881, 299, 17, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 1288, 881, 299, 18, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 531, 489, 789, 489, 754, 275, 286, 14, 2579, 8, 3871, 63, 807, 29, 1162, 9, 339, 291, 14, 629, 8, 1099, 14, 1392, 12, 286, 14, 362, 63, 1392, 1012, 272, 291, 14, 7069, 8, 1099, 1491, 20, 12, 26450, 1862, 59, 80, 17, 566, 272, 291, 14, 7069, 8, 1099, 59, 20, 11941, 26450, 1862, 59, 80, 18, 566, 819, 347, 511, 54, 4851, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 299, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 80, 17, 12, 299, 18, 467, 413, 9, 489, 1862, 275, 469, 881, 299, 17, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 1288, 881, 299, 18, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 531, 489, 789, 489, 754, 275, 286, 14, 2579, 8, 3871, 63, 807, 29, 1162, 9, 339, 291, 14, 629, 8, 1099, 14, 1392, 12, 286, 14, 362, 63, 1392, 1012, 272, 291, 14, 7069, 8, 1099, 3981, 520, 20, 467, 1862, 59, 80, 17, 566, 272, 291, 14, 7069, 8, 1099, 3981, 841, 8429, 1862, 59, 80, 18, 566, 819, 347, 511, 3241, 708, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 980, 14, 2355, 14, 3759, 8, 18, 12, 650, 680, 6041, 480, 73, 531, 489, 299, 18, 275, 980, 14, 2355, 14, 3759, 8, 18, 12, 650, 680, 6041, 480, 73, 531, 489, 671, 17, 275, 4413, 63, 411, 14, 4083, 8, 80, 17, 9, 489, 671, 18, 275, 4413, 63, 411, 14, 4083, 8, 80, 18, 9, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 88, 17, 12, 671, 18, 467, 378, 9, 489, 754, 275, 286, 14, 2579, 342, 272, 291, 14, 7069, 8, 1099, 1491, 18, 12, 26450, 299, 17, 9, 272, 291, 14, 7069, 8, 1099, 59, 18, 11941, 26450, 299, 18, 9, 819, 347, 485, 396, 3883, 8, 277, 12, 2152, 304, 272, 327, 9571, 17476, 402, 6915, 959, 272, 2215, 275, 980, 14, 2355, 14, 8393, 8, 17, 12, 959, 12, 1568, 29, 21, 9, 272, 327, 9571, 1329, 402, 10519, 12, 1325, 3544, 690, 413, 14, 272, 1967, 63, 10206, 275, 980, 14, 2355, 14, 8393, 8, 18, 12, 1616, 9, 272, 327, 9571, 8134, 370, 17159, 641, 272, 17159, 63, 3572, 275, 980, 14, 2355, 14, 8393, 8, 21, 9, 272, 1862, 275, 1052, 272, 340, 2152, 508, 6674, 14, 66, 1609, 975, 26, 489, 2152, 63, 3871, 275, 6674, 14, 1609, 708, 272, 587, 26, 489, 2152, 63, 3871, 275, 2152, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 275, 942, 489, 367, 284, 315, 980, 14, 5605, 8, 1507, 63, 10206, 304, 267, 1324, 63, 1392, 275, 2215, 267, 1324, 63, 1392, 59, 9419, 63, 3572, 61, 275, 980, 14, 2355, 14, 8393, 8, 17, 12, 959, 9, 267, 10069, 275, 1625, 63, 1483, 14, 6199, 8, 2271, 63, 3871, 12, 2215, 29, 1210, 63, 1392, 9, 267, 299, 14, 740, 8, 6199, 9, 398, 307, 275, 2152, 63, 3871, 14, 305, 63, 4714, 63, 2271, 267, 1862, 59, 6199, 61, 275, 980, 14, 2355, 14, 3759, 2031, 1210, 63, 1392, 680, 6041, 8, 84, 9, 2541, 340, 2152, 1137, 2152, 63, 3871, 26, 267, 17159 ]
[ 1898, 9708, 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, 3481, 279, 2295, 367, 1323, 5837, 1448, 3385, 9319, 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, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 1448, 3385, 774, 8, 56, 20307, 27309, 304, 819, 347, 511, 40, 4851, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 299, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 80, 17, 12, 299, 18, 467, 378, 9, 489, 1862, 275, 469, 881, 299, 17, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 1288, 881, 299, 18, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 531, 489, 789, 489, 754, 275, 286, 14, 2579, 8, 3871, 63, 807, 29, 1162, 9, 339, 291, 14, 629, 8, 1099, 14, 1392, 12, 286, 14, 362, 63, 1392, 1012, 272, 291, 14, 7069, 8, 1099, 1491, 20, 12, 26450, 1862, 59, 80, 17, 566, 272, 291, 14, 7069, 8, 1099, 59, 20, 11941, 26450, 1862, 59, 80, 18, 566, 819, 347, 511, 54, 4851, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 299, 18, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 1524, 20, 12, 841, 566, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 80, 17, 12, 299, 18, 467, 413, 9, 489, 1862, 275, 469, 881, 299, 17, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 1288, 881, 299, 18, 26, 980, 14, 2355, 14, 3759, 8, 20, 12, 841, 680, 6041, 480, 70, 531, 489, 789, 489, 754, 275, 286, 14, 2579, 8, 3871, 63, 807, 29, 1162, 9, 339, 291, 14, 629, 8, 1099, 14, 1392, 12, 286, 14, 362, 63, 1392, 1012, 272, 291, 14, 7069, 8, 1099, 3981, 520, 20, 467, 1862, 59, 80, 17, 566, 272, 291, 14, 7069, 8, 1099, 3981, 841, 8429, 1862, 59, 80, 18, 566, 819, 347, 511, 3241, 708, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 17, 275, 980, 14, 2355, 14, 3759, 8, 18, 12, 650, 680, 6041, 480, 73, 531, 489, 299, 18, 275, 980, 14, 2355, 14, 3759, 8, 18, 12, 650, 680, 6041, 480, 73, 531, 489, 671, 17, 275, 4413, 63, 411, 14, 4083, 8, 80, 17, 9, 489, 671, 18, 275, 4413, 63, 411, 14, 4083, 8, 80, 18, 9, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 286, 275, 1625, 63, 1483, 14, 9419, 779, 88, 17, 12, 671, 18, 467, 378, 9, 489, 754, 275, 286, 14, 2579, 342, 272, 291, 14, 7069, 8, 1099, 1491, 18, 12, 26450, 299, 17, 9, 272, 291, 14, 7069, 8, 1099, 59, 18, 11941, 26450, 299, 18, 9, 819, 347, 485, 396, 3883, 8, 277, 12, 2152, 304, 272, 327, 9571, 17476, 402, 6915, 959, 272, 2215, 275, 980, 14, 2355, 14, 8393, 8, 17, 12, 959, 12, 1568, 29, 21, 9, 272, 327, 9571, 1329, 402, 10519, 12, 1325, 3544, 690, 413, 14, 272, 1967, 63, 10206, 275, 980, 14, 2355, 14, 8393, 8, 18, 12, 1616, 9, 272, 327, 9571, 8134, 370, 17159, 641, 272, 17159, 63, 3572, 275, 980, 14, 2355, 14, 8393, 8, 21, 9, 272, 1862, 275, 1052, 272, 340, 2152, 508, 6674, 14, 66, 1609, 975, 26, 489, 2152, 63, 3871, 275, 6674, 14, 1609, 708, 272, 587, 26, 489, 2152, 63, 3871, 275, 2152, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 299, 275, 942, 489, 367, 284, 315, 980, 14, 5605, 8, 1507, 63, 10206, 304, 267, 1324, 63, 1392, 275, 2215, 267, 1324, 63, 1392, 59, 9419, 63, 3572, 61, 275, 980, 14, 2355, 14, 8393, 8, 17, 12, 959, 9, 267, 10069, 275, 1625, 63, 1483, 14, 6199, 8, 2271, 63, 3871, 12, 2215, 29, 1210, 63, 1392, 9, 267, 299, 14, 740, 8, 6199, 9, 398, 307, 275, 2152, 63, 3871, 14, 305, 63, 4714, 63, 2271, 267, 1862, 59, 6199, 61, 275, 980, 14, 2355, 14, 3759, 2031, 1210, 63, 1392, 680, 6041, 8, 84, 9, 2541, 340, 2152, 1137, 2152, 63, 3871, 26, 267, 17159, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Ashald/uwsgi
contrib/twuwsgi.py
21
4220
from twisted.internet import defer, protocol, reactor from twisted.protocols import basic from twisted.web2 import http, resource, responsecode, stream import struct class uWSGIClientResource(resource.LeafResource): def __init__(self, app='', port=3030, host='localhost'): resource.LeafResource.__init__(self) self.host = host self.port = port self.app = app def renderHTTP(self, request): return uWSGI(request, self.app, self.host, self.port) def uWSGI(request, app, host, port): if request.stream.length is None: return http.Response(responsecode.LENGTH_REQUIRED) request.uwsgi_app = app factory = uWSGIClientProtocolFactory(request) reactor.connectTCP(host, port, factory) return factory.deferred class uWSGIClientProtocol(basic.LineReceiver): def __init__(self, request, deferred): self.request = request self.deferred = deferred self.stream = stream.ProducerStream() self.response = http.Response(stream=self.stream) self.status_parsed = None def build_uwsgi_var(self, key, value): return struct.pack('<H', len(key)) + key + struct.pack('<H', len(value)) + value def connectionMade(self): print(self.request.__dict__) # reset response parser self.status_parsed = None # build header and vars vars = '' if self.request.stream.length: vars += self.build_uwsgi_var('CONTENT_LENGTH', str(self.request.stream.length)) for hkey, hval in self.request.headers.getAllRawHeaders(): # use a list, probably it will be extended if hkey.lower() not in ('content-type'): vars += self.build_uwsgi_var('HTTP_' + hkey.upper().replace('-', '_'), ','.join(hval)) else: vars += self.build_uwsgi_var(hkey.upper().replace('-', '_'), ','.join(hval)) vars += self.build_uwsgi_var('REQUEST_METHOD', self.request.method) vars += self.build_uwsgi_var('SCRIPT_NAME', self.request.uwsgi_app) vars += self.build_uwsgi_var('PATH_INFO', self.request.path[len(self.request.uwsgi_app):]) vars += self.build_uwsgi_var('QUERY_STRING', self.request.querystring) vars += self.build_uwsgi_var('SERVER_NAME', self.request.host) vars += self.build_uwsgi_var('SERVER_PORT', str(self.request.port)) vars += self.build_uwsgi_var('SERVER_PROTOCOL', self.request.scheme.upper() + '/' + str(self.request.clientproto[0]) + '.' + str(self.request.clientproto[1])) vars += self.build_uwsgi_var('REQUEST_URI', self.request.uri) vars += self.build_uwsgi_var('REMOTE_ADDR', self.request.remoteAddr.host) self.transport.write(struct.pack('<BHB', 0, len(vars), 0)) self.transport.write(vars) # send request data stream.StreamProducer(self.request.stream).beginProducing(self.transport) def lineReceived(self, line): if self.status_parsed is None: self.response.code = line.split(' ', 2)[1] self.status_parsed = True return # end of headers if line == '': self.setRawMode() self.deferred.callback(self.response) self.response = None return name, value = line.split(':', 1) value = value.strip() self.response.headers.addRawHeader(name, value) def rawDataReceived(self, data): self.stream.write(data) def connectionLost(self, reason): self.stream.finish() class uWSGIClientProtocolFactory(protocol.ClientFactory): protocol = uWSGIClientProtocol noisy = False # Make Factory shut up def __init__(self, request): self.request = request self.deferred = defer.Deferred() def buildProtocol(self, addr): return self.protocol(self.request, self.deferred) def clientConnectionFailed(self, connector, reason): self.sendFailureResponse(reason) def sendFailureResponse(self, reason): response = http.Response(code=responsecode.BAD_GATEWAY, stream=str(reason.value)) self.deferred.callback(response)
gpl-2.0
[ 504, 7390, 14, 4901, 492, 10133, 12, 4113, 12, 9655, 199, 504, 7390, 14, 16541, 492, 5678, 199, 504, 7390, 14, 2520, 18, 492, 1455, 12, 2073, 12, 1177, 600, 12, 2547, 199, 199, 646, 2702, 421, 199, 533, 399, 55, 4254, 948, 864, 4031, 8, 1927, 14, 20475, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 1145, 4581, 1844, 29, 1216, 1216, 12, 1591, 534, 5967, 735, 267, 2073, 14, 20475, 4031, 855, 826, 721, 277, 9, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 719, 275, 1844, 267, 291, 14, 571, 275, 1145, 339, 347, 3795, 2856, 8, 277, 12, 1056, 304, 267, 372, 399, 16828, 8, 1069, 12, 291, 14, 571, 12, 291, 14, 1102, 12, 291, 14, 719, 9, 421, 199, 318, 399, 16828, 8, 1069, 12, 1145, 12, 1591, 12, 1844, 304, 272, 340, 1056, 14, 1745, 14, 1267, 365, 488, 26, 267, 372, 1455, 14, 2364, 8, 1310, 600, 14, 9127, 63, 12496, 9, 339, 1056, 14, 85, 6508, 63, 571, 275, 1145, 272, 6434, 275, 399, 55, 4254, 948, 864, 3658, 2927, 8, 1069, 9, 272, 9655, 14, 2242, 9735, 8, 1102, 12, 1844, 12, 6434, 9, 272, 372, 6434, 14, 12116, 421, 199, 533, 399, 55, 4254, 948, 864, 3658, 8, 4316, 14, 3049, 21800, 304, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 12309, 304, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 12116, 275, 12309, 267, 291, 14, 1745, 275, 2547, 14, 15532, 3296, 342, 267, 291, 14, 1310, 275, 1455, 14, 2364, 8, 1745, 29, 277, 14, 1745, 9, 267, 291, 14, 1205, 63, 6751, 275, 488, 339, 347, 1900, 63, 85, 6508, 63, 1391, 8, 277, 12, 790, 12, 574, 304, 267, 372, 2702, 14, 1389, 4827, 40, 297, 822, 8, 498, 430, 435, 790, 435, 2702, 14, 1389, 4827, 40, 297, 822, 8, 585, 430, 435, 574, 339, 347, 1950, 26973, 8, 277, 304, 267, 870, 8, 277, 14, 1069, 855, 807, 3368, 267, 327, 5305, 1177, 1798, 267, 291, 14, 1205, 63, 6751, 275, 488, 267, 327, 1900, 1406, 436, 6802, 267, 6802, 275, 2125, 398, 340, 291, 14, 1069, 14, 1745, 14, 1267, 26, 355, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 9663, 63, 9127, 297, 620, 8, 277, 14, 1069, 14, 1745, 14, 1267, 430, 398, 367, 394, 498, 12, 394, 637, 315, 291, 14, 1069, 14, 2139, 14, 31359, 7963, 9883, 837, 355, 327, 675, 282, 769, 12, 8646, 652, 911, 506, 9243, 355, 340, 394, 498, 14, 2325, 342, 440, 315, 661, 1317, 13, 466, 735, 717, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 2856, 8650, 435, 394, 498, 14, 4142, 1252, 1814, 13858, 2513, 659, 12814, 904, 8, 72, 637, 430, 355, 587, 26, 717, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 8, 72, 498, 14, 4142, 1252, 1814, 13858, 2513, 659, 12814, 904, 8, 72, 637, 430, 398, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6780, 63, 9977, 297, 291, 14, 1069, 14, 765, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 10484, 63, 2339, 297, 291, 14, 1069, 14, 85, 6508, 63, 571, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 3243, 63, 4531, 297, 291, 14, 1069, 14, 515, 59, 552, 8, 277, 14, 1069, 14, 85, 6508, 63, 571, 304, 566, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 11938, 63, 5353, 297, 291, 14, 1069, 14, 1131, 875, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 2339, 297, 291, 14, 1069, 14, 1102, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 3657, 297, 620, 8, 277, 14, 1069, 14, 719, 430, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 9583, 297, 291, 14, 1069, 14, 5512, 14, 4142, 342, 435, 7324, 435, 620, 8, 277, 14, 1069, 14, 1258, 2625, 59, 16, 566, 435, 7815, 435, 620, 8, 277, 14, 1069, 14, 1258, 2625, 59, 17, 2459, 398, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6780, 63, 7639, 297, 291, 14, 1069, 14, 2302, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 16058, 63, 7803, 297, 291, 14, 1069, 14, 3846, 11404, 14, 1102, 9, 398, 291, 14, 5545, 14, 952, 8, 1820, 14, 1389, 4827, 34, 25262, 297, 378, 12, 822, 8, 2936, 395, 378, 430, 267, 291, 14, 5545, 14, 952, 8, 2936, 9, 398, 327, 3222, 1056, 666, 267, 2547, 14, 3296, 15532, 8, 277, 14, 1069, 14, 1745, 680, 5037, 24982, 8, 277, 14, 5545, 9, 339, 347, 1004, 9392, 8, 277, 12, 1004, 304, 267, 340, 291, 14, 1205, 63, 6751, 365, 488, 26, 355, 291, 14, 1310, 14, 600, 275, 1004, 14, 1294, 360, 1656, 499, 2788, 17, 61, 355, 291, 14, 1205, 63, 6751, 275, 715, 355, 372, 398, 327, 1284, 402, 2323, 267, 340, 1004, 508, 8061, 288, 291, 14, 409, 7963, 1385, 342, 288, 291, 14, 12116, 14, 3058, 8, 277, 14, 1310, 9, 288, 291, 14, 1310, 275, 488, 288, 372, 398, 536, 12, 574, 275, 1004, 14, 1294, 16451, 413, 9, 267, 574, 275, 574, 14, 1913, 342, 398, 291, 14, 1310, 14, 2139, 14, 525, 7963, 2567, 8, 354, 12, 574, 9, 339, 347, 3066, 1451, 9392, 8, 277, 12, 666, 304, 267, 291, 14, 1745, 14, 952, 8, 576, 9, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 291, 14, 1745, 14, 8192, 342, 421, 199, 533, 399, 55, 4254, 948, 864, 3658, 2927, 8, 3922, 14, 30115, 304, 339, 4113, 275, 399, 55, 4254, 948, 864, 3658, 272, 949, 19765, 275, 756, 221, 327, 4155, 23616, 24761, 1536, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 12116, 275, 10133, 14, 9937, 342, 339, 347, 1900, 3658, 8, 277, 12, 5552, 304, 267, 372, 291, 14, 3922, 8, 277, 14, 1069, 12, 291 ]
[ 7390, 14, 4901, 492, 10133, 12, 4113, 12, 9655, 199, 504, 7390, 14, 16541, 492, 5678, 199, 504, 7390, 14, 2520, 18, 492, 1455, 12, 2073, 12, 1177, 600, 12, 2547, 199, 199, 646, 2702, 421, 199, 533, 399, 55, 4254, 948, 864, 4031, 8, 1927, 14, 20475, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 1145, 4581, 1844, 29, 1216, 1216, 12, 1591, 534, 5967, 735, 267, 2073, 14, 20475, 4031, 855, 826, 721, 277, 9, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 719, 275, 1844, 267, 291, 14, 571, 275, 1145, 339, 347, 3795, 2856, 8, 277, 12, 1056, 304, 267, 372, 399, 16828, 8, 1069, 12, 291, 14, 571, 12, 291, 14, 1102, 12, 291, 14, 719, 9, 421, 199, 318, 399, 16828, 8, 1069, 12, 1145, 12, 1591, 12, 1844, 304, 272, 340, 1056, 14, 1745, 14, 1267, 365, 488, 26, 267, 372, 1455, 14, 2364, 8, 1310, 600, 14, 9127, 63, 12496, 9, 339, 1056, 14, 85, 6508, 63, 571, 275, 1145, 272, 6434, 275, 399, 55, 4254, 948, 864, 3658, 2927, 8, 1069, 9, 272, 9655, 14, 2242, 9735, 8, 1102, 12, 1844, 12, 6434, 9, 272, 372, 6434, 14, 12116, 421, 199, 533, 399, 55, 4254, 948, 864, 3658, 8, 4316, 14, 3049, 21800, 304, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 12309, 304, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 12116, 275, 12309, 267, 291, 14, 1745, 275, 2547, 14, 15532, 3296, 342, 267, 291, 14, 1310, 275, 1455, 14, 2364, 8, 1745, 29, 277, 14, 1745, 9, 267, 291, 14, 1205, 63, 6751, 275, 488, 339, 347, 1900, 63, 85, 6508, 63, 1391, 8, 277, 12, 790, 12, 574, 304, 267, 372, 2702, 14, 1389, 4827, 40, 297, 822, 8, 498, 430, 435, 790, 435, 2702, 14, 1389, 4827, 40, 297, 822, 8, 585, 430, 435, 574, 339, 347, 1950, 26973, 8, 277, 304, 267, 870, 8, 277, 14, 1069, 855, 807, 3368, 267, 327, 5305, 1177, 1798, 267, 291, 14, 1205, 63, 6751, 275, 488, 267, 327, 1900, 1406, 436, 6802, 267, 6802, 275, 2125, 398, 340, 291, 14, 1069, 14, 1745, 14, 1267, 26, 355, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 9663, 63, 9127, 297, 620, 8, 277, 14, 1069, 14, 1745, 14, 1267, 430, 398, 367, 394, 498, 12, 394, 637, 315, 291, 14, 1069, 14, 2139, 14, 31359, 7963, 9883, 837, 355, 327, 675, 282, 769, 12, 8646, 652, 911, 506, 9243, 355, 340, 394, 498, 14, 2325, 342, 440, 315, 661, 1317, 13, 466, 735, 717, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 2856, 8650, 435, 394, 498, 14, 4142, 1252, 1814, 13858, 2513, 659, 12814, 904, 8, 72, 637, 430, 355, 587, 26, 717, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 8, 72, 498, 14, 4142, 1252, 1814, 13858, 2513, 659, 12814, 904, 8, 72, 637, 430, 398, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6780, 63, 9977, 297, 291, 14, 1069, 14, 765, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 10484, 63, 2339, 297, 291, 14, 1069, 14, 85, 6508, 63, 571, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 3243, 63, 4531, 297, 291, 14, 1069, 14, 515, 59, 552, 8, 277, 14, 1069, 14, 85, 6508, 63, 571, 304, 566, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 11938, 63, 5353, 297, 291, 14, 1069, 14, 1131, 875, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 2339, 297, 291, 14, 1069, 14, 1102, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 3657, 297, 620, 8, 277, 14, 1069, 14, 719, 430, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6613, 63, 9583, 297, 291, 14, 1069, 14, 5512, 14, 4142, 342, 435, 7324, 435, 620, 8, 277, 14, 1069, 14, 1258, 2625, 59, 16, 566, 435, 7815, 435, 620, 8, 277, 14, 1069, 14, 1258, 2625, 59, 17, 2459, 398, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 6780, 63, 7639, 297, 291, 14, 1069, 14, 2302, 9, 267, 6802, 847, 291, 14, 1506, 63, 85, 6508, 63, 1391, 360, 16058, 63, 7803, 297, 291, 14, 1069, 14, 3846, 11404, 14, 1102, 9, 398, 291, 14, 5545, 14, 952, 8, 1820, 14, 1389, 4827, 34, 25262, 297, 378, 12, 822, 8, 2936, 395, 378, 430, 267, 291, 14, 5545, 14, 952, 8, 2936, 9, 398, 327, 3222, 1056, 666, 267, 2547, 14, 3296, 15532, 8, 277, 14, 1069, 14, 1745, 680, 5037, 24982, 8, 277, 14, 5545, 9, 339, 347, 1004, 9392, 8, 277, 12, 1004, 304, 267, 340, 291, 14, 1205, 63, 6751, 365, 488, 26, 355, 291, 14, 1310, 14, 600, 275, 1004, 14, 1294, 360, 1656, 499, 2788, 17, 61, 355, 291, 14, 1205, 63, 6751, 275, 715, 355, 372, 398, 327, 1284, 402, 2323, 267, 340, 1004, 508, 8061, 288, 291, 14, 409, 7963, 1385, 342, 288, 291, 14, 12116, 14, 3058, 8, 277, 14, 1310, 9, 288, 291, 14, 1310, 275, 488, 288, 372, 398, 536, 12, 574, 275, 1004, 14, 1294, 16451, 413, 9, 267, 574, 275, 574, 14, 1913, 342, 398, 291, 14, 1310, 14, 2139, 14, 525, 7963, 2567, 8, 354, 12, 574, 9, 339, 347, 3066, 1451, 9392, 8, 277, 12, 666, 304, 267, 291, 14, 1745, 14, 952, 8, 576, 9, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 291, 14, 1745, 14, 8192, 342, 421, 199, 533, 399, 55, 4254, 948, 864, 3658, 2927, 8, 3922, 14, 30115, 304, 339, 4113, 275, 399, 55, 4254, 948, 864, 3658, 272, 949, 19765, 275, 756, 221, 327, 4155, 23616, 24761, 1536, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 12116, 275, 10133, 14, 9937, 342, 339, 347, 1900, 3658, 8, 277, 12, 5552, 304, 267, 372, 291, 14, 3922, 8, 277, 14, 1069, 12, 291,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1, 1, 1 ]
Shekharrajak/Django-facebook
docs/docs_env/Lib/UserDict.py
117
5729
"""A more or less complete user-defined wrapper around dictionary objects.""" class UserDict: def __init__(self, dict=None, **kwargs): self.data = {} if dict is not None: self.update(dict) if len(kwargs): self.update(kwargs) def __repr__(self): return repr(self.data) def __cmp__(self, dict): if isinstance(dict, UserDict): return cmp(self.data, dict.data) else: return cmp(self.data, dict) def __len__(self): return len(self.data) def __getitem__(self, key): if key in self.data: return self.data[key] if hasattr(self.__class__, "__missing__"): return self.__class__.__missing__(self, key) raise KeyError(key) def __setitem__(self, key, item): self.data[key] = item def __delitem__(self, key): del self.data[key] def clear(self): self.data.clear() def copy(self): if self.__class__ is UserDict: return UserDict(self.data.copy()) import copy data = self.data try: self.data = {} c = copy.copy(self) finally: self.data = data c.update(self) return c def keys(self): return self.data.keys() def items(self): return self.data.items() def iteritems(self): return self.data.iteritems() def iterkeys(self): return self.data.iterkeys() def itervalues(self): return self.data.itervalues() def values(self): return self.data.values() def has_key(self, key): return self.data.has_key(key) def update(self, dict=None, **kwargs): if dict is None: pass elif isinstance(dict, UserDict): self.data.update(dict.data) elif isinstance(dict, type({})) or not hasattr(dict, 'items'): self.data.update(dict) else: for k, v in dict.items(): self[k] = v if len(kwargs): self.data.update(kwargs) def get(self, key, failobj=None): if not self.has_key(key): return failobj return self[key] def setdefault(self, key, failobj=None): if not self.has_key(key): self[key] = failobj return self[key] def pop(self, key, *args): return self.data.pop(key, *args) def popitem(self): return self.data.popitem() def __contains__(self, key): return key in self.data @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d class IterableUserDict(UserDict): def __iter__(self): return iter(self.data) class DictMixin: # Mixin defining all dictionary methods for classes that already have # a minimum dictionary interface including getitem, setitem, delitem, # and keys. Without knowledge of the subclass constructor, the mixin # does not define __init__() or copy(). In addition to the four base # methods, progressively more efficiency comes with defining # __contains__(), __iter__(), and iteritems(). # second level definitions support higher levels def __iter__(self): for k in self.keys(): yield k def has_key(self, key): try: value = self[key] except KeyError: return False return True def __contains__(self, key): return self.has_key(key) # third level takes advantage of second level definitions def iteritems(self): for k in self: yield (k, self[k]) def iterkeys(self): return self.__iter__() # fourth level uses definitions from lower levels def itervalues(self): for _, v in self.iteritems(): yield v def values(self): return [v for _, v in self.iteritems()] def items(self): return list(self.iteritems()) def clear(self): for key in self.keys(): del self[key] def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default def pop(self, key, *args): if len(args) > 1: raise TypeError, "pop expected at most 2 arguments, got "\ + repr(1 + len(args)) try: value = self[key] except KeyError: if args: return args[0] raise del self[key] return value def popitem(self): try: k, v = self.iteritems().next() except StopIteration: raise KeyError, 'container is empty' del self[k] return (k, v) def update(self, other=None, **kwargs): # Make progressively weaker assumptions about "other" if other is None: pass elif hasattr(other, 'iteritems'): # iteritems saves memory and lookups for k, v in other.iteritems(): self[k] = v elif hasattr(other, 'keys'): for k in other.keys(): self[k] = other[k] else: for k, v in other: self[k] = v if kwargs: self.update(kwargs) def get(self, key, default=None): try: return self[key] except KeyError: return default def __repr__(self): return repr(dict(self.iteritems())) def __cmp__(self, other): if other is None: return 1 if isinstance(other, DictMixin): other = dict(other.iteritems()) return cmp(dict(self.iteritems()), other) def __len__(self): return len(self.keys())
bsd-3-clause
[ 624, 33, 1655, 503, 6656, 4890, 922, 13, 4037, 4975, 6818, 2600, 2251, 1041, 199, 199, 533, 32241, 26, 272, 347, 636, 826, 721, 277, 12, 1211, 29, 403, 12, 1011, 958, 304, 267, 291, 14, 576, 275, 1052, 267, 340, 1211, 365, 440, 488, 26, 288, 291, 14, 873, 8, 807, 9, 267, 340, 822, 8, 958, 304, 288, 291, 14, 873, 8, 958, 9, 272, 347, 636, 2722, 721, 277, 304, 372, 4700, 8, 277, 14, 576, 9, 272, 347, 636, 5730, 721, 277, 12, 1211, 304, 267, 340, 1228, 8, 807, 12, 32241, 304, 288, 372, 10467, 8, 277, 14, 576, 12, 1211, 14, 576, 9, 267, 587, 26, 288, 372, 10467, 8, 277, 14, 576, 12, 1211, 9, 272, 347, 636, 552, 721, 277, 304, 372, 822, 8, 277, 14, 576, 9, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 576, 26, 288, 372, 291, 14, 576, 59, 498, 61, 267, 340, 2688, 8, 277, 855, 533, 3108, 4396, 4752, 363, 2349, 288, 372, 291, 855, 533, 4914, 4752, 721, 277, 12, 790, 9, 267, 746, 4067, 8, 498, 9, 272, 347, 636, 8617, 721, 277, 12, 790, 12, 1242, 304, 291, 14, 576, 59, 498, 61, 275, 1242, 272, 347, 636, 13228, 721, 277, 12, 790, 304, 2150, 291, 14, 576, 59, 498, 61, 272, 347, 5436, 8, 277, 304, 291, 14, 576, 14, 3584, 342, 272, 347, 1331, 8, 277, 304, 267, 340, 291, 855, 533, 363, 365, 32241, 26, 288, 372, 32241, 8, 277, 14, 576, 14, 1574, 1012, 267, 492, 1331, 267, 666, 275, 291, 14, 576, 267, 862, 26, 288, 291, 14, 576, 275, 1052, 288, 286, 275, 1331, 14, 1574, 8, 277, 9, 267, 3753, 26, 288, 291, 14, 576, 275, 666, 267, 286, 14, 873, 8, 277, 9, 267, 372, 286, 272, 347, 2883, 8, 277, 304, 372, 291, 14, 576, 14, 1612, 342, 272, 347, 2974, 8, 277, 304, 372, 291, 14, 576, 14, 1744, 342, 272, 347, 10849, 8, 277, 304, 372, 291, 14, 576, 14, 4611, 342, 272, 347, 25706, 8, 277, 304, 372, 291, 14, 576, 14, 16007, 342, 272, 347, 24451, 8, 277, 304, 372, 291, 14, 576, 14, 13012, 342, 272, 347, 1338, 8, 277, 304, 372, 291, 14, 576, 14, 1459, 342, 272, 347, 965, 63, 498, 8, 277, 12, 790, 304, 372, 291, 14, 576, 14, 1989, 63, 498, 8, 498, 9, 272, 347, 1678, 8, 277, 12, 1211, 29, 403, 12, 1011, 958, 304, 267, 340, 1211, 365, 488, 26, 288, 986, 267, 916, 1228, 8, 807, 12, 32241, 304, 288, 291, 14, 576, 14, 873, 8, 807, 14, 576, 9, 267, 916, 1228, 8, 807, 12, 730, 24692, 430, 503, 440, 2688, 8, 807, 12, 283, 1744, 735, 288, 291, 14, 576, 14, 873, 8, 807, 9, 267, 587, 26, 288, 367, 1022, 12, 373, 315, 1211, 14, 1744, 837, 355, 291, 59, 75, 61, 275, 373, 267, 340, 822, 8, 958, 304, 288, 291, 14, 576, 14, 873, 8, 958, 9, 272, 347, 664, 8, 277, 12, 790, 12, 1433, 11737, 468, 29, 403, 304, 267, 340, 440, 291, 14, 1989, 63, 498, 8, 498, 304, 288, 372, 1433, 11737, 468, 267, 372, 291, 59, 498, 61, 272, 347, 29408, 8, 277, 12, 790, 12, 1433, 11737, 468, 29, 403, 304, 267, 340, 440, 291, 14, 1989, 63, 498, 8, 498, 304, 288, 291, 59, 498, 61, 275, 1433, 11737, 468, 267, 372, 291, 59, 498, 61, 272, 347, 4560, 8, 277, 12, 790, 12, 627, 589, 304, 267, 372, 291, 14, 576, 14, 1935, 8, 498, 12, 627, 589, 9, 272, 347, 4560, 1053, 8, 277, 304, 267, 372, 291, 14, 576, 14, 24882, 342, 272, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 790, 315, 291, 14, 576, 272, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 6076, 12, 574, 29, 403, 304, 267, 366, 275, 843, 342, 267, 367, 790, 315, 6076, 26, 288, 366, 59, 498, 61, 275, 574, 267, 372, 366, 199, 199, 533, 19937, 30088, 8, 30088, 304, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 576, 9, 199, 199, 533, 7448, 4256, 26, 272, 327, 28438, 12669, 1006, 2600, 3102, 367, 3992, 626, 2575, 1172, 272, 327, 282, 7481, 2600, 3217, 5893, 2312, 4484, 12, 542, 4484, 12, 9122, 563, 12, 272, 327, 436, 2883, 14, 23952, 29105, 402, 314, 5516, 3787, 12, 314, 20048, 272, 327, 1630, 440, 5627, 636, 826, 4533, 503, 1331, 1252, 221, 1010, 10234, 370, 314, 11648, 1300, 272, 327, 3102, 12, 557, 7266, 9840, 1655, 25978, 12477, 543, 12669, 272, 327, 636, 6134, 29709, 636, 1661, 29709, 436, 10849, 1252, 339, 327, 3499, 2166, 10269, 2291, 10948, 11106, 272, 347, 636, 1661, 721, 277, 304, 267, 367, 1022, 315, 291, 14, 1612, 837, 288, 1995, 1022, 272, 347, 965, 63, 498, 8, 277, 12, 790, 304, 267, 862, 26, 288, 574, 275, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 756, 267, 372, 715, 272, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 291, 14, 1989, 63, 498, 8, 498, 9, 339, 327, 10919, 2166, 6181, 30268, 402, 3499, 2166, 10269, 272, 347, 10849, 8, 277, 304, 267, 367, 1022, 315, 291, 26, 288, 1995, 334, 75, 12, 291, 59, 75, 566, 272, 347, 25706, 8, 277, 304, 267, 372, 291, 855, 1661, 4533, 339, 327, 11648, 273, 2166, 4440, 10269, 687, 5117, 11106, 272, 347, 24451, 8, 277, 304, 267, 367, 5501, 373, 315, 291, 14, 4611, 837, 288, 1995, 373, 272, 347, 1338, 8, 277, 304, 267, 372, 359, 86, 367, 5501, 373, 315, 291, 14, 4611, 5106, 272, 347, 2974, 8, 277, 304, 267, 372, 769, 8, 277, 14, 4611, 1012, 272, 347, 5436, 8, 277, 304, 267, 367, 790, 315, 291, 14, 1612, 837, 288, 2150, 291, 59, 498, 61, 272, 347, 29408, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 862, 26, 288, 372, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 291, 59, 498, 61, 275, 849, 267, 372, 849, 272 ]
[ 33, 1655, 503, 6656, 4890, 922, 13, 4037, 4975, 6818, 2600, 2251, 1041, 199, 199, 533, 32241, 26, 272, 347, 636, 826, 721, 277, 12, 1211, 29, 403, 12, 1011, 958, 304, 267, 291, 14, 576, 275, 1052, 267, 340, 1211, 365, 440, 488, 26, 288, 291, 14, 873, 8, 807, 9, 267, 340, 822, 8, 958, 304, 288, 291, 14, 873, 8, 958, 9, 272, 347, 636, 2722, 721, 277, 304, 372, 4700, 8, 277, 14, 576, 9, 272, 347, 636, 5730, 721, 277, 12, 1211, 304, 267, 340, 1228, 8, 807, 12, 32241, 304, 288, 372, 10467, 8, 277, 14, 576, 12, 1211, 14, 576, 9, 267, 587, 26, 288, 372, 10467, 8, 277, 14, 576, 12, 1211, 9, 272, 347, 636, 552, 721, 277, 304, 372, 822, 8, 277, 14, 576, 9, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 576, 26, 288, 372, 291, 14, 576, 59, 498, 61, 267, 340, 2688, 8, 277, 855, 533, 3108, 4396, 4752, 363, 2349, 288, 372, 291, 855, 533, 4914, 4752, 721, 277, 12, 790, 9, 267, 746, 4067, 8, 498, 9, 272, 347, 636, 8617, 721, 277, 12, 790, 12, 1242, 304, 291, 14, 576, 59, 498, 61, 275, 1242, 272, 347, 636, 13228, 721, 277, 12, 790, 304, 2150, 291, 14, 576, 59, 498, 61, 272, 347, 5436, 8, 277, 304, 291, 14, 576, 14, 3584, 342, 272, 347, 1331, 8, 277, 304, 267, 340, 291, 855, 533, 363, 365, 32241, 26, 288, 372, 32241, 8, 277, 14, 576, 14, 1574, 1012, 267, 492, 1331, 267, 666, 275, 291, 14, 576, 267, 862, 26, 288, 291, 14, 576, 275, 1052, 288, 286, 275, 1331, 14, 1574, 8, 277, 9, 267, 3753, 26, 288, 291, 14, 576, 275, 666, 267, 286, 14, 873, 8, 277, 9, 267, 372, 286, 272, 347, 2883, 8, 277, 304, 372, 291, 14, 576, 14, 1612, 342, 272, 347, 2974, 8, 277, 304, 372, 291, 14, 576, 14, 1744, 342, 272, 347, 10849, 8, 277, 304, 372, 291, 14, 576, 14, 4611, 342, 272, 347, 25706, 8, 277, 304, 372, 291, 14, 576, 14, 16007, 342, 272, 347, 24451, 8, 277, 304, 372, 291, 14, 576, 14, 13012, 342, 272, 347, 1338, 8, 277, 304, 372, 291, 14, 576, 14, 1459, 342, 272, 347, 965, 63, 498, 8, 277, 12, 790, 304, 372, 291, 14, 576, 14, 1989, 63, 498, 8, 498, 9, 272, 347, 1678, 8, 277, 12, 1211, 29, 403, 12, 1011, 958, 304, 267, 340, 1211, 365, 488, 26, 288, 986, 267, 916, 1228, 8, 807, 12, 32241, 304, 288, 291, 14, 576, 14, 873, 8, 807, 14, 576, 9, 267, 916, 1228, 8, 807, 12, 730, 24692, 430, 503, 440, 2688, 8, 807, 12, 283, 1744, 735, 288, 291, 14, 576, 14, 873, 8, 807, 9, 267, 587, 26, 288, 367, 1022, 12, 373, 315, 1211, 14, 1744, 837, 355, 291, 59, 75, 61, 275, 373, 267, 340, 822, 8, 958, 304, 288, 291, 14, 576, 14, 873, 8, 958, 9, 272, 347, 664, 8, 277, 12, 790, 12, 1433, 11737, 468, 29, 403, 304, 267, 340, 440, 291, 14, 1989, 63, 498, 8, 498, 304, 288, 372, 1433, 11737, 468, 267, 372, 291, 59, 498, 61, 272, 347, 29408, 8, 277, 12, 790, 12, 1433, 11737, 468, 29, 403, 304, 267, 340, 440, 291, 14, 1989, 63, 498, 8, 498, 304, 288, 291, 59, 498, 61, 275, 1433, 11737, 468, 267, 372, 291, 59, 498, 61, 272, 347, 4560, 8, 277, 12, 790, 12, 627, 589, 304, 267, 372, 291, 14, 576, 14, 1935, 8, 498, 12, 627, 589, 9, 272, 347, 4560, 1053, 8, 277, 304, 267, 372, 291, 14, 576, 14, 24882, 342, 272, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 790, 315, 291, 14, 576, 272, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 6076, 12, 574, 29, 403, 304, 267, 366, 275, 843, 342, 267, 367, 790, 315, 6076, 26, 288, 366, 59, 498, 61, 275, 574, 267, 372, 366, 199, 199, 533, 19937, 30088, 8, 30088, 304, 272, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 576, 9, 199, 199, 533, 7448, 4256, 26, 272, 327, 28438, 12669, 1006, 2600, 3102, 367, 3992, 626, 2575, 1172, 272, 327, 282, 7481, 2600, 3217, 5893, 2312, 4484, 12, 542, 4484, 12, 9122, 563, 12, 272, 327, 436, 2883, 14, 23952, 29105, 402, 314, 5516, 3787, 12, 314, 20048, 272, 327, 1630, 440, 5627, 636, 826, 4533, 503, 1331, 1252, 221, 1010, 10234, 370, 314, 11648, 1300, 272, 327, 3102, 12, 557, 7266, 9840, 1655, 25978, 12477, 543, 12669, 272, 327, 636, 6134, 29709, 636, 1661, 29709, 436, 10849, 1252, 339, 327, 3499, 2166, 10269, 2291, 10948, 11106, 272, 347, 636, 1661, 721, 277, 304, 267, 367, 1022, 315, 291, 14, 1612, 837, 288, 1995, 1022, 272, 347, 965, 63, 498, 8, 277, 12, 790, 304, 267, 862, 26, 288, 574, 275, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 756, 267, 372, 715, 272, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 372, 291, 14, 1989, 63, 498, 8, 498, 9, 339, 327, 10919, 2166, 6181, 30268, 402, 3499, 2166, 10269, 272, 347, 10849, 8, 277, 304, 267, 367, 1022, 315, 291, 26, 288, 1995, 334, 75, 12, 291, 59, 75, 566, 272, 347, 25706, 8, 277, 304, 267, 372, 291, 855, 1661, 4533, 339, 327, 11648, 273, 2166, 4440, 10269, 687, 5117, 11106, 272, 347, 24451, 8, 277, 304, 267, 367, 5501, 373, 315, 291, 14, 4611, 837, 288, 1995, 373, 272, 347, 1338, 8, 277, 304, 267, 372, 359, 86, 367, 5501, 373, 315, 291, 14, 4611, 5106, 272, 347, 2974, 8, 277, 304, 267, 372, 769, 8, 277, 14, 4611, 1012, 272, 347, 5436, 8, 277, 304, 267, 367, 790, 315, 291, 14, 1612, 837, 288, 2150, 291, 59, 498, 61, 272, 347, 29408, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 862, 26, 288, 372, 291, 59, 498, 61, 267, 871, 4067, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
elbeardmorez/quodlibet
osx_bundle/misc/list_content.py
6
2493
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2015 Christoph Reiter # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. import os import sys from collections import namedtuple from xml.dom import minidom # .py <jhbuild_prefix> <bundle.app> # takes a jhbuild prefix and an app bundle and lists all the # files and from which jhbuild package they come from def main(argv): assert sys.version_info[0] == 3 assert len(argv) == 3 jhbuild = os.path.join(argv[1], "_jhbuild") bundle_base = os.path.join(argv[2], "Contents", "Resources") info = os.path.join(jhbuild, "info") Entry = namedtuple("Entry", ["package", "version", "files"]) entries = {} for key in os.listdir(info): path = os.path.join(info, key) xmldoc = minidom.parse(path) item = xmldoc.getElementsByTagName('entry')[0] package = item.attributes['package'].value version = item.attributes['version'].value entry = Entry(package, version, set()) entries[key] = entry def norm_py(path): # reduce all paths to their source variant so we can connect # different variants between the installed state and the # final one in the bundle (since we compile and delete # the sources..) if path.endswith((".pyc", ".pyo")): return path[:-1] return path manifests = os.path.join(jhbuild, "manifests") for key in os.listdir(manifests): path = os.path.join(manifests, key) with open(path, "r", encoding="utf-8") as h: for file_ in h.read().splitlines(): entries[key].files.add(norm_py(file_)) found = set() for root, dirs, files in os.walk(bundle_base): for f in files: path = os.path.relpath(os.path.join(root, f), bundle_base) found.add(norm_py(path)) for entry in sorted(entries.values(), key=lambda e: e.package): here = set([p for p in entry.files if p in found]) if here: print(entry.package, entry.version) found -= here for p in sorted(here): print(" ", p) if found: print("__UNKNOWN_SOURCE__") for p in sorted(found): print(" ", p) if __name__ == '__main__': main(sys.argv)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6900, 2799, 322, 2379, 72, 799, 1661, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 646, 747, 199, 646, 984, 199, 504, 5055, 492, 12863, 199, 504, 2748, 14, 4556, 492, 19165, 199, 199, 3, 1275, 647, 665, 31623, 1506, 63, 1861, 30, 665, 6469, 14, 571, 30, 199, 3, 6181, 282, 1335, 72, 1506, 2403, 436, 376, 1145, 8844, 436, 5548, 1006, 314, 199, 3, 1584, 436, 687, 1314, 1335, 72, 1506, 2559, 2985, 11492, 687, 421, 199, 318, 2446, 8, 3020, 304, 272, 702, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 272, 702, 822, 8, 3020, 9, 508, 650, 339, 1335, 72, 1506, 275, 747, 14, 515, 14, 904, 8, 3020, 59, 17, 467, 2668, 31623, 1506, 531, 272, 8844, 63, 1095, 275, 747, 14, 515, 14, 904, 8, 3020, 59, 18, 467, 298, 11383, 401, 298, 13745, 531, 272, 2256, 275, 747, 14, 515, 14, 904, 8, 31623, 1506, 12, 298, 815, 531, 339, 11855, 275, 12863, 480, 3900, 401, 2097, 2491, 401, 298, 1023, 401, 298, 1725, 3135, 272, 4811, 275, 1052, 339, 367, 790, 315, 747, 14, 7374, 8, 815, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 815, 12, 790, 9, 267, 2748, 1301, 275, 19165, 14, 1122, 8, 515, 9, 267, 1242, 275, 2748, 1301, 14, 15045, 360, 2373, 5832, 16, 61, 267, 2559, 275, 1242, 14, 2987, 459, 2491, 2278, 585, 267, 1015, 275, 1242, 14, 2987, 459, 1023, 2278, 585, 398, 2397, 275, 11855, 8, 2491, 12, 1015, 12, 663, 1012, 267, 4811, 59, 498, 61, 275, 2397, 339, 347, 6316, 63, 647, 8, 515, 304, 267, 327, 7114, 1006, 3792, 370, 3932, 1350, 9854, 880, 781, 883, 4907, 267, 327, 3365, 21169, 3382, 314, 4903, 1174, 436, 314, 267, 327, 4242, 1373, 315, 314, 8844, 334, 8585, 781, 6555, 436, 3145, 267, 327, 314, 5274, 703, 9, 267, 340, 931, 14, 4130, 9313, 14, 11357, 401, 3680, 22345, 14150, 288, 372, 931, 4439, 17, 61, 267, 372, 931, 339, 7712, 83, 275, 747, 14, 515, 14, 904, 8, 31623, 1506, 12, 298, 6418, 83, 531, 272, 367, 790, 315, 747, 14, 7374, 8, 6418, 83, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 6418, 83, 12, 790, 9, 398, 543, 1551, 8, 515, 12, 298, 82, 401, 2644, 628, 1624, 13, 24, 531, 465, 394, 26, 288, 367, 570, 63, 315, 394, 14, 739, 1252, 7644, 837, 355, 4811, 59, 498, 1055, 1725, 14, 525, 8, 4791, 63, 647, 8, 493, 13309, 339, 1911, 275, 663, 342, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 6469, 63, 1095, 304, 267, 367, 289, 315, 1584, 26, 288, 931, 275, 747, 14, 515, 14, 12405, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 395, 8844, 63, 1095, 9, 288, 1911, 14, 525, 8, 4791, 63, 647, 8, 515, 430, 339, 367, 2397, 315, 3355, 8, 3189, 14, 1459, 1062, 790, 29, 2734, 325, 26, 325, 14, 2491, 304, 267, 2348, 275, 663, 779, 80, 367, 299, 315, 2397, 14, 1725, 340, 299, 315, 1911, 566, 267, 340, 2348, 26, 288, 870, 8, 2373, 14, 2491, 12, 2397, 14, 1023, 9, 267, 1911, 4862, 2348, 267, 367, 299, 315, 3355, 8, 1681, 304, 288, 870, 480, 221, 3872, 299, 9, 339, 340, 1911, 26, 267, 870, 16232, 11588, 63, 10187, 18617, 267, 367, 299, 315, 3355, 8, 4214, 304, 288, 870, 480, 221, 3872, 299, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 8, 1274, 14, 3020, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6900, 2799, 322, 2379, 72, 799, 1661, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 646, 747, 199, 646, 984, 199, 504, 5055, 492, 12863, 199, 504, 2748, 14, 4556, 492, 19165, 199, 199, 3, 1275, 647, 665, 31623, 1506, 63, 1861, 30, 665, 6469, 14, 571, 30, 199, 3, 6181, 282, 1335, 72, 1506, 2403, 436, 376, 1145, 8844, 436, 5548, 1006, 314, 199, 3, 1584, 436, 687, 1314, 1335, 72, 1506, 2559, 2985, 11492, 687, 421, 199, 318, 2446, 8, 3020, 304, 272, 702, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 272, 702, 822, 8, 3020, 9, 508, 650, 339, 1335, 72, 1506, 275, 747, 14, 515, 14, 904, 8, 3020, 59, 17, 467, 2668, 31623, 1506, 531, 272, 8844, 63, 1095, 275, 747, 14, 515, 14, 904, 8, 3020, 59, 18, 467, 298, 11383, 401, 298, 13745, 531, 272, 2256, 275, 747, 14, 515, 14, 904, 8, 31623, 1506, 12, 298, 815, 531, 339, 11855, 275, 12863, 480, 3900, 401, 2097, 2491, 401, 298, 1023, 401, 298, 1725, 3135, 272, 4811, 275, 1052, 339, 367, 790, 315, 747, 14, 7374, 8, 815, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 815, 12, 790, 9, 267, 2748, 1301, 275, 19165, 14, 1122, 8, 515, 9, 267, 1242, 275, 2748, 1301, 14, 15045, 360, 2373, 5832, 16, 61, 267, 2559, 275, 1242, 14, 2987, 459, 2491, 2278, 585, 267, 1015, 275, 1242, 14, 2987, 459, 1023, 2278, 585, 398, 2397, 275, 11855, 8, 2491, 12, 1015, 12, 663, 1012, 267, 4811, 59, 498, 61, 275, 2397, 339, 347, 6316, 63, 647, 8, 515, 304, 267, 327, 7114, 1006, 3792, 370, 3932, 1350, 9854, 880, 781, 883, 4907, 267, 327, 3365, 21169, 3382, 314, 4903, 1174, 436, 314, 267, 327, 4242, 1373, 315, 314, 8844, 334, 8585, 781, 6555, 436, 3145, 267, 327, 314, 5274, 703, 9, 267, 340, 931, 14, 4130, 9313, 14, 11357, 401, 3680, 22345, 14150, 288, 372, 931, 4439, 17, 61, 267, 372, 931, 339, 7712, 83, 275, 747, 14, 515, 14, 904, 8, 31623, 1506, 12, 298, 6418, 83, 531, 272, 367, 790, 315, 747, 14, 7374, 8, 6418, 83, 304, 267, 931, 275, 747, 14, 515, 14, 904, 8, 6418, 83, 12, 790, 9, 398, 543, 1551, 8, 515, 12, 298, 82, 401, 2644, 628, 1624, 13, 24, 531, 465, 394, 26, 288, 367, 570, 63, 315, 394, 14, 739, 1252, 7644, 837, 355, 4811, 59, 498, 1055, 1725, 14, 525, 8, 4791, 63, 647, 8, 493, 13309, 339, 1911, 275, 663, 342, 272, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 6469, 63, 1095, 304, 267, 367, 289, 315, 1584, 26, 288, 931, 275, 747, 14, 515, 14, 12405, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 289, 395, 8844, 63, 1095, 9, 288, 1911, 14, 525, 8, 4791, 63, 647, 8, 515, 430, 339, 367, 2397, 315, 3355, 8, 3189, 14, 1459, 1062, 790, 29, 2734, 325, 26, 325, 14, 2491, 304, 267, 2348, 275, 663, 779, 80, 367, 299, 315, 2397, 14, 1725, 340, 299, 315, 1911, 566, 267, 340, 2348, 26, 288, 870, 8, 2373, 14, 2491, 12, 2397, 14, 1023, 9, 267, 1911, 4862, 2348, 267, 367, 299, 315, 3355, 8, 1681, 304, 288, 870, 480, 221, 3872, 299, 9, 339, 340, 1911, 26, 267, 870, 16232, 11588, 63, 10187, 18617, 267, 367, 299, 315, 3355, 8, 4214, 304, 288, 870, 480, 221, 3872, 299, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 8, 1274, 14, 3020, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
forman/dectree
dectree/codegen.py
1
21170
import ast from collections import OrderedDict from io import StringIO from typing import List, Dict, Any, Tuple, Optional import dectree.propfuncs as propfuncs from dectree.config import CONFIG_NAME_INPUTS_NAME, CONFIG_NAME_OUTPUTS_NAME, CONFIG_NAME_PARAMS_NAME from .config import get_config_value, \ CONFIG_NAME_VECTORIZE, CONFIG_NAME_PARAMETERIZE, CONFIG_NAME_FUNCTION_NAME, CONFIG_NAME_TYPES, VECTORIZE_FUNC, \ VECTORIZE_PROP, CONFIG_NAME_OR_PATTERN, CONFIG_NAME_NOT_PATTERN, \ CONFIG_NAME_NO_JIT, VECTORIZE_NONE, CONFIG_NAME_AND_PATTERN from .types import VarName, PropName, TypeName, PropDef, TypeDefs, VarDefs, PropFuncParamName def gen_code(type_defs, input_defs, output_defs, rules, **options): text_io = StringIO() code_gen = CodeGen(type_defs, input_defs, output_defs, rules, text_io, options) code_gen.gen_code() return text_io.getvalue() class CodeGen: def __init__(self, type_defs, input_defs, output_defs, rules, out_file, options): assert type_defs assert input_defs assert output_defs assert rules assert out_file self.type_defs = type_defs self.input_defs = input_defs self.output_defs = output_defs self.rules = rules self.out_file = out_file self.output_assignments = None options = dict(options or {}) self.no_jit = get_config_value(options, CONFIG_NAME_NO_JIT) self.vectorize = get_config_value(options, CONFIG_NAME_VECTORIZE) self.parameterize = get_config_value(options, CONFIG_NAME_PARAMETERIZE) self.function_name = get_config_value(options, CONFIG_NAME_FUNCTION_NAME) self.inputs_name = get_config_value(options, CONFIG_NAME_INPUTS_NAME) self.outputs_name = get_config_value(options, CONFIG_NAME_OUTPUTS_NAME) self.params_name = get_config_value(options, CONFIG_NAME_PARAMS_NAME) self.use_py_types = get_config_value(options, CONFIG_NAME_TYPES) self.and_pattern = _get_config_op_pattern(options, CONFIG_NAME_AND_PATTERN) self.or_pattern = _get_config_op_pattern(options, CONFIG_NAME_OR_PATTERN) self.not_pattern = _get_config_op_pattern(options, CONFIG_NAME_NOT_PATTERN) self.expr_gen = ExprGen(type_defs, input_defs, parameterize=self.parameterize, vectorize=self.vectorize, no_jit=self.no_jit, not_pattern=self.not_pattern, and_pattern=self.and_pattern, or_pattern=self.or_pattern) def gen_code(self): self.output_assignments = {} self._write_imports() self._write_type_prop_functions() self._write_inputs_class() self._write_outputs_class() self._write_params() self._write_apply_rules_function() def _write_imports(self): numba_import = 'from numba import jit, jitclass, float64' numpy_import = 'import numpy as np' if self.no_jit: if self.vectorize == VECTORIZE_FUNC: self._write_lines('', numpy_import) else: if self.vectorize == VECTORIZE_PROP: self._write_lines('', numba_import + ', vectorize', numpy_import) elif self.vectorize == VECTORIZE_FUNC: self._write_lines('', numba_import, numpy_import) else: self._write_lines('', numba_import) def _write_type_prop_functions(self): numba_decorator = self._get_numba_decorator(prop_func=True) for type_name, type_def in self.type_defs.items(): for prop_name, prop_def in type_def.items(): prop_value, func_params, func_body_pattern = prop_def if self.parameterize and func_params: func_header = 'def _{}_{}(x{}):'.format(type_name, prop_name, ', ' + ', '.join(func_params.keys())) func_body = func_body_pattern.format(**{key: key for key in func_params.keys()}) else: func_header = 'def _{}_{}(x):'.format(type_name, prop_name) func_body = func_body_pattern.format(**func_params) func_body_lines = map(lambda line: ' ' + str(line), func_body.split('\n')) self._write_lines('', '', numba_decorator, func_header, ' # {}.{}: {}'.format(type_name, prop_name, prop_value), *func_body_lines) def _write_apply_rules_function(self): if self.parameterize: function_params = [('inputs', self.inputs_name), ('outputs', self.outputs_name), ('params', self.params_name)] else: function_params = [('inputs', self.inputs_name), ('outputs', self.outputs_name)] if self.use_py_types: function_args = ', '.join(['{}: {}'.format(param_name, param_type) for param_name, param_type in function_params]) else: function_args = ', '.join(['{}'.format(param_name) for param_name, _ in function_params]) numba_decorator = self._get_numba_decorator() self._write_lines('', '', numba_decorator, 'def {}({}):'.format(self.function_name, function_args)) if self.vectorize == VECTORIZE_FUNC: output_var = list(self.output_defs.keys())[0] self._write_lines(' for i in range(len(outputs.{output_var})):'.format(output_var=output_var)) self._write_lines(' t0 = 1.0') else: self._write_lines(' t0 = 1.0') for rule in self.rules: self._write_rule(rule, 1, 1) def _get_numba_decorator(self, prop_func=False): if self.vectorize == VECTORIZE_PROP and prop_func: numba_decorator = '@vectorize([float64(float64)])' else: numba_decorator = '@jit(nopython=True)' if self.no_jit: numba_decorator = '# ' + numba_decorator return numba_decorator def _write_inputs_class(self): self._write_io_class(self.inputs_name, self.input_defs) def _write_outputs_class(self): self._write_io_class(self.outputs_name, self.output_defs) def _write_io_class(self, class_name, var_defs): self._write_class(class_name, var_defs.keys()) def _write_params(self): if not self.parameterize: return param_names = [] param_values = {} for type_name, type_def in self.type_defs.items(): for prop_name, prop_def in type_def.items(): prop_value, func_params, func_body = prop_def for param_name, param_value in func_params.items(): qualified_param_name = _get_qualified_param_name(type_name, prop_name, param_name) param_names.append(qualified_param_name) param_values[qualified_param_name] = param_value self._write_class(self.params_name, param_names, param_values) # See http://numba.pydata.org/numba-doc/dev/user/jitclass.html def _write_class(self, class_name, var_names, param_values: Optional[Dict[str, Any]] = None): is_io = param_values is None spec_name = '_{}Spec'.format(class_name) spec_lines = ['{} = ['.format(spec_name)] for var_name in var_names: if param_values: spec_lines.append(' ("{}", float64),'.format(var_name)) elif not self.no_jit and self.vectorize != VECTORIZE_NONE: spec_lines.append(' ("{}", float64[:]),'.format(var_name)) else: spec_lines.append(' ("{}", float64),'.format(var_name)) spec_lines.append(']') if self.no_jit: spec_lines = map(lambda line: '# ' + line, spec_lines) self._write_lines('', '', *spec_lines) numba_line = '@jitclass({})'.format(spec_name) if self.no_jit: numba_line = '# ' + numba_line if is_io and self.vectorize == VECTORIZE_FUNC: if self.use_py_types: init_head = ' def __init__(self, size: int):' else: init_head = ' def __init__(self, size):' else: init_head = ' def __init__(self):' self._write_lines('', '', numba_line, 'class {}:'.format(class_name), init_head) for var_name in var_names: if param_values: self._write_lines(' self.{} = {}'.format(var_name, param_values[var_name])) elif is_io and self.vectorize == VECTORIZE_FUNC: self._write_lines(' self.{} = np.zeros(size, dtype=np.float64)'.format(var_name)) elif self.vectorize != VECTORIZE_NONE: self._write_lines(' self.{} = np.zeros(1, dtype=np.float64)'.format(var_name)) else: self._write_lines(' self.{} = 0.0'.format(var_name)) def _write_rule(self, rule: List, source_level: int, target_level: int): sub_target_level = target_level for stmt in rule: keyword = stmt[0] if keyword == 'if': sub_target_level = target_level self._write_stmt(keyword, stmt[1], stmt[2], source_level, sub_target_level) elif keyword == 'elif': sub_target_level += 1 self._write_stmt(keyword, stmt[1], stmt[2], source_level, sub_target_level) elif keyword == 'else': self._write_stmt(keyword, None, stmt[1], source_level, sub_target_level) elif keyword == '=': self._write_assignment(stmt[1], stmt[2], source_level, sub_target_level) else: raise NotImplemented def _write_stmt(self, keyword: str, condition_expr: Optional[str], body: List, source_level: int, target_level: int): not_pattern = '1.0 - {x}' # note, not using self.not_pattern here! source_indent = (4 * source_level) * ' ' if self.vectorize == VECTORIZE_FUNC: target_indent = 8 * ' ' else: target_indent = 4 * ' ' t0 = 't' + str(target_level - 1) t1 = 't' + str(target_level - 0) if keyword == 'if' or keyword == 'elif': condition = self.expr_gen.gen_expr(condition_expr) if keyword == 'if': self._write_lines('{tind}#{sind}{key} {expr}:'.format(tind=target_indent, sind=source_indent, key=keyword, expr=condition_expr)) target_value = self.and_pattern.format(x=t0, y=condition) else: tp = 't' + str(target_level - 2) self._write_lines('{tind}#{sind}{key} {expr}:'.format(tind=target_indent, sind=source_indent, key=keyword, expr=condition_expr)) target_value = self.and_pattern.format(x=tp, y=not_pattern.format(x=t0)) self._write_lines('{tind}{tvar} = {tval}'.format(tind=target_indent, tvar=t0, tval=target_value)) target_value = self.and_pattern.format(x=t0, y=condition) else: self._write_lines('{tind}#{sind}else:'.format(tind=target_indent, sind=source_indent)) target_value = self.and_pattern.format(x=t0, y=not_pattern.format(x=t1)) self._write_lines('{tind}{tvar} = {tval}'.format(tind=target_indent, tvar=t1, tval=target_value)) self._write_rule(body, source_level + 1, target_level + 1) def _write_assignment(self, var_name: str, var_value: str, source_level: int, target_level: int): source_indent = (source_level * 4) * ' ' if self.vectorize == VECTORIZE_FUNC: target_indent = 8 * ' ' else: target_indent = 4 * ' ' t0 = 't' + str(target_level - 1) _, prop_def = self._get_output_def(var_name, var_value) prop_value, _, _ = prop_def if prop_value == 'true()': assignment_value = t0 elif prop_value == 'false()': assignment_value = self.not_pattern.format(x=t0) else: raise ValueError('Currently you can only assign properties,' ' whose values are "true()" or "false()') output_assignments = self.output_assignments.get(var_name) if output_assignments is None: output_assignments = [assignment_value] self.output_assignments[var_name] = output_assignments else: output_assignments.append(assignment_value) out_pattern = '{tval}' if len(output_assignments) > 1: if self.vectorize == VECTORIZE_FUNC: out_pattern = self.or_pattern.format(x='outputs.{name}[i]', y=out_pattern) else: out_pattern = self.or_pattern.format(x='outputs.{name}', y=out_pattern) if self.vectorize == VECTORIZE_FUNC: line_pattern = '{tind}outputs.{name}[i] = ' + out_pattern else: line_pattern = '{tind}outputs.{name} = ' + out_pattern self._write_lines('{tind}#{sind}{name} = {sval}'.format(tind=target_indent, sind=source_indent, name=var_name, sval=var_value)) self._write_lines(line_pattern.format(tind=target_indent, name=var_name, tval=assignment_value)) def _get_output_def(self, var_name: VarName, prop_name: PropName) -> Tuple[TypeName, PropDef]: return _get_type_name_and_prop_def(var_name, prop_name, self.type_defs, self.output_defs) def _write_lines(self, *lines): for line in lines: self.out_file.write('%s\n' % line) class ExprGen: def __init__(self, type_defs: TypeDefs, var_defs: VarDefs, parameterize=False, vectorize=VECTORIZE_NONE, no_jit=False, not_pattern='1.0 - ({x})', and_pattern='min({x}, {y})', or_pattern='max({x}, {y})'): assert type_defs assert var_defs assert vectorize assert not_pattern assert and_pattern assert or_pattern self.type_defs = type_defs self.var_defs = var_defs self.parameterize = parameterize self.vectorize = vectorize self.no_jit = no_jit self.not_pattern = not_pattern self.and_pattern = and_pattern self.or_pattern = or_pattern def gen_expr(self, rule_condition: str) -> str: mod = ast.parse(rule_condition) body = mod.body if len(body) != 1 or not isinstance(body[0], ast.Expr): raise ValueError('Invalid condition expression: [{}]'.format(rule_condition)) expr = body[0].value return self._transpile_expression(expr) def _transpile_expression(self, expr) -> str: if isinstance(expr, ast.Compare): left = expr.left if not isinstance(left, ast.Name): raise ValueError('Left side of comparison must be the name of an input') var_name = expr.left.id prop_name = expr.comparators[0].id compare_op = expr.ops[0] if isinstance(compare_op, ast.Eq) or isinstance(compare_op, ast.Is): if self.vectorize == VECTORIZE_FUNC: op_pattern = '_{t}_{r}(inputs.{l}{p}[i])' else: op_pattern = '_{t}_{r}(inputs.{l}{p})' elif isinstance(compare_op, ast.NotEq) or isinstance(compare_op, ast.IsNot): if self.vectorize == VECTORIZE_FUNC: op_pattern = self.not_pattern.format(x='_{t}_{r}(inputs.{l}{p}[i])') else: op_pattern = self.not_pattern.format(x='_{t}_{r}(inputs.{l}{p})') else: raise ValueError('"==", "!=", "is", and "is not" are the only supported comparison operators') type_name, prop_def = _get_type_name_and_prop_def(var_name, prop_name, self.type_defs, self.var_defs) _, func_params, _ = prop_def if self.parameterize and func_params: params = ', ' + ', '.join(['{p}=params.{qp}'.format(p=param_name, qp=_get_qualified_param_name(type_name, prop_name, param_name)) for param_name in func_params.keys()]) else: params = '' return op_pattern.format(t=type_name, r=prop_name, l=var_name, p=params) if isinstance(expr, ast.UnaryOp): op = expr.op if isinstance(op, ast.Not): op_pattern = self.not_pattern else: raise ValueError('"not" is the only supported unary operator') v = expr.operand t = self._transpile_expression(v) return op_pattern.format(x=t) if isinstance(expr, ast.BoolOp): op = expr.op if isinstance(op, ast.And): op_pattern = self.and_pattern elif isinstance(op, ast.Or): op_pattern = self.or_pattern else: raise ValueError('"and" and "or" are the only supported binary operators') t1 = None for v in expr.values: if t1 is None: t1 = self._transpile_expression(v) else: t2 = self._transpile_expression(v) t1 = op_pattern.format(x=t1, y=t2) return t1 raise ValueError('Unsupported expression') def _types_to_type_defs(types: Dict[str, Dict[str, str]]) -> TypeDefs: type_defs = OrderedDict() for type_name, type_properties in types.items(): type_def = {} type_defs[type_name] = type_def for prop_name, prop_value in type_properties.items(): try: prop_result = eval(prop_value, vars(propfuncs), {}) except Exception: raise ValueError('Illegal value for property "{}" of type "{}": {}'.format(prop_name, type_name, prop_value)) func_params, func_body = prop_result type_def[prop_name] = prop_value, func_params, func_body return type_defs def _get_type_name_and_prop_def(var_name: VarName, prop_name: PropName, type_defs: TypeDefs, var_defs: VarDefs) -> Tuple[TypeName, PropDef]: type_name = var_defs.get(var_name) if type_name is None: raise ValueError('Variable "{}" is undefined'.format(var_name)) type_def = type_defs.get(type_name) if type_def is None: raise ValueError('Type "{}" of variable "{}" is undefined'.format(type_name, var_name)) if prop_name not in type_def: raise ValueError('"{}" is not a property of type "{}" of variable "{}"'.format(prop_name, type_name, var_name)) prop_def = type_def[prop_name] return type_name, prop_def def _get_qualified_param_name(type_name: TypeName, prop_name: PropName, param_name: PropFuncParamName) -> str: return '{t}_{p}_{k}'.format(t=type_name, p=prop_name, k=param_name) def _get_config_op_pattern(options, op_pattern_name): op_pattern = get_config_value(options, op_pattern_name) no_jit = get_config_value(options, CONFIG_NAME_NO_JIT) vectorize = get_config_value(options, CONFIG_NAME_VECTORIZE) return _get_effective_op_pattern(op_pattern, no_jit=no_jit, vectorize=vectorize) def _get_effective_op_pattern(op_pattern, no_jit=False, vectorize=VECTORIZE_NONE): if not no_jit and vectorize == VECTORIZE_PROP: # TODO: improve following naive replacements, e.g. use regex-based approach return op_pattern.replace('min(', 'np.minimum(').replace('max(', 'np.maximum(') else: return op_pattern
mit
[ 646, 6073, 199, 504, 5055, 492, 8773, 199, 504, 5890, 492, 5228, 199, 504, 14090, 492, 3820, 12, 7448, 12, 6184, 12, 11634, 12, 4879, 199, 199, 646, 477, 16970, 14, 4469, 9204, 465, 5931, 9204, 199, 504, 477, 16970, 14, 888, 492, 15869, 63, 2339, 63, 7321, 51, 63, 2339, 12, 15869, 63, 2339, 63, 8414, 51, 63, 2339, 12, 15869, 63, 2339, 63, 17978, 63, 2339, 199, 504, 1275, 888, 492, 664, 63, 888, 63, 585, 12, 971, 272, 15869, 63, 2339, 63, 2524, 1028, 726, 11025, 12, 15869, 63, 2339, 63, 14472, 11025, 12, 15869, 63, 2339, 63, 15476, 63, 2339, 12, 15869, 63, 2339, 63, 7893, 12, 812, 3582, 726, 11025, 63, 19587, 12, 971, 272, 812, 3582, 726, 11025, 63, 19926, 12, 15869, 63, 2339, 63, 726, 63, 10764, 12, 15869, 63, 2339, 63, 4609, 63, 10764, 12, 971, 272, 15869, 63, 2339, 63, 2826, 63, 42, 649, 12, 812, 3582, 726, 11025, 63, 9185, 12, 15869, 63, 2339, 63, 3649, 63, 10764, 199, 504, 1275, 1313, 492, 21084, 985, 12, 2165, 80, 985, 12, 2434, 985, 12, 2165, 80, 6172, 12, 2434, 872, 2319, 12, 21084, 872, 2319, 12, 2165, 80, 7465, 4098, 985, 421, 199, 318, 3805, 63, 600, 8, 466, 63, 8710, 12, 1467, 1324, 63, 8710, 12, 1467, 1072, 63, 8710, 12, 1467, 4713, 12, 1467, 1011, 1419, 304, 272, 1318, 63, 2308, 275, 5228, 342, 272, 1233, 63, 2268, 275, 5495, 8168, 8, 466, 63, 8710, 12, 1324, 63, 8710, 12, 1072, 63, 8710, 12, 4713, 12, 1318, 63, 2308, 12, 1511, 9, 272, 1233, 63, 2268, 14, 2268, 63, 600, 342, 272, 372, 1318, 63, 2308, 14, 7150, 342, 421, 199, 533, 5495, 8168, 26, 272, 347, 636, 826, 721, 277, 12, 326, 730, 63, 8710, 12, 326, 1324, 63, 8710, 12, 326, 1072, 63, 8710, 12, 326, 4713, 12, 326, 734, 63, 493, 12, 326, 1511, 304, 267, 702, 730, 63, 8710, 267, 702, 1324, 63, 8710, 267, 702, 1072, 63, 8710, 267, 702, 4713, 267, 702, 734, 63, 493, 398, 291, 14, 466, 63, 8710, 275, 730, 63, 8710, 267, 291, 14, 1210, 63, 8710, 275, 1324, 63, 8710, 267, 291, 14, 1199, 63, 8710, 275, 1072, 63, 8710, 267, 291, 14, 4423, 275, 4713, 267, 291, 14, 548, 63, 493, 275, 734, 63, 493, 267, 291, 14, 1199, 63, 18922, 275, 488, 398, 1511, 275, 1211, 8, 1419, 503, 5009, 267, 291, 14, 889, 63, 17676, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 2826, 63, 42, 649, 9, 267, 291, 14, 4106, 794, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 2524, 1028, 726, 11025, 9, 267, 291, 14, 8121, 6236, 806, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 14472, 11025, 9, 267, 291, 14, 1593, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 15476, 63, 2339, 9, 267, 291, 14, 3711, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 7321, 51, 63, 2339, 9, 267, 291, 14, 4467, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 8414, 51, 63, 2339, 9, 267, 291, 14, 1162, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 17978, 63, 2339, 9, 267, 291, 14, 1180, 63, 647, 63, 1313, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 7893, 9, 267, 291, 14, 460, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 3649, 63, 10764, 9, 267, 291, 14, 269, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 726, 63, 10764, 9, 267, 291, 14, 1397, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 4609, 63, 10764, 9, 398, 291, 14, 3684, 63, 2268, 275, 14754, 8168, 8, 466, 63, 8710, 12, 1324, 63, 8710, 12, 1816, 18117, 6236, 806, 29, 277, 14, 8121, 6236, 806, 12, 1816, 5477, 794, 29, 277, 14, 4106, 794, 12, 1816, 949, 63, 17676, 29, 277, 14, 889, 63, 17676, 12, 1816, 440, 63, 3401, 29, 277, 14, 1397, 63, 3401, 12, 1816, 436, 63, 3401, 29, 277, 14, 460, 63, 3401, 12, 1816, 503, 63, 3401, 29, 277, 14, 269, 63, 3401, 9, 339, 347, 3805, 63, 600, 8, 277, 304, 267, 291, 14, 1199, 63, 18922, 275, 1052, 267, 291, 423, 952, 63, 12775, 342, 267, 291, 423, 952, 63, 466, 63, 4469, 63, 5777, 342, 267, 291, 423, 952, 63, 3711, 63, 533, 342, 267, 291, 423, 952, 63, 4467, 63, 533, 342, 267, 291, 423, 952, 63, 1162, 342, 267, 291, 423, 952, 63, 4998, 63, 4423, 63, 1593, 342, 339, 347, 485, 952, 63, 12775, 8, 277, 304, 267, 1967, 2470, 63, 646, 275, 283, 504, 1967, 2470, 492, 31292, 12, 31292, 533, 12, 2069, 772, 7, 267, 2680, 63, 646, 275, 283, 646, 2680, 465, 980, 7, 398, 340, 291, 14, 889, 63, 17676, 26, 288, 340, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19587, 26, 355, 291, 423, 952, 63, 1278, 8594, 2680, 63, 646, 9, 267, 587, 26, 288, 340, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19926, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 435, 1656, 5477, 794, 297, 2680, 63, 646, 9, 288, 916, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19587, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 12, 2680, 63, 646, 9, 288, 587, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 9, 339, 347, 485, 952, 63, 466, 63, 4469, 63, 5777, 8, 277, 304, 267, 1967, 2470, 63, 11547, 275, 291, 423, 362, 63, 1507, 2470, 63, 11547, 8, 4469, 63, 1532, 29, 549, 9, 267, 367, 730, 63, 354, 12, 730, 63, 318, 315, 291, 14, 466, 63, 8710, 14 ]
[ 6073, 199, 504, 5055, 492, 8773, 199, 504, 5890, 492, 5228, 199, 504, 14090, 492, 3820, 12, 7448, 12, 6184, 12, 11634, 12, 4879, 199, 199, 646, 477, 16970, 14, 4469, 9204, 465, 5931, 9204, 199, 504, 477, 16970, 14, 888, 492, 15869, 63, 2339, 63, 7321, 51, 63, 2339, 12, 15869, 63, 2339, 63, 8414, 51, 63, 2339, 12, 15869, 63, 2339, 63, 17978, 63, 2339, 199, 504, 1275, 888, 492, 664, 63, 888, 63, 585, 12, 971, 272, 15869, 63, 2339, 63, 2524, 1028, 726, 11025, 12, 15869, 63, 2339, 63, 14472, 11025, 12, 15869, 63, 2339, 63, 15476, 63, 2339, 12, 15869, 63, 2339, 63, 7893, 12, 812, 3582, 726, 11025, 63, 19587, 12, 971, 272, 812, 3582, 726, 11025, 63, 19926, 12, 15869, 63, 2339, 63, 726, 63, 10764, 12, 15869, 63, 2339, 63, 4609, 63, 10764, 12, 971, 272, 15869, 63, 2339, 63, 2826, 63, 42, 649, 12, 812, 3582, 726, 11025, 63, 9185, 12, 15869, 63, 2339, 63, 3649, 63, 10764, 199, 504, 1275, 1313, 492, 21084, 985, 12, 2165, 80, 985, 12, 2434, 985, 12, 2165, 80, 6172, 12, 2434, 872, 2319, 12, 21084, 872, 2319, 12, 2165, 80, 7465, 4098, 985, 421, 199, 318, 3805, 63, 600, 8, 466, 63, 8710, 12, 1467, 1324, 63, 8710, 12, 1467, 1072, 63, 8710, 12, 1467, 4713, 12, 1467, 1011, 1419, 304, 272, 1318, 63, 2308, 275, 5228, 342, 272, 1233, 63, 2268, 275, 5495, 8168, 8, 466, 63, 8710, 12, 1324, 63, 8710, 12, 1072, 63, 8710, 12, 4713, 12, 1318, 63, 2308, 12, 1511, 9, 272, 1233, 63, 2268, 14, 2268, 63, 600, 342, 272, 372, 1318, 63, 2308, 14, 7150, 342, 421, 199, 533, 5495, 8168, 26, 272, 347, 636, 826, 721, 277, 12, 326, 730, 63, 8710, 12, 326, 1324, 63, 8710, 12, 326, 1072, 63, 8710, 12, 326, 4713, 12, 326, 734, 63, 493, 12, 326, 1511, 304, 267, 702, 730, 63, 8710, 267, 702, 1324, 63, 8710, 267, 702, 1072, 63, 8710, 267, 702, 4713, 267, 702, 734, 63, 493, 398, 291, 14, 466, 63, 8710, 275, 730, 63, 8710, 267, 291, 14, 1210, 63, 8710, 275, 1324, 63, 8710, 267, 291, 14, 1199, 63, 8710, 275, 1072, 63, 8710, 267, 291, 14, 4423, 275, 4713, 267, 291, 14, 548, 63, 493, 275, 734, 63, 493, 267, 291, 14, 1199, 63, 18922, 275, 488, 398, 1511, 275, 1211, 8, 1419, 503, 5009, 267, 291, 14, 889, 63, 17676, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 2826, 63, 42, 649, 9, 267, 291, 14, 4106, 794, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 2524, 1028, 726, 11025, 9, 267, 291, 14, 8121, 6236, 806, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 14472, 11025, 9, 267, 291, 14, 1593, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 15476, 63, 2339, 9, 267, 291, 14, 3711, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 7321, 51, 63, 2339, 9, 267, 291, 14, 4467, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 8414, 51, 63, 2339, 9, 267, 291, 14, 1162, 63, 354, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 17978, 63, 2339, 9, 267, 291, 14, 1180, 63, 647, 63, 1313, 275, 664, 63, 888, 63, 585, 8, 1419, 12, 15869, 63, 2339, 63, 7893, 9, 267, 291, 14, 460, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 3649, 63, 10764, 9, 267, 291, 14, 269, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 726, 63, 10764, 9, 267, 291, 14, 1397, 63, 3401, 275, 485, 362, 63, 888, 63, 411, 63, 3401, 8, 1419, 12, 15869, 63, 2339, 63, 4609, 63, 10764, 9, 398, 291, 14, 3684, 63, 2268, 275, 14754, 8168, 8, 466, 63, 8710, 12, 1324, 63, 8710, 12, 1816, 18117, 6236, 806, 29, 277, 14, 8121, 6236, 806, 12, 1816, 5477, 794, 29, 277, 14, 4106, 794, 12, 1816, 949, 63, 17676, 29, 277, 14, 889, 63, 17676, 12, 1816, 440, 63, 3401, 29, 277, 14, 1397, 63, 3401, 12, 1816, 436, 63, 3401, 29, 277, 14, 460, 63, 3401, 12, 1816, 503, 63, 3401, 29, 277, 14, 269, 63, 3401, 9, 339, 347, 3805, 63, 600, 8, 277, 304, 267, 291, 14, 1199, 63, 18922, 275, 1052, 267, 291, 423, 952, 63, 12775, 342, 267, 291, 423, 952, 63, 466, 63, 4469, 63, 5777, 342, 267, 291, 423, 952, 63, 3711, 63, 533, 342, 267, 291, 423, 952, 63, 4467, 63, 533, 342, 267, 291, 423, 952, 63, 1162, 342, 267, 291, 423, 952, 63, 4998, 63, 4423, 63, 1593, 342, 339, 347, 485, 952, 63, 12775, 8, 277, 304, 267, 1967, 2470, 63, 646, 275, 283, 504, 1967, 2470, 492, 31292, 12, 31292, 533, 12, 2069, 772, 7, 267, 2680, 63, 646, 275, 283, 646, 2680, 465, 980, 7, 398, 340, 291, 14, 889, 63, 17676, 26, 288, 340, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19587, 26, 355, 291, 423, 952, 63, 1278, 8594, 2680, 63, 646, 9, 267, 587, 26, 288, 340, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19926, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 435, 1656, 5477, 794, 297, 2680, 63, 646, 9, 288, 916, 291, 14, 4106, 794, 508, 812, 3582, 726, 11025, 63, 19587, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 12, 2680, 63, 646, 9, 288, 587, 26, 355, 291, 423, 952, 63, 1278, 8594, 1967, 2470, 63, 646, 9, 339, 347, 485, 952, 63, 466, 63, 4469, 63, 5777, 8, 277, 304, 267, 1967, 2470, 63, 11547, 275, 291, 423, 362, 63, 1507, 2470, 63, 11547, 8, 4469, 63, 1532, 29, 549, 9, 267, 367, 730, 63, 354, 12, 730, 63, 318, 315, 291, 14, 466, 63, 8710, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jounex/hue
desktop/core/ext-py/Paste-2.0.1/paste/fileapp.py
50
13698
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # (c) 2005 Ian Bicking, Clark C. Evans and contributors # This module is part of the Python Paste Project and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """ This module handles sending static content such as in-memory data or files. At this time it has cache helpers and understands the if-modified-since request header. """ import os, time, mimetypes, zipfile, tarfile from paste.httpexceptions import * from paste.httpheaders import * CACHE_SIZE = 4096 BLOCK_SIZE = 4096 * 16 __all__ = ['DataApp', 'FileApp', 'DirectoryApp', 'ArchiveStore'] class DataApp(object): """ Returns an application that will send content in a single chunk, this application has support for setting cache-control and for responding to conditional (or HEAD) requests. Constructor Arguments: ``content`` the content being sent to the client ``headers`` the headers to send /w the response The remaining ``kwargs`` correspond to headers, where the underscore is replaced with a dash. These values are only added to the headers if they are not already provided; thus, they can be used for default values. Examples include, but are not limited to: ``content_type`` ``content_encoding`` ``content_location`` ``cache_control()`` This method provides validated construction of the ``Cache-Control`` header as well as providing for automated filling out of the ``EXPIRES`` header for HTTP/1.0 clients. ``set_content()`` This method provides a mechanism to set the content after the application has been constructed. This method does things like changing ``Last-Modified`` and ``Content-Length`` headers. """ allowed_methods = ('GET', 'HEAD') def __init__(self, content, headers=None, allowed_methods=None, **kwargs): assert isinstance(headers, (type(None), list)) self.expires = None self.content = None self.content_length = None self.last_modified = 0 if allowed_methods is not None: self.allowed_methods = allowed_methods self.headers = headers or [] for (k, v) in kwargs.items(): header = get_header(k) header.update(self.headers, v) ACCEPT_RANGES.update(self.headers, bytes=True) if not CONTENT_TYPE(self.headers): CONTENT_TYPE.update(self.headers) if content is not None: self.set_content(content) def cache_control(self, **kwargs): self.expires = CACHE_CONTROL.apply(self.headers, **kwargs) or None return self def set_content(self, content, last_modified=None): assert content is not None if last_modified is None: self.last_modified = time.time() else: self.last_modified = last_modified self.content = content self.content_length = len(content) LAST_MODIFIED.update(self.headers, time=self.last_modified) return self def content_disposition(self, **kwargs): CONTENT_DISPOSITION.apply(self.headers, **kwargs) return self def __call__(self, environ, start_response): method = environ['REQUEST_METHOD'].upper() if method not in self.allowed_methods: exc = HTTPMethodNotAllowed( 'You cannot %s a file' % method, headers=[('Allow', ','.join(self.allowed_methods))]) return exc(environ, start_response) return self.get(environ, start_response) def calculate_etag(self): return '"%s-%s"' % (self.last_modified, self.content_length) def get(self, environ, start_response): headers = self.headers[:] current_etag = self.calculate_etag() ETAG.update(headers, current_etag) if self.expires is not None: EXPIRES.update(headers, delta=self.expires) try: client_etags = IF_NONE_MATCH.parse(environ) if client_etags: for etag in client_etags: if etag == current_etag or etag == '*': # horribly inefficient, n^2 performance, yuck! for head in list_headers(entity=True): head.delete(headers) start_response('304 Not Modified', headers) return [b''] except HTTPBadRequest as exce: return exce.wsgi_application(environ, start_response) # If we get If-None-Match and If-Modified-Since, and # If-None-Match doesn't match, then we should not try to # figure out If-Modified-Since (which has 1-second granularity # and just isn't as accurate) if not client_etags: try: client_clock = IF_MODIFIED_SINCE.parse(environ) if (client_clock is not None and client_clock >= int(self.last_modified)): # horribly inefficient, n^2 performance, yuck! for head in list_headers(entity=True): head.delete(headers) start_response('304 Not Modified', headers) return [b''] # empty body except HTTPBadRequest as exce: return exce.wsgi_application(environ, start_response) (lower, upper) = (0, self.content_length - 1) range = RANGE.parse(environ) if range and 'bytes' == range[0] and 1 == len(range[1]): (lower, upper) = range[1][0] upper = upper or (self.content_length - 1) if upper >= self.content_length or lower > upper: return HTTPRequestRangeNotSatisfiable(( "Range request was made beyond the end of the content,\r\n" "which is %s long.\r\n Range: %s\r\n") % ( self.content_length, RANGE(environ)) ).wsgi_application(environ, start_response) content_length = upper - lower + 1 CONTENT_RANGE.update(headers, first_byte=lower, last_byte=upper, total_length = self.content_length) CONTENT_LENGTH.update(headers, content_length) if range or content_length != self.content_length: start_response('206 Partial Content', headers) else: start_response('200 OK', headers) if self.content is not None: return [self.content[lower:upper+1]] return (lower, content_length) class FileApp(DataApp): """ Returns an application that will send the file at the given filename. Adds a mime type based on ``mimetypes.guess_type()``. See DataApp for the arguments beyond ``filename``. """ def __init__(self, filename, headers=None, **kwargs): self.filename = filename content_type, content_encoding = self.guess_type() if content_type and 'content_type' not in kwargs: kwargs['content_type'] = content_type if content_encoding and 'content_encoding' not in kwargs: kwargs['content_encoding'] = content_encoding DataApp.__init__(self, None, headers, **kwargs) def guess_type(self): return mimetypes.guess_type(self.filename) def update(self, force=False): stat = os.stat(self.filename) if not force and stat.st_mtime == self.last_modified: return self.last_modified = stat.st_mtime if stat.st_size < CACHE_SIZE: fh = open(self.filename,"rb") self.set_content(fh.read(), stat.st_mtime) fh.close() else: self.content = None self.content_length = stat.st_size # This is updated automatically if self.set_content() is # called LAST_MODIFIED.update(self.headers, time=self.last_modified) def get(self, environ, start_response): is_head = environ['REQUEST_METHOD'].upper() == 'HEAD' if 'max-age=0' in CACHE_CONTROL(environ).lower(): self.update(force=True) # RFC 2616 13.2.6 else: self.update() if not self.content: if not os.path.exists(self.filename): exc = HTTPNotFound( 'The resource does not exist', comment="No file at %r" % self.filename) return exc(environ, start_response) try: file = open(self.filename, 'rb') except (IOError, OSError) as e: exc = HTTPForbidden( 'You are not permitted to view this file (%s)' % e) return exc.wsgi_application( environ, start_response) retval = DataApp.get(self, environ, start_response) if isinstance(retval, list): # cached content, exception, or not-modified if is_head: return [b''] return retval (lower, content_length) = retval if is_head: return [b''] file.seek(lower) file_wrapper = environ.get('wsgi.file_wrapper', None) if file_wrapper: return file_wrapper(file, BLOCK_SIZE) else: return _FileIter(file, size=content_length) class _FileIter(object): def __init__(self, file, block_size=None, size=None): self.file = file self.size = size self.block_size = block_size or BLOCK_SIZE def __iter__(self): return self def next(self): chunk_size = self.block_size if self.size is not None: if chunk_size > self.size: chunk_size = self.size self.size -= chunk_size data = self.file.read(chunk_size) if not data: raise StopIteration return data __next__ = next def close(self): self.file.close() class DirectoryApp(object): """ Returns an application that dispatches requests to corresponding FileApps based on PATH_INFO. FileApp instances are cached. This app makes sure not to serve any files that are not in a subdirectory. To customize FileApp creation override ``DirectoryApp.make_fileapp`` """ def __init__(self, path): self.path = os.path.abspath(path) if not self.path.endswith(os.path.sep): self.path += os.path.sep assert os.path.isdir(self.path) self.cached_apps = {} make_fileapp = FileApp def __call__(self, environ, start_response): path_info = environ['PATH_INFO'] app = self.cached_apps.get(path_info) if app is None: path = os.path.join(self.path, path_info.lstrip('/')) if not os.path.normpath(path).startswith(self.path): app = HTTPForbidden() elif os.path.isfile(path): app = self.make_fileapp(path) self.cached_apps[path_info] = app else: app = HTTPNotFound(comment=path) return app(environ, start_response) class ArchiveStore(object): """ Returns an application that serves up a DataApp for items requested in a given zip or tar archive. Constructor Arguments: ``filepath`` the path to the archive being served ``cache_control()`` This method provides validated construction of the ``Cache-Control`` header as well as providing for automated filling out of the ``EXPIRES`` header for HTTP/1.0 clients. """ def __init__(self, filepath): if zipfile.is_zipfile(filepath): self.archive = zipfile.ZipFile(filepath,"r") elif tarfile.is_tarfile(filepath): self.archive = tarfile.TarFileCompat(filepath,"r") else: raise AssertionError("filepath '%s' is not a zip or tar " % filepath) self.expires = None self.last_modified = time.time() self.cache = {} def cache_control(self, **kwargs): self.expires = CACHE_CONTROL.apply(self.headers, **kwargs) or None return self def __call__(self, environ, start_response): path = environ.get("PATH_INFO","") if path.startswith("/"): path = path[1:] application = self.cache.get(path) if application: return application(environ, start_response) try: info = self.archive.getinfo(path) except KeyError: exc = HTTPNotFound("The file requested, '%s', was not found." % path) return exc.wsgi_application(environ, start_response) if info.filename.endswith("/"): exc = HTTPNotFound("Path requested, '%s', is not a file." % path) return exc.wsgi_application(environ, start_response) content_type, content_encoding = mimetypes.guess_type(info.filename) # 'None' is not a valid content-encoding, so don't set the header if # mimetypes.guess_type returns None if content_encoding is not None: app = DataApp(None, content_type = content_type, content_encoding = content_encoding) else: app = DataApp(None, content_type = content_type) app.set_content(self.archive.read(path), time.mktime(info.date_time + (0,0,0))) self.cache[path] = app app.expires = self.expires return app(environ, start_response)
apache-2.0
[ 3, 334, 67, 9, 11811, 473, 290, 699, 2000, 316, 436, 8417, 27, 5313, 367, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 9, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 3, 334, 67, 9, 11811, 473, 290, 699, 2000, 316, 12, 8465, 1096, 445, 14, 662, 86, 796, 436, 8417, 199, 3, 961, 859, 365, 1777, 402, 314, 2018, 510, 9209, 7290, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 624, 199, 2765, 859, 10022, 10209, 2955, 1564, 4066, 465, 315, 13, 4844, 666, 503, 199, 1725, 14, 221, 2854, 642, 900, 652, 965, 2581, 10897, 436, 1334, 26580, 314, 199, 692, 13, 5540, 13, 8585, 1056, 1406, 14, 199, 624, 199, 199, 646, 747, 12, 900, 12, 13290, 12, 10392, 12, 13608, 199, 504, 20901, 14, 16916, 321, 16010, 83, 492, 627, 199, 504, 20901, 14, 1014, 2139, 492, 627, 199, 199, 8677, 63, 4305, 275, 17125, 199, 8475, 63, 4305, 275, 17125, 627, 3193, 199, 199, 363, 452, 363, 275, 788, 1451, 2640, 297, 283, 1173, 2640, 297, 283, 6231, 2640, 297, 283, 13042, 5502, 418, 199, 199, 533, 3918, 2640, 8, 785, 304, 272, 408, 272, 1803, 376, 4223, 626, 911, 3222, 1564, 315, 282, 2849, 3728, 12, 272, 642, 4223, 965, 2291, 367, 4260, 2581, 13, 2785, 436, 367, 272, 9163, 1098, 370, 12303, 334, 269, 13053, 9, 4145, 14, 339, 20297, 7628, 26, 398, 1124, 1317, 1040, 258, 314, 1564, 3769, 4847, 370, 314, 1890, 398, 1124, 2139, 1040, 258, 314, 2323, 370, 3222, 1182, 87, 314, 1177, 398, 710, 7971, 1124, 958, 1040, 17118, 370, 2323, 12, 2382, 314, 267, 18888, 365, 8717, 543, 282, 11847, 14, 221, 5723, 1338, 787, 1454, 267, 3483, 370, 314, 2323, 340, 2985, 787, 440, 2575, 2741, 27, 12850, 12, 267, 2985, 883, 506, 1202, 367, 849, 1338, 14, 221, 6058, 2387, 12, 1325, 267, 787, 440, 13988, 370, 26, 953, 1124, 1317, 63, 466, 1040, 288, 1124, 1317, 63, 2991, 1040, 288, 1124, 1317, 63, 1985, 1040, 339, 1124, 1637, 63, 2785, 8497, 398, 961, 1083, 6571, 16468, 14538, 402, 314, 1124, 4437, 13, 3717, 1040, 267, 1406, 465, 5521, 465, 13070, 367, 6384, 23513, 32499, 734, 402, 314, 267, 1124, 25632, 3830, 1040, 1406, 367, 3101, 15, 17, 14, 16, 13431, 14, 339, 1124, 409, 63, 1317, 8497, 398, 961, 1083, 6571, 282, 14729, 370, 663, 314, 1564, 2410, 314, 267, 4223, 965, 2757, 14701, 14, 221, 961, 1083, 1630, 7645, 267, 2839, 13729, 1124, 6090, 13, 11911, 1040, 436, 1124, 2714, 13, 4625, 1040, 2323, 14, 339, 408, 339, 4370, 63, 2474, 275, 661, 2970, 297, 283, 5211, 358, 339, 347, 636, 826, 721, 277, 12, 1564, 12, 2323, 29, 403, 12, 4370, 63, 2474, 29, 403, 12, 326, 1011, 958, 304, 267, 702, 1228, 8, 2139, 12, 334, 466, 8, 403, 395, 769, 430, 267, 291, 14, 12342, 275, 488, 267, 291, 14, 1317, 275, 488, 267, 291, 14, 1317, 63, 1267, 275, 488, 267, 291, 14, 2019, 63, 5540, 275, 378, 267, 340, 4370, 63, 2474, 365, 440, 488, 26, 288, 291, 14, 6541, 63, 2474, 275, 4370, 63, 2474, 267, 291, 14, 2139, 275, 2323, 503, 942, 267, 367, 334, 75, 12, 373, 9, 315, 2074, 14, 1744, 837, 288, 1406, 275, 664, 63, 1291, 8, 75, 9, 288, 1406, 14, 873, 8, 277, 14, 2139, 12, 373, 9, 267, 28538, 63, 50, 3986, 654, 14, 873, 8, 277, 14, 2139, 12, 2783, 29, 549, 9, 267, 340, 440, 29417, 63, 2711, 8, 277, 14, 2139, 304, 288, 29417, 63, 2711, 14, 873, 8, 277, 14, 2139, 9, 267, 340, 1564, 365, 440, 488, 26, 288, 291, 14, 409, 63, 1317, 8, 1317, 9, 339, 347, 2581, 63, 2785, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 12342, 275, 7240, 4576, 63, 13060, 14, 4998, 8, 277, 14, 2139, 12, 1011, 958, 9, 503, 488, 267, 372, 291, 339, 347, 663, 63, 1317, 8, 277, 12, 1564, 12, 2061, 63, 5540, 29, 403, 304, 267, 702, 1564, 365, 440, 488, 267, 340, 2061, 63, 5540, 365, 488, 26, 288, 291, 14, 2019, 63, 5540, 275, 900, 14, 521, 342, 267, 587, 26, 288, 291, 14, 2019, 63, 5540, 275, 2061, 63, 5540, 267, 291, 14, 1317, 275, 1564, 267, 291, 14, 1317, 63, 1267, 275, 822, 8, 1317, 9, 267, 491, 11307, 63, 30389, 14, 873, 8, 277, 14, 2139, 12, 900, 29, 277, 14, 2019, 63, 5540, 9, 267, 372, 291, 339, 347, 1564, 63, 20173, 8, 277, 12, 1011, 958, 304, 267, 29417, 63, 6178, 15717, 14, 4998, 8, 277, 14, 2139, 12, 1011, 958, 9, 267, 372, 291, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 1083, 275, 6160, 459, 6780, 63, 9977, 2278, 4142, 342, 267, 340, 1083, 440, 315, 291, 14, 6541, 63, 2474, 26, 288, 3178, 275, 3101, 3767, 29967, 8, 355, 283, 5556, 3913, 450, 83, 282, 570, 7, 450, 1083, 12, 355, 2323, 11699, 7852, 297, 12814, 904, 8, 277, 14, 6541, 63, 2474, 18229, 288, 372, 3178, 8, 2314, 12, 1343, 63, 1310, 9, 267, 372, 291, 14, 362, 8, 2314, 12, 1343, 63, 1310, 9, 339, 347, 8671, 63, 11304, 8, 277, 304, 267, 372, 18253, 83, 3295, 83, 4507, 450, 334, 277, 14, 2019, 63, 5540, 12, 291, 14, 1317, 63, 1267, 9, 339, 347, 664, 8, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 2323, 275, 291, 14, 2139, 5873, 267, 1453, 63, 11304, 275, 291, 14, 12063, 63, 11304, 342, 267, 662, 6967, 14, 873, 8, 2139, 12, 1453, 63, 11304, 9, 267, 340, 291, 14, 12342, 365, 440, 488, 26, 288, 3651, 2252, 3830, 14, 873, 8, 2139, 12, 5762, 29, 277, 14, 12342, 9, 398, 862, 26, 288, 1890, 63, 1841, 458, 275, 8036, 63, 9185, 63, 14747, 14, 1122, 8, 2314, 9, 288, 340, 1890, 63, 1841, 458, 26, 355, 367, 13677, 315, 1890, 63 ]
[ 334, 67, 9, 11811, 473, 290, 699, 2000, 316, 436, 8417, 27, 5313, 367, 510, 9209, 334, 1014, 921, 1548, 16586, 14, 1308, 9, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 3, 334, 67, 9, 11811, 473, 290, 699, 2000, 316, 12, 8465, 1096, 445, 14, 662, 86, 796, 436, 8417, 199, 3, 961, 859, 365, 1777, 402, 314, 2018, 510, 9209, 7290, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 624, 199, 2765, 859, 10022, 10209, 2955, 1564, 4066, 465, 315, 13, 4844, 666, 503, 199, 1725, 14, 221, 2854, 642, 900, 652, 965, 2581, 10897, 436, 1334, 26580, 314, 199, 692, 13, 5540, 13, 8585, 1056, 1406, 14, 199, 624, 199, 199, 646, 747, 12, 900, 12, 13290, 12, 10392, 12, 13608, 199, 504, 20901, 14, 16916, 321, 16010, 83, 492, 627, 199, 504, 20901, 14, 1014, 2139, 492, 627, 199, 199, 8677, 63, 4305, 275, 17125, 199, 8475, 63, 4305, 275, 17125, 627, 3193, 199, 199, 363, 452, 363, 275, 788, 1451, 2640, 297, 283, 1173, 2640, 297, 283, 6231, 2640, 297, 283, 13042, 5502, 418, 199, 199, 533, 3918, 2640, 8, 785, 304, 272, 408, 272, 1803, 376, 4223, 626, 911, 3222, 1564, 315, 282, 2849, 3728, 12, 272, 642, 4223, 965, 2291, 367, 4260, 2581, 13, 2785, 436, 367, 272, 9163, 1098, 370, 12303, 334, 269, 13053, 9, 4145, 14, 339, 20297, 7628, 26, 398, 1124, 1317, 1040, 258, 314, 1564, 3769, 4847, 370, 314, 1890, 398, 1124, 2139, 1040, 258, 314, 2323, 370, 3222, 1182, 87, 314, 1177, 398, 710, 7971, 1124, 958, 1040, 17118, 370, 2323, 12, 2382, 314, 267, 18888, 365, 8717, 543, 282, 11847, 14, 221, 5723, 1338, 787, 1454, 267, 3483, 370, 314, 2323, 340, 2985, 787, 440, 2575, 2741, 27, 12850, 12, 267, 2985, 883, 506, 1202, 367, 849, 1338, 14, 221, 6058, 2387, 12, 1325, 267, 787, 440, 13988, 370, 26, 953, 1124, 1317, 63, 466, 1040, 288, 1124, 1317, 63, 2991, 1040, 288, 1124, 1317, 63, 1985, 1040, 339, 1124, 1637, 63, 2785, 8497, 398, 961, 1083, 6571, 16468, 14538, 402, 314, 1124, 4437, 13, 3717, 1040, 267, 1406, 465, 5521, 465, 13070, 367, 6384, 23513, 32499, 734, 402, 314, 267, 1124, 25632, 3830, 1040, 1406, 367, 3101, 15, 17, 14, 16, 13431, 14, 339, 1124, 409, 63, 1317, 8497, 398, 961, 1083, 6571, 282, 14729, 370, 663, 314, 1564, 2410, 314, 267, 4223, 965, 2757, 14701, 14, 221, 961, 1083, 1630, 7645, 267, 2839, 13729, 1124, 6090, 13, 11911, 1040, 436, 1124, 2714, 13, 4625, 1040, 2323, 14, 339, 408, 339, 4370, 63, 2474, 275, 661, 2970, 297, 283, 5211, 358, 339, 347, 636, 826, 721, 277, 12, 1564, 12, 2323, 29, 403, 12, 4370, 63, 2474, 29, 403, 12, 326, 1011, 958, 304, 267, 702, 1228, 8, 2139, 12, 334, 466, 8, 403, 395, 769, 430, 267, 291, 14, 12342, 275, 488, 267, 291, 14, 1317, 275, 488, 267, 291, 14, 1317, 63, 1267, 275, 488, 267, 291, 14, 2019, 63, 5540, 275, 378, 267, 340, 4370, 63, 2474, 365, 440, 488, 26, 288, 291, 14, 6541, 63, 2474, 275, 4370, 63, 2474, 267, 291, 14, 2139, 275, 2323, 503, 942, 267, 367, 334, 75, 12, 373, 9, 315, 2074, 14, 1744, 837, 288, 1406, 275, 664, 63, 1291, 8, 75, 9, 288, 1406, 14, 873, 8, 277, 14, 2139, 12, 373, 9, 267, 28538, 63, 50, 3986, 654, 14, 873, 8, 277, 14, 2139, 12, 2783, 29, 549, 9, 267, 340, 440, 29417, 63, 2711, 8, 277, 14, 2139, 304, 288, 29417, 63, 2711, 14, 873, 8, 277, 14, 2139, 9, 267, 340, 1564, 365, 440, 488, 26, 288, 291, 14, 409, 63, 1317, 8, 1317, 9, 339, 347, 2581, 63, 2785, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 12342, 275, 7240, 4576, 63, 13060, 14, 4998, 8, 277, 14, 2139, 12, 1011, 958, 9, 503, 488, 267, 372, 291, 339, 347, 663, 63, 1317, 8, 277, 12, 1564, 12, 2061, 63, 5540, 29, 403, 304, 267, 702, 1564, 365, 440, 488, 267, 340, 2061, 63, 5540, 365, 488, 26, 288, 291, 14, 2019, 63, 5540, 275, 900, 14, 521, 342, 267, 587, 26, 288, 291, 14, 2019, 63, 5540, 275, 2061, 63, 5540, 267, 291, 14, 1317, 275, 1564, 267, 291, 14, 1317, 63, 1267, 275, 822, 8, 1317, 9, 267, 491, 11307, 63, 30389, 14, 873, 8, 277, 14, 2139, 12, 900, 29, 277, 14, 2019, 63, 5540, 9, 267, 372, 291, 339, 347, 1564, 63, 20173, 8, 277, 12, 1011, 958, 304, 267, 29417, 63, 6178, 15717, 14, 4998, 8, 277, 14, 2139, 12, 1011, 958, 9, 267, 372, 291, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 1083, 275, 6160, 459, 6780, 63, 9977, 2278, 4142, 342, 267, 340, 1083, 440, 315, 291, 14, 6541, 63, 2474, 26, 288, 3178, 275, 3101, 3767, 29967, 8, 355, 283, 5556, 3913, 450, 83, 282, 570, 7, 450, 1083, 12, 355, 2323, 11699, 7852, 297, 12814, 904, 8, 277, 14, 6541, 63, 2474, 18229, 288, 372, 3178, 8, 2314, 12, 1343, 63, 1310, 9, 267, 372, 291, 14, 362, 8, 2314, 12, 1343, 63, 1310, 9, 339, 347, 8671, 63, 11304, 8, 277, 304, 267, 372, 18253, 83, 3295, 83, 4507, 450, 334, 277, 14, 2019, 63, 5540, 12, 291, 14, 1317, 63, 1267, 9, 339, 347, 664, 8, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 2323, 275, 291, 14, 2139, 5873, 267, 1453, 63, 11304, 275, 291, 14, 12063, 63, 11304, 342, 267, 662, 6967, 14, 873, 8, 2139, 12, 1453, 63, 11304, 9, 267, 340, 291, 14, 12342, 365, 440, 488, 26, 288, 3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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bdh1011/wau
venv/lib/python2.7/site-packages/twisted/logger/_format.py
12
8176
# -*- test-case-name: twisted.logger.test.test_format -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tools for formatting logging events. """ from datetime import datetime as DateTime from twisted.python.compat import unicode from twisted.python.failure import Failure from twisted.python.reflect import safe_repr from twisted.python._tzhelper import FixedOffsetTimeZone from ._flatten import flatFormat, aFormatter timeFormatRFC3339 = "%Y-%m-%dT%H:%M:%S%z" def formatEvent(event): """ Formats an event as a L{unicode}, using the format in C{event["log_format"]}. This implementation should never raise an exception; if the formatting cannot be done, the returned string will describe the event generically so that a useful message is emitted regardless. @param event: A logging event. @type event: L{dict} @return: A formatted string. @rtype: L{unicode} """ try: if "log_flattened" in event: return flatFormat(event) format = event.get("log_format", None) if format is None: return u"" # Make sure format is unicode. if isinstance(format, bytes): # If we get bytes, assume it's UTF-8 bytes format = format.decode("utf-8") elif not isinstance(format, unicode): raise TypeError( "Log format must be unicode or bytes, not {0!r}".format(format) ) return formatWithCall(format, event) except Exception as e: return formatUnformattableEvent(event, e) def formatUnformattableEvent(event, error): """ Formats an event as a L{unicode} that describes the event generically and a formatting error. @param event: A logging event. @type event: L{dict} @param error: The formatting error. @type error: L{Exception} @return: A formatted string. @rtype: L{unicode} """ try: return ( u"Unable to format event {event!r}: {error}" .format(event=event, error=error) ) except BaseException: # Yikes, something really nasty happened. # # Try to recover as much formattable data as possible; hopefully at # least the namespace is sane, which will help you find the offending # logger. failure = Failure() text = u", ".join( u" = ".join((safe_repr(key), safe_repr(value))) for key, value in event.items() ) return ( u"MESSAGE LOST: unformattable object logged: {error}\n" u"Recoverable data: {text}\n" u"Exception during formatting:\n{failure}" .format(error=safe_repr(error), failure=failure, text=text) ) def formatTime(when, timeFormat=timeFormatRFC3339, default=u"-"): """ Format a timestamp as text. Example:: >>> from time import time >>> from twisted.logger import formatTime >>> >>> t = time() >>> formatTime(t) u'2013-10-22T14:19:11-0700' >>> formatTime(t, timeFormat="%Y/%W") # Year and week number u'2013/42' >>> @param when: A timestamp. @type then: L{float} @param timeFormat: A time format. @type timeFormat: L{unicode} or C{None} @param default: Text to return if C{when} or C{timeFormat} is C{None}. @type default: L{unicode} @return: A formatted time. @rtype: L{unicode} """ if (timeFormat is None or when is None): return default else: tz = FixedOffsetTimeZone.fromLocalTimeStamp(when) datetime = DateTime.fromtimestamp(when, tz) return unicode(datetime.strftime(timeFormat)) def formatEventAsClassicLogText(event, formatTime=formatTime): """ Format an event as a line of human-readable text for, e.g. traditional log file output. The output format is C{u"{timeStamp} [{system}] {event}\\n"}, where: - C{timeStamp} is computed by calling the given C{formatTime} callable on the event's C{"log_time"} value - C{system} is the event's C{"log_system"} value, if set, otherwise, the C{"log_namespace"} and C{"log_level"}, joined by a C{u"#"}. Each defaults to C{u"-"} is not set. - C{event} is the event, as formatted by L{formatEvent}. Example:: >>> from __future__ import print_function >>> from time import time >>> from twisted.logger import formatEventAsClassicLogText >>> from twisted.logger import LogLevel >>> >>> formatEventAsClassicLogText(dict()) # No format, returns None >>> formatEventAsClassicLogText(dict(log_format=u"Hello!")) u'- [-#-] Hello!\\n' >>> formatEventAsClassicLogText(dict( ... log_format=u"Hello!", ... log_time=time(), ... log_namespace="my_namespace", ... log_level=LogLevel.info, ... )) u'2013-10-22T17:30:02-0700 [my_namespace#info] Hello!\\n' >>> formatEventAsClassicLogText(dict( ... log_format=u"Hello!", ... log_time=time(), ... log_system="my_system", ... )) u'2013-11-11T17:22:06-0800 [my_system] Hello!\\n' >>> @param event: an event. @type event: L{dict} @param formatTime: A time formatter @type formatTime: L{callable} that takes an C{event} argument and returns a L{unicode} @return: A formatted event, or C{None} if no output is appropriate. @rtype: L{unicode} or C{None} """ eventText = formatEvent(event) if not eventText: return None eventText = eventText.replace(u"\n", u"\n\t") timeStamp = formatTime(event.get("log_time", None)) system = event.get("log_system", None) if system is None: level = event.get("log_level", None) if level is None: levelName = u"-" else: levelName = level.name system = u"{namespace}#{level}".format( namespace=event.get("log_namespace", u"-"), level=levelName, ) else: try: system = unicode(system) except Exception: system = u"UNFORMATTABLE" return u"{timeStamp} [{system}] {event}\n".format( timeStamp=timeStamp, system=system, event=eventText, ) class CallMapping(object): """ Read-only mapping that turns a C{()}-suffix in key names into an invocation of the key rather than a lookup of the key. Implementation support for L{formatWithCall}. """ def __init__(self, submapping): """ @param submapping: Another read-only mapping which will be used to look up items. """ self._submapping = submapping def __getitem__(self, key): """ Look up an item in the submapping for this L{CallMapping}, calling it if C{key} ends with C{"()"}. """ callit = key.endswith(u"()") realKey = key[:-2] if callit else key value = self._submapping[realKey] if callit: value = value() return value def formatWithCall(formatString, mapping): """ Format a string like L{unicode.format}, but: - taking only a name mapping; no positional arguments - with the additional syntax that an empty set of parentheses correspond to a formatting item that should be called, and its result C{str}'d, rather than calling C{str} on the element directly as normal. For example:: >>> formatWithCall("{string}, {function()}.", ... dict(string="just a string", ... function=lambda: "a function")) 'just a string, a function.' @param formatString: A PEP-3101 format string. @type formatString: L{unicode} @param mapping: A L{dict}-like object to format. @return: The string with formatted values interpolated. @rtype: L{unicode} """ return unicode( aFormatter.vformat(formatString, (), CallMapping(mapping)) )
mit
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2921, 14, 396, 14, 396, 63, 908, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 11654, 367, 10803, 2050, 4474, 14, 199, 624, 199, 199, 504, 2197, 492, 2197, 465, 13686, 199, 199, 504, 7390, 14, 1548, 14, 5819, 492, 2649, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 1548, 14, 21963, 492, 5048, 63, 2722, 199, 504, 7390, 14, 1548, 423, 3903, 3676, 492, 18659, 6397, 32515, 199, 199, 504, 13653, 8487, 492, 6829, 3484, 12, 282, 7772, 199, 199, 521, 3484, 14468, 29536, 275, 2071, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 5, 90, 2, 4388, 199, 318, 1475, 2390, 8, 1430, 304, 272, 408, 272, 9701, 83, 376, 1566, 465, 282, 491, 91, 2975, 1386, 1808, 314, 1475, 315, 272, 445, 91, 1430, 905, 793, 63, 908, 937, 5565, 339, 961, 4514, 1077, 7078, 746, 376, 1919, 27, 340, 314, 10803, 272, 3913, 506, 4224, 12, 314, 2138, 1059, 911, 13743, 314, 1566, 1519, 7288, 880, 272, 626, 282, 2997, 1245, 365, 19515, 15270, 14, 339, 768, 635, 1566, 26, 437, 2050, 1566, 14, 272, 768, 466, 1566, 26, 491, 91, 807, 93, 339, 768, 1107, 26, 437, 7871, 1059, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 862, 26, 267, 340, 298, 793, 63, 28079, 2, 315, 1566, 26, 288, 372, 6829, 3484, 8, 1430, 9, 398, 1475, 275, 1566, 14, 362, 480, 793, 63, 908, 401, 488, 9, 267, 340, 1475, 365, 488, 26, 288, 372, 399, 341, 398, 327, 4155, 3238, 1475, 365, 2649, 14, 267, 340, 1228, 8, 908, 12, 2783, 304, 288, 327, 982, 781, 664, 2783, 12, 5534, 652, 1159, 9094, 13, 24, 2783, 288, 1475, 275, 1475, 14, 2708, 480, 1624, 13, 24, 531, 267, 916, 440, 1228, 8, 908, 12, 2649, 304, 288, 746, 3146, 8, 355, 298, 2445, 1475, 1471, 506, 2649, 503, 2783, 12, 440, 469, 16, 1, 82, 5469, 908, 8, 908, 9, 288, 776, 398, 372, 1475, 3007, 2176, 8, 908, 12, 1566, 9, 339, 871, 2186, 465, 325, 26, 267, 372, 1475, 1358, 908, 1224, 2390, 8, 1430, 12, 325, 9, 4388, 199, 318, 1475, 1358, 908, 1224, 2390, 8, 1430, 12, 1125, 304, 272, 408, 272, 9701, 83, 376, 1566, 465, 282, 491, 91, 2975, 93, 626, 23369, 314, 1566, 1519, 7288, 436, 282, 272, 10803, 1125, 14, 339, 768, 635, 1566, 26, 437, 2050, 1566, 14, 272, 768, 466, 1566, 26, 491, 91, 807, 93, 339, 768, 635, 1125, 26, 710, 10803, 1125, 14, 272, 768, 466, 1125, 26, 491, 91, 1726, 93, 339, 768, 1107, 26, 437, 7871, 1059, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 862, 26, 267, 372, 334, 288, 399, 2, 6005, 370, 1475, 1566, 469, 1430, 1, 82, 9160, 469, 705, 7063, 288, 1275, 908, 8, 1430, 29, 1430, 12, 1125, 29, 705, 9, 267, 776, 272, 871, 25416, 26, 267, 327, 1488, 3258, 397, 12, 6020, 7710, 302, 27352, 21056, 14, 267, 327, 267, 327, 7649, 370, 22803, 465, 8298, 1475, 1224, 666, 465, 3962, 27, 3661, 5836, 737, 267, 327, 5210, 314, 3231, 365, 31648, 12, 1314, 911, 1720, 1265, 2342, 314, 2331, 3219, 267, 327, 2512, 14, 267, 5988, 275, 20367, 342, 398, 1318, 275, 399, 401, 3680, 904, 8, 288, 399, 2, 275, 3680, 904, 1332, 3489, 63, 2722, 8, 498, 395, 5048, 63, 2722, 8, 585, 1724, 288, 367, 790, 12, 574, 315, 1566, 14, 1744, 342, 267, 776, 398, 372, 334, 288, 399, 2, 8272, 3412, 840, 26, 625, 908, 1224, 909, 10367, 26, 469, 705, 4988, 78, 2, 288, 399, 2, 497, 5899, 461, 666, 26, 469, 505, 4988, 78, 2, 288, 399, 2, 1726, 5309, 10803, 3427, 78, 91, 5328, 7063, 288, 1275, 908, 8, 705, 29, 3489, 63, 2722, 8, 705, 395, 5988, 29, 5328, 12, 1318, 29, 505, 9, 267, 776, 4388, 199, 318, 1475, 1366, 8, 6526, 12, 900, 3484, 29, 521, 3484, 14468, 29536, 12, 849, 29, 85, 32095, 2349, 272, 408, 272, 9701, 282, 4913, 465, 1318, 14, 339, 5679, 447, 398, 1306, 687, 900, 492, 900, 267, 1306, 687, 7390, 14, 2921, 492, 1475, 1366, 267, 1306, 267, 1306, 307, 275, 900, 342, 267, 1306, 1475, 1366, 8, 84, 9, 267, 399, 7, 6965, 13, 709, 13, 1081, 52, 1079, 26, 1167, 26, 845, 13, 1780, 383, 7, 267, 1306, 1475, 1366, 8, 84, 12, 900, 3484, 5961, 57, 3149, 55, 531, 221, 327, 28497, 436, 8620, 1329, 267, 399, 7, 6965, 15, 2260, 7, 267, 1306, 339, 768, 635, 1380, 26, 437, 4913, 14, 272, 768, 466, 2066, 26, 491, 91, 1609, 93, 339, 768, 635, 900, 3484, 26, 437, 900, 1475, 14, 272, 768, 466, 900, 3484, 26, 491, 91, 2975, 93, 503, 445, 91, 403, 93, 339, 768, 635, 849, 26, 4516, 370, 372, 340, 445, 91, 6526, 93, 503, 445, 91, 521, 3484, 93, 365, 445, 91, 403, 5565, 272, 768, 466, 849, 26, 491, 91, 2975, 93, 339, 768, 1107, 26, 437, 7871, 900, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 340, 334, 521, 3484, 365, 488, 503, 1380, 365, 488, 304, 267, 372, 849, 272, 587, 26, 267, 5823, 275, 18659, 6397, 32515, 14, 504, 5339, 27335, 8, 6526, 9, 267, 2197, 275, 13686, 14, 18531, 8, 6526, 12, 5823, 9, 267, 372, 2649, 8, 2083, 14, 6205, 8, 521, 3484, 430, 4388, 199, 318, 1475, 2390, 2822, 30722, 67, 2445, 1872, 8, 1430, 12, 1475, 1366, 29, 908, 1366, 304, 272, 408, 272, 9701, 376, 1566, 465, 282, 1004, 402, 11779, 13, 11875, 1318, 367, 12, 325, 14, 71, 14, 1468, 2603, 943, 272, 570, 1072, 14, 339, 710, 1072, 1475, 365, 445, 91, 85, 14381, 521, 16649, 93, 8910, 2253, 11049, 469, 1430, 32201, 78, 6018, 2382, 26, 398, 446, 445, 91, 521, 16649, 93, 365, 9235, 701, 6358, 314, 1627, 445, 91, 908, 1366, 93, 4550, 881, 641, 314, 1566, 1159 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2921, 14, 396, 14, 396, 63, 908, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 11654, 367, 10803, 2050, 4474, 14, 199, 624, 199, 199, 504, 2197, 492, 2197, 465, 13686, 199, 199, 504, 7390, 14, 1548, 14, 5819, 492, 2649, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 1548, 14, 21963, 492, 5048, 63, 2722, 199, 504, 7390, 14, 1548, 423, 3903, 3676, 492, 18659, 6397, 32515, 199, 199, 504, 13653, 8487, 492, 6829, 3484, 12, 282, 7772, 199, 199, 521, 3484, 14468, 29536, 275, 2071, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 5, 90, 2, 4388, 199, 318, 1475, 2390, 8, 1430, 304, 272, 408, 272, 9701, 83, 376, 1566, 465, 282, 491, 91, 2975, 1386, 1808, 314, 1475, 315, 272, 445, 91, 1430, 905, 793, 63, 908, 937, 5565, 339, 961, 4514, 1077, 7078, 746, 376, 1919, 27, 340, 314, 10803, 272, 3913, 506, 4224, 12, 314, 2138, 1059, 911, 13743, 314, 1566, 1519, 7288, 880, 272, 626, 282, 2997, 1245, 365, 19515, 15270, 14, 339, 768, 635, 1566, 26, 437, 2050, 1566, 14, 272, 768, 466, 1566, 26, 491, 91, 807, 93, 339, 768, 1107, 26, 437, 7871, 1059, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 862, 26, 267, 340, 298, 793, 63, 28079, 2, 315, 1566, 26, 288, 372, 6829, 3484, 8, 1430, 9, 398, 1475, 275, 1566, 14, 362, 480, 793, 63, 908, 401, 488, 9, 267, 340, 1475, 365, 488, 26, 288, 372, 399, 341, 398, 327, 4155, 3238, 1475, 365, 2649, 14, 267, 340, 1228, 8, 908, 12, 2783, 304, 288, 327, 982, 781, 664, 2783, 12, 5534, 652, 1159, 9094, 13, 24, 2783, 288, 1475, 275, 1475, 14, 2708, 480, 1624, 13, 24, 531, 267, 916, 440, 1228, 8, 908, 12, 2649, 304, 288, 746, 3146, 8, 355, 298, 2445, 1475, 1471, 506, 2649, 503, 2783, 12, 440, 469, 16, 1, 82, 5469, 908, 8, 908, 9, 288, 776, 398, 372, 1475, 3007, 2176, 8, 908, 12, 1566, 9, 339, 871, 2186, 465, 325, 26, 267, 372, 1475, 1358, 908, 1224, 2390, 8, 1430, 12, 325, 9, 4388, 199, 318, 1475, 1358, 908, 1224, 2390, 8, 1430, 12, 1125, 304, 272, 408, 272, 9701, 83, 376, 1566, 465, 282, 491, 91, 2975, 93, 626, 23369, 314, 1566, 1519, 7288, 436, 282, 272, 10803, 1125, 14, 339, 768, 635, 1566, 26, 437, 2050, 1566, 14, 272, 768, 466, 1566, 26, 491, 91, 807, 93, 339, 768, 635, 1125, 26, 710, 10803, 1125, 14, 272, 768, 466, 1125, 26, 491, 91, 1726, 93, 339, 768, 1107, 26, 437, 7871, 1059, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 862, 26, 267, 372, 334, 288, 399, 2, 6005, 370, 1475, 1566, 469, 1430, 1, 82, 9160, 469, 705, 7063, 288, 1275, 908, 8, 1430, 29, 1430, 12, 1125, 29, 705, 9, 267, 776, 272, 871, 25416, 26, 267, 327, 1488, 3258, 397, 12, 6020, 7710, 302, 27352, 21056, 14, 267, 327, 267, 327, 7649, 370, 22803, 465, 8298, 1475, 1224, 666, 465, 3962, 27, 3661, 5836, 737, 267, 327, 5210, 314, 3231, 365, 31648, 12, 1314, 911, 1720, 1265, 2342, 314, 2331, 3219, 267, 327, 2512, 14, 267, 5988, 275, 20367, 342, 398, 1318, 275, 399, 401, 3680, 904, 8, 288, 399, 2, 275, 3680, 904, 1332, 3489, 63, 2722, 8, 498, 395, 5048, 63, 2722, 8, 585, 1724, 288, 367, 790, 12, 574, 315, 1566, 14, 1744, 342, 267, 776, 398, 372, 334, 288, 399, 2, 8272, 3412, 840, 26, 625, 908, 1224, 909, 10367, 26, 469, 705, 4988, 78, 2, 288, 399, 2, 497, 5899, 461, 666, 26, 469, 505, 4988, 78, 2, 288, 399, 2, 1726, 5309, 10803, 3427, 78, 91, 5328, 7063, 288, 1275, 908, 8, 705, 29, 3489, 63, 2722, 8, 705, 395, 5988, 29, 5328, 12, 1318, 29, 505, 9, 267, 776, 4388, 199, 318, 1475, 1366, 8, 6526, 12, 900, 3484, 29, 521, 3484, 14468, 29536, 12, 849, 29, 85, 32095, 2349, 272, 408, 272, 9701, 282, 4913, 465, 1318, 14, 339, 5679, 447, 398, 1306, 687, 900, 492, 900, 267, 1306, 687, 7390, 14, 2921, 492, 1475, 1366, 267, 1306, 267, 1306, 307, 275, 900, 342, 267, 1306, 1475, 1366, 8, 84, 9, 267, 399, 7, 6965, 13, 709, 13, 1081, 52, 1079, 26, 1167, 26, 845, 13, 1780, 383, 7, 267, 1306, 1475, 1366, 8, 84, 12, 900, 3484, 5961, 57, 3149, 55, 531, 221, 327, 28497, 436, 8620, 1329, 267, 399, 7, 6965, 15, 2260, 7, 267, 1306, 339, 768, 635, 1380, 26, 437, 4913, 14, 272, 768, 466, 2066, 26, 491, 91, 1609, 93, 339, 768, 635, 900, 3484, 26, 437, 900, 1475, 14, 272, 768, 466, 900, 3484, 26, 491, 91, 2975, 93, 503, 445, 91, 403, 93, 339, 768, 635, 849, 26, 4516, 370, 372, 340, 445, 91, 6526, 93, 503, 445, 91, 521, 3484, 93, 365, 445, 91, 403, 5565, 272, 768, 466, 849, 26, 491, 91, 2975, 93, 339, 768, 1107, 26, 437, 7871, 900, 14, 272, 768, 4500, 26, 491, 91, 2975, 93, 272, 408, 272, 340, 334, 521, 3484, 365, 488, 503, 1380, 365, 488, 304, 267, 372, 849, 272, 587, 26, 267, 5823, 275, 18659, 6397, 32515, 14, 504, 5339, 27335, 8, 6526, 9, 267, 2197, 275, 13686, 14, 18531, 8, 6526, 12, 5823, 9, 267, 372, 2649, 8, 2083, 14, 6205, 8, 521, 3484, 430, 4388, 199, 318, 1475, 2390, 2822, 30722, 67, 2445, 1872, 8, 1430, 12, 1475, 1366, 29, 908, 1366, 304, 272, 408, 272, 9701, 376, 1566, 465, 282, 1004, 402, 11779, 13, 11875, 1318, 367, 12, 325, 14, 71, 14, 1468, 2603, 943, 272, 570, 1072, 14, 339, 710, 1072, 1475, 365, 445, 91, 85, 14381, 521, 16649, 93, 8910, 2253, 11049, 469, 1430, 32201, 78, 6018, 2382, 26, 398, 446, 445, 91, 521, 16649, 93, 365, 9235, 701, 6358, 314, 1627, 445, 91, 908, 1366, 93, 4550, 881, 641, 314, 1566, 1159, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rightbraindev/asyncio-redis-cluster
asyncio_redis_cluster/cursors.py
2
2998
import asyncio from collections import deque __all__ = ( 'Cursor', 'DictCursor', 'SetCursor', 'ZCursor', ) class Cursor: """ Cursor for walking through the results of a :func:`scan <asyncio_redis.RedisProtocol.scan>` query. """ def __init__(self, name, scanfunc): self._queue = deque() self._cursor = 0 self._name = name self._scanfunc = scanfunc self._done = False def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self._name) @asyncio.coroutine def _fetch_more(self): """ Get next chunk of keys from Redis """ if not self._done: chunk = yield from self._scanfunc(self._cursor) self._cursor = chunk.new_cursor_pos if chunk.new_cursor_pos == 0: self._done = True for i in chunk.items: self._queue.append(i) @asyncio.coroutine def fetchone(self): """ Coroutines that returns the next item. It returns `None` after the last item. """ if not self._queue and not self._done: yield from self._fetch_more() if self._queue: return self._queue.popleft() @asyncio.coroutine def fetchall(self): """ Coroutine that reads all the items in one list. """ results = [] while True: i = yield from self.fetchone() if i is None: break else: results.append(i) return results class SetCursor(Cursor): """ Cursor for walking through the results of a :func:`sscan <asyncio_redis.RedisProtocol.sscan>` query. """ @asyncio.coroutine def fetchall(self): result = yield from super().fetchall() return set(result) class DictCursor(Cursor): """ Cursor for walking through the results of a :func:`hscan <asyncio_redis.RedisProtocol.hscan>` query. """ def _parse(self, key, value): return key, value @asyncio.coroutine def fetchone(self): """ Get next { key: value } tuple It returns `None` after the last item. """ key = yield from super().fetchone() value = yield from super().fetchone() if key is not None: key, value = self._parse(key, value) return { key: value } @asyncio.coroutine def fetchall(self): """ Coroutine that reads all the items in one dictionary. """ results = {} while True: i = yield from self.fetchone() if i is None: break else: results.update(i) return results class ZCursor(DictCursor): """ Cursor for walking through the results of a :func:`zscan <asyncio_redis.RedisProtocol.zscan>` query. """ def _parse(self, key, value): # Mapping { key: score_as_float } return key, float(value)
bsd-2-clause
[ 646, 16195, 199, 504, 5055, 492, 15782, 199, 199, 363, 452, 363, 275, 334, 272, 283, 8993, 297, 272, 283, 2141, 8993, 297, 272, 283, 1084, 8993, 297, 272, 283, 58, 8993, 297, 199, 9, 421, 199, 533, 20385, 26, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 6282, 8637, 1827, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 8000, 1532, 304, 267, 291, 423, 1825, 275, 15782, 342, 267, 291, 423, 3937, 275, 378, 267, 291, 423, 354, 275, 536, 267, 291, 423, 6282, 1532, 275, 8000, 1532, 267, 291, 423, 4456, 275, 756, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 18342, 83, 450, 83, 3524, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 354, 9, 339, 768, 19343, 14, 16675, 272, 347, 485, 3535, 63, 6878, 8, 277, 304, 267, 408, 2372, 2163, 3728, 402, 2883, 687, 25496, 408, 267, 340, 440, 291, 423, 4456, 26, 288, 3728, 275, 1995, 687, 291, 423, 6282, 1532, 8, 277, 423, 3937, 9, 288, 291, 423, 3937, 275, 3728, 14, 1222, 63, 3937, 63, 1712, 953, 340, 3728, 14, 1222, 63, 3937, 63, 1712, 508, 378, 26, 355, 291, 423, 4456, 275, 715, 953, 367, 284, 315, 3728, 14, 1744, 26, 355, 291, 423, 1825, 14, 740, 8, 73, 9, 339, 768, 19343, 14, 16675, 272, 347, 5267, 368, 8, 277, 304, 267, 408, 267, 7499, 548, 3746, 626, 2529, 314, 2163, 1242, 14, 267, 2779, 2529, 658, 403, 64, 2410, 314, 2061, 1242, 14, 267, 408, 267, 340, 440, 291, 423, 1825, 436, 440, 291, 423, 4456, 26, 288, 1995, 687, 291, 423, 3535, 63, 6878, 342, 398, 340, 291, 423, 1825, 26, 288, 372, 291, 423, 1825, 14, 25704, 342, 339, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 408, 7499, 13242, 626, 11597, 1006, 314, 2974, 315, 1373, 769, 14, 408, 267, 2058, 275, 942, 398, 1830, 715, 26, 288, 284, 275, 1995, 687, 291, 14, 11591, 342, 288, 340, 284, 365, 488, 26, 355, 2059, 288, 587, 26, 355, 2058, 14, 740, 8, 73, 9, 398, 372, 2058, 421, 199, 533, 2494, 8993, 8, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 385, 2425, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 385, 2425, 8637, 1827, 14, 272, 408, 272, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 754, 275, 1995, 687, 1613, 1252, 10174, 342, 267, 372, 663, 8, 1099, 9, 421, 199, 533, 7448, 8993, 8, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 72, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 72, 6282, 8637, 1827, 14, 272, 408, 272, 347, 485, 1122, 8, 277, 12, 790, 12, 574, 304, 267, 372, 790, 12, 574, 339, 768, 19343, 14, 16675, 272, 347, 5267, 368, 8, 277, 304, 267, 408, 267, 2372, 2163, 469, 790, 26, 574, 789, 2008, 267, 2779, 2529, 658, 403, 64, 2410, 314, 2061, 1242, 14, 267, 408, 267, 790, 275, 1995, 687, 1613, 1252, 11591, 342, 267, 574, 275, 1995, 687, 1613, 1252, 11591, 342, 398, 340, 790, 365, 440, 488, 26, 288, 790, 12, 574, 275, 291, 423, 1122, 8, 498, 12, 574, 9, 288, 372, 469, 790, 26, 574, 789, 339, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 408, 7499, 13242, 626, 11597, 1006, 314, 2974, 315, 1373, 2600, 14, 408, 267, 2058, 275, 1052, 398, 1830, 715, 26, 288, 284, 275, 1995, 687, 291, 14, 11591, 342, 288, 340, 284, 365, 488, 26, 355, 2059, 288, 587, 26, 355, 2058, 14, 873, 8, 73, 9, 398, 372, 2058, 421, 199, 533, 3107, 8993, 8, 2141, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 90, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 90, 6282, 8637, 1827, 14, 272, 408, 272, 347, 485, 1122, 8, 277, 12, 790, 12, 574, 304, 267, 327, 12340, 469, 790, 26, 5396, 63, 305, 63, 1609, 789, 267, 372, 790, 12, 2069, 8, 585, 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 ]
[ 16195, 199, 504, 5055, 492, 15782, 199, 199, 363, 452, 363, 275, 334, 272, 283, 8993, 297, 272, 283, 2141, 8993, 297, 272, 283, 1084, 8993, 297, 272, 283, 58, 8993, 297, 199, 9, 421, 199, 533, 20385, 26, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 6282, 8637, 1827, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 8000, 1532, 304, 267, 291, 423, 1825, 275, 15782, 342, 267, 291, 423, 3937, 275, 378, 267, 291, 423, 354, 275, 536, 267, 291, 423, 6282, 1532, 275, 8000, 1532, 267, 291, 423, 4456, 275, 756, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 18342, 83, 450, 83, 3524, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 354, 9, 339, 768, 19343, 14, 16675, 272, 347, 485, 3535, 63, 6878, 8, 277, 304, 267, 408, 2372, 2163, 3728, 402, 2883, 687, 25496, 408, 267, 340, 440, 291, 423, 4456, 26, 288, 3728, 275, 1995, 687, 291, 423, 6282, 1532, 8, 277, 423, 3937, 9, 288, 291, 423, 3937, 275, 3728, 14, 1222, 63, 3937, 63, 1712, 953, 340, 3728, 14, 1222, 63, 3937, 63, 1712, 508, 378, 26, 355, 291, 423, 4456, 275, 715, 953, 367, 284, 315, 3728, 14, 1744, 26, 355, 291, 423, 1825, 14, 740, 8, 73, 9, 339, 768, 19343, 14, 16675, 272, 347, 5267, 368, 8, 277, 304, 267, 408, 267, 7499, 548, 3746, 626, 2529, 314, 2163, 1242, 14, 267, 2779, 2529, 658, 403, 64, 2410, 314, 2061, 1242, 14, 267, 408, 267, 340, 440, 291, 423, 1825, 436, 440, 291, 423, 4456, 26, 288, 1995, 687, 291, 423, 3535, 63, 6878, 342, 398, 340, 291, 423, 1825, 26, 288, 372, 291, 423, 1825, 14, 25704, 342, 339, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 408, 7499, 13242, 626, 11597, 1006, 314, 2974, 315, 1373, 769, 14, 408, 267, 2058, 275, 942, 398, 1830, 715, 26, 288, 284, 275, 1995, 687, 291, 14, 11591, 342, 288, 340, 284, 365, 488, 26, 355, 2059, 288, 587, 26, 355, 2058, 14, 740, 8, 73, 9, 398, 372, 2058, 421, 199, 533, 2494, 8993, 8, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 385, 2425, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 385, 2425, 8637, 1827, 14, 272, 408, 272, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 754, 275, 1995, 687, 1613, 1252, 10174, 342, 267, 372, 663, 8, 1099, 9, 421, 199, 533, 7448, 8993, 8, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 72, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 72, 6282, 8637, 1827, 14, 272, 408, 272, 347, 485, 1122, 8, 277, 12, 790, 12, 574, 304, 267, 372, 790, 12, 574, 339, 768, 19343, 14, 16675, 272, 347, 5267, 368, 8, 277, 304, 267, 408, 267, 2372, 2163, 469, 790, 26, 574, 789, 2008, 267, 2779, 2529, 658, 403, 64, 2410, 314, 2061, 1242, 14, 267, 408, 267, 790, 275, 1995, 687, 1613, 1252, 11591, 342, 267, 574, 275, 1995, 687, 1613, 1252, 11591, 342, 398, 340, 790, 365, 440, 488, 26, 288, 790, 12, 574, 275, 291, 423, 1122, 8, 498, 12, 574, 9, 288, 372, 469, 790, 26, 574, 789, 339, 768, 19343, 14, 16675, 272, 347, 5267, 452, 8, 277, 304, 267, 408, 7499, 13242, 626, 11597, 1006, 314, 2974, 315, 1373, 2600, 14, 408, 267, 2058, 275, 1052, 398, 1830, 715, 26, 288, 284, 275, 1995, 687, 291, 14, 11591, 342, 288, 340, 284, 365, 488, 26, 355, 2059, 288, 587, 26, 355, 2058, 14, 873, 8, 73, 9, 398, 372, 2058, 421, 199, 533, 3107, 8993, 8, 2141, 8993, 304, 272, 408, 272, 20385, 367, 12778, 316, 4012, 314, 2058, 402, 282, 520, 1532, 1705, 90, 6282, 272, 665, 19343, 63, 15369, 14, 29605, 3658, 14, 90, 6282, 8637, 1827, 14, 272, 408, 272, 347, 485, 1122, 8, 277, 12, 790, 12, 574, 304, 267, 327, 12340, 469, 790, 26, 5396, 63, 305, 63, 1609, 789, 267, 372, 790, 12, 2069, 8, 585, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
googleapis/python-asset
scripts/readme-gen/readme_gen.py
122
1722
#!/usr/bin/env python # Copyright 2016 Google Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Generates READMEs using configuration defined in yaml.""" import argparse import io import os import subprocess import jinja2 import yaml jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) README_TMPL = jinja_env.get_template('README.tmpl.rst') def get_help(file): return subprocess.check_output(['python', file, '--help']).decode() def main(): parser = argparse.ArgumentParser() parser.add_argument('source') parser.add_argument('--destination', default='README.rst') args = parser.parse_args() source = os.path.abspath(args.source) root = os.path.dirname(source) destination = os.path.join(root, args.destination) jinja_env.globals['get_help'] = get_help with io.open(source, 'r') as f: config = yaml.load(f) # This allows get_help to execute in the right directory. os.chdir(root) output = README_TMPL.render(config) with io.open(destination, 'w') as f: f.write(output) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 7800, 4475, 3277, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 20551, 27781, 83, 1808, 2897, 3247, 315, 8864, 1041, 199, 199, 646, 7534, 199, 646, 5890, 199, 646, 747, 199, 646, 3873, 199, 199, 646, 10321, 18, 199, 646, 8864, 421, 199, 12264, 63, 1813, 275, 10321, 18, 14, 8263, 8, 272, 11639, 63, 4166, 29, 549, 12, 272, 5077, 29, 12264, 18, 14, 17521, 5455, 8, 267, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 31789, 199, 199, 18195, 63, 23719, 275, 10321, 63, 1813, 14, 362, 63, 1160, 360, 18195, 14, 11510, 14, 8332, 358, 421, 199, 318, 664, 63, 3437, 8, 493, 304, 272, 372, 3873, 14, 1074, 63, 1199, 2941, 1548, 297, 570, 12, 2850, 3437, 13227, 2708, 342, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 360, 1365, 358, 272, 1798, 14, 525, 63, 2094, 4517, 6881, 297, 849, 534, 18195, 14, 8332, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 1350, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1365, 9, 272, 1738, 275, 747, 14, 515, 14, 3475, 8, 1365, 9, 272, 5724, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 6881, 9, 339, 10321, 63, 1813, 14, 8473, 459, 362, 63, 3437, 418, 275, 664, 63, 3437, 339, 543, 5890, 14, 1490, 8, 1365, 12, 283, 82, 358, 465, 289, 26, 267, 1101, 275, 8864, 14, 912, 8, 70, 9, 339, 327, 961, 6127, 664, 63, 3437, 370, 5341, 315, 314, 2451, 2082, 14, 272, 747, 14, 8563, 8, 1231, 9, 339, 1072, 275, 27781, 63, 23719, 14, 3352, 8, 888, 9, 339, 543, 5890, 14, 1490, 8, 6881, 12, 283, 87, 358, 465, 289, 26, 267, 289, 14, 952, 8, 1199, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 7800, 4475, 3277, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 20551, 27781, 83, 1808, 2897, 3247, 315, 8864, 1041, 199, 199, 646, 7534, 199, 646, 5890, 199, 646, 747, 199, 646, 3873, 199, 199, 646, 10321, 18, 199, 646, 8864, 421, 199, 12264, 63, 1813, 275, 10321, 18, 14, 8263, 8, 272, 11639, 63, 4166, 29, 549, 12, 272, 5077, 29, 12264, 18, 14, 17521, 5455, 8, 267, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 31789, 199, 199, 18195, 63, 23719, 275, 10321, 63, 1813, 14, 362, 63, 1160, 360, 18195, 14, 11510, 14, 8332, 358, 421, 199, 318, 664, 63, 3437, 8, 493, 304, 272, 372, 3873, 14, 1074, 63, 1199, 2941, 1548, 297, 570, 12, 2850, 3437, 13227, 2708, 342, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 360, 1365, 358, 272, 1798, 14, 525, 63, 2094, 4517, 6881, 297, 849, 534, 18195, 14, 8332, 358, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 1350, 275, 747, 14, 515, 14, 4832, 8, 589, 14, 1365, 9, 272, 1738, 275, 747, 14, 515, 14, 3475, 8, 1365, 9, 272, 5724, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 6881, 9, 339, 10321, 63, 1813, 14, 8473, 459, 362, 63, 3437, 418, 275, 664, 63, 3437, 339, 543, 5890, 14, 1490, 8, 1365, 12, 283, 82, 358, 465, 289, 26, 267, 1101, 275, 8864, 14, 912, 8, 70, 9, 339, 327, 961, 6127, 664, 63, 3437, 370, 5341, 315, 314, 2451, 2082, 14, 272, 747, 14, 8563, 8, 1231, 9, 339, 1072, 275, 27781, 63, 23719, 14, 3352, 8, 888, 9, 339, 543, 5890, 14, 1490, 8, 6881, 12, 283, 87, 358, 465, 289, 26, 267, 289, 14, 952, 8, 1199, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bsmrstu-warriors/Moytri---The-Drone-Aider
Lib/keyword.py
179
1994
#! /usr/bin/env python """Keywords (from "graminit.c") This file is automatically generated; please don't muck it up! To update the symbols in this file, 'cd' to the top directory of the python source tree after building the interpreter and run: python Lib/keyword.py """ __all__ = ["iskeyword", "kwlist"] kwlist = [ #--start keywords-- 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield', #--end keywords-- ] iskeyword = frozenset(kwlist).__contains__ def main(): import sys, re args = sys.argv[1:] iptfile = args and args[0] or "Python/graminit.c" if len(args) > 1: optfile = args[1] else: optfile = "Lib/keyword.py" # scan the source file for keywords fp = open(iptfile) strprog = re.compile('"([^"]+)"') lines = [] for line in fp: if '{1, "' in line: match = strprog.search(line) if match: lines.append(" '" + match.group(1) + "',\n") fp.close() lines.sort() # load the output skeleton from the target fp = open(optfile) format = fp.readlines() fp.close() # insert the lines of keywords try: start = format.index("#--start keywords--\n") + 1 end = format.index("#--end keywords--\n") format[start:end] = lines except ValueError: sys.stderr.write("target does not contain format markers\n") sys.exit(1) # write the output file fp = open(optfile, 'w') fp.write(''.join(format)) fp.close() if __name__ == "__main__": main()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 23611, 334, 504, 298, 1679, 826, 14, 67, 531, 199, 199, 2765, 570, 365, 5847, 4046, 27, 8749, 2793, 1133, 8504, 346, 652, 1536, 1, 199, 199, 1378, 1678, 314, 6698, 315, 642, 570, 12, 283, 2866, 7, 370, 314, 2746, 2082, 402, 199, 1589, 2366, 1350, 3123, 2410, 10015, 314, 12693, 436, 1255, 26, 339, 2366, 8003, 15, 6691, 14, 647, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 374, 6691, 401, 298, 829, 513, 937, 199, 199, 829, 513, 275, 359, 199, 3, 306, 928, 7681, 306, 267, 283, 460, 297, 267, 283, 305, 297, 267, 283, 479, 297, 267, 283, 4785, 297, 267, 283, 533, 297, 267, 283, 6958, 297, 267, 283, 318, 297, 267, 283, 2264, 297, 267, 283, 4164, 297, 267, 283, 2836, 297, 267, 283, 2590, 297, 267, 283, 1628, 297, 267, 283, 15172, 297, 267, 283, 509, 297, 267, 283, 504, 297, 267, 283, 2966, 297, 267, 283, 692, 297, 267, 283, 646, 297, 267, 283, 262, 297, 267, 283, 374, 297, 267, 283, 2734, 297, 267, 283, 1397, 297, 267, 283, 269, 297, 267, 283, 1529, 297, 267, 283, 1361, 297, 267, 283, 3730, 297, 267, 283, 1107, 297, 267, 283, 893, 297, 267, 283, 6710, 297, 267, 283, 1045, 297, 267, 283, 11481, 297, 199, 3, 306, 500, 7681, 306, 267, 1622, 199, 199, 374, 6691, 275, 9522, 8, 829, 513, 2843, 6134, 363, 199, 199, 318, 2446, 837, 272, 492, 984, 12, 295, 339, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 24170, 493, 275, 1249, 436, 1249, 59, 16, 61, 503, 298, 4718, 15, 1679, 826, 14, 67, 2, 272, 340, 822, 8, 589, 9, 690, 413, 26, 2450, 493, 275, 1249, 59, 17, 61, 272, 587, 26, 2450, 493, 275, 298, 4728, 15, 6691, 14, 647, 2, 339, 327, 8000, 314, 1350, 570, 367, 7681, 272, 4090, 275, 1551, 8, 10432, 493, 9, 272, 620, 6595, 275, 295, 14, 2014, 14088, 15710, 20415, 358, 272, 2385, 275, 942, 272, 367, 1004, 315, 4090, 26, 267, 340, 5041, 17, 12, 3546, 315, 1004, 26, 288, 1336, 275, 620, 6595, 14, 1733, 8, 604, 9, 288, 340, 1336, 26, 355, 2385, 14, 740, 480, 263, 5522, 435, 1336, 14, 923, 8, 17, 9, 435, 298, 30989, 78, 531, 272, 4090, 14, 1600, 342, 272, 2385, 14, 3191, 342, 339, 327, 2248, 314, 1072, 30537, 687, 314, 1347, 272, 4090, 275, 1551, 8, 2992, 493, 9, 272, 1475, 275, 4090, 14, 9684, 342, 272, 4090, 14, 1600, 342, 339, 327, 5518, 314, 2385, 402, 7681, 272, 862, 26, 267, 1343, 275, 1475, 14, 1080, 10064, 306, 928, 7681, 306, 60, 78, 531, 435, 413, 267, 1284, 275, 1475, 14, 1080, 10064, 306, 500, 7681, 306, 60, 78, 531, 267, 1475, 59, 928, 26, 500, 61, 275, 2385, 272, 871, 1722, 26, 267, 984, 14, 3083, 14, 952, 480, 1375, 1630, 440, 1395, 1475, 14327, 60, 78, 531, 267, 984, 14, 2224, 8, 17, 9, 339, 327, 2218, 314, 1072, 570, 272, 4090, 275, 1551, 8, 2992, 493, 12, 283, 87, 358, 272, 4090, 14, 952, 17840, 904, 8, 908, 430, 272, 4090, 14, 1600, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 23611, 334, 504, 298, 1679, 826, 14, 67, 531, 199, 199, 2765, 570, 365, 5847, 4046, 27, 8749, 2793, 1133, 8504, 346, 652, 1536, 1, 199, 199, 1378, 1678, 314, 6698, 315, 642, 570, 12, 283, 2866, 7, 370, 314, 2746, 2082, 402, 199, 1589, 2366, 1350, 3123, 2410, 10015, 314, 12693, 436, 1255, 26, 339, 2366, 8003, 15, 6691, 14, 647, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 374, 6691, 401, 298, 829, 513, 937, 199, 199, 829, 513, 275, 359, 199, 3, 306, 928, 7681, 306, 267, 283, 460, 297, 267, 283, 305, 297, 267, 283, 479, 297, 267, 283, 4785, 297, 267, 283, 533, 297, 267, 283, 6958, 297, 267, 283, 318, 297, 267, 283, 2264, 297, 267, 283, 4164, 297, 267, 283, 2836, 297, 267, 283, 2590, 297, 267, 283, 1628, 297, 267, 283, 15172, 297, 267, 283, 509, 297, 267, 283, 504, 297, 267, 283, 2966, 297, 267, 283, 692, 297, 267, 283, 646, 297, 267, 283, 262, 297, 267, 283, 374, 297, 267, 283, 2734, 297, 267, 283, 1397, 297, 267, 283, 269, 297, 267, 283, 1529, 297, 267, 283, 1361, 297, 267, 283, 3730, 297, 267, 283, 1107, 297, 267, 283, 893, 297, 267, 283, 6710, 297, 267, 283, 1045, 297, 267, 283, 11481, 297, 199, 3, 306, 500, 7681, 306, 267, 1622, 199, 199, 374, 6691, 275, 9522, 8, 829, 513, 2843, 6134, 363, 199, 199, 318, 2446, 837, 272, 492, 984, 12, 295, 339, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 24170, 493, 275, 1249, 436, 1249, 59, 16, 61, 503, 298, 4718, 15, 1679, 826, 14, 67, 2, 272, 340, 822, 8, 589, 9, 690, 413, 26, 2450, 493, 275, 1249, 59, 17, 61, 272, 587, 26, 2450, 493, 275, 298, 4728, 15, 6691, 14, 647, 2, 339, 327, 8000, 314, 1350, 570, 367, 7681, 272, 4090, 275, 1551, 8, 10432, 493, 9, 272, 620, 6595, 275, 295, 14, 2014, 14088, 15710, 20415, 358, 272, 2385, 275, 942, 272, 367, 1004, 315, 4090, 26, 267, 340, 5041, 17, 12, 3546, 315, 1004, 26, 288, 1336, 275, 620, 6595, 14, 1733, 8, 604, 9, 288, 340, 1336, 26, 355, 2385, 14, 740, 480, 263, 5522, 435, 1336, 14, 923, 8, 17, 9, 435, 298, 30989, 78, 531, 272, 4090, 14, 1600, 342, 272, 2385, 14, 3191, 342, 339, 327, 2248, 314, 1072, 30537, 687, 314, 1347, 272, 4090, 275, 1551, 8, 2992, 493, 9, 272, 1475, 275, 4090, 14, 9684, 342, 272, 4090, 14, 1600, 342, 339, 327, 5518, 314, 2385, 402, 7681, 272, 862, 26, 267, 1343, 275, 1475, 14, 1080, 10064, 306, 928, 7681, 306, 60, 78, 531, 435, 413, 267, 1284, 275, 1475, 14, 1080, 10064, 306, 500, 7681, 306, 60, 78, 531, 267, 1475, 59, 928, 26, 500, 61, 275, 2385, 272, 871, 1722, 26, 267, 984, 14, 3083, 14, 952, 480, 1375, 1630, 440, 1395, 1475, 14327, 60, 78, 531, 267, 984, 14, 2224, 8, 17, 9, 339, 327, 2218, 314, 1072, 570, 272, 4090, 275, 1551, 8, 2992, 493, 12, 283, 87, 358, 272, 4090, 14, 952, 17840, 904, 8, 908, 430, 272, 4090, 14, 1600, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ghtmtt/QGIS
tests/src/python/test_qgis_local_server.py
45
6464
# -*- coding: utf-8 -*- """QGIS Unit tests for qgis_local_server.py Python test module From build dir: ctest -R PyQgsLocalServer -V Set the following env variables when manually running tests: QGIS_TEST_SUITE to run specific tests (define in __main__) QGIS_TEST_VERBOSE to output individual test summary QGIS_TEST_REPORT to open any failed image check reports in web browser .. note:: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. """ __author__ = 'Larry Shaffer' __date__ = '2014/02/16' __copyright__ = 'Copyright 2014, The QGIS Project' import os import sys import datetime if os.name == 'nt': print("TestQgisLocalServer currently doesn't support windows") sys.exit(0) from qgis.core import ( QgsRectangle, QgsCoordinateReferenceSystem, QgsRenderChecker ) from qgis_local_server import getLocalServer from qgis.testing import ( start_app, unittest ) from utilities import openInBrowserTab, getTempfilePath start_app() MAPSERV = getLocalServer() QGIS_TEST_REPORT = 'QGIS_TEST_REPORT' in os.environ TESTREPORTS = {} class TestQgisLocalServer(unittest.TestCase): @classmethod def setUpClass(cls): """Run before all tests""" # setup server controller class # verify controller can re-initialize processes and temp directory setup MAPSERV.startup() # should recreate tempdir msg = 'Server processes could not be restarted' assert MAPSERV.processes_running(), msg msg = 'Temp web directory could not be recreated' assert os.path.exists(MAPSERV.temp_dir()), msg # install test project components to temporary web directory test_proj_dir = os.path.join(MAPSERV.config_dir(), 'test-project') MAPSERV.web_dir_install(os.listdir(test_proj_dir), test_proj_dir) msg = 'Test project could not be re-copied to temp web directory' res = os.path.exists(os.path.join(MAPSERV.web_dir(), 'test-server.qgs')) assert res, msg # web server should be left running throughout fcgi tests @classmethod def tearDownClass(cls): """Run after all tests""" MAPSERV.shutdown() def setUp(self): """Run before each test.""" # web server stays up across all tests MAPSERV.fcgi_server_process().start() def tearDown(self): """Run after each test.""" # web server stays up across all tests MAPSERV.fcgi_server_process().stop() # @unittest.skip('') def test_convert_param_instances(self): params = dict() params['LAYERS'] = ['background', 'aoi'] params['BBOX'] = QgsRectangle(606510, 4823130, 612510, 4827130) # creating crs needs QGISAPP instance to access resources/srs.db # WGS 84 / UTM zone 13N params['CRS'] = QgsCoordinateReferenceSystem( 32613, QgsCoordinateReferenceSystem.EpsgCrsId) params_p = MAPSERV.process_params(params) # print repr(params_p) param_lyrs = 'LAYERS=background%2Caoi' param_crs = 'CRS=EPSG%3A32613' param_bbx = 'BBOX=606510%2C4823130%2C612510%2C4827130' msg = '\nParameter instances could not be converted' assert (param_lyrs in params_p and param_crs in params_p and param_bbx in params_p), msg # @unittest.skip('') def test_getmap(self): test_name = 'qgis_local_server' success, img_path, url = MAPSERV.get_map(self.getmap_params()) msg = '\nLocal server get_map failed' assert success, msg chk = QgsRenderChecker() chk.setControlName('expected_' + test_name) # chk.setMapRenderer(None) res = chk.compareImages(test_name, 0, img_path) if QGIS_TEST_REPORT and not res: # don't report OK checks TESTREPORTS[test_name] = chk.report() msg = '\nRender check failed for "{0}"'.format(test_name) assert res, msg def getmap_params(self): return { 'SERVICE': 'WMS', 'VERSION': '1.3.0', 'REQUEST': 'GetMap', # 'MAP': abs path, also looks in localserver.web_dir() 'MAP': 'test-server.qgs', # layer stacking order for rendering: bottom, to, top 'LAYERS': ['background', 'aoi'], # or 'background,aoi' 'STYLES': ',', 'CRS': 'EPSG:32613', # or QgsCoordinateReferenceSystem obj 'BBOX': '606510,4823130,612510,4827130', # or QgsRectangle obj 'FORMAT': 'image/png', # or: 'image/png; mode=8bit' 'WIDTH': '600', 'HEIGHT': '400', 'DPI': '72', 'MAP_RESOLUTION': '72', 'FORMAT_OPTIONS': 'dpi:72', 'TRANSPARENT': 'FALSE', 'IgnoreGetMapUrl': '1' } def run_suite(module, tests): """This allows for a list of test names to be selectively run. Also, ensures unittest verbose output comes at end, after debug output""" loader = unittest.defaultTestLoader if 'QGIS_TEST_SUITE' in os.environ and tests: suite = loader.loadTestsFromNames(tests, module) else: suite = loader.loadTestsFromModule(module) verb = 2 if 'QGIS_TEST_VERBOSE' in os.environ else 0 res = unittest.TextTestRunner(verbosity=verb).run(suite) if QGIS_TEST_REPORT and len(TESTREPORTS) > 0: teststamp = 'Local Server Test Report: ' + \ datetime.datetime.now().strftime('%Y-%m-%d %X') report = '<html><head><title>{0}</title></head><body>'.format(teststamp) report += '\n<h2>Failed Image Tests: {0}</h2>'.format(len(TESTREPORTS)) for k, v in list(TESTREPORTS.items()): report += '\n<h3>{0}</h3>\n{1}'.format(k, v) report += '</body></html>' tmp_name = getTempfilePath("html") with open(tmp_name, 'wb') as temp_file: temp_file.write(report) openInBrowserTab('file://' + tmp_name) return res if __name__ == '__main__': # NOTE: unless QGIS_TEST_SUITE env var is set all tests will be run test_suite = [ 'TestQgisLocalServer.test_getmap' ] test_res = run_suite(sys.modules[__name__], test_suite) sys.exit(not test_res.wasSuccessful())
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 15640, 63, 1832, 63, 1000, 14, 647, 2018, 511, 859, 199, 199, 2532, 1900, 2935, 26, 286, 396, 446, 50, 1611, 7350, 5339, 3120, 446, 54, 199, 1084, 314, 2569, 2589, 2860, 1380, 10250, 3879, 2295, 26, 523, 27024, 63, 2864, 63, 6195, 4427, 370, 1255, 2488, 2295, 334, 4640, 315, 636, 973, 3368, 523, 27024, 63, 2864, 63, 16075, 370, 1072, 8212, 511, 6212, 523, 27024, 63, 2864, 63, 17356, 370, 1551, 1263, 3405, 1834, 1104, 13924, 315, 3330, 7042, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 44, 285, 651, 428, 2411, 1260, 7, 199, 363, 602, 363, 275, 283, 7280, 15, 996, 15, 975, 7, 199, 363, 7307, 363, 275, 283, 7384, 6927, 12, 710, 27024, 7290, 7, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2197, 199, 199, 692, 747, 14, 354, 508, 283, 343, 356, 272, 870, 480, 774, 49, 5668, 5339, 3120, 5544, 3181, 1133, 2291, 10061, 531, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 504, 15640, 14, 1018, 492, 334, 272, 4888, 18127, 12, 272, 4888, 18017, 5083, 3989, 12, 272, 4888, 9216, 3048, 199, 9, 199, 199, 504, 15640, 63, 1832, 63, 1000, 492, 664, 5339, 3120, 199, 199, 504, 15640, 14, 4776, 492, 334, 272, 1343, 63, 571, 12, 272, 2882, 199, 9, 199, 199, 504, 15841, 492, 1551, 607, 11930, 7690, 12, 664, 6530, 27501, 199, 199, 928, 63, 571, 342, 199, 5443, 3279, 54, 275, 664, 5339, 3120, 342, 199, 199, 31329, 63, 2864, 63, 17356, 275, 283, 31329, 63, 2864, 63, 17356, 7, 315, 747, 14, 2314, 199, 2864, 17356, 51, 275, 1052, 421, 199, 533, 1379, 49, 5668, 5339, 3120, 8, 2796, 14, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2540, 2544, 1006, 2295, 624, 267, 327, 3272, 1654, 7614, 1021, 398, 327, 4911, 7614, 883, 295, 13, 8489, 10358, 436, 2388, 2082, 3272, 267, 603, 1282, 3279, 54, 14, 16480, 342, 221, 327, 1077, 23959, 21628, 267, 1499, 275, 283, 3120, 10358, 4293, 440, 506, 32277, 7, 267, 702, 603, 1282, 3279, 54, 14, 11816, 63, 5720, 1062, 1499, 398, 1499, 275, 283, 6530, 3330, 2082, 4293, 440, 506, 295, 3966, 7, 267, 702, 747, 14, 515, 14, 2444, 8, 5443, 3279, 54, 14, 808, 63, 694, 4000, 1499, 398, 327, 3907, 511, 2199, 7323, 370, 7937, 3330, 2082, 267, 511, 63, 5468, 63, 694, 275, 747, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 888, 63, 694, 1062, 283, 396, 13, 1715, 358, 267, 603, 1282, 3279, 54, 14, 2520, 63, 694, 63, 3174, 8, 736, 14, 7374, 8, 396, 63, 5468, 63, 694, 395, 511, 63, 5468, 63, 694, 9, 267, 1499, 275, 283, 774, 2199, 4293, 440, 506, 295, 13, 23581, 370, 2388, 3330, 2082, 7, 267, 522, 275, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 2520, 63, 694, 1062, 5101, 283, 396, 13, 1000, 14, 81, 458, 1333, 267, 702, 522, 12, 1499, 398, 327, 3330, 1654, 1077, 506, 3602, 3879, 23088, 10821, 6153, 2295, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 603, 1282, 3279, 54, 14, 8831, 342, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 2540, 2410, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 2379, 342, 339, 327, 768, 2796, 14, 2759, 8355, 272, 347, 511, 63, 3916, 63, 635, 63, 5990, 8, 277, 304, 267, 1862, 275, 1211, 342, 267, 1862, 459, 16897, 3960, 418, 275, 788, 7451, 297, 283, 8035, 73, 418, 267, 1862, 459, 34, 15694, 418, 275, 4888, 18127, 8, 16220, 27161, 12, 9615, 1789, 9056, 12, 1227, 6889, 709, 12, 9615, 1465, 9056, 9, 267, 327, 6425, 32313, 4839, 27024, 7121, 1256, 370, 2879, 5944, 15, 12722, 14, 697, 267, 327, 644, 8021, 8264, 1182, 738, 20690, 5718, 4944, 46, 267, 1862, 459, 2944, 51, 418, 275, 4888, 18017, 5083, 3989, 8, 288, 650, 1479, 969, 12, 4888, 18017, 5083, 3989, 14, 37, 1190, 71, 35, 2393, 1304, 9, 267, 1862, 63, 80, 275, 603, 1282, 3279, 54, 14, 1412, 63, 1162, 8, 1162, 9, 267, 327, 870, 4700, 8, 1162, 63, 80, 9, 267, 1215, 63, 590, 2393, 275, 283, 16897, 3960, 29, 7451, 5, 18, 3630, 16142, 7, 267, 1215, 63, 19034, 275, 283, 2944, 51, 29, 19672, 5, 19, 33, 8342, 969, 7, 267, 1215, 63, 2501, 88, 275, 283, 34, 15694, 29, 16220, 27161, 5, 18, 35, 2006, 1789, 9056, 5, 18, 35, 22, 6889, 709, 5, 18, 35, 2006, 1465, 9056, 7, 267, 1499, 275, 1557, 78, 4720, 4454, 4293, 440, 506, 6702, 7, 267, 702, 334, 635, 63, 590, 2393, 315, 1862, 63, 80, 436, 355, 1215, 63, 19034, 315, 1862, 63, 80, 436, 355, 1215, 63, 2501, 88, 315, 1862, 63, 80, 395, 1499, 339, 327, 768, 2796, 14, 2759, 8355, 272, 347, 511, 63, 362, 1130, 8, 277, 304, 267, 511, 63, 354, 275, 283, 25325, 63, 1832, 63, 1000, 7, 267, 3182, 12, 6050, 63, 515, 12, 1166, 275, 603, 1282, 3279, 54, 14, 362, 63, 1130, 8, 277, 14, 362, 1130, 63, 1162, 1012, 267, 1499, 275, 1557, 78, 5339, 1654, 664, 63, 1130, 3405, 7, 267, 702, 3182, 12, 1499, 398, 26979, 275, 4888, 9216, 3048, 342, 267, 26979, 14, 409, 3717, 985, 360, 2062, 8650, 435, 511, 63, 354, 9, 267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 15640, 63, 1832, 63, 1000, 14, 647, 2018, 511, 859, 199, 199, 2532, 1900, 2935, 26, 286, 396, 446, 50, 1611, 7350, 5339, 3120, 446, 54, 199, 1084, 314, 2569, 2589, 2860, 1380, 10250, 3879, 2295, 26, 523, 27024, 63, 2864, 63, 6195, 4427, 370, 1255, 2488, 2295, 334, 4640, 315, 636, 973, 3368, 523, 27024, 63, 2864, 63, 16075, 370, 1072, 8212, 511, 6212, 523, 27024, 63, 2864, 63, 17356, 370, 1551, 1263, 3405, 1834, 1104, 13924, 315, 3330, 7042, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 44, 285, 651, 428, 2411, 1260, 7, 199, 363, 602, 363, 275, 283, 7280, 15, 996, 15, 975, 7, 199, 363, 7307, 363, 275, 283, 7384, 6927, 12, 710, 27024, 7290, 7, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2197, 199, 199, 692, 747, 14, 354, 508, 283, 343, 356, 272, 870, 480, 774, 49, 5668, 5339, 3120, 5544, 3181, 1133, 2291, 10061, 531, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 504, 15640, 14, 1018, 492, 334, 272, 4888, 18127, 12, 272, 4888, 18017, 5083, 3989, 12, 272, 4888, 9216, 3048, 199, 9, 199, 199, 504, 15640, 63, 1832, 63, 1000, 492, 664, 5339, 3120, 199, 199, 504, 15640, 14, 4776, 492, 334, 272, 1343, 63, 571, 12, 272, 2882, 199, 9, 199, 199, 504, 15841, 492, 1551, 607, 11930, 7690, 12, 664, 6530, 27501, 199, 199, 928, 63, 571, 342, 199, 5443, 3279, 54, 275, 664, 5339, 3120, 342, 199, 199, 31329, 63, 2864, 63, 17356, 275, 283, 31329, 63, 2864, 63, 17356, 7, 315, 747, 14, 2314, 199, 2864, 17356, 51, 275, 1052, 421, 199, 533, 1379, 49, 5668, 5339, 3120, 8, 2796, 14, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2540, 2544, 1006, 2295, 624, 267, 327, 3272, 1654, 7614, 1021, 398, 327, 4911, 7614, 883, 295, 13, 8489, 10358, 436, 2388, 2082, 3272, 267, 603, 1282, 3279, 54, 14, 16480, 342, 221, 327, 1077, 23959, 21628, 267, 1499, 275, 283, 3120, 10358, 4293, 440, 506, 32277, 7, 267, 702, 603, 1282, 3279, 54, 14, 11816, 63, 5720, 1062, 1499, 398, 1499, 275, 283, 6530, 3330, 2082, 4293, 440, 506, 295, 3966, 7, 267, 702, 747, 14, 515, 14, 2444, 8, 5443, 3279, 54, 14, 808, 63, 694, 4000, 1499, 398, 327, 3907, 511, 2199, 7323, 370, 7937, 3330, 2082, 267, 511, 63, 5468, 63, 694, 275, 747, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 888, 63, 694, 1062, 283, 396, 13, 1715, 358, 267, 603, 1282, 3279, 54, 14, 2520, 63, 694, 63, 3174, 8, 736, 14, 7374, 8, 396, 63, 5468, 63, 694, 395, 511, 63, 5468, 63, 694, 9, 267, 1499, 275, 283, 774, 2199, 4293, 440, 506, 295, 13, 23581, 370, 2388, 3330, 2082, 7, 267, 522, 275, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 2520, 63, 694, 1062, 5101, 283, 396, 13, 1000, 14, 81, 458, 1333, 267, 702, 522, 12, 1499, 398, 327, 3330, 1654, 1077, 506, 3602, 3879, 23088, 10821, 6153, 2295, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 603, 1282, 3279, 54, 14, 8831, 342, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 2540, 2410, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 2379, 342, 339, 327, 768, 2796, 14, 2759, 8355, 272, 347, 511, 63, 3916, 63, 635, 63, 5990, 8, 277, 304, 267, 1862, 275, 1211, 342, 267, 1862, 459, 16897, 3960, 418, 275, 788, 7451, 297, 283, 8035, 73, 418, 267, 1862, 459, 34, 15694, 418, 275, 4888, 18127, 8, 16220, 27161, 12, 9615, 1789, 9056, 12, 1227, 6889, 709, 12, 9615, 1465, 9056, 9, 267, 327, 6425, 32313, 4839, 27024, 7121, 1256, 370, 2879, 5944, 15, 12722, 14, 697, 267, 327, 644, 8021, 8264, 1182, 738, 20690, 5718, 4944, 46, 267, 1862, 459, 2944, 51, 418, 275, 4888, 18017, 5083, 3989, 8, 288, 650, 1479, 969, 12, 4888, 18017, 5083, 3989, 14, 37, 1190, 71, 35, 2393, 1304, 9, 267, 1862, 63, 80, 275, 603, 1282, 3279, 54, 14, 1412, 63, 1162, 8, 1162, 9, 267, 327, 870, 4700, 8, 1162, 63, 80, 9, 267, 1215, 63, 590, 2393, 275, 283, 16897, 3960, 29, 7451, 5, 18, 3630, 16142, 7, 267, 1215, 63, 19034, 275, 283, 2944, 51, 29, 19672, 5, 19, 33, 8342, 969, 7, 267, 1215, 63, 2501, 88, 275, 283, 34, 15694, 29, 16220, 27161, 5, 18, 35, 2006, 1789, 9056, 5, 18, 35, 22, 6889, 709, 5, 18, 35, 2006, 1465, 9056, 7, 267, 1499, 275, 1557, 78, 4720, 4454, 4293, 440, 506, 6702, 7, 267, 702, 334, 635, 63, 590, 2393, 315, 1862, 63, 80, 436, 355, 1215, 63, 19034, 315, 1862, 63, 80, 436, 355, 1215, 63, 2501, 88, 315, 1862, 63, 80, 395, 1499, 339, 327, 768, 2796, 14, 2759, 8355, 272, 347, 511, 63, 362, 1130, 8, 277, 304, 267, 511, 63, 354, 275, 283, 25325, 63, 1832, 63, 1000, 7, 267, 3182, 12, 6050, 63, 515, 12, 1166, 275, 603, 1282, 3279, 54, 14, 362, 63, 1130, 8, 277, 14, 362, 1130, 63, 1162, 1012, 267, 1499, 275, 1557, 78, 5339, 1654, 664, 63, 1130, 3405, 7, 267, 702, 3182, 12, 1499, 398, 26979, 275, 4888, 9216, 3048, 342, 267, 26979, 14, 409, 3717, 985, 360, 2062, 8650, 435, 511, 63, 354, 9, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
spadae22/odoo
addons/account/tests/test_tax.py
449
1740
from openerp.tests.common import TransactionCase class TestTax(TransactionCase): """Tests for taxes (account.tax) We don't really need at this point to link taxes to tax codes (account.tax.code) nor to companies (base.company) to check computation results. """ def setUp(self): super(TestTax, self).setUp() self.tax_model = self.registry('account.tax') def test_programmatic_tax(self): cr, uid = self.cr, self.uid tax_id = self.tax_model.create(cr, uid, dict( name="Programmatic tax", type='code', python_compute='result = 12.0', python_compute_inv='result = 11.0', )) tax_records = self.tax_model.browse(cr, uid, [tax_id]) res = self.tax_model.compute_all(cr, uid, tax_records, 50.0, 2) tax_detail = res['taxes'][0] self.assertEquals(tax_detail['amount'], 24.0) self.assertEquals(res['total_included'], 124.0) def test_percent_tax(self): """Test computations done by a 10 percent tax.""" cr, uid = self.cr, self.uid tax_id = self.tax_model.create(cr, uid, dict( name="Percent tax", type='percent', amount='0.1', )) tax_records = self.tax_model.browse(cr, uid, [tax_id]) res = self.tax_model.compute_all(cr, uid, tax_records, 50.0, 2) tax_detail = res['taxes'][0] self.assertEquals(tax_detail['amount'], 10.0) self.assertEquals(res['total_included'], 110.0) # now the inverse computation res = self.tax_model.compute_inv(cr, uid, tax_records, 55.0, 2) self.assertEquals(res[0]['amount'], 10.0)
agpl-3.0
[ 504, 5166, 14, 2219, 14, 2330, 492, 18244, 1538, 199, 199, 533, 1379, 26019, 8, 10161, 1538, 304, 272, 408, 2925, 367, 21139, 334, 2048, 14, 5530, 9, 339, 2136, 2793, 1133, 7710, 1929, 737, 642, 2376, 370, 2142, 21139, 370, 9067, 9479, 272, 334, 2048, 14, 5530, 14, 600, 9, 6590, 370, 1013, 23461, 334, 1095, 14, 4627, 9, 370, 1104, 14009, 272, 2058, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 26019, 12, 291, 680, 5996, 342, 267, 291, 14, 5530, 63, 1238, 275, 291, 14, 5189, 360, 2048, 14, 5530, 358, 339, 347, 511, 63, 6815, 3889, 63, 5530, 8, 277, 304, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 9067, 63, 344, 275, 291, 14, 5530, 63, 1238, 14, 981, 8, 1556, 12, 1747, 12, 1211, 8, 355, 536, 628, 9184, 3889, 9067, 401, 355, 730, 534, 600, 297, 355, 2366, 63, 3357, 534, 1099, 275, 3144, 14, 16, 297, 355, 2366, 63, 3357, 63, 5350, 534, 1099, 275, 4119, 14, 16, 297, 355, 5082, 398, 9067, 63, 6502, 275, 291, 14, 5530, 63, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 359, 5530, 63, 344, 566, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 452, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 5238, 14, 16, 12, 499, 9, 398, 9067, 63, 5506, 275, 522, 459, 22272, 3488, 16, 61, 267, 291, 14, 2947, 8, 5530, 63, 5506, 459, 4606, 995, 5504, 14, 16, 9, 267, 291, 14, 2947, 8, 470, 459, 2923, 63, 12409, 995, 25442, 14, 16, 9, 339, 347, 511, 63, 7045, 63, 5530, 8, 277, 304, 267, 408, 774, 28319, 1298, 4224, 701, 282, 1616, 8878, 9067, 1041, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 9067, 63, 344, 275, 291, 14, 5530, 63, 1238, 14, 981, 8, 1556, 12, 1747, 12, 1211, 8, 355, 536, 628, 17931, 9067, 401, 355, 730, 534, 7045, 297, 355, 5982, 534, 16, 14, 17, 297, 355, 5082, 398, 9067, 63, 6502, 275, 291, 14, 5530, 63, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 359, 5530, 63, 344, 566, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 452, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 5238, 14, 16, 12, 499, 9, 398, 9067, 63, 5506, 275, 522, 459, 22272, 3488, 16, 61, 267, 291, 14, 2947, 8, 5530, 63, 5506, 459, 4606, 995, 1616, 14, 16, 9, 267, 291, 14, 2947, 8, 470, 459, 2923, 63, 12409, 995, 16814, 14, 16, 9, 398, 327, 3063, 314, 11484, 14009, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 5350, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 12766, 14, 16, 12, 499, 9, 267, 291, 14, 2947, 8, 470, 59, 16, 2733, 4606, 995, 1616, 14, 16, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5166, 14, 2219, 14, 2330, 492, 18244, 1538, 199, 199, 533, 1379, 26019, 8, 10161, 1538, 304, 272, 408, 2925, 367, 21139, 334, 2048, 14, 5530, 9, 339, 2136, 2793, 1133, 7710, 1929, 737, 642, 2376, 370, 2142, 21139, 370, 9067, 9479, 272, 334, 2048, 14, 5530, 14, 600, 9, 6590, 370, 1013, 23461, 334, 1095, 14, 4627, 9, 370, 1104, 14009, 272, 2058, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 26019, 12, 291, 680, 5996, 342, 267, 291, 14, 5530, 63, 1238, 275, 291, 14, 5189, 360, 2048, 14, 5530, 358, 339, 347, 511, 63, 6815, 3889, 63, 5530, 8, 277, 304, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 9067, 63, 344, 275, 291, 14, 5530, 63, 1238, 14, 981, 8, 1556, 12, 1747, 12, 1211, 8, 355, 536, 628, 9184, 3889, 9067, 401, 355, 730, 534, 600, 297, 355, 2366, 63, 3357, 534, 1099, 275, 3144, 14, 16, 297, 355, 2366, 63, 3357, 63, 5350, 534, 1099, 275, 4119, 14, 16, 297, 355, 5082, 398, 9067, 63, 6502, 275, 291, 14, 5530, 63, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 359, 5530, 63, 344, 566, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 452, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 5238, 14, 16, 12, 499, 9, 398, 9067, 63, 5506, 275, 522, 459, 22272, 3488, 16, 61, 267, 291, 14, 2947, 8, 5530, 63, 5506, 459, 4606, 995, 5504, 14, 16, 9, 267, 291, 14, 2947, 8, 470, 459, 2923, 63, 12409, 995, 25442, 14, 16, 9, 339, 347, 511, 63, 7045, 63, 5530, 8, 277, 304, 267, 408, 774, 28319, 1298, 4224, 701, 282, 1616, 8878, 9067, 1041, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 9067, 63, 344, 275, 291, 14, 5530, 63, 1238, 14, 981, 8, 1556, 12, 1747, 12, 1211, 8, 355, 536, 628, 17931, 9067, 401, 355, 730, 534, 7045, 297, 355, 5982, 534, 16, 14, 17, 297, 355, 5082, 398, 9067, 63, 6502, 275, 291, 14, 5530, 63, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 359, 5530, 63, 344, 566, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 452, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 5238, 14, 16, 12, 499, 9, 398, 9067, 63, 5506, 275, 522, 459, 22272, 3488, 16, 61, 267, 291, 14, 2947, 8, 5530, 63, 5506, 459, 4606, 995, 1616, 14, 16, 9, 267, 291, 14, 2947, 8, 470, 459, 2923, 63, 12409, 995, 16814, 14, 16, 9, 398, 327, 3063, 314, 11484, 14009, 267, 522, 275, 291, 14, 5530, 63, 1238, 14, 3357, 63, 5350, 8, 1556, 12, 1747, 12, 9067, 63, 6502, 12, 12766, 14, 16, 12, 499, 9, 267, 291, 14, 2947, 8, 470, 59, 16, 2733, 4606, 995, 1616, 14, 16, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
kbrebanov/ansible
lib/ansible/modules/network/cloudengine/ce_vrf.py
22
10873
#!/usr/bin/python # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ce_vrf version_added: "2.4" short_description: Manages VPN instance on HUAWEI CloudEngine switches. description: - Manages VPN instance of HUAWEI CloudEngine switches. author: Yang yang (@CloudEngine-Ansible) notes: - If I(state=absent), the route will be removed, regardless of the non-required options. options: vrf: description: - VPN instance, the length of vrf name is 1 - 31, i.e. "test", but can not be C(_public_). required: true description: description: - Description of the vrf, the string length is 1 - 242 . required: false default: null state: description: - Manage the state of the resource. required: false choices: ['present','absent'] default: present ''' EXAMPLES = ''' - name: vrf module test hosts: cloudengine connection: local gather_facts: no vars: cli: host: "{{ inventory_hostname }}" port: "{{ ansible_ssh_port }}" username: "{{ username }}" password: "{{ password }}" transport: cli tasks: - name: Config a vpn install named vpna, description is test ce_vrf: vrf: vpna description: test state: present provider: "{{ cli }}" - name: Delete a vpn install named vpna ce_vrf: vrf: vpna state: absent provider: "{{ cli }}" ''' RETURN = ''' proposed: description: k/v pairs of parameters passed into module returned: always type: dict sample: {"vrf": "vpna", "description": "test", "state": "present"} existing: description: k/v pairs of existing switchport returned: always type: dict sample: {} end_state: description: k/v pairs of switchport after module execution returned: always type: dict sample: {"vrf": "vpna", "description": "test", "present": "present"} updates: description: command list sent to the device returned: always type: list sample: ["ip vpn-instance vpna", "description test"] changed: description: check to see if a change was made on the device returned: always type: boolean sample: true ''' from xml.etree import ElementTree from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.cloudengine.ce import get_nc_config, set_nc_config, ce_argument_spec CE_NC_GET_VRF = """ <filter type="subtree"> <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance> <vrfName></vrfName> <vrfDescription></vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> </filter> """ CE_NC_CREATE_VRF = """ <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance operation="merge"> <vrfName>%s</vrfName> <vrfDescription>%s</vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> """ CE_NC_DELETE_VRF = """ <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance operation="delete"> <vrfName>%s</vrfName> <vrfDescription>%s</vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> """ def build_config_xml(xmlstr): """build_config_xml""" return '<config> ' + xmlstr + ' </config>' class Vrf(object): """Manange vpn instance""" def __init__(self, argument_spec, ): self.spec = argument_spec self.module = None self.init_module() # vpn instance info self.vrf = self.module.params['vrf'] self.description = self.module.params['description'] self.state = self.module.params['state'] # state self.changed = False self.updates_cmd = list() self.results = dict() self.proposed = dict() self.existing = dict() self.end_state = dict() def init_module(self): """init_module""" self.module = AnsibleModule( argument_spec=self.spec, supports_check_mode=True) def check_response(self, xml_str, xml_name): """Check if response message is already succeed.""" if "<ok/>" not in xml_str: self.module.fail_json(msg='Error: %s failed.' % xml_name) def set_update_cmd(self): """ set update command""" if not self.changed: return if self.state == "present": self.updates_cmd.append('ip vpn-instance %s' % (self.vrf)) if self.description: self.updates_cmd.append('description %s' % (self.description)) else: self.updates_cmd.append('undo ip vpn-instance %s' % (self.vrf)) def get_vrf(self): """ check if vrf is need to change""" getxmlstr = CE_NC_GET_VRF xml_str = get_nc_config(self.module, getxmlstr) xml_str = xml_str.replace('\r', '').replace('\n', '').\ replace('xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"', "").\ replace('xmlns="http://www.huawei.com/netconf/vrp"', "") root = ElementTree.fromstring(xml_str) vpn_instances = root.findall( "data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") if vpn_instances: for vpn_instance in vpn_instances: if vpn_instance.find('vrfName').text == self.vrf: if vpn_instance.find('vrfDescription').text == self.description: if self.state == "present": return False else: return True else: return True return self.state == "present" else: return self.state == "present" def check_params(self): """Check all input params""" # vrf and description check if self.vrf == '_public_': self.module.fail_json( msg='Error: The vrf name _public_ is reserved.') if len(self.vrf) < 1 or len(self.vrf) > 31: self.module.fail_json( msg='Error: The vrf name length must between 1 and 242.') if self.description: if len(self.description) < 1 or len(self.description) > 242: self.module.fail_json( msg='Error: The vrf description length must between 1 and 242.') def operate_vrf(self): """config/delete vrf""" if not self.changed: return if self.state == "present": if self.description is None: configxmlstr = CE_NC_CREATE_VRF % (self.vrf, '') else: configxmlstr = CE_NC_CREATE_VRF % (self.vrf, self.description) else: configxmlstr = CE_NC_DELETE_VRF % (self.vrf, self.description) conf_str = build_config_xml(configxmlstr) recv_xml = set_nc_config(self.module, conf_str) self.check_response(recv_xml, "OPERATE_VRF") def get_proposed(self): """get_proposed""" if self.state == 'present': self.proposed['vrf'] = self.vrf if self.description: self.proposed['description'] = self.description else: self.proposed = dict() self.proposed['state'] = self.state def get_existing(self): """get_existing""" change = self.get_vrf() if change: if self.state == 'present': self.existing = dict() else: self.existing['vrf'] = self.vrf if self.description: self.existing['description'] = self.description self.changed = True else: if self.state == 'absent': self.existing = dict() else: self.existing['vrf'] = self.vrf if self.description: self.existing['description'] = self.description self.changed = False def get_end_state(self): """get_end_state""" change = self.get_vrf() if not change: if self.state == 'present': self.end_state['vrf'] = self.vrf if self.description: self.end_state['description'] = self.description else: self.end_state = dict() else: if self.state == 'present': self.end_state = dict() else: self.end_state['vrf'] = self.vrf if self.description: self.end_state['description'] = self.description def work(self): """worker""" self.check_params() self.get_existing() self.get_proposed() self.operate_vrf() self.set_update_cmd() self.get_end_state() self.results['changed'] = self.changed self.results['proposed'] = self.proposed self.results['existing'] = self.existing self.results['end_state'] = self.end_state if self.changed: self.results['updates'] = self.updates_cmd else: self.results['updates'] = list() self.module.exit_json(**self.results) def main(): """main""" argument_spec = dict( vrf=dict(required=True, type='str'), description=dict(required=False, type='str'), state=dict(choices=['absent', 'present'], default='present', required=False), ) argument_spec.update(ce_argument_spec) interface = Vrf(argument_spec) interface.work() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 10142, 63, 11863, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 29057, 1256, 641, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 1802, 26, 272, 446, 21612, 29057, 1256, 402, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 2502, 26, 1488, 621, 31193, 8593, 9089, 8524, 13, 10047, 9, 199, 5983, 26, 272, 446, 982, 473, 8, 929, 29, 5575, 395, 314, 7475, 911, 506, 4829, 12, 15270, 402, 314, 489, 2222, 13, 2427, 1511, 14, 199, 1419, 26, 272, 15209, 26, 267, 1369, 26, 288, 446, 29057, 1256, 12, 314, 2582, 402, 15209, 536, 365, 413, 446, 7105, 12, 284, 14, 69, 14, 298, 396, 401, 1325, 883, 440, 506, 445, 1547, 3455, 63, 680, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 314, 15209, 12, 314, 1059, 2582, 365, 413, 446, 499, 2260, 1275, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 14944, 314, 1174, 402, 314, 2073, 14, 267, 1415, 26, 3055, 267, 3415, 26, 788, 1881, 1673, 5575, 418, 267, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 15209, 859, 511, 523, 7057, 26, 2463, 85, 848, 2598, 523, 1950, 26, 2257, 523, 13082, 63, 5047, 26, 949, 523, 6802, 26, 272, 5053, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 7820, 489, 1844, 26, 7370, 3242, 63, 5510, 63, 719, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 7773, 26, 5053, 819, 6527, 26, 819, 446, 536, 26, 4094, 282, 15978, 3907, 4310, 373, 80, 3540, 12, 1369, 365, 511, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1369, 26, 511, 489, 1174, 26, 3451, 489, 5022, 26, 7370, 5053, 7820, 523, 446, 536, 26, 8496, 282, 15978, 3907, 4310, 373, 80, 3540, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1174, 26, 9552, 489, 5022, 26, 7370, 5053, 7820, 199, 2344, 199, 9677, 275, 1449, 199, 15676, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 2633, 3032, 1901, 859, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 2420, 11863, 582, 298, 11702, 3540, 401, 1467, 298, 1802, 582, 298, 396, 401, 1467, 298, 929, 582, 298, 1881, 3570, 199, 5952, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 3411, 6258, 719, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 1052, 199, 500, 63, 929, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 6258, 719, 2410, 859, 6451, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 2420, 11863, 582, 298, 11702, 3540, 401, 1598, 298, 1802, 582, 298, 396, 401, 1598, 298, 1881, 582, 298, 1881, 3570, 199, 7618, 26, 272, 1369, 26, 1414, 769, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 711, 15978, 13, 842, 373, 80, 3540, 401, 1467, 298, 1802, 511, 937, 199, 2489, 26, 272, 1369, 26, 1104, 370, 1937, 340, 282, 1570, 1990, 6326, 641, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 5046, 272, 2690, 26, 2549, 199, 2344, 199, 199, 504, 2748, 14, 9464, 492, 13139, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 1251, 85, 848, 2598, 14, 301, 492, 664, 63, 7966, 63, 888, 12, 663, 63, 7966, 63, 888, 12, 10142, 63, 2094, 63, 1650, 421, 199, 2089, 63, 6389, 63, 2970, 63, 54, 11778, 275, 408, 199, 28, 1541, 730, 628, 26043, 1743, 489, 665, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 30, 1598, 665, 11863, 985, 2957, 11863, 985, 30, 1598, 665, 11863, 5831, 2957, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404, 30, 489, 3068, 76, 19, 9702, 30, 272, 3068, 1541, 30, 199, 624, 199, 199, 2089, 63, 6389, 63, 8366, 63, 54, 11778, 275, 408, 199, 28, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 3439, 628, 5628, 1743, 1598, 665, 11863, 985, 6598, 83, 1108, 11863, 985, 30, 1598, 665, 11863, 5831, 6598, 83, 1108, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 10142, 63, 11863, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 29057, 1256, 641, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 1802, 26, 272, 446, 21612, 29057, 1256, 402, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 2502, 26, 1488, 621, 31193, 8593, 9089, 8524, 13, 10047, 9, 199, 5983, 26, 272, 446, 982, 473, 8, 929, 29, 5575, 395, 314, 7475, 911, 506, 4829, 12, 15270, 402, 314, 489, 2222, 13, 2427, 1511, 14, 199, 1419, 26, 272, 15209, 26, 267, 1369, 26, 288, 446, 29057, 1256, 12, 314, 2582, 402, 15209, 536, 365, 413, 446, 7105, 12, 284, 14, 69, 14, 298, 396, 401, 1325, 883, 440, 506, 445, 1547, 3455, 63, 680, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 314, 15209, 12, 314, 1059, 2582, 365, 413, 446, 499, 2260, 1275, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 14944, 314, 1174, 402, 314, 2073, 14, 267, 1415, 26, 3055, 267, 3415, 26, 788, 1881, 1673, 5575, 418, 267, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 15209, 859, 511, 523, 7057, 26, 2463, 85, 848, 2598, 523, 1950, 26, 2257, 523, 13082, 63, 5047, 26, 949, 523, 6802, 26, 272, 5053, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 7820, 489, 1844, 26, 7370, 3242, 63, 5510, 63, 719, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 7773, 26, 5053, 819, 6527, 26, 819, 446, 536, 26, 4094, 282, 15978, 3907, 4310, 373, 80, 3540, 12, 1369, 365, 511, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1369, 26, 511, 489, 1174, 26, 3451, 489, 5022, 26, 7370, 5053, 7820, 523, 446, 536, 26, 8496, 282, 15978, 3907, 4310, 373, 80, 3540, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1174, 26, 9552, 489, 5022, 26, 7370, 5053, 7820, 199, 2344, 199, 9677, 275, 1449, 199, 15676, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 2633, 3032, 1901, 859, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 2420, 11863, 582, 298, 11702, 3540, 401, 1467, 298, 1802, 582, 298, 396, 401, 1467, 298, 929, 582, 298, 1881, 3570, 199, 5952, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 3411, 6258, 719, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 1052, 199, 500, 63, 929, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 6258, 719, 2410, 859, 6451, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 2420, 11863, 582, 298, 11702, 3540, 401, 1598, 298, 1802, 582, 298, 396, 401, 1598, 298, 1881, 582, 298, 1881, 3570, 199, 7618, 26, 272, 1369, 26, 1414, 769, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 711, 15978, 13, 842, 373, 80, 3540, 401, 1467, 298, 1802, 511, 937, 199, 2489, 26, 272, 1369, 26, 1104, 370, 1937, 340, 282, 1570, 1990, 6326, 641, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 5046, 272, 2690, 26, 2549, 199, 2344, 199, 199, 504, 2748, 14, 9464, 492, 13139, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 1251, 85, 848, 2598, 14, 301, 492, 664, 63, 7966, 63, 888, 12, 663, 63, 7966, 63, 888, 12, 10142, 63, 2094, 63, 1650, 421, 199, 2089, 63, 6389, 63, 2970, 63, 54, 11778, 275, 408, 199, 28, 1541, 730, 628, 26043, 1743, 489, 665, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 30, 1598, 665, 11863, 985, 2957, 11863, 985, 30, 1598, 665, 11863, 5831, 2957, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404, 30, 489, 3068, 76, 19, 9702, 30, 272, 3068, 1541, 30, 199, 624, 199, 199, 2089, 63, 6389, 63, 8366, 63, 54, 11778, 275, 408, 199, 28, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 3439, 628, 5628, 1743, 1598, 665, 11863, 985, 6598, 83, 1108, 11863, 985, 30, 1598, 665, 11863, 5831, 6598, 83, 1108, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nysan/yocto-autobuilder
lib/python2.6/site-packages/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/words/test/test_irc_service.py
17
7167
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for IRC portions of L{twisted.words.service}. """ from twisted.trial import unittest from twisted.test import proto_helpers from twisted.words.service import InMemoryWordsRealm, IRCFactory, IRCUser from twisted.words.protocols import irc from twisted.cred import checkers, portal class IRCUserTestCase(unittest.TestCase): """ Isolated tests for L{IRCUser} """ def setUp(self): """ Sets up a Realm, Portal, Factory, IRCUser, Transport, and Connection for our tests. """ self.wordsRealm = InMemoryWordsRealm("example.com") self.portal = portal.Portal(self.wordsRealm, [checkers.InMemoryUsernamePasswordDatabaseDontUse(john="pass")]) self.factory = IRCFactory(self.wordsRealm, self.portal) self.ircUser = self.factory.buildProtocol(None) self.stringTransport = proto_helpers.StringTransport() self.ircUser.makeConnection(self.stringTransport) def test_sendMessage(self): """ Sending a message to a user after they have sent NICK, but before they have authenticated, results in a message from "example.com". """ self.ircUser.irc_NICK("", ["mynick"]) self.stringTransport.clear() self.ircUser.sendMessage("foo") self.assertEquals(":example.com foo mynick\r\n", self.stringTransport.value()) def response(self): """ Grabs our responses and then clears the transport """ response = self.ircUser.transport.value().splitlines() self.ircUser.transport.clear() return map(irc.parsemsg, response) def scanResponse(self, response, messageType): """ Gets messages out of a response @param response: The parsed IRC messages of the response, as returned by L{IRCServiceTestCase.response} @param messageType: The string type of the desired messages. @return: An iterator which yields 2-tuples of C{(index, ircMessage)} """ for n, message in enumerate(response): if (message[1] == messageType): yield n, message def test_sendNickSendsGreeting(self): """ Receiving NICK without authenticating sends the MOTD Start and MOTD End messages, which is required by certain popular IRC clients (such as Pidgin) before a connection is considered to be fully established. """ self.ircUser.irc_NICK("", ["mynick"]) response = self.response() start = list(self.scanResponse(response, irc.RPL_MOTDSTART)) end = list(self.scanResponse(response, irc.RPL_ENDOFMOTD)) self.assertEquals(start, [(0, ('example.com', '375', ['mynick', '- example.com Message of the Day - ']))]) self.assertEquals(end, [(1, ('example.com', '376', ['mynick', 'End of /MOTD command.']))]) def test_fullLogin(self): """ Receiving USER, PASS, NICK will log in the user, and transmit the appropriate response messages. """ self.ircUser.irc_USER("", ["john doe"]) self.ircUser.irc_PASS("", ["pass"]) self.ircUser.irc_NICK("", ["john"]) version = ('Your host is example.com, running version %s' % (self.factory._serverInfo["serviceVersion"],)) creation = ('This server was created on %s' % (self.factory._serverInfo["creationDate"],)) self.assertEquals(self.response(), [('example.com', '375', ['john', '- example.com Message of the Day - ']), ('example.com', '376', ['john', 'End of /MOTD command.']), ('example.com', '001', ['john', 'connected to Twisted IRC']), ('example.com', '002', ['john', version]), ('example.com', '003', ['john', creation]), ('example.com', '004', ['john', 'example.com', self.factory._serverInfo["serviceVersion"], 'w', 'n'])]) class MocksyIRCUser(IRCUser): def __init__(self): self.mockedCodes = [] def sendMessage(self, code, *_, **__): self.mockedCodes.append(code) BADTEXT = '\xff' class IRCUserBadEncodingTestCase(unittest.TestCase): """ Verifies that L{IRCUser} sends the correct error messages back to clients when given indecipherable bytes """ # TODO: irc_NICK -- but NICKSERV is used for that, so it isn't as easy. def setUp(self): self.ircuser = MocksyIRCUser() def assertChokesOnBadBytes(self, irc_x, error): """ Asserts that IRCUser sends the relevant error code when a given irc_x dispatch method is given undecodable bytes. @param irc_x: the name of the irc_FOO method to test. For example, irc_x = 'PRIVMSG' will check irc_PRIVMSG @param error: the error code irc_x should send. For example, irc.ERR_NOTONCHANNEL """ getattr(self.ircuser, 'irc_%s' % irc_x)(None, [BADTEXT]) self.assertEqual(self.ircuser.mockedCodes, [error]) # no such channel def test_JOIN(self): """ Tests that irc_JOIN sends ERR_NOSUCHCHANNEL if the channel name can't be decoded. """ self.assertChokesOnBadBytes('JOIN', irc.ERR_NOSUCHCHANNEL) def test_NAMES(self): """ Tests that irc_NAMES sends ERR_NOSUCHCHANNEL if the channel name can't be decoded. """ self.assertChokesOnBadBytes('NAMES', irc.ERR_NOSUCHCHANNEL) def test_TOPIC(self): """ Tests that irc_TOPIC sends ERR_NOSUCHCHANNEL if the channel name can't be decoded. """ self.assertChokesOnBadBytes('TOPIC', irc.ERR_NOSUCHCHANNEL) def test_LIST(self): """ Tests that irc_LIST sends ERR_NOSUCHCHANNEL if the channel name can't be decoded. """ self.assertChokesOnBadBytes('LIST', irc.ERR_NOSUCHCHANNEL) # no such nick def test_MODE(self): """ Tests that irc_MODE sends ERR_NOSUCHNICK if the target name can't be decoded. """ self.assertChokesOnBadBytes('MODE', irc.ERR_NOSUCHNICK) def test_PRIVMSG(self): """ Tests that irc_PRIVMSG sends ERR_NOSUCHNICK if the target name can't be decoded. """ self.assertChokesOnBadBytes('PRIVMSG', irc.ERR_NOSUCHNICK) def test_WHOIS(self): """ Tests that irc_WHOIS sends ERR_NOSUCHNICK if the target name can't be decoded. """ self.assertChokesOnBadBytes('WHOIS', irc.ERR_NOSUCHNICK) # not on channel def test_PART(self): """ Tests that irc_PART sends ERR_NOTONCHANNEL if the target name can't be decoded. """ self.assertChokesOnBadBytes('PART', irc.ERR_NOTONCHANNEL) # probably nothing def test_WHO(self): """ Tests that irc_WHO immediately ends the WHO list if the target name can't be decoded. """ self.assertChokesOnBadBytes('WHO', irc.RPL_ENDOFWHO)
gpl-2.0
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2925, 367, 473, 8205, 12468, 402, 491, 91, 12145, 14, 3148, 14, 1364, 5565, 199, 624, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 492, 4104, 63, 7546, 199, 504, 7390, 14, 3148, 14, 1364, 492, 1010, 8628, 23759, 27422, 12, 473, 8205, 2927, 12, 473, 8205, 1899, 199, 504, 7390, 14, 3148, 14, 16541, 492, 22157, 199, 504, 7390, 14, 18639, 492, 1104, 1192, 12, 18428, 199, 199, 533, 473, 8205, 1899, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 6596, 12918, 2295, 367, 491, 91, 3927, 35, 1899, 93, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 10729, 1536, 282, 27715, 12, 10977, 279, 12, 23616, 12, 473, 8205, 1899, 12, 27018, 12, 436, 8113, 267, 367, 4154, 2295, 14, 267, 408, 267, 291, 14, 3148, 27422, 275, 1010, 8628, 23759, 27422, 480, 2694, 14, 957, 531, 267, 291, 14, 8707, 275, 18428, 14, 26708, 8, 277, 14, 3148, 27422, 12, 288, 359, 32514, 14, 607, 8628, 13355, 6139, 7243, 20028, 6119, 8, 20216, 628, 1529, 13403, 267, 291, 14, 3702, 275, 473, 8205, 2927, 8, 277, 14, 3148, 27422, 12, 291, 14, 8707, 9, 267, 291, 14, 5958, 1899, 275, 291, 14, 3702, 14, 1506, 3658, 8, 403, 9, 267, 291, 14, 875, 7836, 275, 4104, 63, 7546, 14, 1558, 7836, 342, 267, 291, 14, 5958, 1899, 14, 1875, 3225, 8, 277, 14, 875, 7836, 9, 2378, 347, 511, 63, 2254, 2209, 8, 277, 304, 267, 408, 267, 428, 3219, 282, 1245, 370, 282, 922, 2410, 2985, 1172, 4847, 653, 13884, 12, 1325, 2544, 2985, 267, 1172, 15082, 12, 2058, 315, 282, 1245, 687, 298, 2694, 14, 957, 1674, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 77, 1236, 2000, 3135, 267, 291, 14, 875, 7836, 14, 3584, 342, 267, 291, 14, 5958, 1899, 14, 2254, 2209, 480, 1421, 531, 267, 291, 14, 2947, 20308, 2694, 14, 957, 3925, 333, 1236, 2000, 60, 82, 60, 78, 401, 2079, 291, 14, 875, 7836, 14, 585, 1012, 2378, 347, 1177, 8, 277, 304, 267, 408, 267, 10268, 1533, 4154, 9320, 436, 2066, 5436, 83, 314, 7773, 267, 408, 267, 1177, 275, 291, 14, 5958, 1899, 14, 5545, 14, 585, 1252, 7644, 342, 267, 291, 14, 5958, 1899, 14, 5545, 14, 3584, 342, 267, 372, 2341, 8, 5958, 14, 1122, 1328, 12, 1177, 9, 2378, 347, 8000, 2364, 8, 277, 12, 1177, 12, 1245, 804, 304, 267, 408, 267, 14509, 3788, 734, 402, 282, 1177, 398, 768, 635, 1177, 26, 710, 4565, 473, 8205, 3788, 402, 314, 1177, 12, 465, 2138, 267, 701, 491, 91, 3927, 35, 3167, 1746, 14, 1310, 93, 398, 768, 635, 1245, 804, 26, 710, 1059, 730, 402, 314, 6387, 3788, 14, 398, 768, 1107, 26, 1626, 6122, 1314, 14801, 499, 13, 11760, 402, 445, 91, 8, 1080, 12, 22157, 2209, 6769, 267, 408, 267, 367, 302, 12, 1245, 315, 3874, 8, 1310, 304, 288, 340, 334, 1188, 59, 17, 61, 508, 1245, 804, 304, 355, 1995, 302, 12, 1245, 2378, 347, 511, 63, 2254, 32172, 26276, 39, 23457, 8, 277, 304, 267, 408, 267, 799, 2375, 316, 653, 13884, 1928, 28532, 1958, 16178, 314, 603, 1387, 36, 7707, 436, 603, 1387, 36, 9599, 267, 3788, 12, 1314, 365, 1415, 701, 9842, 4560, 2238, 473, 8205, 13431, 334, 10180, 465, 267, 510, 344, 903, 9, 2544, 282, 1950, 365, 8652, 370, 506, 9999, 23594, 14, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 77, 1236, 2000, 3135, 267, 1177, 275, 291, 14, 1310, 342, 267, 1343, 275, 769, 8, 277, 14, 6282, 2364, 8, 1310, 12, 22157, 14, 50, 2749, 63, 27235, 36, 7363, 430, 267, 1284, 275, 769, 8, 277, 14, 6282, 2364, 8, 1310, 12, 22157, 14, 50, 2749, 63, 742, 1649, 22367, 1387, 36, 430, 267, 291, 14, 2947, 8, 928, 12, 288, 3842, 16, 12, 661, 2694, 14, 957, 297, 283, 9946, 297, 788, 77, 1236, 2000, 297, 2475, 2893, 14, 957, 6430, 402, 314, 28358, 446, 283, 2459, 566, 267, 291, 14, 2947, 8, 500, 12, 288, 3842, 17, 12, 661, 2694, 14, 957, 297, 283, 11452, 297, 788, 77, 1236, 2000, 297, 283, 3005, 402, 1182, 27235, 36, 1414, 14, 5156, 566, 2378, 347, 511, 63, 2861, 8880, 8, 277, 304, 267, 408, 267, 799, 2375, 316, 13044, 12, 21705, 12, 653, 13884, 911, 943, 315, 314, 922, 12, 436, 27754, 314, 267, 5827, 1177, 3788, 14, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 3791, 12398, 2097, 20216, 886, 69, 3135, 267, 291, 14, 5958, 1899, 14, 5958, 63, 6909, 12398, 2097, 1529, 3135, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 20216, 3135, 398, 1015, 275, 661, 14398, 1591, 365, 2893, 14, 957, 12, 3879, 1015, 450, 83, 7, 450, 288, 334, 277, 14, 3702, 423, 1000, 2354, 905, 1364, 3353, 2255, 430, 398, 7143, 275, 661, 2765, 1654, 1990, 2737, 641, 450, 83, 7, 450, 288, 334, 277, 14, 3702, 423, 1000, 2354, 905, 8782, 2506, 2255, 430, 398, 291, 14, 2947, 8, 277, 14, 1310, 1062, 288, 4274, 2694, 14, 957, 297, 283, 9946, 297, 1598, 788, 20216, 297, 2475, 2893, 14, 957, 6430, 402, 314, 28358, 446, 283, 2522, 1467, 661, 2694, 14, 957, 297, 283, 11452, 297, 788, 20216, 297, 283, 3005, 402, 1182, 27235, 36, 1414, 14, 3815, 1467, 661, 2694, 14, 957, 297, 283, 4587, 297, 788, 20216, 297, 283, 7113, 370, 17078, 473, 8205, 3815, 1467, 661, 2694, 14, 957, 297, 283, 7432, 297, 788, 20216, 297, 1015, 2522, 1467, 661, 2694, 14, 957, 297, 283, 8262, 297, 788, 20216, 297, 7143, 2522, 1467, 661, 2694, 14, 957, 297, 283, 7979, 297, 1598, 788, 20216, 297, 283, 2694, 14, 957, 297, 291, 14, 3702, 423, 1000, 2354, 905, 1364, 3353, 2255, 2049, 283, 87, 297, 283, 78, 31161, 4388, 199, 533, 4420, 1786, 3927, 35, 1899, 8, 3927, 35, 1899, 304, 272, 347, 636, 826, 721, 277, 304 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2925, 367, 473, 8205, 12468, 402, 491, 91, 12145, 14, 3148, 14, 1364, 5565, 199, 624, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 396, 492, 4104, 63, 7546, 199, 504, 7390, 14, 3148, 14, 1364, 492, 1010, 8628, 23759, 27422, 12, 473, 8205, 2927, 12, 473, 8205, 1899, 199, 504, 7390, 14, 3148, 14, 16541, 492, 22157, 199, 504, 7390, 14, 18639, 492, 1104, 1192, 12, 18428, 199, 199, 533, 473, 8205, 1899, 1746, 8, 2796, 14, 1746, 304, 272, 408, 272, 6596, 12918, 2295, 367, 491, 91, 3927, 35, 1899, 93, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 10729, 1536, 282, 27715, 12, 10977, 279, 12, 23616, 12, 473, 8205, 1899, 12, 27018, 12, 436, 8113, 267, 367, 4154, 2295, 14, 267, 408, 267, 291, 14, 3148, 27422, 275, 1010, 8628, 23759, 27422, 480, 2694, 14, 957, 531, 267, 291, 14, 8707, 275, 18428, 14, 26708, 8, 277, 14, 3148, 27422, 12, 288, 359, 32514, 14, 607, 8628, 13355, 6139, 7243, 20028, 6119, 8, 20216, 628, 1529, 13403, 267, 291, 14, 3702, 275, 473, 8205, 2927, 8, 277, 14, 3148, 27422, 12, 291, 14, 8707, 9, 267, 291, 14, 5958, 1899, 275, 291, 14, 3702, 14, 1506, 3658, 8, 403, 9, 267, 291, 14, 875, 7836, 275, 4104, 63, 7546, 14, 1558, 7836, 342, 267, 291, 14, 5958, 1899, 14, 1875, 3225, 8, 277, 14, 875, 7836, 9, 2378, 347, 511, 63, 2254, 2209, 8, 277, 304, 267, 408, 267, 428, 3219, 282, 1245, 370, 282, 922, 2410, 2985, 1172, 4847, 653, 13884, 12, 1325, 2544, 2985, 267, 1172, 15082, 12, 2058, 315, 282, 1245, 687, 298, 2694, 14, 957, 1674, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 77, 1236, 2000, 3135, 267, 291, 14, 875, 7836, 14, 3584, 342, 267, 291, 14, 5958, 1899, 14, 2254, 2209, 480, 1421, 531, 267, 291, 14, 2947, 20308, 2694, 14, 957, 3925, 333, 1236, 2000, 60, 82, 60, 78, 401, 2079, 291, 14, 875, 7836, 14, 585, 1012, 2378, 347, 1177, 8, 277, 304, 267, 408, 267, 10268, 1533, 4154, 9320, 436, 2066, 5436, 83, 314, 7773, 267, 408, 267, 1177, 275, 291, 14, 5958, 1899, 14, 5545, 14, 585, 1252, 7644, 342, 267, 291, 14, 5958, 1899, 14, 5545, 14, 3584, 342, 267, 372, 2341, 8, 5958, 14, 1122, 1328, 12, 1177, 9, 2378, 347, 8000, 2364, 8, 277, 12, 1177, 12, 1245, 804, 304, 267, 408, 267, 14509, 3788, 734, 402, 282, 1177, 398, 768, 635, 1177, 26, 710, 4565, 473, 8205, 3788, 402, 314, 1177, 12, 465, 2138, 267, 701, 491, 91, 3927, 35, 3167, 1746, 14, 1310, 93, 398, 768, 635, 1245, 804, 26, 710, 1059, 730, 402, 314, 6387, 3788, 14, 398, 768, 1107, 26, 1626, 6122, 1314, 14801, 499, 13, 11760, 402, 445, 91, 8, 1080, 12, 22157, 2209, 6769, 267, 408, 267, 367, 302, 12, 1245, 315, 3874, 8, 1310, 304, 288, 340, 334, 1188, 59, 17, 61, 508, 1245, 804, 304, 355, 1995, 302, 12, 1245, 2378, 347, 511, 63, 2254, 32172, 26276, 39, 23457, 8, 277, 304, 267, 408, 267, 799, 2375, 316, 653, 13884, 1928, 28532, 1958, 16178, 314, 603, 1387, 36, 7707, 436, 603, 1387, 36, 9599, 267, 3788, 12, 1314, 365, 1415, 701, 9842, 4560, 2238, 473, 8205, 13431, 334, 10180, 465, 267, 510, 344, 903, 9, 2544, 282, 1950, 365, 8652, 370, 506, 9999, 23594, 14, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 77, 1236, 2000, 3135, 267, 1177, 275, 291, 14, 1310, 342, 267, 1343, 275, 769, 8, 277, 14, 6282, 2364, 8, 1310, 12, 22157, 14, 50, 2749, 63, 27235, 36, 7363, 430, 267, 1284, 275, 769, 8, 277, 14, 6282, 2364, 8, 1310, 12, 22157, 14, 50, 2749, 63, 742, 1649, 22367, 1387, 36, 430, 267, 291, 14, 2947, 8, 928, 12, 288, 3842, 16, 12, 661, 2694, 14, 957, 297, 283, 9946, 297, 788, 77, 1236, 2000, 297, 2475, 2893, 14, 957, 6430, 402, 314, 28358, 446, 283, 2459, 566, 267, 291, 14, 2947, 8, 500, 12, 288, 3842, 17, 12, 661, 2694, 14, 957, 297, 283, 11452, 297, 788, 77, 1236, 2000, 297, 283, 3005, 402, 1182, 27235, 36, 1414, 14, 5156, 566, 2378, 347, 511, 63, 2861, 8880, 8, 277, 304, 267, 408, 267, 799, 2375, 316, 13044, 12, 21705, 12, 653, 13884, 911, 943, 315, 314, 922, 12, 436, 27754, 314, 267, 5827, 1177, 3788, 14, 267, 408, 267, 291, 14, 5958, 1899, 14, 5958, 63, 3791, 12398, 2097, 20216, 886, 69, 3135, 267, 291, 14, 5958, 1899, 14, 5958, 63, 6909, 12398, 2097, 1529, 3135, 267, 291, 14, 5958, 1899, 14, 5958, 63, 46, 13884, 12398, 2097, 20216, 3135, 398, 1015, 275, 661, 14398, 1591, 365, 2893, 14, 957, 12, 3879, 1015, 450, 83, 7, 450, 288, 334, 277, 14, 3702, 423, 1000, 2354, 905, 1364, 3353, 2255, 430, 398, 7143, 275, 661, 2765, 1654, 1990, 2737, 641, 450, 83, 7, 450, 288, 334, 277, 14, 3702, 423, 1000, 2354, 905, 8782, 2506, 2255, 430, 398, 291, 14, 2947, 8, 277, 14, 1310, 1062, 288, 4274, 2694, 14, 957, 297, 283, 9946, 297, 1598, 788, 20216, 297, 2475, 2893, 14, 957, 6430, 402, 314, 28358, 446, 283, 2522, 1467, 661, 2694, 14, 957, 297, 283, 11452, 297, 788, 20216, 297, 283, 3005, 402, 1182, 27235, 36, 1414, 14, 3815, 1467, 661, 2694, 14, 957, 297, 283, 4587, 297, 788, 20216, 297, 283, 7113, 370, 17078, 473, 8205, 3815, 1467, 661, 2694, 14, 957, 297, 283, 7432, 297, 788, 20216, 297, 1015, 2522, 1467, 661, 2694, 14, 957, 297, 283, 8262, 297, 788, 20216, 297, 7143, 2522, 1467, 661, 2694, 14, 957, 297, 283, 7979, 297, 1598, 788, 20216, 297, 283, 2694, 14, 957, 297, 291, 14, 3702, 423, 1000, 2354, 905, 1364, 3353, 2255, 2049, 283, 87, 297, 283, 78, 31161, 4388, 199, 533, 4420, 1786, 3927, 35, 1899, 8, 3927, 35, 1899, 304, 272, 347, 636, 826, 721, 277, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
swarna-k/MyDiary
app/models.py
1
1566
from app import db from werkzeug import generate_password_hash, check_password_hash class User(db.Model): id = db.Column(db.Integer, primary_key = True) firstname = db.Column(db.String(100)) lastname = db.Column(db.String(100)) email = db.Column(db.String(120), unique=True) pwdhash = db.Column(db.String(54)) entries = db.relationship('Entry', backref='author', lazy='dynamic') reminders = db.relationship('Reminder', backref='author', lazy='dynamic') def __init__(self, firstname, lastname, email, password): self.firstname = firstname.title() self.lastname = lastname.title() self.email = email.lower() self.set_password(password) def set_password(self, password): self.pwdhash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.pwdhash, password) def __repr__(self): return '<User %r>' % (self.firstname) class Entry(db.Model): id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(100)) body = db.Column(db.Text) timestamp = db.Column(db.DateTime) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Entry %r>' % (self.body) class Reminder(db.Model): id = db.Column(db.Integer, primary_key = True) when = db.Column(db.DateTime) body = db.Column(db.Text) timestamp = db.Column(db.DateTime) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Reminder %r>' % (self.body)
bsd-3-clause
[ 504, 1145, 492, 1592, 199, 504, 10380, 492, 3550, 63, 2060, 63, 2227, 12, 1104, 63, 2060, 63, 2227, 199, 199, 533, 2876, 8, 697, 14, 1685, 304, 12244, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 523, 1642, 354, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 523, 2061, 354, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 523, 3031, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 6708, 395, 3747, 29, 549, 9, 523, 14374, 2227, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1477, 430, 523, 4811, 275, 1592, 14, 11704, 360, 3900, 297, 23412, 534, 2502, 297, 9617, 534, 7764, 358, 523, 295, 827, 7735, 275, 1592, 14, 11704, 360, 497, 24820, 297, 23412, 534, 2502, 297, 9617, 534, 7764, 358, 819, 347, 636, 826, 721, 277, 12, 1642, 354, 12, 2061, 354, 12, 3031, 12, 2505, 304, 272, 291, 14, 25603, 275, 1642, 354, 14, 1213, 342, 272, 291, 14, 31164, 275, 2061, 354, 14, 1213, 342, 272, 291, 14, 2123, 275, 3031, 14, 2325, 342, 272, 291, 14, 409, 63, 2060, 8, 2060, 9, 489, 523, 347, 663, 63, 2060, 8, 277, 12, 2505, 304, 272, 291, 14, 14258, 2227, 275, 3550, 63, 2060, 63, 2227, 8, 2060, 9, 272, 523, 347, 1104, 63, 2060, 8, 277, 12, 2505, 304, 272, 372, 1104, 63, 2060, 63, 2227, 8, 277, 14, 14258, 2227, 12, 2505, 9, 819, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 1899, 450, 82, 3524, 450, 334, 277, 14, 25603, 9, 199, 199, 533, 11855, 8, 697, 14, 1685, 304, 272, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 272, 536, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 272, 2396, 275, 1592, 14, 4547, 8, 697, 14, 1872, 9, 272, 4913, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 922, 63, 344, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 1592, 14, 3190, 360, 751, 14, 344, 1333, 1362, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3900, 450, 82, 3524, 450, 334, 277, 14, 2030, 9, 199, 199, 533, 799, 24820, 8, 697, 14, 1685, 304, 272, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 272, 1380, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 2396, 275, 1592, 14, 4547, 8, 697, 14, 1872, 9, 272, 4913, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 922, 63, 344, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 1592, 14, 3190, 360, 751, 14, 344, 1333, 1362, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 497, 24820, 450, 82, 3524, 450, 334, 277, 14, 2030, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1145, 492, 1592, 199, 504, 10380, 492, 3550, 63, 2060, 63, 2227, 12, 1104, 63, 2060, 63, 2227, 199, 199, 533, 2876, 8, 697, 14, 1685, 304, 12244, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 523, 1642, 354, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 523, 2061, 354, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 523, 3031, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 6708, 395, 3747, 29, 549, 9, 523, 14374, 2227, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1477, 430, 523, 4811, 275, 1592, 14, 11704, 360, 3900, 297, 23412, 534, 2502, 297, 9617, 534, 7764, 358, 523, 295, 827, 7735, 275, 1592, 14, 11704, 360, 497, 24820, 297, 23412, 534, 2502, 297, 9617, 534, 7764, 358, 819, 347, 636, 826, 721, 277, 12, 1642, 354, 12, 2061, 354, 12, 3031, 12, 2505, 304, 272, 291, 14, 25603, 275, 1642, 354, 14, 1213, 342, 272, 291, 14, 31164, 275, 2061, 354, 14, 1213, 342, 272, 291, 14, 2123, 275, 3031, 14, 2325, 342, 272, 291, 14, 409, 63, 2060, 8, 2060, 9, 489, 523, 347, 663, 63, 2060, 8, 277, 12, 2505, 304, 272, 291, 14, 14258, 2227, 275, 3550, 63, 2060, 63, 2227, 8, 2060, 9, 272, 523, 347, 1104, 63, 2060, 8, 277, 12, 2505, 304, 272, 372, 1104, 63, 2060, 63, 2227, 8, 277, 14, 14258, 2227, 12, 2505, 9, 819, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 1899, 450, 82, 3524, 450, 334, 277, 14, 25603, 9, 199, 199, 533, 11855, 8, 697, 14, 1685, 304, 272, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 272, 536, 275, 1592, 14, 4547, 8, 697, 14, 1558, 8, 1960, 430, 272, 2396, 275, 1592, 14, 4547, 8, 697, 14, 1872, 9, 272, 4913, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 922, 63, 344, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 1592, 14, 3190, 360, 751, 14, 344, 1333, 1362, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 3900, 450, 82, 3524, 450, 334, 277, 14, 2030, 9, 199, 199, 533, 799, 24820, 8, 697, 14, 1685, 304, 272, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 275, 715, 9, 272, 1380, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 2396, 275, 1592, 14, 4547, 8, 697, 14, 1872, 9, 272, 4913, 275, 1592, 14, 4547, 8, 697, 14, 3926, 9, 272, 922, 63, 344, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 1592, 14, 3190, 360, 751, 14, 344, 1333, 1362, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 497, 24820, 450, 82, 3524, 450, 334, 277, 14, 2030, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
keir-rex/zipline
zipline/utils/tradingcalendar_tse.py
24
10413
# # Copyright 2014 Quantopian, 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 pandas as pd import pytz from datetime import datetime from dateutil import rrule from zipline.utils.tradingcalendar import end, canonicalize_datetime start = pd.Timestamp('1994-01-01', tz='UTC') def get_non_trading_days(start, end): non_trading_rules = [] start = canonicalize_datetime(start) end = canonicalize_datetime(end) weekends = rrule.rrule( rrule.YEARLY, byweekday=(rrule.SA, rrule.SU), cache=True, dtstart=start, until=end ) non_trading_rules.append(weekends) new_years = rrule.rrule( rrule.MONTHLY, byyearday=1, cache=True, dtstart=start, until=end ) non_trading_rules.append(new_years) new_years_sunday = rrule.rrule( rrule.MONTHLY, byyearday=2, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(new_years_sunday) new_years_saturday = rrule.rrule( rrule.MONTHLY, byyearday=3, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(new_years_saturday) # Family day in Ontario, starting in 2008, third monday of February family_day = rrule.rrule( rrule.MONTHLY, bymonth=2, byweekday=(rrule.MO(3)), cache=True, dtstart=datetime(2008, 1, 1, tzinfo=pytz.utc), until=end ) non_trading_rules.append(family_day) good_friday = rrule.rrule( rrule.DAILY, byeaster=-2, cache=True, dtstart=start, until=end ) non_trading_rules.append(good_friday) # Monday prior to May 25th. victoria_day = rrule.rrule( rrule.MONTHLY, bymonth=5, byweekday=rrule.MO, bymonthday=[24, 23, 22, 21, 20, 19, 18], cache=True, dtstart=start, until=end ) non_trading_rules.append(victoria_day) july_1st = rrule.rrule( rrule.MONTHLY, bymonth=7, bymonthday=1, cache=True, dtstart=start, until=end ) non_trading_rules.append(july_1st) july_1st_sunday = rrule.rrule( rrule.MONTHLY, bymonth=7, bymonthday=2, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(july_1st_sunday) july_1st_saturday = rrule.rrule( rrule.MONTHLY, bymonth=7, bymonthday=3, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(july_1st_saturday) civic_holiday = rrule.rrule( rrule.MONTHLY, bymonth=8, byweekday=rrule.MO(1), cache=True, dtstart=start, until=end ) non_trading_rules.append(civic_holiday) labor_day = rrule.rrule( rrule.MONTHLY, bymonth=9, byweekday=(rrule.MO(1)), cache=True, dtstart=start, until=end ) non_trading_rules.append(labor_day) thanksgiving = rrule.rrule( rrule.MONTHLY, bymonth=10, byweekday=(rrule.MO(2)), cache=True, dtstart=start, until=end ) non_trading_rules.append(thanksgiving) christmas = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=25, cache=True, dtstart=start, until=end ) non_trading_rules.append(christmas) # If Christmas is a Sunday then the 26th, a Monday is observed. # (but that would be boxing day), so the 27th is also observed. christmas_sunday = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=27, byweekday=rrule.TU, cache=True, dtstart=start, until=end ) non_trading_rules.append(christmas_sunday) # If Christmas is a Saturday then the 27th, a monday is observed. christmas_saturday = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=27, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(christmas_saturday) boxing_day = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=26, cache=True, dtstart=start, until=end ) non_trading_rules.append(boxing_day) # if boxing day is a sunday, the Christmas was saturday. # Christmas is observed on the 27th, a month and boxing day is observed # on the 28th, a tuesday. boxing_day_sunday = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=28, byweekday=rrule.TU, cache=True, dtstart=start, until=end ) non_trading_rules.append(boxing_day_sunday) # If boxing day is a Saturday then the 28th, a monday is observed. boxing_day_saturday = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=28, byweekday=rrule.MO, cache=True, dtstart=start, until=end ) non_trading_rules.append(boxing_day_saturday) non_trading_ruleset = rrule.rruleset() for rule in non_trading_rules: non_trading_ruleset.rrule(rule) non_trading_days = non_trading_ruleset.between(start, end, inc=True) # Add September 11th closings # The TSX was open for 71 minutes on September 11, 2011. # It was closed on the 12th and reopened on the 13th. # http://www.cbc.ca/news2/interactives/map-tsx/ # # September 2001 # Su Mo Tu We Th Fr Sa # 1 # 2 3 4 5 6 7 8 # 9 10 11 12 13 14 15 # 16 17 18 19 20 21 22 # 23 24 25 26 27 28 29 # 30 non_trading_days.append( datetime(2001, 9, 12, tzinfo=pytz.utc)) non_trading_days.sort() return pd.DatetimeIndex(non_trading_days) non_trading_days = get_non_trading_days(start, end) trading_day = pd.tseries.offsets.CDay(holidays=non_trading_days) def get_trading_days(start, end, trading_day=trading_day): return pd.date_range(start=start.date(), end=end.date(), freq=trading_day).tz_localize('UTC') trading_days = get_trading_days(start, end) # Days in Environment but not in Calendar (using ^GSPTSE as bm_symbol): # -------------------------------------------------------------------- # Used http://web.tmxmoney.com/pricehistory.php?qm_page=61468&qm_symbol=^TSX # to check whether exchange was open on these days. # 1994-07-01 - July 1st, Yahoo Finance has Volume = 0 # 1996-07-01 - July 1st, Yahoo Finance has Volume = 0 # 1996-08-05 - Civic Holiday, Yahoo Finance has Volume = 0 # 1997-07-01 - July 1st, Yahoo Finance has Volume = 0 # 1997-08-04 - Civic Holiday, Yahoo Finance has Volume = 0 # 2001-05-21 - Victoria day, Yahoo Finance has Volume = 0 # 2004-10-11 - Closed, Thanksgiving - Confirmed closed # 2004-12-28 - Closed, Boxing Day - Confirmed closed # 2012-10-08 - Closed, Thanksgiving - Confirmed closed # Days in Calendar but not in Environment using ^GSPTSE as bm_symbol: # -------------------------------------------------------------------- # Used http://web.tmxmoney.com/pricehistory.php?qm_page=61468&qm_symbol=^TSX # to check whether exchange was open on these days. # 2000-06-28 - No data this far back, can't confirm # 2000-08-28 - No data this far back, can't confirm # 2000-08-29 - No data this far back, can't confirm # 2001-09-11 - TSE Open for 71 min. # 2002-02-01 - Confirm TSE Open # 2002-06-14 - Confirm TSE Open # 2002-07-02 - Confirm TSE Open # 2002-11-11 - TSX website has no data for 2 weeks in 2002 # 2003-07-07 - Confirm TSE Open # 2003-12-16 - Confirm TSE Open def get_early_closes(start, end): # TSX closed at 1:00 PM on december 24th. start = canonicalize_datetime(start) end = canonicalize_datetime(end) start = max(start, datetime(1993, 1, 1, tzinfo=pytz.utc)) end = max(end, datetime(1993, 1, 1, tzinfo=pytz.utc)) # Not included here are early closes prior to 1993 # or unplanned early closes early_close_rules = [] christmas_eve = rrule.rrule( rrule.MONTHLY, bymonth=12, bymonthday=24, byweekday=(rrule.MO, rrule.TU, rrule.WE, rrule.TH, rrule.FR), cache=True, dtstart=start, until=end ) early_close_rules.append(christmas_eve) early_close_ruleset = rrule.rruleset() for rule in early_close_rules: early_close_ruleset.rrule(rule) early_closes = early_close_ruleset.between(start, end, inc=True) early_closes.sort() return pd.DatetimeIndex(early_closes) early_closes = get_early_closes(start, end) def get_open_and_closes(trading_days, early_closes, tz='US/Eastern'): open_and_closes = pd.DataFrame(index=trading_days, columns=('market_open', 'market_close')) for day in trading_days: market_open = pd.Timestamp( datetime( year=day.year, month=day.month, day=day.day, hour=9, minute=31), tz='US/Eastern').tz_convert('UTC') # 1 PM if early close, 4 PM otherwise close_hour = 13 if day in early_closes else 16 market_close = pd.Timestamp( datetime( year=day.year, month=day.month, day=day.day, hour=close_hour), tz='US/Eastern').tz_convert('UTC') open_and_closes.loc[day, 'market_open'] = market_open open_and_closes.loc[day, 'market_close'] = market_close return open_and_closes open_and_closes = get_open_and_closes(trading_days, early_closes)
apache-2.0
[ 3, 199, 3, 1898, 6927, 5843, 867, 411, 5653, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 646, 10634, 465, 6454, 199, 646, 15444, 199, 199, 504, 2197, 492, 2197, 199, 504, 22208, 492, 519, 2200, 199, 504, 3482, 604, 14, 1208, 14, 1239, 1098, 8183, 492, 1284, 12, 11358, 794, 63, 2083, 199, 199, 928, 275, 6454, 14, 10239, 360, 7155, 20, 13, 614, 13, 614, 297, 5823, 534, 11288, 358, 421, 199, 318, 664, 63, 2865, 63, 1239, 1098, 63, 4899, 8, 928, 12, 1284, 304, 272, 2222, 63, 1239, 1098, 63, 4423, 275, 942, 339, 1343, 275, 11358, 794, 63, 2083, 8, 928, 9, 272, 1284, 275, 11358, 794, 63, 2083, 8, 500, 9, 339, 8620, 3198, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 19216, 6084, 12, 267, 701, 12451, 2687, 82, 2200, 14, 4251, 12, 519, 2200, 14, 6195, 395, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 6419, 3198, 9, 339, 892, 63, 18431, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 17, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 9, 339, 892, 63, 18431, 63, 83, 24759, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 18, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 63, 83, 24759, 9, 339, 892, 63, 18431, 63, 14997, 300, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 19, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 63, 14997, 300, 2977, 9, 339, 327, 481, 4632, 5382, 315, 593, 343, 6936, 12, 6617, 315, 9079, 12, 10919, 3485, 2977, 402, 21141, 26709, 272, 9614, 63, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 18, 12, 267, 701, 12451, 2687, 82, 2200, 14, 2679, 8, 19, 1826, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 2083, 8, 9300, 12, 413, 12, 413, 12, 10313, 29, 21948, 14, 5834, 395, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 6606, 63, 2977, 9, 339, 6954, 63, 25876, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 36, 6593, 57, 12, 267, 701, 69, 2311, 4022, 18, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 8302, 63, 25876, 2977, 9, 339, 327, 32740, 6791, 370, 10162, 5661, 273, 14, 272, 1321, 630, 4674, 63, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 21, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 701, 4482, 2977, 1524, 1194, 12, 6546, 12, 6928, 12, 7829, 12, 3388, 12, 5851, 12, 6155, 467, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 433, 630, 4674, 63, 2977, 9, 339, 1335, 21797, 63, 17, 270, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 17, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 9, 339, 1335, 21797, 63, 17, 270, 63, 83, 24759, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 18, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 63, 83, 24759, 9, 339, 1335, 21797, 63, 17, 270, 63, 14997, 300, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 19, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 63, 14997, 300, 2977, 9, 339, 16279, 31629, 63, 20154, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 24, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 8 ]
[ 199, 3, 1898, 6927, 5843, 867, 411, 5653, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 646, 10634, 465, 6454, 199, 646, 15444, 199, 199, 504, 2197, 492, 2197, 199, 504, 22208, 492, 519, 2200, 199, 504, 3482, 604, 14, 1208, 14, 1239, 1098, 8183, 492, 1284, 12, 11358, 794, 63, 2083, 199, 199, 928, 275, 6454, 14, 10239, 360, 7155, 20, 13, 614, 13, 614, 297, 5823, 534, 11288, 358, 421, 199, 318, 664, 63, 2865, 63, 1239, 1098, 63, 4899, 8, 928, 12, 1284, 304, 272, 2222, 63, 1239, 1098, 63, 4423, 275, 942, 339, 1343, 275, 11358, 794, 63, 2083, 8, 928, 9, 272, 1284, 275, 11358, 794, 63, 2083, 8, 500, 9, 339, 8620, 3198, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 19216, 6084, 12, 267, 701, 12451, 2687, 82, 2200, 14, 4251, 12, 519, 2200, 14, 6195, 395, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 6419, 3198, 9, 339, 892, 63, 18431, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 17, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 9, 339, 892, 63, 18431, 63, 83, 24759, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 18, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 63, 83, 24759, 9, 339, 892, 63, 18431, 63, 14997, 300, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 3403, 2977, 29, 19, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 1222, 63, 18431, 63, 14997, 300, 2977, 9, 339, 327, 481, 4632, 5382, 315, 593, 343, 6936, 12, 6617, 315, 9079, 12, 10919, 3485, 2977, 402, 21141, 26709, 272, 9614, 63, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 18, 12, 267, 701, 12451, 2687, 82, 2200, 14, 2679, 8, 19, 1826, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 2083, 8, 9300, 12, 413, 12, 413, 12, 10313, 29, 21948, 14, 5834, 395, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 6606, 63, 2977, 9, 339, 6954, 63, 25876, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 36, 6593, 57, 12, 267, 701, 69, 2311, 4022, 18, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 8302, 63, 25876, 2977, 9, 339, 327, 32740, 6791, 370, 10162, 5661, 273, 14, 272, 1321, 630, 4674, 63, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 21, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 701, 4482, 2977, 1524, 1194, 12, 6546, 12, 6928, 12, 7829, 12, 3388, 12, 5851, 12, 6155, 467, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 433, 630, 4674, 63, 2977, 9, 339, 1335, 21797, 63, 17, 270, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 17, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 9, 339, 1335, 21797, 63, 17, 270, 63, 83, 24759, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 18, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 63, 83, 24759, 9, 339, 1335, 21797, 63, 17, 270, 63, 14997, 300, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 23, 12, 267, 701, 4482, 2977, 29, 19, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 12, 267, 2581, 29, 549, 12, 267, 4487, 928, 29, 928, 12, 267, 5133, 29, 500, 272, 776, 272, 2222, 63, 1239, 1098, 63, 4423, 14, 740, 8, 74, 21797, 63, 17, 270, 63, 14997, 300, 2977, 9, 339, 16279, 31629, 63, 20154, 2977, 275, 519, 2200, 14, 82, 2200, 8, 267, 519, 2200, 14, 16413, 6084, 12, 267, 701, 4482, 29, 24, 12, 267, 701, 12451, 29, 82, 2200, 14, 2679, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
connor4312/socketIO-client
socketIO_client/__init__.py
6
18043
from .exceptions import ConnectionError, TimeoutError, PacketError from .heartbeats import HeartbeatThread from .logs import LoggingMixin from .namespaces import ( EngineIONamespace, SocketIONamespace, LoggingSocketIONamespace, find_callback) from .parsers import ( parse_host, parse_engineIO_session, format_socketIO_packet_data, parse_socketIO_packet_data, get_namespace_path) from .symmetries import get_character from .transports import ( WebsocketTransport, XHR_PollingTransport, prepare_http_session, TRANSPORTS) __all__ = 'SocketIO', 'SocketIONamespace' __version__ = '0.6.3' BaseNamespace = SocketIONamespace LoggingNamespace = LoggingSocketIONamespace def retry(f): def wrap(*args, **kw): self = args[0] try: return f(*args, **kw) except (TimeoutError, ConnectionError): self._opened = False return f(*args, **kw) return wrap class EngineIO(LoggingMixin): def __init__( self, host, port=None, Namespace=EngineIONamespace, wait_for_connection=True, transports=TRANSPORTS, resource='engine.io', hurry_interval_in_seconds=1, **kw): self._is_secure, self._url = parse_host(host, port, resource) self._wait_for_connection = wait_for_connection self._client_transports = transports self._hurry_interval_in_seconds = hurry_interval_in_seconds self._http_session = prepare_http_session(kw) self._log_name = self._url self._wants_to_close = False self._opened = False if Namespace: self.define(Namespace) self._transport # Connect @property def _transport(self): if self._opened: return self._transport_instance self._engineIO_session = self._get_engineIO_session() self._negotiate_transport() self._connect_namespaces() self._opened = True self._reset_heartbeat() return self._transport_instance def _get_engineIO_session(self): warning_screen = self._yield_warning_screen() for elapsed_time in warning_screen: transport = XHR_PollingTransport( self._http_session, self._is_secure, self._url) try: engineIO_packet_type, engineIO_packet_data = next( transport.recv_packet()) break except (TimeoutError, ConnectionError) as e: if not self._wait_for_connection: raise warning = Exception('[waiting for connection] %s' % e) warning_screen.throw(warning) assert engineIO_packet_type == 0 # engineIO_packet_type == open return parse_engineIO_session(engineIO_packet_data) def _negotiate_transport(self): self._transport_instance = self._get_transport('xhr-polling') self.transport_name = 'xhr-polling' is_ws_client = 'websocket' in self._client_transports is_ws_server = 'websocket' in self._engineIO_session.transport_upgrades if is_ws_client and is_ws_server: try: transport = self._get_transport('websocket') transport.send_packet(2, 'probe') for packet_type, packet_data in transport.recv_packet(): if packet_type == 3 and packet_data == b'probe': transport.send_packet(5, '') self._transport_instance = transport self.transport_name = 'websocket' else: self._warn('unexpected engine.io packet') except Exception: pass self._debug('[transport selected] %s', self.transport_name) def _reset_heartbeat(self): try: self._heartbeat_thread.halt() hurried = self._heartbeat_thread.hurried except AttributeError: hurried = False ping_interval = self._engineIO_session.ping_interval if self.transport_name.endswith('-polling'): # Use ping/pong to unblock recv for polling transport hurry_interval_in_seconds = self._hurry_interval_in_seconds else: # Use timeout to unblock recv for websocket transport hurry_interval_in_seconds = ping_interval self._heartbeat_thread = HeartbeatThread( send_heartbeat=self._ping, relax_interval_in_seconds=ping_interval, hurry_interval_in_seconds=hurry_interval_in_seconds) self._heartbeat_thread.start() if hurried: self._heartbeat_thread.hurry() self._debug('[heartbeat reset]') def _connect_namespaces(self): pass def _get_transport(self, transport_name): SelectedTransport = { 'xhr-polling': XHR_PollingTransport, 'websocket': WebsocketTransport, }[transport_name] return SelectedTransport( self._http_session, self._is_secure, self._url, self._engineIO_session) def __enter__(self): return self def __exit__(self, *exception_pack): self._close() def __del__(self): self._close() # Define def define(self, Namespace): self._namespace = namespace = Namespace(self) return namespace def on(self, event, callback): try: namespace = self.get_namespace() except PacketError: namespace = self.define(EngineIONamespace) return namespace.on(event, callback) def get_namespace(self): try: return self._namespace except AttributeError: raise PacketError('undefined engine.io namespace') # Act def send(self, engineIO_packet_data): self._message(engineIO_packet_data) def _open(self): engineIO_packet_type = 0 self._transport_instance.send_packet(engineIO_packet_type) def _close(self): self._wants_to_close = True try: self._heartbeat_thread.halt() except AttributeError: pass if not self._opened: return engineIO_packet_type = 1 try: self._transport_instance.send_packet(engineIO_packet_type) except (TimeoutError, ConnectionError): pass self._opened = False def _ping(self, engineIO_packet_data=''): engineIO_packet_type = 2 self._transport_instance.send_packet( engineIO_packet_type, engineIO_packet_data) def _pong(self, engineIO_packet_data=''): engineIO_packet_type = 3 self._transport_instance.send_packet( engineIO_packet_type, engineIO_packet_data) @retry def _message(self, engineIO_packet_data, with_transport_instance=False): engineIO_packet_type = 4 if with_transport_instance: transport = self._transport_instance else: transport = self._transport transport.send_packet(engineIO_packet_type, engineIO_packet_data) self._debug('[socket.io packet sent] %s', engineIO_packet_data) def _upgrade(self): engineIO_packet_type = 5 self._transport_instance.send_packet(engineIO_packet_type) def _noop(self): engineIO_packet_type = 6 self._transport_instance.send_packet(engineIO_packet_type) # React def wait(self, seconds=None, **kw): 'Wait in a loop and react to events as defined in the namespaces' # Use ping/pong to unblock recv for polling transport self._heartbeat_thread.hurry() # Use timeout to unblock recv for websocket transport self._transport.set_timeout(seconds=1) # Listen warning_screen = self._yield_warning_screen(seconds) for elapsed_time in warning_screen: if self._should_stop_waiting(**kw): break try: try: self._process_packets() except TimeoutError: pass except ConnectionError as e: self._opened = False try: warning = Exception('[connection error] %s' % e) warning_screen.throw(warning) except StopIteration: self._warn(warning) try: namespace = self.get_namespace() namespace.on_disconnect() except PacketError: pass self._heartbeat_thread.relax() self._transport.set_timeout() def _should_stop_waiting(self): return self._wants_to_close def _process_packets(self): for engineIO_packet in self._transport.recv_packet(): try: self._process_packet(engineIO_packet) except PacketError as e: self._warn('[packet error] %s', e) def _process_packet(self, packet): engineIO_packet_type, engineIO_packet_data = packet # Launch callbacks namespace = self.get_namespace() try: delegate = { 0: self._on_open, 1: self._on_close, 2: self._on_ping, 3: self._on_pong, 4: self._on_message, 5: self._on_upgrade, 6: self._on_noop, }[engineIO_packet_type] except KeyError: raise PacketError( 'unexpected engine.io packet type (%s)' % engineIO_packet_type) delegate(engineIO_packet_data, namespace) if engineIO_packet_type is 4: return engineIO_packet_data def _on_open(self, data, namespace): namespace._find_packet_callback('open')() def _on_close(self, data, namespace): namespace._find_packet_callback('close')() def _on_ping(self, data, namespace): self._pong(data) namespace._find_packet_callback('ping')(data) def _on_pong(self, data, namespace): namespace._find_packet_callback('pong')(data) def _on_message(self, data, namespace): namespace._find_packet_callback('message')(data) def _on_upgrade(self, data, namespace): namespace._find_packet_callback('upgrade')() def _on_noop(self, data, namespace): namespace._find_packet_callback('noop')() class SocketIO(EngineIO): """Create a socket.io client that connects to a socket.io server at the specified host and port. - Define the behavior of the client by specifying a custom Namespace. - Prefix host with https:// to use SSL. - Set wait_for_connection=True to block until we have a connection. - Specify desired transports=['websocket', 'xhr-polling']. - Pass query params, headers, cookies, proxies as keyword arguments. SocketIO( 'localhost', 8000, params={'q': 'qqq'}, headers={'Authorization': 'Basic ' + b64encode('username:password')}, cookies={'a': 'aaa'}, proxies={'https': 'https://proxy.example.com:8080'}) """ def __init__( self, host, port=None, Namespace=SocketIONamespace, wait_for_connection=True, transports=TRANSPORTS, resource='socket.io', hurry_interval_in_seconds=1, **kw): self._namespace_by_path = {} self._callback_by_ack_id = {} self._ack_id = 0 super(SocketIO, self).__init__( host, port, Namespace, wait_for_connection, transports, resource, hurry_interval_in_seconds, **kw) # Connect @property def connected(self): return self._opened def _connect_namespaces(self): for path, namespace in self._namespace_by_path.items(): namespace._transport = self._transport_instance if path: self.connect(path, with_transport_instance=True) def __exit__(self, *exception_pack): self.disconnect() super(SocketIO, self).__exit__(*exception_pack) def __del__(self): self.disconnect() super(SocketIO, self).__del__() # Define def define(self, Namespace, path=''): self._namespace_by_path[path] = namespace = Namespace(self, path) if path: self.connect(path) self.wait(for_connect=True) return namespace def on(self, event, callback, path=''): try: namespace = self.get_namespace(path) except PacketError: namespace = self.define(SocketIONamespace, path) return namespace.on(event, callback) def get_namespace(self, path=''): try: return self._namespace_by_path[path] except KeyError: raise PacketError('undefined socket.io namespace (%s)' % path) # Act def connect(self, path, with_transport_instance=False): socketIO_packet_type = 0 socketIO_packet_data = format_socketIO_packet_data(path) self._message( str(socketIO_packet_type) + socketIO_packet_data, with_transport_instance) def disconnect(self, path=''): if not path or not self._opened: self._close() elif path: socketIO_packet_type = 1 socketIO_packet_data = format_socketIO_packet_data(path) try: self._message(str(socketIO_packet_type) + socketIO_packet_data) except (TimeoutError, ConnectionError): pass try: namespace = self._namespace_by_path.pop(path) namespace.on_disconnect() except KeyError: pass def emit(self, event, *args, **kw): path = kw.get('path', '') callback, args = find_callback(args, kw) ack_id = self._set_ack_callback(callback) if callback else None args = [event] + list(args) socketIO_packet_type = 2 socketIO_packet_data = format_socketIO_packet_data(path, ack_id, args) self._message(str(socketIO_packet_type) + socketIO_packet_data) def send(self, data='', callback=None, **kw): path = kw.get('path', '') args = [data] if callback: args.append(callback) self.emit('message', *args, path=path) def _ack(self, path, ack_id, *args): socketIO_packet_type = 3 socketIO_packet_data = format_socketIO_packet_data(path, ack_id, args) self._message(str(socketIO_packet_type) + socketIO_packet_data) # React def wait_for_callbacks(self, seconds=None): self.wait(seconds, for_callbacks=True) def _should_stop_waiting(self, for_connect=False, for_callbacks=False): if for_connect: for namespace in self._namespace_by_path.values(): is_namespace_connected = getattr( namespace, '_connected', False) if not is_namespace_connected: return False return True if for_callbacks and not self._has_ack_callback: return True return super(SocketIO, self)._should_stop_waiting() def _process_packet(self, packet): engineIO_packet_data = super(SocketIO, self)._process_packet(packet) if engineIO_packet_data is None: return self._debug('[socket.io packet received] %s', engineIO_packet_data) socketIO_packet_type = int(get_character(engineIO_packet_data, 0)) socketIO_packet_data = engineIO_packet_data[1:] # Launch callbacks path = get_namespace_path(socketIO_packet_data) namespace = self.get_namespace(path) try: delegate = { 0: self._on_connect, 1: self._on_disconnect, 2: self._on_event, 3: self._on_ack, 4: self._on_error, 5: self._on_binary_event, 6: self._on_binary_ack, }[socketIO_packet_type] except KeyError: raise PacketError( 'unexpected socket.io packet type (%s)' % socketIO_packet_type) delegate(socketIO_packet_data, namespace) return socketIO_packet_data def _on_connect(self, data, namespace): namespace._connected = True namespace._find_packet_callback('connect')() def _on_disconnect(self, data, namespace): namespace._connected = False namespace._find_packet_callback('disconnect')() def _on_event(self, data, namespace): data_parsed = parse_socketIO_packet_data(data) args = data_parsed.args try: event = args.pop(0) except IndexError: raise PacketError('missing event name') if data_parsed.ack_id is not None: args.append(self._prepare_to_send_ack( data_parsed.path, data_parsed.ack_id)) namespace._find_packet_callback(event)(*args) def _on_ack(self, data, namespace): data_parsed = parse_socketIO_packet_data(data) try: ack_callback = self._get_ack_callback(data_parsed.ack_id) except KeyError: return ack_callback(*data_parsed.args) def _on_error(self, data, namespace): namespace._find_packet_callback('error')(data) def _on_binary_event(self, data, namespace): self._warn('[not implemented] binary event') def _on_binary_ack(self, data, namespace): self._warn('[not implemented] binary ack') def _prepare_to_send_ack(self, path, ack_id): 'Return function that acknowledges the server' return lambda *args: self._ack(path, ack_id, *args) def _set_ack_callback(self, callback): self._ack_id += 1 self._callback_by_ack_id[self._ack_id] = callback return self._ack_id def _get_ack_callback(self, ack_id): return self._callback_by_ack_id.pop(ack_id) @property def _has_ack_callback(self): return True if self._callback_by_ack_id else False
mit
[ 504, 1275, 3924, 492, 25417, 12, 31886, 12, 31782, 547, 199, 504, 1275, 426, 580, 1235, 1956, 492, 5311, 16145, 4436, 199, 504, 1275, 7270, 492, 19928, 4256, 199, 504, 1275, 9247, 492, 334, 272, 12580, 1075, 313, 2638, 12, 17766, 1075, 313, 2638, 12, 19928, 3869, 1075, 313, 2638, 12, 272, 2342, 63, 3058, 9, 199, 504, 1275, 11531, 492, 334, 272, 2198, 63, 1102, 12, 2198, 63, 3908, 2090, 63, 1730, 12, 272, 1475, 63, 3450, 2090, 63, 6253, 63, 576, 12, 2198, 63, 3450, 2090, 63, 6253, 63, 576, 12, 272, 664, 63, 3251, 63, 515, 9, 199, 504, 1275, 3840, 3318, 397, 492, 664, 63, 10856, 199, 504, 1275, 5545, 83, 492, 334, 272, 2136, 10833, 7836, 12, 1323, 14784, 63, 28588, 7836, 12, 9275, 63, 1014, 63, 1730, 12, 9074, 5622, 3657, 51, 9, 421, 199, 363, 452, 363, 275, 283, 3869, 2090, 297, 283, 3869, 1075, 313, 2638, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 22, 14, 19, 7, 199, 1563, 8814, 275, 17766, 1075, 313, 2638, 199, 14054, 8814, 275, 19928, 3869, 1075, 313, 2638, 421, 199, 318, 7269, 8, 70, 304, 272, 347, 4816, 2031, 589, 12, 1011, 829, 304, 267, 291, 275, 1249, 59, 16, 61, 267, 862, 26, 288, 372, 289, 2031, 589, 12, 1011, 829, 9, 267, 871, 334, 19382, 12, 25417, 304, 288, 291, 423, 19234, 275, 756, 288, 372, 289, 2031, 589, 12, 1011, 829, 9, 272, 372, 4816, 421, 199, 533, 12580, 2090, 8, 14054, 4256, 304, 339, 347, 636, 826, 721, 288, 291, 12, 1591, 12, 1844, 29, 403, 12, 19317, 29, 8524, 1075, 313, 2638, 12, 288, 3618, 63, 509, 63, 2105, 29, 549, 12, 7773, 83, 29, 12191, 3657, 51, 12, 288, 2073, 534, 3908, 14, 2308, 297, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 29, 17, 12, 1011, 829, 304, 267, 291, 423, 374, 63, 7817, 12, 291, 423, 633, 275, 2198, 63, 1102, 8, 1102, 12, 1844, 12, 2073, 9, 267, 291, 423, 2573, 63, 509, 63, 2105, 275, 3618, 63, 509, 63, 2105, 267, 291, 423, 1258, 63, 5545, 83, 275, 7773, 83, 267, 291, 423, 72, 300, 651, 63, 4284, 63, 262, 63, 4515, 275, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 267, 291, 423, 1014, 63, 1730, 275, 9275, 63, 1014, 63, 1730, 8, 829, 9, 398, 291, 423, 793, 63, 354, 275, 291, 423, 633, 267, 291, 423, 28789, 63, 475, 63, 1600, 275, 756, 267, 291, 423, 19234, 275, 756, 398, 340, 19317, 26, 288, 291, 14, 4640, 8, 8814, 9, 267, 291, 423, 5545, 339, 327, 15175, 339, 768, 1829, 272, 347, 485, 5545, 8, 277, 304, 267, 340, 291, 423, 19234, 26, 288, 372, 291, 423, 5545, 63, 842, 267, 291, 423, 3908, 2090, 63, 1730, 275, 291, 423, 362, 63, 3908, 2090, 63, 1730, 342, 267, 291, 423, 21961, 323, 63, 5545, 342, 267, 291, 423, 2242, 63, 9247, 342, 267, 291, 423, 19234, 275, 715, 267, 291, 423, 3958, 63, 22685, 342, 267, 372, 291, 423, 5545, 63, 842, 339, 347, 485, 362, 63, 3908, 2090, 63, 1730, 8, 277, 304, 267, 5721, 63, 5410, 275, 291, 423, 11481, 63, 3764, 63, 5410, 342, 267, 367, 14439, 63, 521, 315, 5721, 63, 5410, 26, 288, 7773, 275, 1323, 14784, 63, 28588, 7836, 8, 355, 291, 423, 1014, 63, 1730, 12, 291, 423, 374, 63, 7817, 12, 291, 423, 633, 9, 288, 862, 26, 355, 6869, 2090, 63, 6253, 63, 466, 12, 6869, 2090, 63, 6253, 63, 576, 275, 2163, 8, 490, 7773, 14, 7637, 63, 6253, 1012, 355, 2059, 288, 871, 334, 19382, 12, 25417, 9, 465, 325, 26, 355, 340, 440, 291, 423, 2573, 63, 509, 63, 2105, 26, 490, 746, 355, 5721, 275, 2186, 11894, 14093, 367, 1950, 61, 450, 83, 7, 450, 325, 9, 355, 5721, 63, 5410, 14, 11964, 8, 3764, 9, 267, 702, 6869, 2090, 63, 6253, 63, 466, 508, 378, 221, 327, 6869, 2090, 63, 6253, 63, 466, 508, 1551, 267, 372, 2198, 63, 3908, 2090, 63, 1730, 8, 3908, 2090, 63, 6253, 63, 576, 9, 339, 347, 485, 21961, 323, 63, 5545, 8, 277, 304, 267, 291, 423, 5545, 63, 842, 275, 291, 423, 362, 63, 5545, 360, 88, 6271, 13, 17154, 358, 267, 291, 14, 5545, 63, 354, 275, 283, 88, 6271, 13, 17154, 7, 267, 365, 63, 3569, 63, 1258, 275, 283, 13508, 7, 315, 291, 423, 1258, 63, 5545, 83, 267, 365, 63, 3569, 63, 1000, 275, 283, 13508, 7, 315, 291, 423, 3908, 2090, 63, 1730, 14, 5545, 63, 384, 18050, 267, 340, 365, 63, 3569, 63, 1258, 436, 365, 63, 3569, 63, 1000, 26, 288, 862, 26, 355, 7773, 275, 291, 423, 362, 63, 5545, 360, 13508, 358, 355, 7773, 14, 2254, 63, 6253, 8, 18, 12, 283, 15944, 358, 355, 367, 3644, 63, 466, 12, 3644, 63, 576, 315, 7773, 14, 7637, 63, 6253, 837, 490, 340, 3644, 63, 466, 508, 650, 436, 3644, 63, 576, 508, 330, 7, 15944, 356, 717, 7773, 14, 2254, 63, 6253, 8, 21, 12, 4074, 717, 291, 423, 5545, 63, 842, 275, 7773, 717, 291, 14, 5545, 63, 354, 275, 283, 13508, 7, 490, 587, 26, 717, 291, 423, 4050, 360, 8953, 6869, 14, 2308, 3644, 358, 288, 871, 2186, 26, 355, 986, 267, 291, 423, 1757, 11894, 5545, 4895, 61, 450, 83, 297, 291, 14, 5545, 63, 354, 9, 339, 347, 485, 3958, 63, 22685, 8, 277, 304, 267, 862, 26, 288, 291, 423, 22685, 63, 2671, 14, 72, 4478, 342, 288, 394, 300, 18906, 275, 291, 423, 22685, 63, 2671, 14, 72, 300, 18906, 267, 871, 4281, 26, 288, 394, 300, 18906, 275, 756, 267, 18249, 63, 4284, 275, 291, 423, 3908, 2090, 63, 1730, 14, 4073, 63, 4284, 267, 340, 291, 14, 5545, 63, 354, 14, 4130, 3654, 17154, 735, 288, 327, 3645, 18249, 15, 26992, 370, 625, 1457, 11904, 367, 12353, 7773, 288, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 275, 291, 423, 72, 300, 651, 63, 4284, 63, 262, 63, 4515, 267, 587, 26, 288, 327, 3645, 2653, 370, 625, 1457, 11904, 367, 24897 ]
[ 1275, 3924, 492, 25417, 12, 31886, 12, 31782, 547, 199, 504, 1275, 426, 580, 1235, 1956, 492, 5311, 16145, 4436, 199, 504, 1275, 7270, 492, 19928, 4256, 199, 504, 1275, 9247, 492, 334, 272, 12580, 1075, 313, 2638, 12, 17766, 1075, 313, 2638, 12, 19928, 3869, 1075, 313, 2638, 12, 272, 2342, 63, 3058, 9, 199, 504, 1275, 11531, 492, 334, 272, 2198, 63, 1102, 12, 2198, 63, 3908, 2090, 63, 1730, 12, 272, 1475, 63, 3450, 2090, 63, 6253, 63, 576, 12, 2198, 63, 3450, 2090, 63, 6253, 63, 576, 12, 272, 664, 63, 3251, 63, 515, 9, 199, 504, 1275, 3840, 3318, 397, 492, 664, 63, 10856, 199, 504, 1275, 5545, 83, 492, 334, 272, 2136, 10833, 7836, 12, 1323, 14784, 63, 28588, 7836, 12, 9275, 63, 1014, 63, 1730, 12, 9074, 5622, 3657, 51, 9, 421, 199, 363, 452, 363, 275, 283, 3869, 2090, 297, 283, 3869, 1075, 313, 2638, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 22, 14, 19, 7, 199, 1563, 8814, 275, 17766, 1075, 313, 2638, 199, 14054, 8814, 275, 19928, 3869, 1075, 313, 2638, 421, 199, 318, 7269, 8, 70, 304, 272, 347, 4816, 2031, 589, 12, 1011, 829, 304, 267, 291, 275, 1249, 59, 16, 61, 267, 862, 26, 288, 372, 289, 2031, 589, 12, 1011, 829, 9, 267, 871, 334, 19382, 12, 25417, 304, 288, 291, 423, 19234, 275, 756, 288, 372, 289, 2031, 589, 12, 1011, 829, 9, 272, 372, 4816, 421, 199, 533, 12580, 2090, 8, 14054, 4256, 304, 339, 347, 636, 826, 721, 288, 291, 12, 1591, 12, 1844, 29, 403, 12, 19317, 29, 8524, 1075, 313, 2638, 12, 288, 3618, 63, 509, 63, 2105, 29, 549, 12, 7773, 83, 29, 12191, 3657, 51, 12, 288, 2073, 534, 3908, 14, 2308, 297, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 29, 17, 12, 1011, 829, 304, 267, 291, 423, 374, 63, 7817, 12, 291, 423, 633, 275, 2198, 63, 1102, 8, 1102, 12, 1844, 12, 2073, 9, 267, 291, 423, 2573, 63, 509, 63, 2105, 275, 3618, 63, 509, 63, 2105, 267, 291, 423, 1258, 63, 5545, 83, 275, 7773, 83, 267, 291, 423, 72, 300, 651, 63, 4284, 63, 262, 63, 4515, 275, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 267, 291, 423, 1014, 63, 1730, 275, 9275, 63, 1014, 63, 1730, 8, 829, 9, 398, 291, 423, 793, 63, 354, 275, 291, 423, 633, 267, 291, 423, 28789, 63, 475, 63, 1600, 275, 756, 267, 291, 423, 19234, 275, 756, 398, 340, 19317, 26, 288, 291, 14, 4640, 8, 8814, 9, 267, 291, 423, 5545, 339, 327, 15175, 339, 768, 1829, 272, 347, 485, 5545, 8, 277, 304, 267, 340, 291, 423, 19234, 26, 288, 372, 291, 423, 5545, 63, 842, 267, 291, 423, 3908, 2090, 63, 1730, 275, 291, 423, 362, 63, 3908, 2090, 63, 1730, 342, 267, 291, 423, 21961, 323, 63, 5545, 342, 267, 291, 423, 2242, 63, 9247, 342, 267, 291, 423, 19234, 275, 715, 267, 291, 423, 3958, 63, 22685, 342, 267, 372, 291, 423, 5545, 63, 842, 339, 347, 485, 362, 63, 3908, 2090, 63, 1730, 8, 277, 304, 267, 5721, 63, 5410, 275, 291, 423, 11481, 63, 3764, 63, 5410, 342, 267, 367, 14439, 63, 521, 315, 5721, 63, 5410, 26, 288, 7773, 275, 1323, 14784, 63, 28588, 7836, 8, 355, 291, 423, 1014, 63, 1730, 12, 291, 423, 374, 63, 7817, 12, 291, 423, 633, 9, 288, 862, 26, 355, 6869, 2090, 63, 6253, 63, 466, 12, 6869, 2090, 63, 6253, 63, 576, 275, 2163, 8, 490, 7773, 14, 7637, 63, 6253, 1012, 355, 2059, 288, 871, 334, 19382, 12, 25417, 9, 465, 325, 26, 355, 340, 440, 291, 423, 2573, 63, 509, 63, 2105, 26, 490, 746, 355, 5721, 275, 2186, 11894, 14093, 367, 1950, 61, 450, 83, 7, 450, 325, 9, 355, 5721, 63, 5410, 14, 11964, 8, 3764, 9, 267, 702, 6869, 2090, 63, 6253, 63, 466, 508, 378, 221, 327, 6869, 2090, 63, 6253, 63, 466, 508, 1551, 267, 372, 2198, 63, 3908, 2090, 63, 1730, 8, 3908, 2090, 63, 6253, 63, 576, 9, 339, 347, 485, 21961, 323, 63, 5545, 8, 277, 304, 267, 291, 423, 5545, 63, 842, 275, 291, 423, 362, 63, 5545, 360, 88, 6271, 13, 17154, 358, 267, 291, 14, 5545, 63, 354, 275, 283, 88, 6271, 13, 17154, 7, 267, 365, 63, 3569, 63, 1258, 275, 283, 13508, 7, 315, 291, 423, 1258, 63, 5545, 83, 267, 365, 63, 3569, 63, 1000, 275, 283, 13508, 7, 315, 291, 423, 3908, 2090, 63, 1730, 14, 5545, 63, 384, 18050, 267, 340, 365, 63, 3569, 63, 1258, 436, 365, 63, 3569, 63, 1000, 26, 288, 862, 26, 355, 7773, 275, 291, 423, 362, 63, 5545, 360, 13508, 358, 355, 7773, 14, 2254, 63, 6253, 8, 18, 12, 283, 15944, 358, 355, 367, 3644, 63, 466, 12, 3644, 63, 576, 315, 7773, 14, 7637, 63, 6253, 837, 490, 340, 3644, 63, 466, 508, 650, 436, 3644, 63, 576, 508, 330, 7, 15944, 356, 717, 7773, 14, 2254, 63, 6253, 8, 21, 12, 4074, 717, 291, 423, 5545, 63, 842, 275, 7773, 717, 291, 14, 5545, 63, 354, 275, 283, 13508, 7, 490, 587, 26, 717, 291, 423, 4050, 360, 8953, 6869, 14, 2308, 3644, 358, 288, 871, 2186, 26, 355, 986, 267, 291, 423, 1757, 11894, 5545, 4895, 61, 450, 83, 297, 291, 14, 5545, 63, 354, 9, 339, 347, 485, 3958, 63, 22685, 8, 277, 304, 267, 862, 26, 288, 291, 423, 22685, 63, 2671, 14, 72, 4478, 342, 288, 394, 300, 18906, 275, 291, 423, 22685, 63, 2671, 14, 72, 300, 18906, 267, 871, 4281, 26, 288, 394, 300, 18906, 275, 756, 267, 18249, 63, 4284, 275, 291, 423, 3908, 2090, 63, 1730, 14, 4073, 63, 4284, 267, 340, 291, 14, 5545, 63, 354, 14, 4130, 3654, 17154, 735, 288, 327, 3645, 18249, 15, 26992, 370, 625, 1457, 11904, 367, 12353, 7773, 288, 394, 300, 651, 63, 4284, 63, 262, 63, 4515, 275, 291, 423, 72, 300, 651, 63, 4284, 63, 262, 63, 4515, 267, 587, 26, 288, 327, 3645, 2653, 370, 625, 1457, 11904, 367, 24897, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pfnet/chainer
tests/chainerx_tests/unit_tests/routines_tests/test_connection.py
5
24647
import unittest import chainer from chainer import functions as F import numpy import pytest import chainerx from chainerx_tests import array_utils from chainerx_tests import dtype_utils from chainerx_tests import op_utils # A special parameter object used to represent an unspecified argument. class Unspecified(object): pass lstm_dtypes_valid = dtype_utils._permutate_dtype_mapping([ # Floats. (('float16', 'float16'), ('float16', 'float16')), (('float32', 'float32'), ('float32', 'float32')), (('float64', 'float64'), ('float64', 'float64')), ]) lstm_dtypes_invalid = dtype_utils._permutate_dtype_mapping([ # Bools. (('bool_', 'bool_'), ('bool_', 'bool_')), # Floats. (('float32', 'float16'), ('float32', 'float16')), (('float64', 'float16'), ('float64', 'float16')), (('float64', 'float32'), ('float64', 'float32')), # Signed ints. (('int8', 'int8'), ('int8', 'int8')), (('int8', 'int16'), ('int8', 'int16')), (('int8', 'int32'), ('int8', 'int32')), (('int8', 'int64'), ('int8', 'int64')), (('int16', 'int16'), ('int16', 'int16')), (('int32', 'int32'), ('int32', 'int32')), (('int64', 'int64'), ('int64', 'int64')), (('int16', 'int32'), ('int16', 'int32')), (('int16', 'int64'), ('int16', 'int64')), (('int32', 'int64'), ('int32', 'int64')), # Unsigned ints. (('uint8', 'uint8'), ('uint8', 'uint8')), # Signed int and unsigned int. (('uint8', 'int8'), ('uint8', 'int8')), (('uint8', 'int16'), ('uint8', 'int16')), (('uint8', 'int32'), ('uint8', 'int32')), # Int and float. (('int8', 'float16'), ('int8', 'float16')), (('uint8', 'float16'), ('uint8', 'float16')), (('int16', 'float32'), ('int16', 'float32')), (('int32', 'float32'), ('int32', 'float32')), (('int64', 'float32'), ('int64', 'float32')), # Bool and other. (('bool_', 'uint8'), ('bool_', 'uint8')), (('bool_', 'int8'), ('bool_', 'int8')), (('bool_', 'int16'), ('bool_', 'int16')), (('bool_', 'float16'), ('bool_', 'float16')), (('bool_', 'float64'), ('bool_', 'float64')), ]) def _create_lstm_args(xp, device, c_shape, x_shape, float_dtype): c = array_utils.create_dummy_ndarray(xp, c_shape, float_dtype[0]) x = array_utils.create_dummy_ndarray(xp, x_shape, float_dtype[1]) return c, x def _create_conv_args( xp, device, x_shape, w_shape, b_shape, stride, pad, cover_all, float_dtype): x = array_utils.create_dummy_ndarray(xp, x_shape, float_dtype) w = array_utils.create_dummy_ndarray(xp, w_shape, float_dtype) if b_shape is None: b = None else: b = array_utils.create_dummy_ndarray(xp, b_shape, float_dtype) if device.backend.name == 'cuda': # cover_all is not supported by CUDA. cover_all = False return x, w, b, stride, pad, cover_all def _convert_to_nhwc_layout(array): # Converts a contiguous array to NHWC data layout. assert isinstance(array, numpy.ndarray) assert array.flags.c_contiguous shape = array.shape transposed_array = numpy.transpose(array, (0, 3, 1, 2)) transposed_array = numpy.ascontiguousarray(transposed_array) array = numpy.transpose(transposed_array, (0, 2, 3, 1)) assert array.shape == shape return array class _ConvTestBase(object): def setup(self): if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x_kind = numpy.dtype(x_dtype).kind w_kind = numpy.dtype(w_dtype).kind b_kind = None if b_dtype is None else numpy.dtype(b_dtype).kind device = chainerx.get_default_device() if device.backend.name == 'cuda' and len(self.x_shape) <= 3: # TODO(hvy): Support 1 dimensional convolution with CUDA. pytest.skip('cudnn does not support 1-dim convolution') if device.backend.name == 'cuda' and self.cover_all: pytest.skip('cudnn does not support cover_all') # Skip backward/double-backward tests for int dtypes if (x_kind != 'f' and w_kind != 'f' and (b_kind is None or b_kind != 'f')): self.skip_backward_test = True self.skip_double_backward_test = True if (x_dtype == 'float16' or w_dtype == 'float16' or b_dtype == 'float16'): self.check_forward_options.update({'rtol': 5e-2, 'atol': 5e-3}) self.check_backward_options.update({ 'eps': 2 ** -3, 'rtol': 1e-1, 'atol': 1e-2}) else: self.check_forward_options.update({'rtol': 1e-3}) self.check_backward_options.update({ 'eps': 1e-2, 'rtol': 1e-3, 'atol': 1e-4}) self.check_double_backward_options.update({ 'rtol': 5e-2, 'atol': 5e-3}) def generate_inputs(self): x_shape = self.x_shape w_shape = self.w_shape b_shape = self.b_shape if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x = array_utils.uniform(x_shape, x_dtype) w = array_utils.uniform(w_shape, w_dtype) if b_shape is None: return x, w else: b = array_utils.uniform(b_shape, b_dtype) return x, w, b def forward_chainerx(self, inputs): if len(inputs) == 2: (x, w), b = inputs, None else: x, w, b = inputs y = chainerx.conv(x, w, b, self.stride, self.pad, self.cover_all) return y, def forward_chainer(self, inputs): if len(inputs) == 2: (x, w), b = inputs, None else: x, w, b = inputs if x.dtype.kind != 'f': x = F.cast(x, 'float64') if w.dtype.kind != 'f': w = F.cast(w, 'float64') if b is not None and b.dtype.kind != 'f': b = F.cast(b, 'float64') y = F.convolution_nd( x, w, b, self.stride, self.pad, self.cover_all) y = F.cast(y, self.out_dtype) return y, @op_utils.op_test(['native:0', 'cuda:0']) @chainer.testing.parameterize(*( # without bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,stride,pad', [ ((1, 3), (5, 3), None, 1, 0), ((1, 3, 4), (5, 3, 2), None, 3, 2), ((2, 3, 4, 4), (2, 3, 3, 3), None, 2, (2, 0)), ((2, 3, 2, 6, 3), (2, 3, 1, 3, 2), None, (1, 2, 3), (2, 0, 1)), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_two_arrays) ]) + # with bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,stride,pad', [ ((1, 3), (5, 3), (5,), 1, 0), ((2, 3, 4), (5, 3, 1), (5,), 1, 0), ((1, 3, 4), (5, 3, 2), (5,), 3, 2), ((2, 3, 4, 4), (2, 3, 3, 3), (2,), 1, 0), ((1, 3, 4, 4), (2, 3, 3, 3), (2,), (1, 2), 1), ((1, 3, 4, 4), (2, 3, 3, 3), (2,), 2, (2, 0)), ((1, 3, 2, 6, 3), (2, 3, 1, 3, 2), (2,), 2, (2, 0, 1)), ((1, 3, 2, 6, 3), (2, 3, 1, 3, 2), (2,), (1, 2, 3), (2, 0, 1)), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_three_arrays) ]) )) @chainer.testing.parameterize_pytest('cover_all', [True, False]) class TestConv(_ConvTestBase, op_utils.ChainerOpTest): pass # cudnnFindConvolutionForwardAlgorithmEx tends to choose an algorithm which # uses TensorCore when: # - The sizes of the input arrays are large # - The input `x` is aligned with NHWC data layout @op_utils.op_test(['cuda:0']) class TestConvTensorCore(_ConvTestBase, op_utils.ChainerOpTest): x_shape = (8, 3, 227, 227) w_shape = (96, 3, 11, 11) b_shape = (96,) stride = 4 pad = 0 in_dtypes = ('float16', 'float16', 'float16') out_dtype = 'float16' cover_all = False def __init__(self): # TODO(imanishi): Skip only if compute_capability < 70. # Huge floating-point error often arises, because our CI environment # have no Tensor Cores. raise unittest.SkipTest() def generate_inputs(self): x, w, b = super().generate_inputs() return _convert_to_nhwc_layout(x), w, b @pytest.mark.parametrize('x_shape,w_shape,b_shape,stride,pad', [ # Mismatched x and w input channels. ((1, 3, 4, 3), (5, 4, 2, 2), (5,), 3, 2), # Mismatched x and w dimensions. ((2, 3, 4, 3), (5, 3, 2, 2, 1), (5,), 3, 2), ((1, 3, 4, 3), (5, 3, 2, 2), (6,), 1, 0), # Mismatched w and b. ((2, 3, 4, 3), (5, 3, 2, 2), None, (1,), 0), # Wrong number of strides. ((1, 3, 4, 3), (5, 3, 2, 2), None, 3, (2,)), # Wrong number of paddings. ]) @pytest.mark.parametrize('cover_all', [True, False]) @pytest.mark.parametrize_device(['native:0', 'cuda:0']) def test_conv_invalid( device, x_shape, w_shape, b_shape, stride, pad, cover_all, float_dtype): with pytest.raises(chainerx.DimensionError): chainerx.conv( *_create_conv_args( chainerx, device, x_shape, w_shape, b_shape, stride, pad, cover_all, float_dtype)) class _ConvTransposeTestBase(object): def setup(self): if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x_kind = numpy.dtype(x_dtype).kind w_kind = numpy.dtype(w_dtype).kind b_kind = None if b_dtype is None else numpy.dtype(b_dtype).kind device = chainerx.get_default_device() if device.backend.name == 'cuda' and len(self.x_shape) <= 3: # TODO(sonots): Support 1 dimensional convolution with CUDA. pytest.skip( 'cuDNN does not support 1 dimensional convolution and throws ' 'DimensionError') if device.backend.name == 'cuda' and self.cover_all is True: pytest.skip( 'outsize (for cover_all=True) is not supported by CUDA') # Skip backward/double-backward tests for int dtypes if (x_kind != 'f' and w_kind != 'f' and (b_kind is None or b_kind != 'f')): self.skip_backward_test = True self.skip_double_backward_test = True if (x_dtype == 'float16' or w_dtype == 'float16' or b_dtype == 'float16'): self.check_forward_options.update({'rtol': 5e-2, 'atol': 2e-2}) self.check_backward_options.update({ 'eps': 2 ** -3, 'rtol': 1e-1, 'atol': 1e-2}) else: self.check_forward_options.update({'rtol': 1e-3}) self.check_backward_options.update({ 'eps': 1e-2, 'rtol': 1e-3, 'atol': 1e-4}) self.check_double_backward_options.update({ 'rtol': 5e-2, 'atol': 5e-3}) # Determine outsize cover_all = self.cover_all if cover_all is None: outsize = None else: x_shape = self.x_shape w_shape = self.w_shape stride = self.stride pad = self.pad in_dims = x_shape[2:] kernel_size = w_shape[2:] ndim = len(in_dims) stride_tup = ( (stride,) * ndim if isinstance(stride, int) else stride) pad_tup = (pad,) * ndim if isinstance(pad, int) else pad outsize = tuple( chainer.utils.conv.get_deconv_outsize(d, k, s, p, cover_all) for (d, k, s, p) in zip(in_dims, kernel_size, stride_tup, pad_tup)) self.outsize = outsize def generate_inputs(self): x_shape = self.x_shape w_shape = self.w_shape b_shape = self.b_shape if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x = array_utils.uniform(x_shape, x_dtype) w = array_utils.uniform(w_shape, w_dtype) if b_shape is None: return x, w else: b = array_utils.uniform(b_shape, b_dtype) return x, w, b def forward_chainerx(self, inputs): if len(inputs) == 3: x, w, b = inputs else: (x, w), b = inputs, None y = chainerx.conv_transpose( x, w, b, self.stride, self.pad, self.outsize) return y, def forward_chainer(self, inputs): if len(inputs) == 3: x, w, b = inputs else: (x, w), b = inputs, None if x.dtype.kind != 'f': x = F.cast(x, 'float64') if w.dtype.kind != 'f': w = F.cast(w, 'float64') if b is not None and b.dtype.kind != 'f': b = F.cast(b, 'float64') y = chainer.functions.deconvolution_nd( x, w, b, self.stride, self.pad, self.outsize) y = F.cast(y, self.out_dtype) return y, @op_utils.op_test(['native:0', 'cuda:0']) @chainer.testing.parameterize(*( # without bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,stride,pad', [ ((1, 3), (3, 5), None, 1, 0), ((1, 3, 4), (3, 5, 2), None, 3, 2), ((2, 3, 4, 4), (3, 2, 3, 3), None, 2, (2, 0)), ((2, 3, 5, 6, 3), (3, 2, 1, 3, 2), None, (1, 2, 3), (2, 0, 1)), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_two_arrays) ]) + # with bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,stride,pad', [ ((1, 3), (3, 5), (5,), 1, 0), ((2, 3, 4), (3, 5, 1), (5,), 1, 0), ((1, 3, 4), (3, 5, 2), (5,), 3, 2), ((2, 3, 4, 4), (3, 2, 3, 3), (2,), 1, 0), ((1, 3, 4, 4), (3, 2, 3, 3), (2,), (1, 2), 1), ((1, 3, 4, 4), (3, 2, 3, 3), (2,), 2, (2, 0)), ((1, 3, 5, 6, 3), (3, 2, 1, 3, 2), (2,), 2, (2, 0, 1)), ((1, 3, 5, 6, 3), (3, 2, 1, 3, 2), (2,), (1, 2, 3), (2, 0, 1)), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_three_arrays) ]) )) # If None, outsize argument will be None. @chainer.testing.parameterize_pytest('cover_all', [None, True, False]) class TestConvTranspose(_ConvTransposeTestBase, op_utils.ChainerOpTest): pass # cudnnFindConvolutionForwardAlgorithmEx tends to choose an algorithm which # uses TensorCore when: # - The sizes of the input arrays are large # - The input `x` is aligned with NHWC data layout @op_utils.op_test(['cuda:0']) @chainer.testing.parameterize_pytest('cover_all', [None, False]) class TestConvTransposeTensorCore( _ConvTransposeTestBase, op_utils.ChainerOpTest): x_shape = (8, 3, 227, 227) w_shape = (3, 8, 11, 11) b_shape = (8,) stride = 4 pad = 0 in_dtypes = ('float16', 'float16', 'float16') out_dtype = 'float16' def __init__(self): # TODO(imanishi): Skip only if compute_capability < 70. # Huge floating-point error often arises, because our CI environment # have no Tensor Cores. raise unittest.SkipTest() def generate_inputs(self): x, w, b = super().generate_inputs() return _convert_to_nhwc_layout(x), w, b @pytest.mark.parametrize('x_shape,w_shape,b_shape,stride,pad,outsize', [ # Mismatched x and w input channels. ((1, 3, 4, 3), (5, 4, 2, 2), (5,), 3, 2, None), # Mismatched x and w dimensions. ((2, 3, 4, 3), (3, 5, 2, 2, 1), (5,), 3, 2, None), ((1, 3, 4, 3), (3, 5, 2, 2), (6,), 1, 0, None), # Mismatched w and b. # Wrong number of strides. ((2, 3, 4, 3), (3, 5, 2, 2), None, (1,), 0, None), # Wrong number of paddings. ((1, 3, 4, 3), (3, 5, 2, 2), None, 3, (2,), None), ((1, 3, 2, 6, 3), (3, 2, 1, 3, 2), (2,), 2, (2, 0, 1), (-1, 13, 4)), # All output sizes must be non-negative # All output sizes must be non-negative ((1, 3, 2, 6, 3), (3, 2, 1, 3, 2), (2,), 2, (2, 0, 1), None), ((2, 3, 4), (3, 5, 1), (5,), 1, 0, (5,)), # Output dims are inconsistent ]) @pytest.mark.parametrize_device(['native:0', 'cuda:0']) def test_conv_transpose_invalid( device, x_shape, w_shape, b_shape, stride, pad, outsize, float_dtype): dtype = float_dtype x = array_utils.create_dummy_ndarray(chainerx, x_shape, dtype) w = array_utils.create_dummy_ndarray(chainerx, w_shape, dtype) if b_shape is None: b = None else: b = array_utils.create_dummy_ndarray(chainerx, b_shape, float_dtype) with pytest.raises(chainerx.DimensionError): chainerx.conv_transpose(x, w, b, stride, pad, outsize) @op_utils.op_test(['native:0', 'cuda:0']) # TODO(imanishi): Add test cases for more than 2 ndim @chainer.testing.parameterize(*( # without bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,n_batch_axes', [ ((2, 3), (4, 3), None, Unspecified), ((5, 2, 3), (4, 3), None, 2), ((2, 3), (4, 3), Unspecified, Unspecified), ((5, 2, 3), (4, 6), Unspecified, Unspecified), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_two_arrays) ]) + # with bias chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'x_shape,w_shape,b_shape,n_batch_axes', [ ((2, 3), (4, 3), (4,), Unspecified), ((2, 0), (3, 0), (3,), Unspecified), ((0, 2), (0, 2), (0,), Unspecified), ((0, 0), (0, 0), (0,), Unspecified), ((5, 2, 3), (4, 3), (4,), 2), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', dtype_utils.result_dtypes_three_arrays) ]) )) class TestLinear(op_utils.OpTest): def setup(self): if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x_kind = numpy.dtype(x_dtype).kind w_kind = numpy.dtype(w_dtype).kind b_kind = None if b_dtype is None else numpy.dtype(b_dtype).kind device = chainerx.get_default_device() if device.backend.name == 'cuda' and ( x_kind != 'f' or w_kind != 'f' or b_kind != 'f'): raise unittest.SkipTest('CUDA dot does not support integers.') # Skip backward/double-backward tests for int dtypes if (x_kind != 'f' and w_kind != 'f' and (b_kind is None or b_kind != 'f')): self.skip_backward_test = True self.skip_double_backward_test = True # Skip backward/double-backward tests if the output will be # disconnected. # TODO(niboshi): Remove this skip condition after enabling backward() # for such cases. if 0 in self.x_shape or 0 in self.w_shape: self.skip_backward_test = True self.skip_double_backward_test = True if (x_dtype == 'float16' or w_dtype == 'float16' or b_dtype == 'float16'): self.check_forward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) self.check_backward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) self.check_double_backward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) def generate_inputs(self): x_shape = self.x_shape w_shape = self.w_shape b_shape = self.b_shape if len(self.in_dtypes) == 3: x_dtype, w_dtype, b_dtype = self.in_dtypes else: (x_dtype, w_dtype), b_dtype = self.in_dtypes, None x = array_utils.uniform(x_shape, x_dtype) w = array_utils.uniform(w_shape, w_dtype) if b_shape in (None, Unspecified): return x, w else: b = array_utils.uniform(b_shape, b_dtype) return x, w, b def forward_chainerx(self, inputs): if len(inputs) == 3: x, w, b = inputs else: (x, w), b = inputs, None n_batch_axes = self.n_batch_axes if b is Unspecified: y = chainerx.linear(x, w) elif n_batch_axes is Unspecified: y = chainerx.linear(x, w, b) else: y = chainerx.linear(x, w, b, n_batch_axes) return y, def forward_expected(self, inputs): if len(inputs) == 3: x, w, b = inputs else: (x, w), b = inputs, None n_batch_axes = self.n_batch_axes x_shape = self.x_shape w_shape = self.w_shape out_dtype = self.out_dtype if n_batch_axes is Unspecified: n_batch_axes = 1 y_shape = x_shape[:n_batch_axes] + (w_shape[0],) x_ = x.reshape(numpy.prod(x_shape[:n_batch_axes]), numpy.prod(x_shape[n_batch_axes:])) x_ = x_.astype(out_dtype) w_ = w.astype(out_dtype) y = x_.dot(w_.T).reshape(y_shape) if b is not None: y += b assert y.dtype == out_dtype return y, @op_utils.op_test(['native:0', 'cuda:0']) @chainer.testing.parameterize(*( chainer.testing.product([ chainer.testing.from_pytest_parameterize( 'c_shape,x_shape', [ ((10, 3), (10, 12)), ((20, 32), (16, 128)), ((32, 100), (32, 400)), ((16, 20), (2, 80)), ]), chainer.testing.from_pytest_parameterize( 'in_dtypes,out_dtype', lstm_dtypes_valid) ]) )) @chainer.testing.parameterize_pytest('cover_all', [True, False]) class TestLstm(op_utils.ChainerOpTest): def setup(self): c_dtype, x_dtype = self.in_dtypes if 0 in self.c_shape or 0 in self.x_shape: self.skip_backward_test = True self.skip_double_backward_test = True if (c_dtype == 'float16' or x_dtype == 'float16'): self.check_forward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) self.check_backward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) self.check_double_backward_options.update({ 'rtol': 1e-2, 'atol': 1e-2}) def generate_inputs(self): c_shape = self.c_shape x_shape = self.x_shape c_dtype, x_dtype = self.in_dtypes c = array_utils.uniform(c_shape, c_dtype) x = array_utils.uniform(x_shape, x_dtype) return c, x def forward_chainerx(self, inputs): c, x = inputs c, h = chainerx.lstm(c, x) return c, h, def forward_chainer(self, inputs): c, x = inputs c, h = chainer.functions.lstm(c, x) return c, h, @pytest.mark.parametrize('c_shape,x_shape', [ # x.shape()[0] > c.shape()[0] ((16, 20), (20, 80)), ((10, 3), (12, 12)), # x.shape()[1] != 4 * c.shape()[1] ((32, 100), (32, 150)), ((16, 50), (16, 48)), ((64, 200), (16, 200)), ]) @pytest.mark.parametrize('cover_all', [True, False]) @pytest.mark.parametrize_device(['native:0', 'cuda:0']) def test_lstm_invalid_dimension( device, c_shape, x_shape, cover_all, float_dtype): with pytest.raises(chainerx.DimensionError): chainerx.lstm( *_create_lstm_args( chainerx, device, c_shape, x_shape, (float_dtype, float_dtype))) @pytest.mark.parametrize('c_shape,x_shape', [ ((10, 3), (10, 12)), ((20, 32), (16, 128)), ((32, 100), (32, 400)), ((16, 20), (2, 80)), ]) @pytest.mark.parametrize('in_dtypes, out_dtype', lstm_dtypes_invalid) @pytest.mark.parametrize('cover_all', [True, False]) @pytest.mark.parametrize_device(['native:0', 'cuda:0']) def test_lstm_invalid_dtype(device, c_shape, x_shape, in_dtypes, out_dtype, cover_all): with pytest.raises(chainerx.DtypeError): chainerx.lstm( *_create_lstm_args( chainerx, device, c_shape, x_shape, in_dtypes))
mit
[ 646, 2882, 199, 199, 646, 20333, 199, 504, 20333, 492, 3423, 465, 481, 199, 646, 2680, 199, 646, 4613, 199, 199, 646, 20333, 88, 199, 199, 504, 20333, 88, 63, 2219, 492, 1625, 63, 1208, 199, 504, 20333, 88, 63, 2219, 492, 2152, 63, 1208, 199, 504, 20333, 88, 63, 2219, 492, 1687, 63, 1208, 421, 199, 3, 437, 4539, 2725, 909, 1202, 370, 2954, 376, 21994, 1423, 14, 199, 533, 15254, 28387, 8, 785, 304, 272, 986, 421, 199, 26652, 63, 5717, 63, 1078, 275, 2152, 63, 1208, 423, 529, 6552, 323, 63, 2271, 63, 4745, 779, 272, 327, 11140, 83, 14, 272, 13636, 1609, 975, 297, 283, 1609, 975, 659, 661, 1609, 975, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 708, 297, 283, 1609, 708, 659, 661, 1609, 708, 297, 283, 1609, 708, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 772, 659, 661, 1609, 772, 297, 283, 1609, 772, 3855, 199, 566, 421, 199, 26652, 63, 5717, 63, 3197, 275, 2152, 63, 1208, 423, 529, 6552, 323, 63, 2271, 63, 4745, 779, 272, 327, 5088, 1446, 14, 272, 13636, 2245, 14474, 283, 2245, 63, 659, 661, 2245, 14474, 283, 2245, 63, 3855, 272, 327, 11140, 83, 14, 272, 13636, 1609, 708, 297, 283, 1609, 975, 659, 661, 1609, 708, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 975, 659, 661, 1609, 772, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 708, 659, 661, 1609, 772, 297, 283, 1609, 708, 3855, 272, 327, 6632, 379, 14526, 14, 272, 13636, 442, 24, 297, 283, 442, 24, 659, 661, 442, 24, 297, 283, 442, 24, 3855, 272, 13636, 442, 24, 297, 283, 442, 975, 659, 661, 442, 24, 297, 283, 442, 975, 3855, 272, 13636, 442, 24, 297, 283, 442, 708, 659, 661, 442, 24, 297, 283, 442, 708, 3855, 272, 13636, 442, 24, 297, 283, 442, 772, 659, 661, 442, 24, 297, 283, 442, 772, 3855, 272, 13636, 442, 975, 297, 283, 442, 975, 659, 661, 442, 975, 297, 283, 442, 975, 3855, 272, 13636, 442, 708, 297, 283, 442, 708, 659, 661, 442, 708, 297, 283, 442, 708, 3855, 272, 13636, 442, 772, 297, 283, 442, 772, 659, 661, 442, 772, 297, 283, 442, 772, 3855, 272, 13636, 442, 975, 297, 283, 442, 708, 659, 661, 442, 975, 297, 283, 442, 708, 3855, 272, 13636, 442, 975, 297, 283, 442, 772, 659, 661, 442, 975, 297, 283, 442, 772, 3855, 272, 13636, 442, 708, 297, 283, 442, 772, 659, 661, 442, 708, 297, 283, 442, 772, 3855, 272, 327, 1910, 1737, 14526, 14, 272, 13636, 1635, 24, 297, 283, 1635, 24, 659, 661, 1635, 24, 297, 283, 1635, 24, 3855, 272, 327, 6632, 379, 1109, 436, 7381, 1109, 14, 272, 13636, 1635, 24, 297, 283, 442, 24, 659, 661, 1635, 24, 297, 283, 442, 24, 3855, 272, 13636, 1635, 24, 297, 283, 442, 975, 659, 661, 1635, 24, 297, 283, 442, 975, 3855, 272, 13636, 1635, 24, 297, 283, 442, 708, 659, 661, 1635, 24, 297, 283, 442, 708, 3855, 272, 327, 9805, 436, 2069, 14, 272, 13636, 442, 24, 297, 283, 1609, 975, 659, 661, 442, 24, 297, 283, 1609, 975, 3855, 272, 13636, 1635, 24, 297, 283, 1609, 975, 659, 661, 1635, 24, 297, 283, 1609, 975, 3855, 272, 13636, 442, 975, 297, 283, 1609, 708, 659, 661, 442, 975, 297, 283, 1609, 708, 3855, 272, 13636, 442, 708, 297, 283, 1609, 708, 659, 661, 442, 708, 297, 283, 1609, 708, 3855, 272, 13636, 442, 772, 297, 283, 1609, 708, 659, 661, 442, 772, 297, 283, 1609, 708, 3855, 272, 327, 19287, 436, 1163, 14, 272, 13636, 2245, 14474, 283, 1635, 24, 659, 661, 2245, 14474, 283, 1635, 24, 3855, 272, 13636, 2245, 14474, 283, 442, 24, 659, 661, 2245, 14474, 283, 442, 24, 3855, 272, 13636, 2245, 14474, 283, 442, 975, 659, 661, 2245, 14474, 283, 442, 975, 3855, 272, 13636, 2245, 14474, 283, 1609, 975, 659, 661, 2245, 14474, 283, 1609, 975, 3855, 272, 13636, 2245, 14474, 283, 1609, 772, 659, 661, 2245, 14474, 283, 1609, 772, 3855, 199, 566, 421, 199, 318, 485, 981, 63, 26652, 63, 589, 8, 9290, 12, 2243, 12, 286, 63, 1392, 12, 671, 63, 1392, 12, 2069, 63, 2271, 304, 272, 286, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 286, 63, 1392, 12, 2069, 63, 2271, 59, 16, 566, 272, 671, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 671, 63, 1392, 12, 2069, 63, 2271, 59, 17, 566, 272, 372, 286, 12, 671, 421, 199, 318, 485, 981, 63, 5598, 63, 589, 8, 267, 21499, 12, 2243, 12, 671, 63, 1392, 12, 336, 63, 1392, 12, 330, 63, 1392, 12, 7345, 12, 6567, 12, 8486, 63, 452, 12, 267, 2069, 63, 2271, 304, 272, 671, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 671, 63, 1392, 12, 2069, 63, 2271, 9, 272, 336, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 336, 63, 1392, 12, 2069, 63, 2271, 9, 272, 340, 330, 63, 1392, 365, 488, 26, 267, 330, 275, 488, 272, 587, 26, 267, 330, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 330, 63, 1392, 12, 2069, 63, 2271, 9, 272, 340, 2243, 14, 4620, 14, 354, 508, 283, 16309, 356, 221, 327, 8486, 63, 452, 365, 440, 3748, 701, 445, 3383, 33, 14, 267, 8486, 63, 452, 275, 756, 272, 372, 671, 12, 336, 12, 330, 12, 7345, 12, 6567, 12, 8486, 63, 452, 421, 199, 318, 485, 3916, 63, 475, 63, 78, 8090, 67, 63, 4209, 8, 1144, 304, 272, 327, 19107, 282, 26611, 1625, 370, 653, 27121, 666, 7054, 14, 272, 702, 1228, 8, 1144, 12, 2680, 14, 8237, 9, 272, 702, 1625, 14, 2469, 14, 67, 63, 16583, 272, 2215, 275, 1625, 14, 1392, 272, 1752, 5824, 63, 1144, 275, 2680, 14, 10483, 8, 1144, 12, 334, 16, 12, 650, 12, 413, 12, 499, 430, 272, 1752, 5824, 63, 1144, 275, 2680, 14, 305, 16583, 1144, 8, 1515, 5824, 63 ]
[ 2882, 199, 199, 646, 20333, 199, 504, 20333, 492, 3423, 465, 481, 199, 646, 2680, 199, 646, 4613, 199, 199, 646, 20333, 88, 199, 199, 504, 20333, 88, 63, 2219, 492, 1625, 63, 1208, 199, 504, 20333, 88, 63, 2219, 492, 2152, 63, 1208, 199, 504, 20333, 88, 63, 2219, 492, 1687, 63, 1208, 421, 199, 3, 437, 4539, 2725, 909, 1202, 370, 2954, 376, 21994, 1423, 14, 199, 533, 15254, 28387, 8, 785, 304, 272, 986, 421, 199, 26652, 63, 5717, 63, 1078, 275, 2152, 63, 1208, 423, 529, 6552, 323, 63, 2271, 63, 4745, 779, 272, 327, 11140, 83, 14, 272, 13636, 1609, 975, 297, 283, 1609, 975, 659, 661, 1609, 975, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 708, 297, 283, 1609, 708, 659, 661, 1609, 708, 297, 283, 1609, 708, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 772, 659, 661, 1609, 772, 297, 283, 1609, 772, 3855, 199, 566, 421, 199, 26652, 63, 5717, 63, 3197, 275, 2152, 63, 1208, 423, 529, 6552, 323, 63, 2271, 63, 4745, 779, 272, 327, 5088, 1446, 14, 272, 13636, 2245, 14474, 283, 2245, 63, 659, 661, 2245, 14474, 283, 2245, 63, 3855, 272, 327, 11140, 83, 14, 272, 13636, 1609, 708, 297, 283, 1609, 975, 659, 661, 1609, 708, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 975, 659, 661, 1609, 772, 297, 283, 1609, 975, 3855, 272, 13636, 1609, 772, 297, 283, 1609, 708, 659, 661, 1609, 772, 297, 283, 1609, 708, 3855, 272, 327, 6632, 379, 14526, 14, 272, 13636, 442, 24, 297, 283, 442, 24, 659, 661, 442, 24, 297, 283, 442, 24, 3855, 272, 13636, 442, 24, 297, 283, 442, 975, 659, 661, 442, 24, 297, 283, 442, 975, 3855, 272, 13636, 442, 24, 297, 283, 442, 708, 659, 661, 442, 24, 297, 283, 442, 708, 3855, 272, 13636, 442, 24, 297, 283, 442, 772, 659, 661, 442, 24, 297, 283, 442, 772, 3855, 272, 13636, 442, 975, 297, 283, 442, 975, 659, 661, 442, 975, 297, 283, 442, 975, 3855, 272, 13636, 442, 708, 297, 283, 442, 708, 659, 661, 442, 708, 297, 283, 442, 708, 3855, 272, 13636, 442, 772, 297, 283, 442, 772, 659, 661, 442, 772, 297, 283, 442, 772, 3855, 272, 13636, 442, 975, 297, 283, 442, 708, 659, 661, 442, 975, 297, 283, 442, 708, 3855, 272, 13636, 442, 975, 297, 283, 442, 772, 659, 661, 442, 975, 297, 283, 442, 772, 3855, 272, 13636, 442, 708, 297, 283, 442, 772, 659, 661, 442, 708, 297, 283, 442, 772, 3855, 272, 327, 1910, 1737, 14526, 14, 272, 13636, 1635, 24, 297, 283, 1635, 24, 659, 661, 1635, 24, 297, 283, 1635, 24, 3855, 272, 327, 6632, 379, 1109, 436, 7381, 1109, 14, 272, 13636, 1635, 24, 297, 283, 442, 24, 659, 661, 1635, 24, 297, 283, 442, 24, 3855, 272, 13636, 1635, 24, 297, 283, 442, 975, 659, 661, 1635, 24, 297, 283, 442, 975, 3855, 272, 13636, 1635, 24, 297, 283, 442, 708, 659, 661, 1635, 24, 297, 283, 442, 708, 3855, 272, 327, 9805, 436, 2069, 14, 272, 13636, 442, 24, 297, 283, 1609, 975, 659, 661, 442, 24, 297, 283, 1609, 975, 3855, 272, 13636, 1635, 24, 297, 283, 1609, 975, 659, 661, 1635, 24, 297, 283, 1609, 975, 3855, 272, 13636, 442, 975, 297, 283, 1609, 708, 659, 661, 442, 975, 297, 283, 1609, 708, 3855, 272, 13636, 442, 708, 297, 283, 1609, 708, 659, 661, 442, 708, 297, 283, 1609, 708, 3855, 272, 13636, 442, 772, 297, 283, 1609, 708, 659, 661, 442, 772, 297, 283, 1609, 708, 3855, 272, 327, 19287, 436, 1163, 14, 272, 13636, 2245, 14474, 283, 1635, 24, 659, 661, 2245, 14474, 283, 1635, 24, 3855, 272, 13636, 2245, 14474, 283, 442, 24, 659, 661, 2245, 14474, 283, 442, 24, 3855, 272, 13636, 2245, 14474, 283, 442, 975, 659, 661, 2245, 14474, 283, 442, 975, 3855, 272, 13636, 2245, 14474, 283, 1609, 975, 659, 661, 2245, 14474, 283, 1609, 975, 3855, 272, 13636, 2245, 14474, 283, 1609, 772, 659, 661, 2245, 14474, 283, 1609, 772, 3855, 199, 566, 421, 199, 318, 485, 981, 63, 26652, 63, 589, 8, 9290, 12, 2243, 12, 286, 63, 1392, 12, 671, 63, 1392, 12, 2069, 63, 2271, 304, 272, 286, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 286, 63, 1392, 12, 2069, 63, 2271, 59, 16, 566, 272, 671, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 671, 63, 1392, 12, 2069, 63, 2271, 59, 17, 566, 272, 372, 286, 12, 671, 421, 199, 318, 485, 981, 63, 5598, 63, 589, 8, 267, 21499, 12, 2243, 12, 671, 63, 1392, 12, 336, 63, 1392, 12, 330, 63, 1392, 12, 7345, 12, 6567, 12, 8486, 63, 452, 12, 267, 2069, 63, 2271, 304, 272, 671, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 671, 63, 1392, 12, 2069, 63, 2271, 9, 272, 336, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 336, 63, 1392, 12, 2069, 63, 2271, 9, 272, 340, 330, 63, 1392, 365, 488, 26, 267, 330, 275, 488, 272, 587, 26, 267, 330, 275, 1625, 63, 1208, 14, 981, 63, 5869, 63, 8237, 8, 9290, 12, 330, 63, 1392, 12, 2069, 63, 2271, 9, 272, 340, 2243, 14, 4620, 14, 354, 508, 283, 16309, 356, 221, 327, 8486, 63, 452, 365, 440, 3748, 701, 445, 3383, 33, 14, 267, 8486, 63, 452, 275, 756, 272, 372, 671, 12, 336, 12, 330, 12, 7345, 12, 6567, 12, 8486, 63, 452, 421, 199, 318, 485, 3916, 63, 475, 63, 78, 8090, 67, 63, 4209, 8, 1144, 304, 272, 327, 19107, 282, 26611, 1625, 370, 653, 27121, 666, 7054, 14, 272, 702, 1228, 8, 1144, 12, 2680, 14, 8237, 9, 272, 702, 1625, 14, 2469, 14, 67, 63, 16583, 272, 2215, 275, 1625, 14, 1392, 272, 1752, 5824, 63, 1144, 275, 2680, 14, 10483, 8, 1144, 12, 334, 16, 12, 650, 12, 413, 12, 499, 430, 272, 1752, 5824, 63, 1144, 275, 2680, 14, 305, 16583, 1144, 8, 1515, 5824, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SebastianMerz/calalert
Server/venv/lib/python2.7/site-packages/jinja2/optimizer.py
1401
2302
# -*- coding: utf-8 -*- """ jinja2.optimizer ~~~~~~~~~~~~~~~~ The jinja optimizer is currently trying to constant fold a few expressions and modify the AST in place so that it should be easier to evaluate it. Because the AST does not contain all the scoping information and the compiler has to find that out, we cannot do all the optimizations we want. For example loop unrolling doesn't work because unrolled loops would have a different scoping. The solution would be a second syntax tree that has the scoping rules stored. :copyright: (c) 2010 by the Jinja Team. :license: BSD. """ from jinja2 import nodes from jinja2.visitor import NodeTransformer def optimize(node, environment): """The context hint can be used to perform an static optimization based on the context given.""" optimizer = Optimizer(environment) return optimizer.visit(node) class Optimizer(NodeTransformer): def __init__(self, environment): self.environment = environment def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result def fold(self, node): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node visit_Add = visit_Sub = visit_Mul = visit_Div = visit_FloorDiv = \ visit_Pow = visit_Mod = visit_And = visit_Or = visit_Pos = visit_Neg = \ visit_Not = visit_Compare = visit_Getitem = visit_Getattr = visit_Call = \ visit_Filter = visit_Test = visit_CondExpr = fold del fold
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 12290, 272, 18294, 339, 710, 10321, 10736, 365, 5544, 9936, 370, 4413, 20675, 282, 9284, 8455, 272, 436, 2811, 314, 20788, 315, 4192, 880, 626, 652, 1077, 506, 14905, 370, 9352, 652, 14, 339, 13821, 314, 20788, 1630, 440, 1395, 1006, 314, 27748, 4073, 2556, 436, 314, 272, 6365, 965, 370, 2342, 626, 734, 12, 781, 3913, 886, 1006, 314, 5323, 12270, 781, 272, 2934, 14, 221, 2104, 2893, 4438, 625, 31562, 3181, 1133, 1736, 2952, 625, 10504, 17222, 3955, 272, 1172, 282, 3365, 27748, 4073, 14, 339, 710, 8744, 3955, 506, 282, 3499, 6302, 3123, 626, 965, 314, 27748, 4073, 4713, 5489, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 492, 3380, 199, 504, 10321, 18, 14, 19863, 492, 5013, 19761, 421, 199, 318, 13497, 8, 932, 12, 3734, 304, 272, 408, 1918, 1067, 8328, 883, 506, 1202, 370, 5147, 376, 2955, 13712, 272, 4079, 641, 314, 1067, 1627, 1041, 272, 10736, 275, 19246, 1793, 8, 5418, 9, 272, 372, 10736, 14, 5427, 8, 932, 9, 421, 199, 533, 19246, 1793, 8, 1716, 19761, 304, 339, 347, 636, 826, 721, 277, 12, 3734, 304, 267, 291, 14, 5418, 275, 3734, 339, 347, 5684, 63, 3917, 8, 277, 12, 1031, 304, 267, 408, 37, 13769, 323, 12314, 1233, 1041, 267, 327, 886, 440, 13497, 340, 83, 626, 1172, 282, 1853, 6272, 880, 626, 652, 3181, 1133, 267, 327, 2059, 1613, 1252, 267, 340, 1031, 14, 1623, 8, 2415, 14, 3142, 9, 365, 440, 488, 26, 288, 372, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 862, 26, 288, 1139, 275, 291, 14, 5427, 8, 932, 14, 396, 680, 305, 63, 1297, 342, 267, 871, 3380, 14, 8499, 12716, 26, 288, 372, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 340, 1139, 26, 288, 2396, 275, 1031, 14, 2030, 267, 587, 26, 288, 2396, 275, 1031, 14, 2836, 63, 267, 754, 275, 942, 267, 367, 1031, 315, 2396, 26, 288, 754, 14, 2880, 8, 277, 14, 5427, 63, 513, 8, 932, 430, 267, 372, 754, 339, 347, 20675, 8, 277, 12, 1031, 304, 267, 408, 2585, 4413, 1699, 1098, 1041, 267, 1031, 275, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 862, 26, 288, 372, 3380, 14, 6361, 14, 504, 63, 324, 17549, 8, 932, 14, 305, 63, 1297, 1062, 6343, 5874, 29, 932, 14, 3469, 12, 6343, 3734, 29, 277, 14, 5418, 9, 267, 871, 3380, 14, 8499, 12716, 26, 288, 372, 1031, 339, 5684, 63, 1123, 275, 5684, 63, 2610, 275, 5684, 63, 16867, 275, 5684, 63, 24305, 275, 5684, 63, 38, 6367, 24305, 275, 971, 272, 5684, 63, 23432, 275, 5684, 63, 9871, 275, 5684, 63, 3325, 275, 5684, 63, 2844, 275, 5684, 63, 6981, 275, 5684, 63, 27814, 275, 971, 272, 5684, 63, 1763, 275, 5684, 63, 16051, 275, 5684, 63, 4240, 4484, 275, 5684, 63, 1002, 962, 275, 5684, 63, 2176, 275, 971, 272, 5684, 63, 4131, 275, 5684, 63, 774, 275, 5684, 63, 23735, 8561, 275, 20675, 272, 2150, 20675, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 12290, 272, 18294, 339, 710, 10321, 10736, 365, 5544, 9936, 370, 4413, 20675, 282, 9284, 8455, 272, 436, 2811, 314, 20788, 315, 4192, 880, 626, 652, 1077, 506, 14905, 370, 9352, 652, 14, 339, 13821, 314, 20788, 1630, 440, 1395, 1006, 314, 27748, 4073, 2556, 436, 314, 272, 6365, 965, 370, 2342, 626, 734, 12, 781, 3913, 886, 1006, 314, 5323, 12270, 781, 272, 2934, 14, 221, 2104, 2893, 4438, 625, 31562, 3181, 1133, 1736, 2952, 625, 10504, 17222, 3955, 272, 1172, 282, 3365, 27748, 4073, 14, 339, 710, 8744, 3955, 506, 282, 3499, 6302, 3123, 626, 965, 314, 27748, 4073, 4713, 5489, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 492, 3380, 199, 504, 10321, 18, 14, 19863, 492, 5013, 19761, 421, 199, 318, 13497, 8, 932, 12, 3734, 304, 272, 408, 1918, 1067, 8328, 883, 506, 1202, 370, 5147, 376, 2955, 13712, 272, 4079, 641, 314, 1067, 1627, 1041, 272, 10736, 275, 19246, 1793, 8, 5418, 9, 272, 372, 10736, 14, 5427, 8, 932, 9, 421, 199, 533, 19246, 1793, 8, 1716, 19761, 304, 339, 347, 636, 826, 721, 277, 12, 3734, 304, 267, 291, 14, 5418, 275, 3734, 339, 347, 5684, 63, 3917, 8, 277, 12, 1031, 304, 267, 408, 37, 13769, 323, 12314, 1233, 1041, 267, 327, 886, 440, 13497, 340, 83, 626, 1172, 282, 1853, 6272, 880, 626, 652, 3181, 1133, 267, 327, 2059, 1613, 1252, 267, 340, 1031, 14, 1623, 8, 2415, 14, 3142, 9, 365, 440, 488, 26, 288, 372, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 862, 26, 288, 1139, 275, 291, 14, 5427, 8, 932, 14, 396, 680, 305, 63, 1297, 342, 267, 871, 3380, 14, 8499, 12716, 26, 288, 372, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 340, 1139, 26, 288, 2396, 275, 1031, 14, 2030, 267, 587, 26, 288, 2396, 275, 1031, 14, 2836, 63, 267, 754, 275, 942, 267, 367, 1031, 315, 2396, 26, 288, 754, 14, 2880, 8, 277, 14, 5427, 63, 513, 8, 932, 430, 267, 372, 754, 339, 347, 20675, 8, 277, 12, 1031, 304, 267, 408, 2585, 4413, 1699, 1098, 1041, 267, 1031, 275, 291, 14, 6767, 63, 5427, 8, 932, 9, 267, 862, 26, 288, 372, 3380, 14, 6361, 14, 504, 63, 324, 17549, 8, 932, 14, 305, 63, 1297, 1062, 6343, 5874, 29, 932, 14, 3469, 12, 6343, 3734, 29, 277, 14, 5418, 9, 267, 871, 3380, 14, 8499, 12716, 26, 288, 372, 1031, 339, 5684, 63, 1123, 275, 5684, 63, 2610, 275, 5684, 63, 16867, 275, 5684, 63, 24305, 275, 5684, 63, 38, 6367, 24305, 275, 971, 272, 5684, 63, 23432, 275, 5684, 63, 9871, 275, 5684, 63, 3325, 275, 5684, 63, 2844, 275, 5684, 63, 6981, 275, 5684, 63, 27814, 275, 971, 272, 5684, 63, 1763, 275, 5684, 63, 16051, 275, 5684, 63, 4240, 4484, 275, 5684, 63, 1002, 962, 275, 5684, 63, 2176, 275, 971, 272, 5684, 63, 4131, 275, 5684, 63, 774, 275, 5684, 63, 23735, 8561, 275, 20675, 272, 2150, 20675, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
mollstam/UnrealPy
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/PyChart-1.39/demos/fillstyles.py
6
1243
# # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com) # # Pychart is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # Pychart 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. # from pychart import * import pychart.doc_support import chartdemo import re x = 100 y = 500 can = canvas.default_canvas() def drawRect(fill): global x, y name = pychart.doc_support.stringify_value(style) #print "name=", name name = re.sub("fill_style\\.", "", name) name = pychart.doc_support.break_string(name) height = font.text_height(name)[0] + 5 can.rectangle(line_style.default, fill, x, y, x+15, y+15) tb = text_box.T(text=name, loc=(x, y-height), line_style=None, fill_style = None) x = x + 50 tb.draw() for style in fill_style.standards.list(): drawRect(style) if x >= chartdemo.MaxWidth: x=100 y=y-40
mit
[ 3, 199, 3, 1898, 334, 35, 9, 12293, 13, 9397, 701, 1488, 305, 2084, 73, 428, 2781, 79, 334, 89, 305, 2084, 73, 14, 2231, 24308, 32, 6799, 14, 957, 9, 199, 3, 221, 199, 3, 1611, 9019, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 1611, 9019, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 199, 3, 367, 1655, 2436, 14, 199, 3, 199, 504, 1134, 9019, 492, 627, 199, 646, 1134, 9019, 14, 1301, 63, 4058, 199, 646, 10943, 8768, 199, 646, 295, 199, 199, 88, 275, 2948, 199, 89, 275, 6891, 199, 199, 2425, 275, 10218, 14, 885, 63, 7682, 342, 199, 199, 318, 5954, 8252, 8, 4498, 304, 272, 2288, 671, 12, 612, 272, 536, 275, 1134, 9019, 14, 1301, 63, 4058, 14, 875, 2021, 63, 585, 8, 2487, 9, 272, 327, 1361, 298, 354, 11107, 536, 272, 536, 275, 295, 14, 954, 480, 4498, 63, 2487, 1103, 4765, 4873, 536, 9, 272, 536, 275, 1134, 9019, 14, 1301, 63, 4058, 14, 4785, 63, 875, 8, 354, 9, 272, 4569, 275, 5023, 14, 505, 63, 3333, 8, 354, 2788, 16, 61, 435, 959, 339, 883, 14, 19954, 8, 604, 63, 2487, 14, 885, 12, 5554, 12, 671, 12, 612, 12, 671, 11, 1046, 12, 612, 11, 1046, 9, 272, 7070, 275, 1318, 63, 1977, 14, 52, 8, 505, 29, 354, 12, 4355, 2687, 88, 12, 612, 13, 3333, 395, 1004, 63, 2487, 29, 403, 12, 490, 5554, 63, 2487, 275, 488, 9, 272, 671, 275, 671, 435, 5238, 272, 7070, 14, 5485, 342, 199, 199, 509, 3449, 315, 5554, 63, 2487, 14, 7935, 5596, 14, 513, 837, 272, 5954, 8252, 8, 2487, 9, 272, 340, 671, 2356, 10943, 8768, 14, 4261, 6216, 26, 267, 671, 29, 1960, 267, 612, 29, 89, 13, 2167, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 35, 9, 12293, 13, 9397, 701, 1488, 305, 2084, 73, 428, 2781, 79, 334, 89, 305, 2084, 73, 14, 2231, 24308, 32, 6799, 14, 957, 9, 199, 3, 221, 199, 3, 1611, 9019, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 2868, 2290, 2752, 27, 1902, 1015, 499, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 1611, 9019, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 199, 3, 367, 1655, 2436, 14, 199, 3, 199, 504, 1134, 9019, 492, 627, 199, 646, 1134, 9019, 14, 1301, 63, 4058, 199, 646, 10943, 8768, 199, 646, 295, 199, 199, 88, 275, 2948, 199, 89, 275, 6891, 199, 199, 2425, 275, 10218, 14, 885, 63, 7682, 342, 199, 199, 318, 5954, 8252, 8, 4498, 304, 272, 2288, 671, 12, 612, 272, 536, 275, 1134, 9019, 14, 1301, 63, 4058, 14, 875, 2021, 63, 585, 8, 2487, 9, 272, 327, 1361, 298, 354, 11107, 536, 272, 536, 275, 295, 14, 954, 480, 4498, 63, 2487, 1103, 4765, 4873, 536, 9, 272, 536, 275, 1134, 9019, 14, 1301, 63, 4058, 14, 4785, 63, 875, 8, 354, 9, 272, 4569, 275, 5023, 14, 505, 63, 3333, 8, 354, 2788, 16, 61, 435, 959, 339, 883, 14, 19954, 8, 604, 63, 2487, 14, 885, 12, 5554, 12, 671, 12, 612, 12, 671, 11, 1046, 12, 612, 11, 1046, 9, 272, 7070, 275, 1318, 63, 1977, 14, 52, 8, 505, 29, 354, 12, 4355, 2687, 88, 12, 612, 13, 3333, 395, 1004, 63, 2487, 29, 403, 12, 490, 5554, 63, 2487, 275, 488, 9, 272, 671, 275, 671, 435, 5238, 272, 7070, 14, 5485, 342, 199, 199, 509, 3449, 315, 5554, 63, 2487, 14, 7935, 5596, 14, 513, 837, 272, 5954, 8252, 8, 2487, 9, 272, 340, 671, 2356, 10943, 8768, 14, 4261, 6216, 26, 267, 671, 29, 1960, 267, 612, 29, 89, 13, 2167, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
liqi328/rjrepaircompany
django/contrib/gis/gdal/prototypes/geom.py
315
4821
import re from datetime import date from ctypes import c_char, c_char_p, c_double, c_int, c_ubyte, c_void_p, POINTER from django.contrib.gis.gdal.envelope import OGREnvelope from django.contrib.gis.gdal.libgdal import lgdal, GEOJSON from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope from django.contrib.gis.gdal.prototypes.generation import \ const_string_output, double_output, geom_output, int_output, \ srs_output, string_output, void_output ### Generation routines specific to this module ### def env_func(f, argtypes): "For getting OGREnvelopes." f.argtypes = argtypes f.restype = None f.errcheck = check_envelope return f def pnt_func(f): "For accessing point information." return double_output(f, [c_void_p, c_int]) def topology_func(f): f.argtypes = [c_void_p, c_void_p] f.restype = c_int f.errchck = check_bool return f ### OGR_G ctypes function prototypes ### # GeoJSON routines, if supported. if GEOJSON: from_json = geom_output(lgdal.OGR_G_CreateGeometryFromJson, [c_char_p]) to_json = string_output(lgdal.OGR_G_ExportToJson, [c_void_p], str_result=True) to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p, c_char_p], str_result=True) else: from_json = False to_json = False to_kml = False # GetX, GetY, GetZ all return doubles. getx = pnt_func(lgdal.OGR_G_GetX) gety = pnt_func(lgdal.OGR_G_GetY) getz = pnt_func(lgdal.OGR_G_GetZ) # Geometry creation routines. from_wkb = geom_output(lgdal.OGR_G_CreateFromWkb, [c_char_p, c_void_p, POINTER(c_void_p), c_int], offset=-2) from_wkt = geom_output(lgdal.OGR_G_CreateFromWkt, [POINTER(c_char_p), c_void_p, POINTER(c_void_p)], offset=-1) create_geom = geom_output(lgdal.OGR_G_CreateGeometry, [c_int]) clone_geom = geom_output(lgdal.OGR_G_Clone, [c_void_p]) get_geom_ref = geom_output(lgdal.OGR_G_GetGeometryRef, [c_void_p, c_int]) get_boundary = geom_output(lgdal.OGR_G_GetBoundary, [c_void_p]) geom_convex_hull = geom_output(lgdal.OGR_G_ConvexHull, [c_void_p]) geom_diff = geom_output(lgdal.OGR_G_Difference, [c_void_p, c_void_p]) geom_intersection = geom_output(lgdal.OGR_G_Intersection, [c_void_p, c_void_p]) geom_sym_diff = geom_output(lgdal.OGR_G_SymmetricDifference, [c_void_p, c_void_p]) geom_union = geom_output(lgdal.OGR_G_Union, [c_void_p, c_void_p]) # Geometry modification routines. add_geom = void_output(lgdal.OGR_G_AddGeometry, [c_void_p, c_void_p]) import_wkt = void_output(lgdal.OGR_G_ImportFromWkt, [c_void_p, POINTER(c_char_p)]) # Destroys a geometry destroy_geom = void_output(lgdal.OGR_G_DestroyGeometry, [c_void_p], errcheck=False) # Geometry export routines. to_wkb = void_output(lgdal.OGR_G_ExportToWkb, None, errcheck=True) # special handling for WKB. to_wkt = string_output(lgdal.OGR_G_ExportToWkt, [c_void_p, POINTER(c_char_p)]) to_gml = string_output(lgdal.OGR_G_ExportToGML, [c_void_p], str_result=True) get_wkbsize = int_output(lgdal.OGR_G_WkbSize, [c_void_p]) # Geometry spatial-reference related routines. assign_srs = void_output(lgdal.OGR_G_AssignSpatialReference, [c_void_p, c_void_p], errcheck=False) get_geom_srs = srs_output(lgdal.OGR_G_GetSpatialReference, [c_void_p]) # Geometry properties get_area = double_output(lgdal.OGR_G_GetArea, [c_void_p]) get_centroid = void_output(lgdal.OGR_G_Centroid, [c_void_p, c_void_p]) get_dims = int_output(lgdal.OGR_G_GetDimension, [c_void_p]) get_coord_dim = int_output(lgdal.OGR_G_GetCoordinateDimension, [c_void_p]) set_coord_dim = void_output(lgdal.OGR_G_SetCoordinateDimension, [c_void_p, c_int], errcheck=False) get_geom_count = int_output(lgdal.OGR_G_GetGeometryCount, [c_void_p]) get_geom_name = const_string_output(lgdal.OGR_G_GetGeometryName, [c_void_p]) get_geom_type = int_output(lgdal.OGR_G_GetGeometryType, [c_void_p]) get_point_count = int_output(lgdal.OGR_G_GetPointCount, [c_void_p]) get_point = void_output(lgdal.OGR_G_GetPoint, [c_void_p, c_int, POINTER(c_double), POINTER(c_double), POINTER(c_double)], errcheck=False) geom_close_rings = void_output(lgdal.OGR_G_CloseRings, [c_void_p], errcheck=False) # Topology routines. ogr_contains = topology_func(lgdal.OGR_G_Contains) ogr_crosses = topology_func(lgdal.OGR_G_Crosses) ogr_disjoint = topology_func(lgdal.OGR_G_Disjoint) ogr_equals = topology_func(lgdal.OGR_G_Equals) ogr_intersects = topology_func(lgdal.OGR_G_Intersects) ogr_overlaps = topology_func(lgdal.OGR_G_Overlaps) ogr_touches = topology_func(lgdal.OGR_G_Touches) ogr_within = topology_func(lgdal.OGR_G_Within) # Transformation routines. geom_transform = void_output(lgdal.OGR_G_Transform, [c_void_p, c_void_p]) geom_transform_to = void_output(lgdal.OGR_G_TransformTo, [c_void_p, c_void_p]) # For retrieving the envelope of the geometry. get_envelope = env_func(lgdal.OGR_G_GetEnvelope, [c_void_p, POINTER(OGREnvelope)])
bsd-3-clause
[ 646, 295, 199, 504, 2197, 492, 1434, 199, 504, 5577, 492, 286, 63, 1560, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 20790, 12, 286, 63, 1647, 63, 80, 12, 6569, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 19707, 492, 19746, 907, 78, 10658, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 773, 11600, 492, 634, 11600, 12, 21390, 6243, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 21205, 492, 1104, 63, 2245, 12, 1104, 63, 19707, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 15043, 492, 971, 272, 950, 63, 875, 63, 1199, 12, 4270, 63, 1199, 12, 9671, 63, 1199, 12, 1109, 63, 1199, 12, 971, 272, 16191, 63, 1199, 12, 1059, 63, 1199, 12, 2309, 63, 1199, 199, 199, 5680, 1464, 425, 14975, 2488, 370, 642, 859, 6754, 199, 318, 2589, 63, 1532, 8, 70, 12, 29669, 304, 272, 298, 1858, 10232, 19746, 907, 78, 10658, 83, 2122, 272, 289, 14, 10025, 275, 29669, 272, 289, 14, 9990, 275, 488, 272, 289, 14, 21205, 275, 1104, 63, 19707, 272, 372, 289, 199, 199, 318, 19948, 63, 1532, 8, 70, 304, 272, 298, 1858, 18549, 2376, 2556, 2122, 272, 372, 4270, 63, 1199, 8, 70, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 442, 566, 199, 199, 318, 14611, 63, 1532, 8, 70, 304, 272, 289, 14, 10025, 275, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 61, 272, 289, 14, 9990, 275, 286, 63, 442, 272, 289, 14, 1508, 335, 346, 275, 1104, 63, 2245, 272, 372, 289, 199, 199, 5680, 10904, 63, 39, 5577, 805, 19393, 83, 6754, 199, 199, 3, 8875, 6243, 14975, 12, 340, 3748, 14, 199, 692, 21390, 6243, 26, 272, 687, 63, 1001, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 6831, 2532, 9653, 12, 359, 67, 63, 1560, 63, 80, 566, 272, 370, 63, 1001, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 9653, 12, 359, 67, 63, 1647, 63, 80, 467, 620, 63, 1099, 29, 549, 9, 272, 370, 63, 21351, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 43, 1698, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1560, 63, 80, 467, 620, 63, 1099, 29, 549, 9, 221, 199, 2836, 26, 272, 687, 63, 1001, 275, 756, 272, 370, 63, 1001, 275, 756, 272, 370, 63, 21351, 275, 756, 199, 199, 3, 2372, 56, 12, 2372, 57, 12, 2372, 58, 1006, 372, 4270, 83, 14, 199, 362, 88, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 56, 9, 199, 362, 89, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 57, 9, 199, 362, 90, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 58, 9, 1362, 199, 3, 10579, 7143, 14975, 14, 199, 504, 63, 18914, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 2532, 55, 7862, 12, 359, 67, 63, 1560, 63, 80, 12, 286, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1647, 63, 80, 395, 286, 63, 442, 467, 3268, 4022, 18, 9, 199, 504, 63, 11412, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 2532, 31810, 12, 359, 11260, 8, 67, 63, 1560, 63, 80, 395, 286, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1647, 63, 80, 4360, 3268, 4022, 17, 9, 199, 981, 63, 6481, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 6831, 12, 359, 67, 63, 442, 566, 199, 6311, 63, 6481, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 21222, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 362, 63, 6481, 63, 1121, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1002, 6831, 2891, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 442, 566, 199, 362, 63, 9891, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1002, 19831, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 6481, 63, 388, 26221, 63, 72, 979, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 714, 26221, 40, 979, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 6481, 63, 3028, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 32279, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 12569, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 29821, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 3840, 63, 3028, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 16594, 5165, 32279, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 8888, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 15540, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 199, 3, 10579, 7100, 14975, 14, 199, 525, 63, 6481, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1123, 6831, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 646, 63, 11412, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 6295, 2532, 31810, 12, 359, 67, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1560, 63, 80, 3948, 199, 199, 3, 20547, 293, 588, 282, 3400, 199, 7237, 63, 6481, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 14704, 6831, 12, 359, 67, 63, 1647, 63, 80, 467, 2329, 1074, 29, 797, 9, 199, 199, 3, 10579, 4843, 14975, 14, 199, 475, 63, 18914, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 55, 7862, 12, 488, 12, 2329, 1074, 29, 549, 9, 327, 4539, 7252, 367, 644, 12780, 14, 199, 475, 63, 11412, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 31810 ]
[ 295, 199, 504, 2197, 492, 1434, 199, 504, 5577, 492, 286, 63, 1560, 12, 286, 63, 1560, 63, 80, 12, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 20790, 12, 286, 63, 1647, 63, 80, 12, 6569, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 19707, 492, 19746, 907, 78, 10658, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 773, 11600, 492, 634, 11600, 12, 21390, 6243, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 21205, 492, 1104, 63, 2245, 12, 1104, 63, 19707, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 15043, 492, 971, 272, 950, 63, 875, 63, 1199, 12, 4270, 63, 1199, 12, 9671, 63, 1199, 12, 1109, 63, 1199, 12, 971, 272, 16191, 63, 1199, 12, 1059, 63, 1199, 12, 2309, 63, 1199, 199, 199, 5680, 1464, 425, 14975, 2488, 370, 642, 859, 6754, 199, 318, 2589, 63, 1532, 8, 70, 12, 29669, 304, 272, 298, 1858, 10232, 19746, 907, 78, 10658, 83, 2122, 272, 289, 14, 10025, 275, 29669, 272, 289, 14, 9990, 275, 488, 272, 289, 14, 21205, 275, 1104, 63, 19707, 272, 372, 289, 199, 199, 318, 19948, 63, 1532, 8, 70, 304, 272, 298, 1858, 18549, 2376, 2556, 2122, 272, 372, 4270, 63, 1199, 8, 70, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 442, 566, 199, 199, 318, 14611, 63, 1532, 8, 70, 304, 272, 289, 14, 10025, 275, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 61, 272, 289, 14, 9990, 275, 286, 63, 442, 272, 289, 14, 1508, 335, 346, 275, 1104, 63, 2245, 272, 372, 289, 199, 199, 5680, 10904, 63, 39, 5577, 805, 19393, 83, 6754, 199, 199, 3, 8875, 6243, 14975, 12, 340, 3748, 14, 199, 692, 21390, 6243, 26, 272, 687, 63, 1001, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 6831, 2532, 9653, 12, 359, 67, 63, 1560, 63, 80, 566, 272, 370, 63, 1001, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 9653, 12, 359, 67, 63, 1647, 63, 80, 467, 620, 63, 1099, 29, 549, 9, 272, 370, 63, 21351, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 43, 1698, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1560, 63, 80, 467, 620, 63, 1099, 29, 549, 9, 221, 199, 2836, 26, 272, 687, 63, 1001, 275, 756, 272, 370, 63, 1001, 275, 756, 272, 370, 63, 21351, 275, 756, 199, 199, 3, 2372, 56, 12, 2372, 57, 12, 2372, 58, 1006, 372, 4270, 83, 14, 199, 362, 88, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 56, 9, 199, 362, 89, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 57, 9, 199, 362, 90, 275, 19948, 63, 1532, 8, 21935, 14, 17275, 63, 39, 63, 1002, 58, 9, 1362, 199, 3, 10579, 7143, 14975, 14, 199, 504, 63, 18914, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 2532, 55, 7862, 12, 359, 67, 63, 1560, 63, 80, 12, 286, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1647, 63, 80, 395, 286, 63, 442, 467, 3268, 4022, 18, 9, 199, 504, 63, 11412, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 2532, 31810, 12, 359, 11260, 8, 67, 63, 1560, 63, 80, 395, 286, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1647, 63, 80, 4360, 3268, 4022, 17, 9, 199, 981, 63, 6481, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 2499, 6831, 12, 359, 67, 63, 442, 566, 199, 6311, 63, 6481, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 21222, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 362, 63, 6481, 63, 1121, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1002, 6831, 2891, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 442, 566, 199, 362, 63, 9891, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1002, 19831, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 6481, 63, 388, 26221, 63, 72, 979, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 714, 26221, 40, 979, 12, 359, 67, 63, 1647, 63, 80, 566, 199, 6481, 63, 3028, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 32279, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 12569, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 29821, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 3840, 63, 3028, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 16594, 5165, 32279, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 6481, 63, 8888, 275, 9671, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 15540, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 199, 3, 10579, 7100, 14975, 14, 199, 525, 63, 6481, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 1123, 6831, 12, 359, 67, 63, 1647, 63, 80, 12, 286, 63, 1647, 63, 80, 566, 199, 646, 63, 11412, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 6295, 2532, 31810, 12, 359, 67, 63, 1647, 63, 80, 12, 6569, 8, 67, 63, 1560, 63, 80, 3948, 199, 199, 3, 20547, 293, 588, 282, 3400, 199, 7237, 63, 6481, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 14704, 6831, 12, 359, 67, 63, 1647, 63, 80, 467, 2329, 1074, 29, 797, 9, 199, 199, 3, 10579, 4843, 14975, 14, 199, 475, 63, 18914, 275, 2309, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 55, 7862, 12, 488, 12, 2329, 1074, 29, 549, 9, 327, 4539, 7252, 367, 644, 12780, 14, 199, 475, 63, 11412, 275, 1059, 63, 1199, 8, 21935, 14, 17275, 63, 39, 63, 11399, 1378, 31810, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
albertomurillo/ansible
lib/ansible/modules/network/aci/aci_epg_monitoring_policy.py
27
6531
#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified'} DOCUMENTATION = r''' --- module: aci_epg_monitoring_policy short_description: Manage monitoring policies (mon:EPGPol) description: - Manage monitoring policies on Cisco ACI fabrics. version_added: '2.4' options: monitoring_policy: description: - The name of the monitoring policy. type: str required: yes aliases: [ name ] description: description: - Description for the monitoring policy. type: str aliases: [ descr ] tenant: description: - The name of the tenant. type: str required: yes aliases: [ tenant_name ] state: description: - Use C(present) or C(absent) for adding or removing. - Use C(query) for listing an object or multiple objects. type: str choices: [ absent, present, query ] default: present extends_documentation_fragment: aci notes: - The C(tenant) used must exist before using this module in your playbook. The M(aci_tenant) module can be used for this. seealso: - module: aci_tenant - name: APIC Management Information Model reference description: More information about the internal APIC class B(mon:EPGPol). link: https://developer.cisco.com/docs/apic-mim-ref/ author: - Dag Wieers (@dagwieers) ''' # FIXME: Add more, better examples EXAMPLES = r''' - aci_epg_monitoring_policy: host: '{{ hostname }}' username: '{{ username }}' password: '{{ password }}' monitoring_policy: '{{ monitoring_policy }}' description: '{{ description }}' tenant: '{{ tenant }}' delegate_to: localhost ''' RETURN = r''' current: description: The existing configuration from the APIC after the module has finished returned: success type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production environment", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] error: description: The error information as returned from the APIC returned: failure type: dict sample: { "code": "122", "text": "unknown managed object class foo" } raw: description: The raw output returned by the APIC REST API (xml or json) returned: parse error type: str sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>' sent: description: The actual/minimal configuration pushed to the APIC returned: info type: list sample: { "fvTenant": { "attributes": { "descr": "Production environment" } } } previous: description: The original configuration from the APIC before the module has started returned: info type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] proposed: description: The assembled configuration from the user-provided parameters returned: info type: dict sample: { "fvTenant": { "attributes": { "descr": "Production environment", "name": "production" } } } filter_string: description: The filter string used for the request returned: failure or debug type: str sample: ?rsp-prop-include=config-only method: description: The HTTP method used for the request to the APIC returned: failure or debug type: str sample: POST response: description: The HTTP response from the APIC returned: failure or debug type: str sample: OK (30 bytes) status: description: The HTTP status from the APIC returned: failure or debug type: int sample: 200 url: description: The HTTP url used for the request to the APIC returned: failure or debug type: str sample: https://10.11.12.13/api/mo/uni/tn-production.json ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec def main(): argument_spec = aci_argument_spec() argument_spec.update( monitoring_policy=dict(type='str', aliases=['name']), # Not required for querying all objects tenant=dict(type='str', aliases=['tenant_name']), # Not required for querying all objects description=dict(type='str', aliases=['descr']), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['monitoring_policy', 'tenant']], ['state', 'present', ['monitoring_policy', 'tenant']], ], ) monitoring_policy = module.params['monitoring_policy'] description = module.params['description'] state = module.params['state'] tenant = module.params['tenant'] aci = ACIModule(module) aci.construct_url( root_class=dict( aci_class='fvTenant', aci_rn='tn-{0}'.format(tenant), module_object=tenant, target_filter={'name': tenant}, ), subclass_1=dict( aci_class='monEPGPol', aci_rn='monepg-{0}'.format(monitoring_policy), module_object=monitoring_policy, target_filter={'name': monitoring_policy}, ), ) aci.get_existing() if state == 'present': aci.payload( aci_class='monEPGPol', class_config=dict( name=monitoring_policy, descr=description, ), ) aci.get_diff(aci_class='monEPGPol') aci.post_config() elif state == 'absent': aci.delete_config() aci.exit_json() if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 22967, 63, 20554, 63, 3185, 199, 3612, 63, 1802, 26, 14944, 20391, 14118, 334, 2106, 26, 6102, 39, 5858, 9, 199, 1802, 26, 199, 13, 14944, 20391, 14118, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 1419, 26, 523, 20391, 63, 3185, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 20391, 4592, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 1622, 523, 1369, 26, 272, 1369, 26, 272, 446, 11994, 367, 314, 20391, 4592, 14, 272, 730, 26, 620, 272, 5481, 26, 359, 16193, 1622, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 8261, 63, 354, 1622, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 5983, 26, 199, 13, 710, 445, 8, 4647, 9, 1202, 1471, 2187, 2544, 1808, 642, 859, 315, 2195, 15695, 14, 523, 710, 603, 8, 22832, 63, 4647, 9, 859, 883, 506, 1202, 367, 642, 14, 199, 3239, 12344, 26, 199, 13, 859, 26, 19631, 63, 4647, 199, 13, 536, 26, 25418, 8259, 17064, 5822, 3659, 523, 1369, 26, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 2106, 26, 6102, 39, 5858, 680, 523, 2142, 26, 4178, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 2344, 199, 199, 3, 7600, 26, 2654, 1655, 12, 8034, 7251, 199, 8918, 275, 519, 2344, 199, 13, 19631, 63, 22967, 63, 20554, 63, 3185, 26, 272, 1591, 26, 11400, 6246, 16339, 272, 3434, 26, 11400, 3434, 16339, 272, 2505, 26, 11400, 2505, 16339, 272, 20391, 63, 3185, 26, 11400, 20391, 63, 3185, 16339, 272, 1369, 26, 11400, 1369, 16339, 272, 8261, 26, 11400, 8261, 16339, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 620, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 2535, 1017, 576, 3141, 2353, 628, 17, 8186, 705, 1233, 628, 7507, 2, 1318, 628, 5187, 12883, 909, 1021, 3925, 15313, 2957, 1017, 576, 3524, 199, 1150, 26, 523, 1369, 26, 710, 3503, 15, 21508, 2897, 22319, 370, 314, 25418, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 469, 267, 298, 13692, 27807, 582, 469, 288, 298, 2987, 582, 469, 355, 298, 12113, 582, 298, 26432, 3734, 2, 288, 789, 267, 789, 272, 789, 199, 6352, 26, 523, 1369, 26, 710, 3379, 2897, 687, 314, 25418, 2544, 314, 859, 965, 8239, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 15676, 26, 523, 1369, 26, 710, 22931, 68, 2897, 687, 314, 922, 13, 16929, 2633, 523, 2138, 26, 2256, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 13692, 27807, 582, 469, 288, 298, 2987, 582, 469, 355, 298, 12113, 582, 298, 26432, 3734, 401, 355, 298, 354, 582, 298, 10777, 2, 288, 789, 267, 789, 272, 789, 199, 1541, 63, 875, 26, 523, 1369, 26, 710, 2457, 1059, 1202, 367, 314, 1056, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 5805, 15642, 13, 4469, 13, 2613, 29, 888, 13, 2118, 199, 765, 26, 523, 1369, 26, 710, 3101, 1083, 1202, 367, 314, 1056, 370, 314, 25418, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 8761, 199, 1310, 26, 523, 1369, 26, 710, 3101, 1177, 687, 314, 25418, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 9949, 334, 1216, 2783, 9 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 22967, 63, 20554, 63, 3185, 199, 3612, 63, 1802, 26, 14944, 20391, 14118, 334, 2106, 26, 6102, 39, 5858, 9, 199, 1802, 26, 199, 13, 14944, 20391, 14118, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 1419, 26, 523, 20391, 63, 3185, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 20391, 4592, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 1622, 523, 1369, 26, 272, 1369, 26, 272, 446, 11994, 367, 314, 20391, 4592, 14, 272, 730, 26, 620, 272, 5481, 26, 359, 16193, 1622, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 8261, 63, 354, 1622, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 5983, 26, 199, 13, 710, 445, 8, 4647, 9, 1202, 1471, 2187, 2544, 1808, 642, 859, 315, 2195, 15695, 14, 523, 710, 603, 8, 22832, 63, 4647, 9, 859, 883, 506, 1202, 367, 642, 14, 199, 3239, 12344, 26, 199, 13, 859, 26, 19631, 63, 4647, 199, 13, 536, 26, 25418, 8259, 17064, 5822, 3659, 523, 1369, 26, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 2106, 26, 6102, 39, 5858, 680, 523, 2142, 26, 4178, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 2344, 199, 199, 3, 7600, 26, 2654, 1655, 12, 8034, 7251, 199, 8918, 275, 519, 2344, 199, 13, 19631, 63, 22967, 63, 20554, 63, 3185, 26, 272, 1591, 26, 11400, 6246, 16339, 272, 3434, 26, 11400, 3434, 16339, 272, 2505, 26, 11400, 2505, 16339, 272, 20391, 63, 3185, 26, 11400, 20391, 63, 3185, 16339, 272, 1369, 26, 11400, 1369, 16339, 272, 8261, 26, 11400, 8261, 16339, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 620, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 2535, 1017, 576, 3141, 2353, 628, 17, 8186, 705, 1233, 628, 7507, 2, 1318, 628, 5187, 12883, 909, 1021, 3925, 15313, 2957, 1017, 576, 3524, 199, 1150, 26, 523, 1369, 26, 710, 3503, 15, 21508, 2897, 22319, 370, 314, 25418, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 469, 267, 298, 13692, 27807, 582, 469, 288, 298, 2987, 582, 469, 355, 298, 12113, 582, 298, 26432, 3734, 2, 288, 789, 267, 789, 272, 789, 199, 6352, 26, 523, 1369, 26, 710, 3379, 2897, 687, 314, 25418, 2544, 314, 859, 965, 8239, 523, 2138, 26, 2256, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 15676, 26, 523, 1369, 26, 710, 22931, 68, 2897, 687, 314, 922, 13, 16929, 2633, 523, 2138, 26, 2256, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 13692, 27807, 582, 469, 288, 298, 2987, 582, 469, 355, 298, 12113, 582, 298, 26432, 3734, 401, 355, 298, 354, 582, 298, 10777, 2, 288, 789, 267, 789, 272, 789, 199, 1541, 63, 875, 26, 523, 1369, 26, 710, 2457, 1059, 1202, 367, 314, 1056, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 5805, 15642, 13, 4469, 13, 2613, 29, 888, 13, 2118, 199, 765, 26, 523, 1369, 26, 710, 3101, 1083, 1202, 367, 314, 1056, 370, 314, 25418, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 8761, 199, 1310, 26, 523, 1369, 26, 710, 3101, 1177, 687, 314, 25418, 523, 2138, 26, 5988, 503, 3105, 523, 730, 26, 620, 523, 2690, 26, 9949, 334, 1216, 2783, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
omarkadry/rsa_algorithm
RSA.py
1
5283
#!/usr/bin/python #Algoriths Project Part 1a #Omar Kadry #CMSC 441 #Dr. Marron #IMPLEMENTATION NOTES #Python's built in pow function uses Binary Exponentiation and reducing modulo n to compute modular #exponentiation. This is the same algorithm as MODULAR-EXPONENTIATION(a,b,n) as used in the text #For large number mutliplication Python uses Karatsuba's method as discusssed in class #Encrypted using modulus of 2048 bits #Message Encrypted with Private Key = #549335432742725778252187541104443188156944438806863457411666058499398272260706426139538267238120336092084632198514701950566203930065985324580534295693425367212921830205866755643739579288731322322946366466576799796974416100601383412159359169170613839877922173796152893918170136479717941167924064476336789776106984955596378941959676443995574307557232184168653454435294749983774161045180981596162964832360087083009219442813368249004389009182055455524458934480504555947413171214222377987666294266525295763559510397442092718659910879958017424466509571661222667744582625838716048450963735149873220637697801126262181088272 #n = 2372112898706524098783243835606671423055801883554227254030743710505202283932667011668956139382911768876035660572032080308562219037288900124052316286309512108625859836958747947762092799677854295671866288119481685786760570903533545560435541052326183788082279075073373227880942687435505490994525413101260845901748238215480998501123816262694263026377952163660645333809073068011604416987281948409408692393376191358516220341631487894075618891499412550098438456600441042870219500840853342452184082591601805986792948794525871595912715813197678328912976549353915846570322821639411967156886422360861220109970600152445030560129 #public key e = 1977623957817836883919633554596704012915783900570809149483856078010145425692545878452812725561415102822918517227924598205956910940350062144643427460974258169951841328548095289498955467345087157904399185646775059360160689508306113707875539862799501027047474838298216312008836598256088581250099042957573530717659415412893768343977899980494510094815770699761034869232518446869348437561961594909995056962983992121384916099020899755884457999313029602625570516932900789485878260172195900227111449085645227576679740196755445527867666825244974372425673866849078226602801561771006724501838806746943672716086807419555183315337s import sys import os import random import math import argparse s = 5 #s for miller-rabin test #Constants to make code more readable PRIME = 1 COMPOSITE = 2 #Generates Random Psuedoprimes of size bits #validates with miller rabin test def generate_rand(size): n = random.SystemRandom().getrandbits(size) while(n == 1 or n == 0): n = random.SystemRandom().getrandbits(size) while True: if n % 2 == 0: n = n + 1 if(miller_rabin(n,s) == PRIME): return n n = n + 2 #Miller-Rabin test def miller_rabin(n,s): for j in range(0,s): a = random.SystemRandom().randint(1, n-1) if(witness(a,n)): return COMPOSITE return PRIME #Witness function for miller-rabin def witness(a,n): t,u = calc_t_u(n-1) x = [] x.append(modular_exponentiation(a,u,n)) for i in range(1,t+1): x.append(modular_exponentiation(x[i-1],2,n)) if (x[i] == 1) and (x[i-1] != 1) and (x[i-1] != n-1): return True if x[t] != 1: return True return False def modular_exponentiation(a,b,n): a = int(a) b = int(b) n = int(n) return pow(a,b,n) #Calculates t and u for the witness function def calc_t_u(n): t = 0 u = n while (u % 2 == 0): u = u / 2 t+=1 return t,u #Gets a value for e #Generates a random value and checks it's relatively prime to phi_n def get_e(phi_n): e = random.SystemRandom().randint(3, phi_n) while euclid(phi_n,e) != 1: e = random.SystemRandom().randint(3,phi_n) return e #Euclid and extended euclid are iterative due to recursion depth errors #being found when the modulus size was >= 1024 bits #Euclids algorithm def euclid(a,b): if a < b: a, b = b, a while b != 0: a, b = b, a % b return a #Extended Euclid's Algorithm def extend_euclid(a,b): x,y, u,v = 0,1, 1,0 while a != 0: q, r = b//a, b%a m, n = x-u*q, y-v*q b,a, x,y, u,v = a,r, u,v, m,n gcd = b return gcd, x, y def get_mult_inverse(e, phi_n): a,b,n = e,1,phi_n d,_x,_y = extend_euclid(a,n) if(d % b == 0): return _x % n else: return -1 def msg_to_int(m): x = 0 for c in m: x = x << 8 x = x ^ ord(c) return x if __name__ == '__main__': private_key = 0 public_key = 0 parser = argparse.ArgumentParser(description="Generates an RSA public and private key") parser.add_argument("-s", "--size", type=int, help="Size in bits of RSA Key to Generate", required=True) parser.add_argument("-m", "--message", type=str, help="A Message to Encrypt") args = parser.parse_args() modulus_size = args.size p = generate_rand(modulus_size//2) q = generate_rand(modulus_size//2) while(p == q): q = generate_rand(modulus_size//2) n = p * q phi_n = (p - 1) * (q - 1) e = get_e(phi_n) d = int(get_mult_inverse(e, phi_n)) print "N = \n", n, '\n' print "Private Key d = \n", int(d), '\n' print "Public Key e = \n", int(e), '\n' if(args.message): m = args.message "Encrypting: %s" % m print "\"",m,"\" encrypted with the private key is\n", m = msg_to_int(m) p = modular_exponentiation(m,d,n) print p
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2439, 3497, 83, 7290, 14320, 413, 65, 199, 3, 47, 4584, 1804, 350, 651, 199, 3, 17834, 35, 841, 2953, 199, 3, 21733, 14, 16794, 2641, 199, 3, 8947, 10320, 2594, 2845, 654, 199, 3, 4718, 1159, 6137, 315, 13131, 805, 4440, 14161, 1316, 10995, 280, 425, 436, 295, 14713, 27656, 302, 370, 4526, 3413, 2238, 199, 3, 476, 10995, 280, 425, 14, 961, 365, 314, 2011, 5563, 465, 30920, 3038, 13, 11992, 17877, 41, 2594, 8, 65, 12, 66, 12, 78, 9, 465, 1202, 315, 314, 1318, 199, 3, 1858, 7031, 1329, 8567, 3587, 1863, 2018, 4440, 1804, 285, 292, 954, 65, 1159, 1083, 465, 4339, 27678, 939, 315, 1021, 199, 199, 3, 1327, 8274, 1808, 3413, 15909, 402, 18427, 5821, 199, 3, 2209, 3447, 8274, 543, 18551, 2606, 275, 221, 199, 3, 15419, 1153, 1477, 708, 1342, 1465, 821, 16156, 6390, 11775, 1477, 6019, 1602, 2824, 11501, 1046, 1876, 18078, 1703, 1257, 10253, 9908, 1342, 845, 11829, 1717, 23835, 13944, 1465, 11085, 1780, 17010, 1479, 969, 2720, 1703, 1479, 2819, 1703, 6708, 12135, 1643, 1165, 16134, 708, 1167, 2426, 11160, 12512, 13938, 1272, 1165, 1355, 5863, 31485, 2426, 708, 2322, 13027, 1082, 1398, 15143, 1082, 821, 1344, 2819, 713, 2942, 1085, 8551, 1717, 1184, 1822, 1229, 772, 1401, 1355, 1641, 2942, 15989, 2192, 708, 8001, 1398, 2466, 1344, 772, 1272, 1641, 1822, 1020, 1965, 1876, 15839, 975, 1960, 24539, 1703, 1082, 713, 9327, 11444, 10143, 1196, 1690, 8527, 13944, 14580, 1081, 1196, 1401, 2534, 11024, 1407, 1355, 1085, 1196, 13264, 772, 21422, 1196, 2635, 845, 18450, 9873, 10893, 2114, 1153, 1822, 1407, 14626, 709, 1876, 14866, 1229, 15112, 1401, 12128, 1167, 1427, 1822, 772, 2824, 1020, 1229, 1342, 11516, 1229, 2819, 708, 10078, 975, 15102, 1082, 16298, 1276, 10693, 1342, 1020, 2658, 15464, 975, 709, 2322, 1085, 17764, 1046, 2534, 975, 1398, 10552, 708, 11035, 1555, 2036, 5863, 2942, 1167, 1602, 1651, 969, 10997, 11032, 383, 2824, 1407, 8581, 1085, 1165, 1229, 13267, 26419, 2322, 1407, 10875, 13027, 966, 1229, 1427, 13818, 969, 1196, 713, 1079, 1081, 1789, 14580, 1555, 11829, 1398, 2260, 16373, 821, 1398, 1641, 2766, 1229, 2720, 709, 1355, 15839, 11303, 1465, 1085, 2182, 1020, 709, 1555, 1020, 2010, 614, 1342, 11603, 1272, 6576, 1641, 10642, 713, 1081, 1272, 1138, 1602, 2010, 1479, 821, 2658, 1555, 975, 966, 1349, 1400, 2534, 1401, 1276, 10721, 1555, 708, 11089, 1401, 1876, 2277, 614, 7957, 1479, 9252, 709, 1299, 12900, 199, 3, 78, 275, 499, 1401, 2025, 713, 1407, 1555, 21254, 1194, 1643, 14681, 12744, 1703, 1276, 2259, 14916, 1079, 9687, 17686, 614, 1299, 10156, 20, 11385, 821, 2167, 1216, 1342, 1401, 709, 1400, 2528, 996, 1651, 1355, 708, 14916, 614, 10642, 1407, 1367, 7491, 1703, 1398, 31989, 1299, 19036, 1276, 15268, 1641, 1165, 12122, 1257, 12127, 1367, 1081, 12205, 1401, 10740, 17518, 7214, 1717, 1789, 975, 11125, 1216, 2720, 713, 709, 1184, 12234, 15897, 11939, 2010, 1342, 21618, 14626, 11303, 1465, 14140, 16156, 1477, 1398, 5308, 1085, 1272, 10740, 7119, 2006, 6568, 1641, 1184, 19036, 1641, 18526, 1276, 1153, 1477, 18683, 5882, 19264, 709, 2528, 8342, 1085, 12046, 1257, 10228, 1965, 1780, 13583, 11062, 708, 13909, 1257, 2635, 13731, 1342, 10156, 22663, 2710, 1020, 2322, 8306, 969, 4893, 13085, 1349, 1427, 614, 1342, 2564, 1703, 7842, 21853, 1020, 2426, 614, 713, 1703, 975, 1479, 1479, 2635, 1479, 8551, 2766, 14580, 2528, 975, 11065, 16, 13067, 11769, 11782, 1780, 1216, 2333, 614, 975, 9111, 10143, 1555, 1651, 10860, 1349, 1643, 2167, 1184, 2942, 1355, 1153, 2114, 1167, 969, 15959, 975, 11174, 1082, 975, 8988, 1555, 12128, 1780, 1367, 1085, 1407, 1079, 14966, 20197, 8581, 1349, 8188, 29982, 27549, 709, 2260, 1555, 996, 1167, 5783, 1349, 2036, 2481, 1082, 1194, 2528, 10078, 2036, 11990, 975, 614, 1257, 1427, 1184, 1965, 10693, 13657, 2322, 821, 1555, 9327, 1427, 4195, 11240, 969, 11165, 17237, 708, 1407, 7263, 2114, 15419, 1276, 1355, 1046, 16134, 15986, 708, 1651, 9669, 13549, 7119, 1822, 11309, 1299, 772, 1081, 11197, 1184, 713, 6542, 13218, 1690, 23419, 11603, 1400, 1216, 1367, 614, 1398, 199, 3, 3455, 790, 325, 275, 5851, 1138, 2789, 1355, 14992, 11175, 1344, 1299, 1355, 10800, 1153, 19264, 1427, 1822, 28025, 1398, 1046, 2277, 1355, 383, 15986, 11782, 10721, 2006, 1703, 1367, 19226, 614, 10752, 1477, 28515, 821, 2322, 1555, 16963, 1651, 4195, 821, 1367, 32689, 709, 1651, 11182, 10233, 1196, 1081, 1965, 1194, 15897, 1165, 1427, 15143, 6996, 2167, 1276, 383, 2789, 9862, 772, 1082, 9014, 14520, 1342, 12234, 975, 14732, 1085, 2953, 12870, 1477, 11782, 2528, 1407, 1887, 1407, 1229, 16226, 1082, 1400, 1555, 1046, 1965, 5882, 1020, 10233, 11387, 1138, 1400, 1427, 1344, 10882, 1690, 1407, 14585, 11363, 845, 1401, 1780, 1555, 1229, 29451, 1465, 1020, 8216, 14218, 966, 1342, 18770, 1703, 1398, 2564, 11931, 23781, 1299, 1344, 15897, 28999, 1299, 2010, 713, 5783, 1020, 966, 1398, 1641, 1641, 1276, 11516, 10216, 15667, 10478, 713, 1407, 1401, 2333, 1082, 1355, 16156, 1020, 2905, 12809, 2322, 1960, 25, 2006, 1046, 1138, 1690, 1020, 2114, 709, 1082, 1184, 2942, 13288, 1085, 1602, 10253, 30391, 1349, 1401, 1367, 10800, 9327, 26410, 5637, 1400, 1367, 2534, 1398, 2658, 1020, 11722, 969, 14866, 8488, 1020, 996, 2036, 1020, 12315, 1299, 1602, 1641, 1020, 3129, 969, 996, 2534, 14842, 28656, 1717, 10143, 11685, 8255, 1407, 21956, 14681, 1479, 614, 2819, 1167, 1427, 383, 11385, 845, 1079, 1887, 17494, 13067, 11385, 1641, 1272, 1965, 1342, 12512, 1822, 1229, 1602, 1229, 1465, 14927, 1272, 2333, 27752, 1887, 1342, 1401, 1194, 821, 1822, 8040, 22, 14866, 1780, 10228, 1272, 15501, 614, 1367, 8881, 1960, 1822, 1194, 8216, 24, 1703, 1257, 10393, 19421, 12684, 1465, 8488, 1184, 1257, 1342, 1167, 15722, 1085, 1153, 1046, 11062, 83, 199, 199, 646, 984, 199, 646, 747, 199, 646, 2196, 199, 646, 3473, 199, 646, 7534, 199, 199, 83, 275, 959, 327, 83, 367, 333, 19576, 13, 345, 1393, 511, 199, 3, 22185, 370, 1852, 1233, 1655, 12701, 199, 3311, 3465, 275, 413, 221, 199, 11265, 1512, 7917, 275, 499, 199, 199, 3, 20551, 9571, 510, 3309, 68, 21993, 6415, 402, 1568, 5821, 199, 3, 1078, 2335, 543, 333, 19576, 660, 1393, 511, 199, 318, 3550, 63, 3759, 8, 890, 304 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2439, 3497, 83, 7290, 14320, 413, 65, 199, 3, 47, 4584, 1804, 350, 651, 199, 3, 17834, 35, 841, 2953, 199, 3, 21733, 14, 16794, 2641, 199, 3, 8947, 10320, 2594, 2845, 654, 199, 3, 4718, 1159, 6137, 315, 13131, 805, 4440, 14161, 1316, 10995, 280, 425, 436, 295, 14713, 27656, 302, 370, 4526, 3413, 2238, 199, 3, 476, 10995, 280, 425, 14, 961, 365, 314, 2011, 5563, 465, 30920, 3038, 13, 11992, 17877, 41, 2594, 8, 65, 12, 66, 12, 78, 9, 465, 1202, 315, 314, 1318, 199, 3, 1858, 7031, 1329, 8567, 3587, 1863, 2018, 4440, 1804, 285, 292, 954, 65, 1159, 1083, 465, 4339, 27678, 939, 315, 1021, 199, 199, 3, 1327, 8274, 1808, 3413, 15909, 402, 18427, 5821, 199, 3, 2209, 3447, 8274, 543, 18551, 2606, 275, 221, 199, 3, 15419, 1153, 1477, 708, 1342, 1465, 821, 16156, 6390, 11775, 1477, 6019, 1602, 2824, 11501, 1046, 1876, 18078, 1703, 1257, 10253, 9908, 1342, 845, 11829, 1717, 23835, 13944, 1465, 11085, 1780, 17010, 1479, 969, 2720, 1703, 1479, 2819, 1703, 6708, 12135, 1643, 1165, 16134, 708, 1167, 2426, 11160, 12512, 13938, 1272, 1165, 1355, 5863, 31485, 2426, 708, 2322, 13027, 1082, 1398, 15143, 1082, 821, 1344, 2819, 713, 2942, 1085, 8551, 1717, 1184, 1822, 1229, 772, 1401, 1355, 1641, 2942, 15989, 2192, 708, 8001, 1398, 2466, 1344, 772, 1272, 1641, 1822, 1020, 1965, 1876, 15839, 975, 1960, 24539, 1703, 1082, 713, 9327, 11444, 10143, 1196, 1690, 8527, 13944, 14580, 1081, 1196, 1401, 2534, 11024, 1407, 1355, 1085, 1196, 13264, 772, 21422, 1196, 2635, 845, 18450, 9873, 10893, 2114, 1153, 1822, 1407, 14626, 709, 1876, 14866, 1229, 15112, 1401, 12128, 1167, 1427, 1822, 772, 2824, 1020, 1229, 1342, 11516, 1229, 2819, 708, 10078, 975, 15102, 1082, 16298, 1276, 10693, 1342, 1020, 2658, 15464, 975, 709, 2322, 1085, 17764, 1046, 2534, 975, 1398, 10552, 708, 11035, 1555, 2036, 5863, 2942, 1167, 1602, 1651, 969, 10997, 11032, 383, 2824, 1407, 8581, 1085, 1165, 1229, 13267, 26419, 2322, 1407, 10875, 13027, 966, 1229, 1427, 13818, 969, 1196, 713, 1079, 1081, 1789, 14580, 1555, 11829, 1398, 2260, 16373, 821, 1398, 1641, 2766, 1229, 2720, 709, 1355, 15839, 11303, 1465, 1085, 2182, 1020, 709, 1555, 1020, 2010, 614, 1342, 11603, 1272, 6576, 1641, 10642, 713, 1081, 1272, 1138, 1602, 2010, 1479, 821, 2658, 1555, 975, 966, 1349, 1400, 2534, 1401, 1276, 10721, 1555, 708, 11089, 1401, 1876, 2277, 614, 7957, 1479, 9252, 709, 1299, 12900, 199, 3, 78, 275, 499, 1401, 2025, 713, 1407, 1555, 21254, 1194, 1643, 14681, 12744, 1703, 1276, 2259, 14916, 1079, 9687, 17686, 614, 1299, 10156, 20, 11385, 821, 2167, 1216, 1342, 1401, 709, 1400, 2528, 996, 1651, 1355, 708, 14916, 614, 10642, 1407, 1367, 7491, 1703, 1398, 31989, 1299, 19036, 1276, 15268, 1641, 1165, 12122, 1257, 12127, 1367, 1081, 12205, 1401, 10740, 17518, 7214, 1717, 1789, 975, 11125, 1216, 2720, 713, 709, 1184, 12234, 15897, 11939, 2010, 1342, 21618, 14626, 11303, 1465, 14140, 16156, 1477, 1398, 5308, 1085, 1272, 10740, 7119, 2006, 6568, 1641, 1184, 19036, 1641, 18526, 1276, 1153, 1477, 18683, 5882, 19264, 709, 2528, 8342, 1085, 12046, 1257, 10228, 1965, 1780, 13583, 11062, 708, 13909, 1257, 2635, 13731, 1342, 10156, 22663, 2710, 1020, 2322, 8306, 969, 4893, 13085, 1349, 1427, 614, 1342, 2564, 1703, 7842, 21853, 1020, 2426, 614, 713, 1703, 975, 1479, 1479, 2635, 1479, 8551, 2766, 14580, 2528, 975, 11065, 16, 13067, 11769, 11782, 1780, 1216, 2333, 614, 975, 9111, 10143, 1555, 1651, 10860, 1349, 1643, 2167, 1184, 2942, 1355, 1153, 2114, 1167, 969, 15959, 975, 11174, 1082, 975, 8988, 1555, 12128, 1780, 1367, 1085, 1407, 1079, 14966, 20197, 8581, 1349, 8188, 29982, 27549, 709, 2260, 1555, 996, 1167, 5783, 1349, 2036, 2481, 1082, 1194, 2528, 10078, 2036, 11990, 975, 614, 1257, 1427, 1184, 1965, 10693, 13657, 2322, 821, 1555, 9327, 1427, 4195, 11240, 969, 11165, 17237, 708, 1407, 7263, 2114, 15419, 1276, 1355, 1046, 16134, 15986, 708, 1651, 9669, 13549, 7119, 1822, 11309, 1299, 772, 1081, 11197, 1184, 713, 6542, 13218, 1690, 23419, 11603, 1400, 1216, 1367, 614, 1398, 199, 3, 3455, 790, 325, 275, 5851, 1138, 2789, 1355, 14992, 11175, 1344, 1299, 1355, 10800, 1153, 19264, 1427, 1822, 28025, 1398, 1046, 2277, 1355, 383, 15986, 11782, 10721, 2006, 1703, 1367, 19226, 614, 10752, 1477, 28515, 821, 2322, 1555, 16963, 1651, 4195, 821, 1367, 32689, 709, 1651, 11182, 10233, 1196, 1081, 1965, 1194, 15897, 1165, 1427, 15143, 6996, 2167, 1276, 383, 2789, 9862, 772, 1082, 9014, 14520, 1342, 12234, 975, 14732, 1085, 2953, 12870, 1477, 11782, 2528, 1407, 1887, 1407, 1229, 16226, 1082, 1400, 1555, 1046, 1965, 5882, 1020, 10233, 11387, 1138, 1400, 1427, 1344, 10882, 1690, 1407, 14585, 11363, 845, 1401, 1780, 1555, 1229, 29451, 1465, 1020, 8216, 14218, 966, 1342, 18770, 1703, 1398, 2564, 11931, 23781, 1299, 1344, 15897, 28999, 1299, 2010, 713, 5783, 1020, 966, 1398, 1641, 1641, 1276, 11516, 10216, 15667, 10478, 713, 1407, 1401, 2333, 1082, 1355, 16156, 1020, 2905, 12809, 2322, 1960, 25, 2006, 1046, 1138, 1690, 1020, 2114, 709, 1082, 1184, 2942, 13288, 1085, 1602, 10253, 30391, 1349, 1401, 1367, 10800, 9327, 26410, 5637, 1400, 1367, 2534, 1398, 2658, 1020, 11722, 969, 14866, 8488, 1020, 996, 2036, 1020, 12315, 1299, 1602, 1641, 1020, 3129, 969, 996, 2534, 14842, 28656, 1717, 10143, 11685, 8255, 1407, 21956, 14681, 1479, 614, 2819, 1167, 1427, 383, 11385, 845, 1079, 1887, 17494, 13067, 11385, 1641, 1272, 1965, 1342, 12512, 1822, 1229, 1602, 1229, 1465, 14927, 1272, 2333, 27752, 1887, 1342, 1401, 1194, 821, 1822, 8040, 22, 14866, 1780, 10228, 1272, 15501, 614, 1367, 8881, 1960, 1822, 1194, 8216, 24, 1703, 1257, 10393, 19421, 12684, 1465, 8488, 1184, 1257, 1342, 1167, 15722, 1085, 1153, 1046, 11062, 83, 199, 199, 646, 984, 199, 646, 747, 199, 646, 2196, 199, 646, 3473, 199, 646, 7534, 199, 199, 83, 275, 959, 327, 83, 367, 333, 19576, 13, 345, 1393, 511, 199, 3, 22185, 370, 1852, 1233, 1655, 12701, 199, 3311, 3465, 275, 413, 221, 199, 11265, 1512, 7917, 275, 499, 199, 199, 3, 20551, 9571, 510, 3309, 68, 21993, 6415, 402, 1568, 5821, 199, 3, 1078, 2335, 543, 333, 19576, 660, 1393, 511, 199, 318, 3550, 63, 3759, 8, 890, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
delta2323/chainer
examples/imagenet/nin.py
17
1296
import chainer import chainer.functions as F import chainer.initializers as I import chainer.links as L class NIN(chainer.Chain): """Network-in-Network example model.""" insize = 227 def __init__(self): super(NIN, self).__init__() conv_init = I.HeNormal() # MSRA scaling with self.init_scope(): self.mlpconv1 = L.MLPConvolution2D( None, (96, 96, 96), 11, stride=4, conv_init=conv_init) self.mlpconv2 = L.MLPConvolution2D( None, (256, 256, 256), 5, pad=2, conv_init=conv_init) self.mlpconv3 = L.MLPConvolution2D( None, (384, 384, 384), 3, pad=1, conv_init=conv_init) self.mlpconv4 = L.MLPConvolution2D( None, (1024, 1024, 1000), 3, pad=1, conv_init=conv_init) def __call__(self, x, t): h = F.max_pooling_2d(F.relu(self.mlpconv1(x)), 3, stride=2) h = F.max_pooling_2d(F.relu(self.mlpconv2(h)), 3, stride=2) h = F.max_pooling_2d(F.relu(self.mlpconv3(h)), 3, stride=2) h = self.mlpconv4(F.dropout(h)) h = F.reshape(F.average_pooling_2d(h, 6), (len(x), 1000)) loss = F.softmax_cross_entropy(h, t) chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self) return loss
mit
[ 646, 20333, 199, 646, 20333, 14, 5777, 465, 481, 199, 646, 20333, 14, 2747, 6315, 465, 473, 199, 646, 20333, 14, 4614, 465, 491, 421, 199, 533, 653, 568, 8, 27243, 14, 10720, 304, 339, 408, 4491, 13, 262, 13, 4491, 2893, 1402, 1041, 339, 315, 890, 275, 499, 1465, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 46, 568, 12, 291, 2843, 826, 4533, 267, 8260, 63, 826, 275, 473, 14, 1966, 6241, 342, 221, 327, 14282, 2847, 13690, 398, 543, 291, 14, 826, 63, 2645, 837, 288, 291, 14, 757, 80, 5598, 17, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 2534, 12, 15580, 12, 15580, 395, 4119, 12, 7345, 29, 20, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 18, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 3912, 12, 7633, 12, 7633, 395, 959, 12, 6567, 29, 18, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 19, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 8188, 12, 29772, 12, 29772, 395, 650, 12, 6567, 29, 17, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 20, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 7727, 12, 6619, 12, 5198, 395, 650, 12, 6567, 29, 17, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 339, 347, 636, 1250, 721, 277, 12, 671, 12, 307, 304, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 17, 8, 88, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 18, 8, 72, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 19, 8, 72, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 291, 14, 757, 80, 5598, 20, 8, 38, 14, 17953, 8, 72, 430, 267, 394, 275, 481, 14, 5217, 8, 38, 14, 8536, 63, 28624, 63, 18, 68, 8, 72, 12, 1227, 395, 334, 552, 8, 88, 395, 5198, 430, 398, 5621, 275, 481, 14, 16395, 63, 7925, 63, 10435, 8, 72, 12, 307, 9, 267, 20333, 14, 3070, 3252, 4358, 356, 5621, 12, 283, 13374, 356, 481, 14, 13374, 8, 72, 12, 307, 16658, 291, 9, 267, 372, 5621, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20333, 199, 646, 20333, 14, 5777, 465, 481, 199, 646, 20333, 14, 2747, 6315, 465, 473, 199, 646, 20333, 14, 4614, 465, 491, 421, 199, 533, 653, 568, 8, 27243, 14, 10720, 304, 339, 408, 4491, 13, 262, 13, 4491, 2893, 1402, 1041, 339, 315, 890, 275, 499, 1465, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 46, 568, 12, 291, 2843, 826, 4533, 267, 8260, 63, 826, 275, 473, 14, 1966, 6241, 342, 221, 327, 14282, 2847, 13690, 398, 543, 291, 14, 826, 63, 2645, 837, 288, 291, 14, 757, 80, 5598, 17, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 2534, 12, 15580, 12, 15580, 395, 4119, 12, 7345, 29, 20, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 18, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 3912, 12, 7633, 12, 7633, 395, 959, 12, 6567, 29, 18, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 19, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 8188, 12, 29772, 12, 29772, 395, 650, 12, 6567, 29, 17, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 288, 291, 14, 757, 80, 5598, 20, 275, 491, 14, 1698, 48, 27394, 18, 36, 8, 355, 488, 12, 334, 7727, 12, 6619, 12, 5198, 395, 650, 12, 6567, 29, 17, 12, 8260, 63, 826, 29, 5598, 63, 826, 9, 339, 347, 636, 1250, 721, 277, 12, 671, 12, 307, 304, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 17, 8, 88, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 18, 8, 72, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 481, 14, 988, 63, 28624, 63, 18, 68, 8, 38, 14, 12833, 8, 277, 14, 757, 80, 5598, 19, 8, 72, 1826, 650, 12, 7345, 29, 18, 9, 267, 394, 275, 291, 14, 757, 80, 5598, 20, 8, 38, 14, 17953, 8, 72, 430, 267, 394, 275, 481, 14, 5217, 8, 38, 14, 8536, 63, 28624, 63, 18, 68, 8, 72, 12, 1227, 395, 334, 552, 8, 88, 395, 5198, 430, 398, 5621, 275, 481, 14, 16395, 63, 7925, 63, 10435, 8, 72, 12, 307, 9, 267, 20333, 14, 3070, 3252, 4358, 356, 5621, 12, 283, 13374, 356, 481, 14, 13374, 8, 72, 12, 307, 16658, 291, 9, 267, 372, 5621, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
jonathanessen/pyFFTW
conf.py
5
7610
# -*- coding: utf-8 -*- # # pyFFTW documentation build configuration file, created by # sphinx-quickstart on Mon Jan 30 14:37:35 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- autoclass_content = "both" autodoc_docstring_signature = True # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'pyFFTW' copyright = u'2013, Henry Gomersall' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # from setup import version as pyfftw_version # The short X.Y version. version = pyfftw_version # The full version, including alpha/beta/rc tags. release = pyfftw_version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['docs', 'README.rst'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = [os.path.join('sphinx','_static')] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'pyFFTWdoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'pyFFTW.tex', u'pyFFTW Documentation', u'Henry Gomersall', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'pyfftw', u'pyFFTW Documentation', [u'Henry Gomersall'], 1) ] # Intersphinx mappings intersphinx_mapping = {'http://docs.python.org/': None, 'http://docs.scipy.org/doc/numpy': None, 'http://docs.scipy.org/doc/scipy/reference': None} dependencies = {'pyfftw/pyfftw': ['pyfftw/pyfftw.so'], 'pyfftw/builders/builders': ['pyfftw/builders/builders.py'], 'pyfftw/builders/_utils': ['pyfftw/builders/utils.py']}
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1134, 1665, 16491, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 17474, 4233, 4329, 26, 1401, 26, 1276, 6029, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 2495, 533, 63, 1317, 275, 298, 10727, 2, 199, 28056, 63, 12485, 63, 5233, 275, 715, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 11390, 297, 283, 8008, 14, 832, 14, 10828, 297, 267, 283, 8008, 14, 832, 14, 1058, 8008, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 647, 1665, 16491, 7, 199, 7307, 275, 399, 7, 6965, 12, 20855, 651, 598, 1377, 2393, 452, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 504, 3272, 492, 1015, 465, 1134, 556, 8122, 63, 1023, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 1134, 556, 8122, 63, 1023, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1134, 556, 8122, 63, 1023, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 788, 4757, 297, 283, 18195, 14, 8332, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1134, 1665, 16491, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 10953, 17474, 4233, 4329, 26, 1401, 26, 1276, 6029, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 2495, 533, 63, 1317, 275, 298, 10727, 2, 199, 28056, 63, 12485, 63, 5233, 275, 715, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 11390, 297, 283, 8008, 14, 832, 14, 10828, 297, 267, 283, 8008, 14, 832, 14, 1058, 8008, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 647, 1665, 16491, 7, 199, 7307, 275, 399, 7, 6965, 12, 20855, 651, 598, 1377, 2393, 452, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 504, 3272, 492, 1015, 465, 1134, 556, 8122, 63, 1023, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 1134, 556, 8122, 63, 1023, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1134, 556, 8122, 63, 1023, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 788, 4757, 297, 283, 18195, 14, 8332, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
spinza/librenms
poller-service.py
15
14406
#! /usr/bin/env python2 """ poller-service A service to wrap SNMP polling. It will poll up to $threads devices at a time, and will not re-poll devices that have been polled within the last $poll_frequency seconds. It will prioritize devices based on the last time polled. If resources are sufficient, this service should poll every device every $poll_frequency seconds, but should gracefully degrade if resources are inefficient, polling devices as frequently as possible. This service is based on Job Snijders' poller-wrapper.py. Author: Clint Armstrong <clint@clintarmstrong.net> Date: July 2015 License: BSD 2-Clause Copyright (c) 2015, Clint Armstrong All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import json import os import subprocess import sys import threading import time import MySQLdb import logging import logging.handlers from datetime import datetime, timedelta from collections import namedtuple log = logging.getLogger('poller-service') log.setLevel(logging.DEBUG) formatter = logging.Formatter('poller-service: %(message)s') handler = logging.handlers.SysLogHandler(address='/dev/log') handler.setFormatter(formatter) log.addHandler(handler) install_dir = os.path.dirname(os.path.realpath(__file__)) config_file = install_dir + '/config.php' log.info('INFO: Starting poller-service') class DB: conn = None def __init__(self): self.in_use = threading.Lock() self.connect() def connect(self): self.in_use.acquire(True) while True: try: self.conn.close() except: pass try: if db_port == 0: self.conn = MySQLdb.connect(host=db_server, user=db_username, passwd=db_password, db=db_dbname) else: self.conn = MySQLdb.connect(host=db_server, port=db_port, user=db_username, passwd=db_password, db=db_dbname) break except (AttributeError, MySQLdb.OperationalError): log.warning('WARNING: MySQL Error, reconnecting.') time.sleep(.5) self.conn.autocommit(True) self.conn.ping(True) self.in_use.release() def query(self, sql): self.in_use.acquire(True) while True: try: cursor = self.conn.cursor() cursor.execute(sql) ret = cursor.fetchall() cursor.close() self.in_use.release() return ret except (AttributeError, MySQLdb.OperationalError): log.warning('WARNING: MySQL Operational Error during query, reconnecting.') self.in_use.release() self.connect() except (AttributeError, MySQLdb.ProgrammingError): log.warning('WARNING: MySQL Programming Error during query, attempting query again.') cursor.close() def get_config_data(): config_cmd = ['/usr/bin/env', 'php', '%s/config_to_json.php' % install_dir] try: proc = subprocess.Popen(config_cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE) except: log.critical("ERROR: Could not execute: %s" % config_cmd) sys.exit(2) return proc.communicate()[0].decode() try: with open(config_file) as f: pass except IOError as e: log.critical("ERROR: Oh dear... %s does not seem readable" % config_file) sys.exit(2) try: config = json.loads(get_config_data()) except: log.critical("ERROR: Could not load or parse configuration, are PATHs correct?") sys.exit(2) try: loglevel = int(config['poller_service_loglevel']) except KeyError: loglevel = 20 except ValueError: loglevel = logging.getLevelName(config['poller_service_loglevel']) try: log.setLevel(loglevel) except ValueError: log.warning('ERROR: {0} is not a valid log level. If using python 3.4.0-3.4.1 you must specify loglevel by number'.format(str(loglevel))) log.setLevel(20) poller_path = config['install_dir'] + '/poller.php' discover_path = config['install_dir'] + '/discovery.php' db_username = config['db_user'] db_password = config['db_pass'] if config['db_host'][:5].lower() == 'unix:': db_server = config['db_host'] db_port = 0 elif ':' in config['db_host']: db_server = config['db_host'].rsplit(':')[0] db_port = int(config['db_host'].rsplit(':')[1]) else: db_server = config['db_host'] db_port = 0 db_dbname = config['db_name'] try: amount_of_workers = int(config['poller_service_workers']) if amount_of_workers == 0: amount_of_workers = 16 except KeyError: amount_of_workers = 16 try: poll_frequency = int(config['poller_service_poll_frequency']) if poll_frequency == 0: poll_frequency = 300 except KeyError: poll_frequency = 300 try: discover_frequency = int(config['poller_service_discover_frequency']) if discover_frequency == 0: discover_frequency = 21600 except KeyError: discover_frequency = 21600 try: down_retry = int(config['poller_service_down_retry']) if down_retry == 0: down_retry = 60 except KeyError: down_retry = 60 try: retry_query = int(config['poller_service_retry_query']) if retry_query == 0: retry_query = 1 except KeyError: retry_query = 1 try: single_connection = bool(config['poller_service_single_connection']) except KeyError: single_connection = False db = DB() def lockFree(lock, db=db): query = "SELECT IS_FREE_LOCK('{0}')".format(lock) return db.query(query)[0][0] == 1 def getLock(lock, db=db): query = "SELECT GET_LOCK('{0}', 0)".format(lock) return db.query(query)[0][0] == 1 def releaseLock(lock, db=db): query = "SELECT RELEASE_LOCK('{0}')".format(lock) cursor = db.query(query) return db.query(query)[0][0] == 1 def sleep_until(timestamp): now = datetime.now() if timestamp > now: sleeptime = (timestamp - now).seconds else: sleeptime = 0 time.sleep(sleeptime) poller_group = ('and poller_group IN({0}) ' .format(str(config['distributed_poller_group'])) if 'distributed_poller_group' in config else '') # Add last_polled and last_polled_timetaken so we can sort by the time the last poll started, with the goal # of having each device complete a poll within the given time range. dev_query = ('SELECT device_id, status, ' 'CAST( ' ' DATE_ADD( ' ' DATE_SUB( ' ' last_polled, ' ' INTERVAL last_polled_timetaken SECOND ' ' ), ' ' INTERVAL {0} SECOND) ' ' AS DATETIME ' ') AS next_poll, ' 'CAST( ' ' DATE_ADD( ' ' DATE_SUB( ' ' last_discovered, ' ' INTERVAL last_discovered_timetaken SECOND ' ' ), ' ' INTERVAL {1} SECOND) ' ' AS DATETIME ' ') as next_discovery ' 'FROM devices WHERE ' 'disabled = 0 ' 'AND IS_FREE_LOCK(CONCAT("poll.", device_id)) ' 'AND IS_FREE_LOCK(CONCAT("discovery.", device_id)) ' 'AND IS_FREE_LOCK(CONCAT("queue.", device_id)) ' 'AND ( last_poll_attempted < DATE_SUB(NOW(), INTERVAL {2} SECOND ) ' ' OR last_poll_attempted IS NULL ) ' '{3} ' 'ORDER BY next_poll asc ' 'LIMIT 1 ').format(poll_frequency, discover_frequency, down_retry, poller_group) next_update = datetime.now() + timedelta(minutes=1) devices_scanned = 0 dont_query_until = datetime.fromtimestamp(0) def poll_worker(): global dev_query global devices_scanned global dont_query_until global single_connection thread_id = threading.current_thread().name if single_connection: global db else: db = DB() while True: if datetime.now() < dont_query_until: time.sleep(1) continue dev_row = db.query(dev_query) if len(dev_row) < 1: dont_query_until = datetime.now() + timedelta(seconds=retry_query) time.sleep(1) continue device_id, status, next_poll, next_discovery = dev_row[0] if not getLock('queue.{0}'.format(device_id), db): releaseLock('queue.{0}'.format(device_id), db) continue if next_poll and next_poll > datetime.now(): log.debug('DEBUG: Thread {0} Sleeping until {1} before polling {2}'.format(thread_id, next_poll, device_id)) sleep_until(next_poll) action = 'poll' if (not next_discovery or next_discovery < datetime.now()) and status == 1: action = 'discovery' log.debug('DEBUG: Thread {0} Starting {1} of device {2}'.format(thread_id, action, device_id)) devices_scanned += 1 db.query('UPDATE devices SET last_poll_attempted = NOW() WHERE device_id = {0}'.format(device_id)) if not getLock('{0}.{1}'.format(action, device_id), db): releaseLock('{0}.{1}'.format(action, device_id), db) releaseLock('queue.{0}'.format(device_id), db) continue releaseLock('queue.{0}'.format(device_id), db) try: start_time = time.time() path = poller_path if action == 'discovery': path = discover_path command = "/usr/bin/env php %s -h %s >> /dev/null 2>&1" % (path, device_id) subprocess.check_call(command, shell=True) elapsed_time = int(time.time() - start_time) if elapsed_time < 300: log.debug("DEBUG: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time)) else: log.warning("WARNING: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time)) except (KeyboardInterrupt, SystemExit): raise except: pass finally: releaseLock('{0}.{1}'.format(action, device_id), db) for i in range(0, amount_of_workers): t = threading.Thread(target=poll_worker) t.name = i t.daemon = True t.start() while True: sleep_until(next_update) seconds_taken = (datetime.now() - (next_update - timedelta(minutes=1))).seconds update_query = ('INSERT INTO pollers(poller_name, ' ' last_polled, ' ' devices, ' ' time_taken) ' ' values("{0}", NOW(), "{1}", "{2}") ' 'ON DUPLICATE KEY UPDATE ' ' last_polled=values(last_polled), ' ' devices=values(devices), ' ' time_taken=values(time_taken) ').format(config['distributed_poller_name'].strip(), devices_scanned, seconds_taken) try: db.query(update_query) except: log.critical('ERROR: MySQL query error. Is your schema up to date?') sys.exit(2) log.info('INFO: {0} devices scanned in the last minute'.format(devices_scanned)) devices_scanned = 0 next_update = datetime.now() + timedelta(minutes=1)
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 624, 199, 28073, 13, 1364, 437, 2435, 370, 4816, 26549, 12353, 14, 221, 2779, 911, 11271, 1536, 370, 2672, 6962, 7256, 737, 282, 900, 12, 436, 911, 440, 295, 13, 6843, 355, 7256, 626, 1172, 2757, 3708, 1146, 4453, 314, 2061, 2672, 6843, 63, 11132, 4696, 14, 2779, 911, 6791, 5277, 806, 7256, 4079, 355, 641, 314, 2061, 900, 3708, 1146, 14, 982, 5944, 787, 19258, 12, 642, 2435, 1077, 11271, 4036, 2243, 4036, 355, 2672, 6843, 63, 11132, 4696, 12, 1325, 1077, 19756, 5836, 477, 4523, 340, 5944, 787, 315, 21069, 12, 12353, 7256, 465, 355, 28914, 590, 465, 3962, 14, 961, 2435, 365, 4079, 641, 15057, 428, 78, 7879, 7735, 7, 28073, 13, 5029, 14, 647, 14, 421, 6529, 26, 263, 445, 3854, 1952, 77, 9370, 665, 429, 442, 32, 429, 442, 5362, 9370, 14, 846, 30, 199, 6148, 26, 3515, 1603, 21797, 6900, 421, 844, 26, 755, 6289, 499, 13, 16009, 199, 199, 7384, 334, 67, 9, 6900, 12, 445, 3854, 1952, 77, 9370, 199, 2422, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 199, 17, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 199, 18, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 199, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 624, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 25709, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 5055, 492, 12863, 199, 199, 793, 275, 2050, 14, 5572, 360, 26746, 13, 1364, 358, 199, 793, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 8911, 275, 2050, 14, 7772, 360, 26746, 13, 1364, 26, 2818, 1188, 9, 83, 358, 199, 2232, 275, 2050, 14, 5586, 14, 11319, 2445, 2461, 8, 1562, 8805, 2374, 15, 793, 358, 199, 2232, 14, 26076, 8, 8911, 9, 199, 793, 14, 18826, 8, 2232, 9, 199, 199, 3174, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 888, 63, 493, 275, 3907, 63, 694, 435, 1994, 888, 14, 8624, 7, 199, 199, 793, 14, 815, 360, 4531, 26, 24175, 28073, 13, 1364, 358, 421, 199, 533, 6249, 26, 272, 2557, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 262, 63, 1180, 275, 5796, 14, 6432, 342, 267, 291, 14, 2242, 342, 339, 347, 4907, 8, 277, 304, 267, 291, 14, 262, 63, 1180, 14, 8174, 8, 549, 9, 267, 1830, 715, 26, 288, 862, 26, 355, 291, 14, 1631, 14, 1600, 342, 288, 871, 26, 355, 986, 953, 862, 26, 355, 340, 1592, 63, 719, 508, 378, 26, 490, 291, 14, 1631, 275, 25709, 14, 2242, 8, 1102, 29, 697, 63, 1000, 12, 922, 29, 697, 63, 2473, 12, 15081, 29, 697, 63, 2060, 12, 1592, 29, 697, 63, 13238, 9, 355, 587, 26, 490, 291, 14, 1631, 275, 25709, 14, 2242, 8, 1102, 29, 697, 63, 1000, 12, 1844, 29, 697, 63, 719, 12, 922, 29, 697, 63, 2473, 12, 15081, 29, 697, 63, 2060, 12, 1592, 29, 697, 63, 13238, 9, 355, 2059, 288, 871, 334, 10227, 12, 25709, 14, 31998, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 4520, 12, 30882, 316, 2659, 355, 900, 14, 4532, 13417, 21, 9, 398, 291, 14, 1631, 14, 17881, 8, 549, 9, 267, 291, 14, 1631, 14, 4073, 8, 549, 9, 267, 291, 14, 262, 63, 1180, 14, 3221, 342, 339, 347, 1827, 8, 277, 12, 3875, 304, 267, 291, 14, 262, 63, 1180, 14, 8174, 8, 549, 9, 267, 1830, 715, 26, 288, 862, 26, 355, 3920, 275, 291, 14, 1631, 14, 3937, 342, 355, 3920, 14, 2526, 8, 3009, 9, 355, 2203, 275, 3920, 14, 10174, 342, 355, 3920, 14, 1600, 342, 355, 291, 14, 262, 63, 1180, 14, 3221, 342, 355, 372, 2203, 288, 871, 334, 10227, 12, 25709, 14, 31998, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 6654, 6279, 4520, 5309, 1827, 12, 30882, 316, 2659, 355, 291, 14, 262, 63, 1180, 14, 3221, 342, 355, 291, 14, 2242, 342, 288, 871, 334, 10227, 12, 25709, 14, 11411, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 2165, 9258, 4520, 5309, 1827, 12, 19595, 1827, 4020, 2659, 355, 3920, 14, 1600, 342, 421, 199, 318, 664, 63, 888, 63, 576, 837, 272, 1101, 63, 1760, 275, 18744, 2647, 15, 1393, 15, 1813, 297, 283, 8624, 297, 1543, 83, 15, 888, 63, 475, 63, 1001, 14, 8624, 7, 450, 3907, 63, 694, 61, 272, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 888, 63, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 9, 272, 871, 26, 267, 943, 14, 13138, 480, 3170, 26, 18615, 440, 5341, 26, 450, 83, 2, 450, 1101, 63, 1760, 9, 267, 984, 14, 2224, 8, 18, 9, 272, 372, 6499 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 624, 199, 28073, 13, 1364, 437, 2435, 370, 4816, 26549, 12353, 14, 221, 2779, 911, 11271, 1536, 370, 2672, 6962, 7256, 737, 282, 900, 12, 436, 911, 440, 295, 13, 6843, 355, 7256, 626, 1172, 2757, 3708, 1146, 4453, 314, 2061, 2672, 6843, 63, 11132, 4696, 14, 2779, 911, 6791, 5277, 806, 7256, 4079, 355, 641, 314, 2061, 900, 3708, 1146, 14, 982, 5944, 787, 19258, 12, 642, 2435, 1077, 11271, 4036, 2243, 4036, 355, 2672, 6843, 63, 11132, 4696, 12, 1325, 1077, 19756, 5836, 477, 4523, 340, 5944, 787, 315, 21069, 12, 12353, 7256, 465, 355, 28914, 590, 465, 3962, 14, 961, 2435, 365, 4079, 641, 15057, 428, 78, 7879, 7735, 7, 28073, 13, 5029, 14, 647, 14, 421, 6529, 26, 263, 445, 3854, 1952, 77, 9370, 665, 429, 442, 32, 429, 442, 5362, 9370, 14, 846, 30, 199, 6148, 26, 3515, 1603, 21797, 6900, 421, 844, 26, 755, 6289, 499, 13, 16009, 199, 199, 7384, 334, 67, 9, 6900, 12, 445, 3854, 1952, 77, 9370, 199, 2422, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 199, 17, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 199, 18, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 199, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 624, 199, 199, 646, 2022, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 25709, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 5055, 492, 12863, 199, 199, 793, 275, 2050, 14, 5572, 360, 26746, 13, 1364, 358, 199, 793, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 8911, 275, 2050, 14, 7772, 360, 26746, 13, 1364, 26, 2818, 1188, 9, 83, 358, 199, 2232, 275, 2050, 14, 5586, 14, 11319, 2445, 2461, 8, 1562, 8805, 2374, 15, 793, 358, 199, 2232, 14, 26076, 8, 8911, 9, 199, 793, 14, 18826, 8, 2232, 9, 199, 199, 3174, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 888, 63, 493, 275, 3907, 63, 694, 435, 1994, 888, 14, 8624, 7, 199, 199, 793, 14, 815, 360, 4531, 26, 24175, 28073, 13, 1364, 358, 421, 199, 533, 6249, 26, 272, 2557, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 262, 63, 1180, 275, 5796, 14, 6432, 342, 267, 291, 14, 2242, 342, 339, 347, 4907, 8, 277, 304, 267, 291, 14, 262, 63, 1180, 14, 8174, 8, 549, 9, 267, 1830, 715, 26, 288, 862, 26, 355, 291, 14, 1631, 14, 1600, 342, 288, 871, 26, 355, 986, 953, 862, 26, 355, 340, 1592, 63, 719, 508, 378, 26, 490, 291, 14, 1631, 275, 25709, 14, 2242, 8, 1102, 29, 697, 63, 1000, 12, 922, 29, 697, 63, 2473, 12, 15081, 29, 697, 63, 2060, 12, 1592, 29, 697, 63, 13238, 9, 355, 587, 26, 490, 291, 14, 1631, 275, 25709, 14, 2242, 8, 1102, 29, 697, 63, 1000, 12, 1844, 29, 697, 63, 719, 12, 922, 29, 697, 63, 2473, 12, 15081, 29, 697, 63, 2060, 12, 1592, 29, 697, 63, 13238, 9, 355, 2059, 288, 871, 334, 10227, 12, 25709, 14, 31998, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 4520, 12, 30882, 316, 2659, 355, 900, 14, 4532, 13417, 21, 9, 398, 291, 14, 1631, 14, 17881, 8, 549, 9, 267, 291, 14, 1631, 14, 4073, 8, 549, 9, 267, 291, 14, 262, 63, 1180, 14, 3221, 342, 339, 347, 1827, 8, 277, 12, 3875, 304, 267, 291, 14, 262, 63, 1180, 14, 8174, 8, 549, 9, 267, 1830, 715, 26, 288, 862, 26, 355, 3920, 275, 291, 14, 1631, 14, 3937, 342, 355, 3920, 14, 2526, 8, 3009, 9, 355, 2203, 275, 3920, 14, 10174, 342, 355, 3920, 14, 1600, 342, 355, 291, 14, 262, 63, 1180, 14, 3221, 342, 355, 372, 2203, 288, 871, 334, 10227, 12, 25709, 14, 31998, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 6654, 6279, 4520, 5309, 1827, 12, 30882, 316, 2659, 355, 291, 14, 262, 63, 1180, 14, 3221, 342, 355, 291, 14, 2242, 342, 288, 871, 334, 10227, 12, 25709, 14, 11411, 547, 304, 355, 943, 14, 3764, 360, 9171, 26, 11200, 2165, 9258, 4520, 5309, 1827, 12, 19595, 1827, 4020, 2659, 355, 3920, 14, 1600, 342, 421, 199, 318, 664, 63, 888, 63, 576, 837, 272, 1101, 63, 1760, 275, 18744, 2647, 15, 1393, 15, 1813, 297, 283, 8624, 297, 1543, 83, 15, 888, 63, 475, 63, 1001, 14, 8624, 7, 450, 3907, 63, 694, 61, 272, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 888, 63, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 9009, 29, 5781, 14, 6089, 9, 272, 871, 26, 267, 943, 14, 13138, 480, 3170, 26, 18615, 440, 5341, 26, 450, 83, 2, 450, 1101, 63, 1760, 9, 267, 984, 14, 2224, 8, 18, 9, 272, 372, 6499, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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peterson #Permission is hereby granted, free of charge, to any person obtaining a copy of #this software and associated documentation files (the "Software"), to deal in #the Software without restriction, including without limitation the rights to #use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of #the Software, and to permit persons to whom the Software is furnished to do so, #subject to the following conditions: #The above copyright notice and this permission notice shall be included in all #copies or substantial portions of the Software. #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS #FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR #COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER #IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN #CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import operator import sys import types __author__ = "Benjamin Peterson <benjamin@python.org>" __version__ = "1.2.0" # Revision 41c74fef2ded # True if we are running on Python 3. PY3 = sys.version_info[0] == 3 if PY3: string_types = str, integer_types = int, class_types = type, text_type = str binary_type = bytes MAXSIZE = sys.maxsize else: string_types = basestring, integer_types = (int, long) class_types = (type, types.ClassType) text_type = unicode binary_type = str if sys.platform.startswith("java"): # Jython always uses 32 bits. MAXSIZE = int((1 << 31) - 1) else: # It's possible to have sizeof(long) != sizeof(Py_ssize_t). class X(object): def __len__(self): return 1 << 31 try: len(X()) except OverflowError: # 32-bit MAXSIZE = int((1 << 31) - 1) else: # 64-bit MAXSIZE = int((1 << 63) - 1) del X def _add_doc(func, doc): """Add documentation to a function.""" func.__doc__ = doc def _import_module(name): """Import module, returning the module after the last dot.""" __import__(name) return sys.modules[name] class _LazyDescr(object): def __init__(self, name): self.name = name def __get__(self, obj, tp): result = self._resolve() setattr(obj, self.name, result) # This is a bit ugly, but it avoids running this again. delattr(tp, self.name) return result class MovedModule(_LazyDescr): def __init__(self, name, old, new=None): super(MovedModule, self).__init__(name) if PY3: if new is None: new = name self.mod = new else: self.mod = old def _resolve(self): return _import_module(self.mod) class MovedAttribute(_LazyDescr): def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): super(MovedAttribute, self).__init__(name) if PY3: if new_mod is None: new_mod = name self.mod = new_mod if new_attr is None: if old_attr is None: new_attr = name else: new_attr = old_attr self.attr = new_attr else: self.mod = old_mod if old_attr is None: old_attr = name self.attr = old_attr def _resolve(self): module = _import_module(self.mod) return getattr(module, self.attr) class _MovedItems(types.ModuleType): """Lazy loading of moved objects""" _moved_attributes = [ MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), MovedAttribute("map", "itertools", "builtins", "imap", "map"), MovedAttribute("reload_module", "__builtin__", "imp", "reload"), MovedAttribute("reduce", "__builtin__", "functools"), MovedAttribute("StringIO", "StringIO", "io"), MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), MovedModule("builtins", "__builtin__"), MovedModule("configparser", "ConfigParser"), MovedModule("copyreg", "copy_reg"), MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), MovedModule("http_cookies", "Cookie", "http.cookies"), MovedModule("html_entities", "htmlentitydefs", "html.entities"), MovedModule("html_parser", "HTMLParser", "html.parser"), MovedModule("http_client", "httplib", "http.client"), MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), MovedModule("cPickle", "cPickle", "pickle"), MovedModule("queue", "Queue"), MovedModule("reprlib", "repr"), MovedModule("socketserver", "SocketServer"), MovedModule("tkinter", "Tkinter"), MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), MovedModule("tkinter_tix", "Tix", "tkinter.tix"), MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), MovedModule("tkinter_colorchooser", "tkColorChooser", "tkinter.colorchooser"), MovedModule("tkinter_commondialog", "tkCommonDialog", "tkinter.commondialog"), MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), MovedModule("tkinter_font", "tkFont", "tkinter.font"), MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", "tkinter.simpledialog"), MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), MovedModule("winreg", "_winreg"), ] for attr in _moved_attributes: setattr(_MovedItems, attr.name, attr) del attr moves = sys.modules[__name__ + ".moves"] = _MovedItems("moves") def add_move(move): """Add an item to six.moves.""" setattr(_MovedItems, move.name, move) def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,)) if PY3: _meth_func = "__func__" _meth_self = "__self__" _func_code = "__code__" _func_defaults = "__defaults__" _iterkeys = "keys" _itervalues = "values" _iteritems = "items" else: _meth_func = "im_func" _meth_self = "im_self" _func_code = "func_code" _func_defaults = "func_defaults" _iterkeys = "iterkeys" _itervalues = "itervalues" _iteritems = "iteritems" try: advance_iterator = next except NameError: def advance_iterator(it): return it.next() next = advance_iterator if PY3: def get_unbound_function(unbound): return unbound Iterator = object def callable(obj): return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) else: def get_unbound_function(unbound): return unbound.im_func class Iterator(object): def next(self): return type(self).__next__(self) callable = callable _add_doc(get_unbound_function, """Get the function out of a possibly unbound function""") get_method_function = operator.attrgetter(_meth_func) get_method_self = operator.attrgetter(_meth_self) get_function_code = operator.attrgetter(_func_code) get_function_defaults = operator.attrgetter(_func_defaults) def iterkeys(d): """Return an iterator over the keys of a dictionary.""" return iter(getattr(d, _iterkeys)()) def itervalues(d): """Return an iterator over the values of a dictionary.""" return iter(getattr(d, _itervalues)()) def iteritems(d): """Return an iterator over the (key, value) pairs of a dictionary.""" return iter(getattr(d, _iteritems)()) if PY3: def b(s): return s.encode("latin-1") def u(s): return s if sys.version_info[1] <= 1: def int2byte(i): return bytes((i,)) else: # This is about 2x faster than the implementation above on 3.2+ int2byte = operator.methodcaller("to_bytes", 1, "big") import io StringIO = io.StringIO BytesIO = io.BytesIO else: def b(s): return s def u(s): return unicode(s, "unicode_escape") int2byte = chr import StringIO StringIO = BytesIO = StringIO.StringIO _add_doc(b, """Byte literal""") _add_doc(u, """Text literal""") if PY3: import builtins exec_ = getattr(builtins, "exec") def reraise(tp, value, tb=None): if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value print_ = getattr(builtins, "print") del builtins else: def exec_(code, globs=None, locs=None): """Execute code in a namespace.""" if globs is None: frame = sys._getframe(1) globs = frame.f_globals if locs is None: locs = frame.f_locals del frame elif locs is None: locs = globs exec("""exec code in globs, locs""") exec_("""def reraise(tp, value, tb=None): raise tp, value, tb """) def print_(*args, **kwargs): """The new-style print function.""" fp = kwargs.pop("file", sys.stdout) if fp is None: return def write(data): if not isinstance(data, basestring): data = str(data) fp.write(data) want_unicode = False sep = kwargs.pop("sep", None) if sep is not None: if isinstance(sep, unicode): want_unicode = True elif not isinstance(sep, str): raise TypeError("sep must be None or a string") end = kwargs.pop("end", None) if end is not None: if isinstance(end, unicode): want_unicode = True elif not isinstance(end, str): raise TypeError("end must be None or a string") if kwargs: raise TypeError("invalid keyword arguments to print()") if not want_unicode: for arg in args: if isinstance(arg, unicode): want_unicode = True break if want_unicode: newline = unicode("\n") space = unicode(" ") else: newline = "\n" space = " " if sep is None: sep = space if end is None: end = newline for i, arg in enumerate(args): if i: write(sep) write(arg) write(end) _add_doc(reraise, """Reraise an exception.""") def with_metaclass(meta, base=object): """Create a base class with a metaclass.""" return meta("NewBase", (base,), {})
gpl-3.0
[ 624, 22905, 367, 3575, 1233, 626, 7858, 641, 2018, 499, 436, 650, 624, 199, 199, 3, 7384, 334, 67, 9, 7129, 13, 8128, 26844, 16997, 262, 22912, 834, 199, 199, 3, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3, 3749, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 3, 1589, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 3, 1180, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 199, 3, 1589, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 3, 5875, 370, 314, 2569, 3704, 26, 199, 199, 3, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 3092, 199, 3, 2707, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 199, 3, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 199, 3, 568, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 18389, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 4182, 199, 646, 984, 199, 646, 2943, 199, 199, 363, 2502, 363, 275, 298, 31231, 16997, 262, 22912, 834, 665, 18486, 16997, 262, 32, 1548, 14, 1308, 4335, 199, 363, 1023, 363, 275, 298, 17, 14, 18, 14, 16, 2, 221, 327, 27095, 13385, 67, 1342, 32688, 18, 770, 421, 199, 3, 715, 340, 781, 787, 3879, 641, 2018, 650, 14, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 272, 3000, 63, 1313, 275, 1109, 12, 272, 1021, 63, 1313, 275, 730, 12, 272, 1318, 63, 466, 275, 620, 272, 3366, 63, 466, 275, 2783, 339, 9141, 4305, 275, 984, 14, 13634, 199, 2836, 26, 272, 1059, 63, 1313, 275, 7116, 12, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 272, 1021, 63, 1313, 275, 334, 466, 12, 2943, 14, 31165, 9, 272, 1318, 63, 466, 275, 2649, 272, 3366, 63, 466, 275, 620, 339, 340, 984, 14, 3246, 14, 2460, 480, 6138, 2349, 267, 327, 25333, 3544, 4440, 4337, 5821, 14, 267, 9141, 4305, 275, 1109, 1332, 17, 5213, 7105, 9, 446, 413, 9, 272, 587, 26, 267, 327, 2779, 1159, 3962, 370, 1172, 13855, 8, 2809, 9, 1137, 13855, 8, 2713, 63, 30104, 63, 84, 680, 267, 1021, 1323, 8, 785, 304, 288, 347, 636, 552, 721, 277, 304, 355, 372, 413, 5213, 7105, 267, 862, 26, 288, 822, 8, 56, 1012, 267, 871, 23870, 26, 288, 327, 4337, 13, 2075, 288, 9141, 4305, 275, 1109, 1332, 17, 5213, 7105, 9, 446, 413, 9, 267, 587, 26, 288, 327, 5049, 13, 2075, 288, 9141, 4305, 275, 1109, 1332, 17, 5213, 13668, 9, 446, 413, 9, 288, 2150, 1323, 421, 199, 318, 485, 525, 63, 1301, 8, 1532, 12, 1382, 304, 272, 408, 1123, 3794, 370, 282, 805, 1041, 272, 2562, 855, 1301, 363, 275, 1382, 421, 199, 318, 485, 646, 63, 578, 8, 354, 304, 272, 408, 6295, 859, 12, 8152, 314, 859, 2410, 314, 2061, 6308, 1041, 272, 636, 646, 721, 354, 9, 272, 372, 984, 14, 3112, 59, 354, 61, 421, 199, 533, 485, 14269, 28782, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 636, 362, 721, 277, 12, 1559, 12, 9253, 304, 267, 754, 275, 291, 423, 6983, 342, 267, 5371, 8, 1113, 12, 291, 14, 354, 12, 754, 9, 267, 327, 961, 365, 282, 4546, 23761, 12, 1325, 652, 23674, 3879, 642, 4020, 14, 267, 24358, 8, 683, 12, 291, 14, 354, 9, 267, 372, 754, 421, 199, 533, 11147, 1547, 14269, 28782, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2269, 12, 892, 29, 403, 304, 267, 1613, 8, 20774, 2377, 12, 291, 2843, 826, 721, 354, 9, 267, 340, 7843, 19, 26, 288, 340, 892, 365, 488, 26, 355, 892, 275, 536, 288, 291, 14, 1494, 275, 892, 267, 587, 26, 288, 291, 14, 1494, 275, 2269, 339, 347, 485, 6983, 8, 277, 304, 267, 372, 485, 646, 63, 578, 8, 277, 14, 1494, 9, 421, 199, 533, 8863, 1547, 14269, 28782, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2269, 63, 1494, 12, 892, 63, 1494, 12, 2269, 63, 962, 29, 403, 12, 892, 63, 962, 29, 403, 304, 267, 1613, 8, 20774, 1646, 12, 291, 2843, 826, 721, 354, 9, 267, 340, 7843, 19, 26, 288, 340, 892, 63, 1494, 365, 488, 26, 355, 892, 63, 1494, 275, 536, 288, 291, 14, 1494, 275, 892, 63, 1494, 288, 340, 892, 63, 962, 365, 488, 26, 355, 340, 2269, 63, 962, 365, 488, 26, 490, 892, 63, 962, 275, 536, 355, 587, 26, 490, 892, 63, 962, 275, 2269, 63, 962, 288, 291, 14, 962, 275, 892, 63, 962, 267, 587, 26, 288, 291, 14, 1494, 275, 2269, 63, 1494, 288, 340, 2269, 63, 962, 365, 488, 26, 355, 2269, 63, 962, 275, 536, 288, 291, 14, 962, 275, 2269, 63, 962, 339, 347, 485, 6983, 8, 277, 304, 267, 859, 275, 485, 646, 63, 578, 8, 277, 14, 1494, 9, 267, 372, 2519, 8, 578, 12, 291, 14, 962, 9, 4388, 199, 533, 485, 20774, 7412, 8, 1313, 14, 21820, 304, 272, 408, 14269, 8697, 402, 12155, 2251, 624, 421, 199, 63, 3539, 63, 2987, 275, 359, 272, 8863, 480, 67, 6424, 401, 298, 67, 6424, 401, 298, 2308, 401, 298, 6424, 1288, 272, 8863, 480, 1541, 401, 298, 17691, 401, 298, 10372, 401, 298, 73, 1541, 401, 298, 1541, 1288, 272, 8863, 480, 1210, 401, 4396, 5351, 13915, 298 ]
[ 22905, 367, 3575, 1233, 626, 7858, 641, 2018, 499, 436, 650, 624, 199, 199, 3, 7384, 334, 67, 9, 7129, 13, 8128, 26844, 16997, 262, 22912, 834, 199, 199, 3, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3, 3749, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 3, 1589, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 3, 1180, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 199, 3, 1589, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 3, 5875, 370, 314, 2569, 3704, 26, 199, 199, 3, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 3092, 199, 3, 2707, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 199, 3, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 199, 3, 568, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 18389, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 4182, 199, 646, 984, 199, 646, 2943, 199, 199, 363, 2502, 363, 275, 298, 31231, 16997, 262, 22912, 834, 665, 18486, 16997, 262, 32, 1548, 14, 1308, 4335, 199, 363, 1023, 363, 275, 298, 17, 14, 18, 14, 16, 2, 221, 327, 27095, 13385, 67, 1342, 32688, 18, 770, 421, 199, 3, 715, 340, 781, 787, 3879, 641, 2018, 650, 14, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 272, 3000, 63, 1313, 275, 1109, 12, 272, 1021, 63, 1313, 275, 730, 12, 272, 1318, 63, 466, 275, 620, 272, 3366, 63, 466, 275, 2783, 339, 9141, 4305, 275, 984, 14, 13634, 199, 2836, 26, 272, 1059, 63, 1313, 275, 7116, 12, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 272, 1021, 63, 1313, 275, 334, 466, 12, 2943, 14, 31165, 9, 272, 1318, 63, 466, 275, 2649, 272, 3366, 63, 466, 275, 620, 339, 340, 984, 14, 3246, 14, 2460, 480, 6138, 2349, 267, 327, 25333, 3544, 4440, 4337, 5821, 14, 267, 9141, 4305, 275, 1109, 1332, 17, 5213, 7105, 9, 446, 413, 9, 272, 587, 26, 267, 327, 2779, 1159, 3962, 370, 1172, 13855, 8, 2809, 9, 1137, 13855, 8, 2713, 63, 30104, 63, 84, 680, 267, 1021, 1323, 8, 785, 304, 288, 347, 636, 552, 721, 277, 304, 355, 372, 413, 5213, 7105, 267, 862, 26, 288, 822, 8, 56, 1012, 267, 871, 23870, 26, 288, 327, 4337, 13, 2075, 288, 9141, 4305, 275, 1109, 1332, 17, 5213, 7105, 9, 446, 413, 9, 267, 587, 26, 288, 327, 5049, 13, 2075, 288, 9141, 4305, 275, 1109, 1332, 17, 5213, 13668, 9, 446, 413, 9, 288, 2150, 1323, 421, 199, 318, 485, 525, 63, 1301, 8, 1532, 12, 1382, 304, 272, 408, 1123, 3794, 370, 282, 805, 1041, 272, 2562, 855, 1301, 363, 275, 1382, 421, 199, 318, 485, 646, 63, 578, 8, 354, 304, 272, 408, 6295, 859, 12, 8152, 314, 859, 2410, 314, 2061, 6308, 1041, 272, 636, 646, 721, 354, 9, 272, 372, 984, 14, 3112, 59, 354, 61, 421, 199, 533, 485, 14269, 28782, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 636, 362, 721, 277, 12, 1559, 12, 9253, 304, 267, 754, 275, 291, 423, 6983, 342, 267, 5371, 8, 1113, 12, 291, 14, 354, 12, 754, 9, 267, 327, 961, 365, 282, 4546, 23761, 12, 1325, 652, 23674, 3879, 642, 4020, 14, 267, 24358, 8, 683, 12, 291, 14, 354, 9, 267, 372, 754, 421, 199, 533, 11147, 1547, 14269, 28782, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2269, 12, 892, 29, 403, 304, 267, 1613, 8, 20774, 2377, 12, 291, 2843, 826, 721, 354, 9, 267, 340, 7843, 19, 26, 288, 340, 892, 365, 488, 26, 355, 892, 275, 536, 288, 291, 14, 1494, 275, 892, 267, 587, 26, 288, 291, 14, 1494, 275, 2269, 339, 347, 485, 6983, 8, 277, 304, 267, 372, 485, 646, 63, 578, 8, 277, 14, 1494, 9, 421, 199, 533, 8863, 1547, 14269, 28782, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2269, 63, 1494, 12, 892, 63, 1494, 12, 2269, 63, 962, 29, 403, 12, 892, 63, 962, 29, 403, 304, 267, 1613, 8, 20774, 1646, 12, 291, 2843, 826, 721, 354, 9, 267, 340, 7843, 19, 26, 288, 340, 892, 63, 1494, 365, 488, 26, 355, 892, 63, 1494, 275, 536, 288, 291, 14, 1494, 275, 892, 63, 1494, 288, 340, 892, 63, 962, 365, 488, 26, 355, 340, 2269, 63, 962, 365, 488, 26, 490, 892, 63, 962, 275, 536, 355, 587, 26, 490, 892, 63, 962, 275, 2269, 63, 962, 288, 291, 14, 962, 275, 892, 63, 962, 267, 587, 26, 288, 291, 14, 1494, 275, 2269, 63, 1494, 288, 340, 2269, 63, 962, 365, 488, 26, 355, 2269, 63, 962, 275, 536, 288, 291, 14, 962, 275, 2269, 63, 962, 339, 347, 485, 6983, 8, 277, 304, 267, 859, 275, 485, 646, 63, 578, 8, 277, 14, 1494, 9, 267, 372, 2519, 8, 578, 12, 291, 14, 962, 9, 4388, 199, 533, 485, 20774, 7412, 8, 1313, 14, 21820, 304, 272, 408, 14269, 8697, 402, 12155, 2251, 624, 421, 199, 63, 3539, 63, 2987, 275, 359, 272, 8863, 480, 67, 6424, 401, 298, 67, 6424, 401, 298, 2308, 401, 298, 6424, 1288, 272, 8863, 480, 1541, 401, 298, 17691, 401, 298, 10372, 401, 298, 73, 1541, 401, 298, 1541, 1288, 272, 8863, 480, 1210, 401, 4396, 5351, 13915, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
albertliangcode/DiceRoll
venv/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py
203
12894
# -*- coding: utf-8 -*- # # Copyright (C) 2013-2014 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # from io import BytesIO import logging import os import re import struct import sys from .compat import sysconfig, detect_encoding, ZipFile from .resources import finder from .util import (FileOperator, get_export_entry, convert_path, get_executable, in_venv) logger = logging.getLogger(__name__) _DEFAULT_MANIFEST = ''' <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="%s" type="win32"/> <!-- Identify the application security requirements. --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly>'''.strip() # check if Python is called on the first line with this expression FIRST_LINE_RE = re.compile(b'^#!.*pythonw?[0-9.]*([ \t].*)?$') SCRIPT_TEMPLATE = '''# -*- coding: utf-8 -*- if __name__ == '__main__': import sys, re def _resolve(module, func): __import__(module) mod = sys.modules[module] parts = func.split('.') result = getattr(mod, parts.pop(0)) for p in parts: result = getattr(result, p) return result try: sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) func = _resolve('%(module)s', '%(func)s') rc = func() # None interpreted as 0 except Exception as e: # only supporting Python >= 2.6 sys.stderr.write('%%s\\n' %% e) rc = 1 sys.exit(rc) ''' class ScriptMaker(object): """ A class to copy or create scripts from source scripts or callable specifications. """ script_template = SCRIPT_TEMPLATE executable = None # for shebangs def __init__(self, source_dir, target_dir, add_launchers=True, dry_run=False, fileop=None): self.source_dir = source_dir self.target_dir = target_dir self.add_launchers = add_launchers self.force = False self.clobber = False # It only makes sense to set mode bits on POSIX. self.set_mode = (os.name == 'posix') self.variants = set(('', 'X.Y')) self._fileop = fileop or FileOperator(dry_run) def _get_alternate_executable(self, executable, options): if options.get('gui', False) and os.name == 'nt': dn, fn = os.path.split(executable) fn = fn.replace('python', 'pythonw') executable = os.path.join(dn, fn) return executable def _get_shebang(self, encoding, post_interp=b'', options=None): enquote = True if self.executable: executable = self.executable enquote = False # assume this will be taken care of elif not sysconfig.is_python_build(): executable = get_executable() elif in_venv(): executable = os.path.join(sysconfig.get_path('scripts'), 'python%s' % sysconfig.get_config_var('EXE')) else: executable = os.path.join( sysconfig.get_config_var('BINDIR'), 'python%s%s' % (sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('EXE'))) if options: executable = self._get_alternate_executable(executable, options) # If the user didn't specify an executable, it may be necessary to # cater for executable paths with spaces (not uncommon on Windows) if enquote and ' ' in executable: executable = '"%s"' % executable # Issue #51: don't use fsencode, since we later try to # check that the shebang is decodable using utf-8. executable = executable.encode('utf-8') # in case of IronPython, play safe and enable frames support if (sys.platform == 'cli' and '-X:Frames' not in post_interp and '-X:FullFrames' not in post_interp): post_interp += b' -X:Frames' shebang = b'#!' + executable + post_interp + b'\n' # Python parser starts to read a script using UTF-8 until # it gets a #coding:xxx cookie. The shebang has to be the # first line of a file, the #coding:xxx cookie cannot be # written before. So the shebang has to be decodable from # UTF-8. try: shebang.decode('utf-8') except UnicodeDecodeError: raise ValueError( 'The shebang (%r) is not decodable from utf-8' % shebang) # If the script is encoded to a custom encoding (use a # #coding:xxx cookie), the shebang has to be decodable from # the script encoding too. if encoding != 'utf-8': try: shebang.decode(encoding) except UnicodeDecodeError: raise ValueError( 'The shebang (%r) is not decodable ' 'from the script encoding (%r)' % (shebang, encoding)) return shebang def _get_script_text(self, entry): return self.script_template % dict(module=entry.prefix, func=entry.suffix) manifest = _DEFAULT_MANIFEST def get_manifest(self, exename): base = os.path.basename(exename) return self.manifest % base def _write_script(self, names, shebang, script_bytes, filenames, ext): use_launcher = self.add_launchers and os.name == 'nt' linesep = os.linesep.encode('utf-8') if not use_launcher: script_bytes = shebang + linesep + script_bytes else: if ext == 'py': launcher = self._get_launcher('t') else: launcher = self._get_launcher('w') stream = BytesIO() with ZipFile(stream, 'w') as zf: zf.writestr('__main__.py', script_bytes) zip_data = stream.getvalue() script_bytes = launcher + shebang + linesep + zip_data for name in names: outname = os.path.join(self.target_dir, name) if use_launcher: n, e = os.path.splitext(outname) if e.startswith('.py'): outname = n outname = '%s.exe' % outname try: self._fileop.write_binary_file(outname, script_bytes) except Exception: # Failed writing an executable - it might be in use. logger.warning('Failed to write executable - trying to ' 'use .deleteme logic') dfname = '%s.deleteme' % outname if os.path.exists(dfname): os.remove(dfname) # Not allowed to fail here os.rename(outname, dfname) # nor here self._fileop.write_binary_file(outname, script_bytes) logger.debug('Able to replace executable using ' '.deleteme logic') try: os.remove(dfname) except Exception: pass # still in use - ignore error else: if os.name == 'nt' and not outname.endswith('.' + ext): outname = '%s.%s' % (outname, ext) if os.path.exists(outname) and not self.clobber: logger.warning('Skipping existing file %s', outname) continue self._fileop.write_binary_file(outname, script_bytes) if self.set_mode: self._fileop.set_executable_mode([outname]) filenames.append(outname) def _make_script(self, entry, filenames, options=None): post_interp = b'' if options: args = options.get('interpreter_args', []) if args: args = ' %s' % ' '.join(args) post_interp = args.encode('utf-8') shebang = self._get_shebang('utf-8', post_interp, options=options) script = self._get_script_text(entry).encode('utf-8') name = entry.name scriptnames = set() if '' in self.variants: scriptnames.add(name) if 'X' in self.variants: scriptnames.add('%s%s' % (name, sys.version[0])) if 'X.Y' in self.variants: scriptnames.add('%s-%s' % (name, sys.version[:3])) if options and options.get('gui', False): ext = 'pyw' else: ext = 'py' self._write_script(scriptnames, shebang, script, filenames, ext) def _copy_script(self, script, filenames): adjust = False script = os.path.join(self.source_dir, convert_path(script)) outname = os.path.join(self.target_dir, os.path.basename(script)) if not self.force and not self._fileop.newer(script, outname): logger.debug('not copying %s (up-to-date)', script) return # Always open the file, but ignore failures in dry-run mode -- # that way, we'll get accurate feedback if we can read the # script. try: f = open(script, 'rb') except IOError: if not self.dry_run: raise f = None else: encoding, lines = detect_encoding(f.readline) f.seek(0) first_line = f.readline() if not first_line: logger.warning('%s: %s is an empty file (skipping)', self.get_command_name(), script) return match = FIRST_LINE_RE.match(first_line.replace(b'\r\n', b'\n')) if match: adjust = True post_interp = match.group(1) or b'' if not adjust: if f: f.close() self._fileop.copy_file(script, outname) if self.set_mode: self._fileop.set_executable_mode([outname]) filenames.append(outname) else: logger.info('copying and adjusting %s -> %s', script, self.target_dir) if not self._fileop.dry_run: shebang = self._get_shebang(encoding, post_interp) if b'pythonw' in first_line: ext = 'pyw' else: ext = 'py' n = os.path.basename(outname) self._write_script([n], shebang, f.read(), filenames, ext) if f: f.close() @property def dry_run(self): return self._fileop.dry_run @dry_run.setter def dry_run(self, value): self._fileop.dry_run = value if os.name == 'nt': # Executable launcher support. # Launchers are from https://bitbucket.org/vinay.sajip/simple_launcher/ def _get_launcher(self, kind): if struct.calcsize('P') == 8: # 64-bit bits = '64' else: bits = '32' name = '%s%s.exe' % (kind, bits) # Issue 31: don't hardcode an absolute package name, but # determine it relative to the current package distlib_package = __name__.rsplit('.', 1)[0] result = finder(distlib_package).find(name).bytes return result # Public API follows def make(self, specification, options=None): """ Make a script. :param specification: The specification, which is either a valid export entry specification (to make a script from a callable) or a filename (to make a script by copying from a source location). :param options: A dictionary of options controlling script generation. :return: A list of all absolute pathnames written to. """ filenames = [] entry = get_export_entry(specification) if entry is None: self._copy_script(specification, filenames) else: self._make_script(entry, filenames, options=options) return filenames def make_multiple(self, specifications, options=None): """ Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to, """ filenames = [] for specification in specifications: filenames.extend(self.make(specification, options)) return filenames
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 13, 7280, 28882, 1187, 428, 9091, 711, 14, 199, 3, 3909, 370, 314, 2018, 2290, 2752, 1334, 282, 11615, 25025, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 504, 5890, 492, 11808, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 2702, 199, 646, 984, 199, 199, 504, 1275, 5819, 492, 22381, 12, 9696, 63, 2991, 12, 26755, 199, 504, 1275, 4435, 492, 11569, 199, 504, 1275, 1974, 492, 334, 1173, 7961, 12, 664, 63, 3790, 63, 2373, 12, 3957, 63, 515, 12, 673, 664, 63, 5904, 12, 315, 63, 23195, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 3472, 63, 24067, 275, 1449, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 2, 18042, 628, 5066, 24327, 199, 28, 17828, 9604, 628, 349, 26, 9482, 13, 17040, 13, 957, 26, 11374, 14, 86, 17, 2, 7712, 3353, 628, 17, 14, 16, 1743, 199, 665, 17828, 10193, 1015, 628, 17, 14, 16, 14, 16, 14, 16, 2, 199, 12495, 8438, 10497, 628, 56, 1184, 2, 199, 536, 5961, 83, 2, 199, 730, 628, 2676, 708, 7897, 421, 28253, 473, 848, 3338, 314, 4223, 6391, 9760, 14, 10541, 199, 665, 15756, 2354, 9604, 628, 349, 26, 9482, 13, 17040, 13, 957, 26, 11374, 14, 86, 19, 1743, 199, 665, 4416, 30, 199, 665, 11151, 4562, 13886, 30, 199, 665, 11151, 11310, 4670, 2166, 628, 305, 14883, 26790, 2, 8574, 3946, 628, 3910, 7897, 199, 3068, 11151, 4562, 13886, 30, 199, 3068, 4416, 30, 199, 3068, 15756, 2354, 30, 199, 1108, 17828, 30, 891, 1370, 1913, 342, 199, 199, 3, 1104, 340, 2018, 365, 2797, 641, 314, 1642, 1004, 543, 642, 3965, 199, 12903, 63, 6174, 63, 907, 275, 295, 14, 2014, 8, 66, 4289, 3168, 2795, 1548, 87, 26736, 16, 13, 25, 14, 3672, 779, 971, 84, 1055, 10, 5547, 9988, 199, 10484, 63, 7433, 275, 1449, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 12, 295, 339, 347, 485, 6983, 8, 578, 12, 2562, 304, 267, 636, 646, 721, 578, 9, 267, 3413, 275, 984, 14, 3112, 59, 578, 61, 267, 4184, 275, 2562, 14, 1294, 7563, 267, 754, 275, 2519, 8, 1494, 12, 4184, 14, 1935, 8, 16, 430, 267, 367, 299, 315, 4184, 26, 288, 754, 275, 2519, 8, 1099, 12, 299, 9, 267, 372, 754, 339, 862, 26, 267, 984, 14, 3020, 59, 16, 61, 275, 295, 14, 954, 8, 82, 7, 2801, 1579, 4537, 647, 87, 92, 4537, 5803, 5547, 4268, 3260, 984, 14, 3020, 59, 16, 566, 398, 2562, 275, 485, 6983, 24713, 578, 9, 83, 297, 9487, 1532, 9, 83, 358, 267, 4819, 275, 2562, 342, 327, 488, 11922, 465, 378, 272, 871, 2186, 465, 325, 26, 221, 327, 1454, 21038, 2018, 2356, 499, 14, 22, 267, 984, 14, 3083, 14, 952, 3508, 5, 83, 1103, 78, 7, 11539, 325, 9, 267, 4819, 275, 413, 272, 984, 14, 2224, 8, 1195, 9, 199, 2344, 421, 199, 533, 14914, 23560, 8, 785, 304, 272, 408, 272, 437, 1021, 370, 1331, 503, 1218, 10554, 687, 1350, 10554, 503, 4550, 272, 28754, 14, 272, 408, 272, 2884, 63, 1160, 275, 30203, 63, 7433, 339, 7286, 275, 488, 221, 327, 367, 308, 9260, 20068, 339, 347, 636, 826, 721, 277, 12, 1350, 63, 694, 12, 1347, 63, 694, 12, 1050, 63, 9850, 1192, 29, 549, 12, 326, 9951, 63, 1065, 29, 797, 12, 570, 411, 29, 403, 304, 267, 291, 14, 1365, 63, 694, 275, 1350, 63, 694, 267, 291, 14, 1375, 63, 694, 275, 1347, 63, 694, 267, 291, 14, 525, 63, 9850, 1192, 275, 1050, 63, 9850, 1192, 267, 291, 14, 3990, 275, 756, 267, 291, 14, 67, 22669, 275, 756, 267, 327, 2779, 1454, 7704, 12249, 370, 663, 818, 5821, 641, 18169, 14, 267, 291, 14, 409, 63, 632, 275, 334, 736, 14, 354, 508, 283, 9228, 358, 267, 291, 14, 15680, 275, 663, 4725, 297, 283, 56, 14, 57, 1333, 267, 291, 423, 493, 411, 275, 570, 411, 503, 3814, 7961, 8, 10481, 63, 1065, 9, 339, 347, 485, 362, 63, 17170, 63, 5904, 8, 277, 12, 7286, 12, 1511, 304, 267, 340, 1511, 14, 362, 360, 5885, 297, 756, 9, 436, 747, 14, 354, 508, 283, 343, 356, 288, 14052, 12, 4325, 275, 747, 14, 515, 14, 1294, 8, 5904, 9, 288, 4325, 275, 4325, 14, 1814, 360, 1548, 297, 283, 1548, 87, 358, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 4272, 12, 4325, 9, 267, 372, 7286, 339, 347, 485, 362, 63, 83, 20909, 8, 277, 12, 2644, 12, 2963, 63, 14252, 29, 66, 6448, 1511, 29, 403, 304, 267, 655, 3513, 275, 715, 267, 340, 291, 14, 5904, 26, 288, 7286, 275, 291, 14, 5904, 288, 655, 3513, 275, 756, 258, 327, 5534, 642, 911, 506, 9394, 10296, 402, 267, 916, 440, 22381, 14, 374, 63, 1548, 63, 1506, 837, 288, 7286, 275, 664, 63, 5904, 342, 267, 916, 315, 63, 23195, 837, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 24030, 14, 362, 63, 515, 360, 6429, 659, 1169, 283, 1548, 5, 83, 7, 450, 22381, 14, 362, 63, 888, 63, 1391, 360, 23017, 1333, 267, 587, 26, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 355, 22381, 14, 362, 63, 888, 63, 1391, 360, 9431, 3022, 659, 2049, 283, 1548, 5, 83, 5, 83, 7, 450, 334, 24030, 14, 362, 63, 888, 63, 1391, 360, 4612, 659, 3044, 22381, 14, 362, 63, 888, 63, 1391, 360, 23017, 7058, 267, 340, 1511, 26, 288, 7286, 275, 291, 423, 362, 63, 17170, 63, 5904, 8, 5904, 12, 1511, 9, 398, 327, 982, 314, 922, 9980, 1133, 4165, 376, 7286, 12, 652, 1443, 506, 5784, 370, 267, 327, 286, 6618, 367, 7286, 3792, 543, 7883, 334, 1397, 625, 2330, 641, 5417, 9, 267, 340, 655, 3513, 436, 283, 283, 315, 7286, 26, 288, 7286, 275, 18253, 83, 4507, 450, 7286, 267, 327 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6171, 13, 7280, 28882, 1187, 428, 9091, 711, 14, 199, 3, 3909, 370, 314, 2018, 2290, 2752, 1334, 282, 11615, 25025, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 504, 5890, 492, 11808, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 2702, 199, 646, 984, 199, 199, 504, 1275, 5819, 492, 22381, 12, 9696, 63, 2991, 12, 26755, 199, 504, 1275, 4435, 492, 11569, 199, 504, 1275, 1974, 492, 334, 1173, 7961, 12, 664, 63, 3790, 63, 2373, 12, 3957, 63, 515, 12, 673, 664, 63, 5904, 12, 315, 63, 23195, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 3472, 63, 24067, 275, 1449, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 2, 18042, 628, 5066, 24327, 199, 28, 17828, 9604, 628, 349, 26, 9482, 13, 17040, 13, 957, 26, 11374, 14, 86, 17, 2, 7712, 3353, 628, 17, 14, 16, 1743, 199, 665, 17828, 10193, 1015, 628, 17, 14, 16, 14, 16, 14, 16, 2, 199, 12495, 8438, 10497, 628, 56, 1184, 2, 199, 536, 5961, 83, 2, 199, 730, 628, 2676, 708, 7897, 421, 28253, 473, 848, 3338, 314, 4223, 6391, 9760, 14, 10541, 199, 665, 15756, 2354, 9604, 628, 349, 26, 9482, 13, 17040, 13, 957, 26, 11374, 14, 86, 19, 1743, 199, 665, 4416, 30, 199, 665, 11151, 4562, 13886, 30, 199, 665, 11151, 11310, 4670, 2166, 628, 305, 14883, 26790, 2, 8574, 3946, 628, 3910, 7897, 199, 3068, 11151, 4562, 13886, 30, 199, 3068, 4416, 30, 199, 3068, 15756, 2354, 30, 199, 1108, 17828, 30, 891, 1370, 1913, 342, 199, 199, 3, 1104, 340, 2018, 365, 2797, 641, 314, 1642, 1004, 543, 642, 3965, 199, 12903, 63, 6174, 63, 907, 275, 295, 14, 2014, 8, 66, 4289, 3168, 2795, 1548, 87, 26736, 16, 13, 25, 14, 3672, 779, 971, 84, 1055, 10, 5547, 9988, 199, 10484, 63, 7433, 275, 1449, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 12, 295, 339, 347, 485, 6983, 8, 578, 12, 2562, 304, 267, 636, 646, 721, 578, 9, 267, 3413, 275, 984, 14, 3112, 59, 578, 61, 267, 4184, 275, 2562, 14, 1294, 7563, 267, 754, 275, 2519, 8, 1494, 12, 4184, 14, 1935, 8, 16, 430, 267, 367, 299, 315, 4184, 26, 288, 754, 275, 2519, 8, 1099, 12, 299, 9, 267, 372, 754, 339, 862, 26, 267, 984, 14, 3020, 59, 16, 61, 275, 295, 14, 954, 8, 82, 7, 2801, 1579, 4537, 647, 87, 92, 4537, 5803, 5547, 4268, 3260, 984, 14, 3020, 59, 16, 566, 398, 2562, 275, 485, 6983, 24713, 578, 9, 83, 297, 9487, 1532, 9, 83, 358, 267, 4819, 275, 2562, 342, 327, 488, 11922, 465, 378, 272, 871, 2186, 465, 325, 26, 221, 327, 1454, 21038, 2018, 2356, 499, 14, 22, 267, 984, 14, 3083, 14, 952, 3508, 5, 83, 1103, 78, 7, 11539, 325, 9, 267, 4819, 275, 413, 272, 984, 14, 2224, 8, 1195, 9, 199, 2344, 421, 199, 533, 14914, 23560, 8, 785, 304, 272, 408, 272, 437, 1021, 370, 1331, 503, 1218, 10554, 687, 1350, 10554, 503, 4550, 272, 28754, 14, 272, 408, 272, 2884, 63, 1160, 275, 30203, 63, 7433, 339, 7286, 275, 488, 221, 327, 367, 308, 9260, 20068, 339, 347, 636, 826, 721, 277, 12, 1350, 63, 694, 12, 1347, 63, 694, 12, 1050, 63, 9850, 1192, 29, 549, 12, 326, 9951, 63, 1065, 29, 797, 12, 570, 411, 29, 403, 304, 267, 291, 14, 1365, 63, 694, 275, 1350, 63, 694, 267, 291, 14, 1375, 63, 694, 275, 1347, 63, 694, 267, 291, 14, 525, 63, 9850, 1192, 275, 1050, 63, 9850, 1192, 267, 291, 14, 3990, 275, 756, 267, 291, 14, 67, 22669, 275, 756, 267, 327, 2779, 1454, 7704, 12249, 370, 663, 818, 5821, 641, 18169, 14, 267, 291, 14, 409, 63, 632, 275, 334, 736, 14, 354, 508, 283, 9228, 358, 267, 291, 14, 15680, 275, 663, 4725, 297, 283, 56, 14, 57, 1333, 267, 291, 423, 493, 411, 275, 570, 411, 503, 3814, 7961, 8, 10481, 63, 1065, 9, 339, 347, 485, 362, 63, 17170, 63, 5904, 8, 277, 12, 7286, 12, 1511, 304, 267, 340, 1511, 14, 362, 360, 5885, 297, 756, 9, 436, 747, 14, 354, 508, 283, 343, 356, 288, 14052, 12, 4325, 275, 747, 14, 515, 14, 1294, 8, 5904, 9, 288, 4325, 275, 4325, 14, 1814, 360, 1548, 297, 283, 1548, 87, 358, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 4272, 12, 4325, 9, 267, 372, 7286, 339, 347, 485, 362, 63, 83, 20909, 8, 277, 12, 2644, 12, 2963, 63, 14252, 29, 66, 6448, 1511, 29, 403, 304, 267, 655, 3513, 275, 715, 267, 340, 291, 14, 5904, 26, 288, 7286, 275, 291, 14, 5904, 288, 655, 3513, 275, 756, 258, 327, 5534, 642, 911, 506, 9394, 10296, 402, 267, 916, 440, 22381, 14, 374, 63, 1548, 63, 1506, 837, 288, 7286, 275, 664, 63, 5904, 342, 267, 916, 315, 63, 23195, 837, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 24030, 14, 362, 63, 515, 360, 6429, 659, 1169, 283, 1548, 5, 83, 7, 450, 22381, 14, 362, 63, 888, 63, 1391, 360, 23017, 1333, 267, 587, 26, 288, 7286, 275, 747, 14, 515, 14, 904, 8, 355, 22381, 14, 362, 63, 888, 63, 1391, 360, 9431, 3022, 659, 2049, 283, 1548, 5, 83, 5, 83, 7, 450, 334, 24030, 14, 362, 63, 888, 63, 1391, 360, 4612, 659, 3044, 22381, 14, 362, 63, 888, 63, 1391, 360, 23017, 7058, 267, 340, 1511, 26, 288, 7286, 275, 291, 423, 362, 63, 17170, 63, 5904, 8, 5904, 12, 1511, 9, 398, 327, 982, 314, 922, 9980, 1133, 4165, 376, 7286, 12, 652, 1443, 506, 5784, 370, 267, 327, 286, 6618, 367, 7286, 3792, 543, 7883, 334, 1397, 625, 2330, 641, 5417, 9, 267, 340, 655, 3513, 436, 283, 283, 315, 7286, 26, 288, 7286, 275, 18253, 83, 4507, 450, 7286, 267, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jianghaolu/AutoRest
src/generator/AutoRest.Python.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/fixtures/acceptancetestssubscriptionidapiversion/models/error.py
16
1271
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model from msrest.exceptions import HttpOperationError class Error(Model): """Error. :param code: :type code: int :param message: :type message: str """ _attribute_map = { 'code': {'key': 'code', 'type': 'int'}, 'message': {'key': 'message', 'type': 'str'}, } def __init__(self, code=None, message=None): self.code = code self.message = message class ErrorException(HttpOperationError): """Server responsed with exception of type: 'Error'. :param deserialize: A deserializer :param response: Server response to be deserialized. """ def __init__(self, deserialize, response, *args): super(ErrorException, self).__init__(deserialize, response, 'Error', *args)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 199, 504, 6605, 3911, 14, 3924, 492, 4760, 3632, 5263, 421, 199, 533, 4520, 8, 1685, 304, 272, 408, 547, 14, 339, 520, 635, 1233, 26, 272, 520, 466, 1233, 26, 1109, 272, 520, 635, 1245, 26, 272, 520, 466, 1245, 26, 620, 272, 408, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 600, 356, 791, 498, 356, 283, 600, 297, 283, 466, 356, 283, 442, 2267, 267, 283, 1188, 356, 791, 498, 356, 283, 1188, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1233, 29, 403, 12, 1245, 29, 403, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 1188, 275, 1245, 421, 199, 533, 4520, 1726, 8, 5779, 3632, 5263, 304, 272, 408, 3120, 1177, 68, 543, 1919, 402, 730, 26, 283, 547, 1370, 339, 520, 635, 22920, 26, 437, 30237, 272, 520, 635, 1177, 26, 7146, 1177, 370, 506, 13256, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 22920, 12, 1177, 12, 627, 589, 304, 398, 1613, 8, 547, 1726, 12, 291, 2843, 826, 721, 11143, 12, 1177, 12, 283, 547, 297, 627, 589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 199, 504, 6605, 3911, 14, 3924, 492, 4760, 3632, 5263, 421, 199, 533, 4520, 8, 1685, 304, 272, 408, 547, 14, 339, 520, 635, 1233, 26, 272, 520, 466, 1233, 26, 1109, 272, 520, 635, 1245, 26, 272, 520, 466, 1245, 26, 620, 272, 408, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 600, 356, 791, 498, 356, 283, 600, 297, 283, 466, 356, 283, 442, 2267, 267, 283, 1188, 356, 791, 498, 356, 283, 1188, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1233, 29, 403, 12, 1245, 29, 403, 304, 267, 291, 14, 600, 275, 1233, 267, 291, 14, 1188, 275, 1245, 421, 199, 533, 4520, 1726, 8, 5779, 3632, 5263, 304, 272, 408, 3120, 1177, 68, 543, 1919, 402, 730, 26, 283, 547, 1370, 339, 520, 635, 22920, 26, 437, 30237, 272, 520, 635, 1177, 26, 7146, 1177, 370, 506, 13256, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 22920, 12, 1177, 12, 627, 589, 304, 398, 1613, 8, 547, 1726, 12, 291, 2843, 826, 721, 11143, 12, 1177, 12, 283, 547, 297, 627, 589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Xperia-Nicki/android_kernel_sony_nicki
tools/perf/scripts/python/net_dropmonitor.py
4235
1554
# Monitor the system for dropped packets and proudce a report of drop locations and counts import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * drop_log = {} kallsyms = [] def get_kallsyms_table(): global kallsyms try: f = open("/proc/kallsyms", "r") linecount = 0 for line in f: linecount = linecount+1 f.seek(0) except: return j = 0 for line in f: loc = int(line.split()[0], 16) name = line.split()[2] j = j +1 if ((j % 100) == 0): print "\r" + str(j) + "/" + str(linecount), kallsyms.append({ 'loc': loc, 'name' : name}) print "\r" + str(j) + "/" + str(linecount) kallsyms.sort() return def get_sym(sloc): loc = int(sloc) for i in kallsyms: if (i['loc'] >= loc): return (i['name'], i['loc']-loc) return (None, 0) def print_drop_table(): print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT") for i in drop_log.keys(): (sym, off) = get_sym(i) if sym == None: sym = i print "%25s %25s %25s" % (sym, off, drop_log[i]) def trace_begin(): print "Starting trace (Ctrl-C to dump results)" def trace_end(): print "Gathering kallsyms data" get_kallsyms_table() print_drop_table() # called from perf, when it finds a correspoinding event def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr, protocol, location): slocation = str(location) try: drop_log[slocation] = drop_log[slocation] + 1 except: drop_log[slocation] = 1
gpl-2.0
[ 3, 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 507, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 26504, 314, 2656, 367, 17481, 14593, 436, 557, 1181, 301, 282, 3622, 402, 5978, 9918, 436, 8242, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 507, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 4824, 63, 793, 275, 1052, 199, 32483, 275, 942, 199, 199, 318, 664, 63, 32483, 63, 1224, 837, 199, 198, 2966, 1022, 452, 13807, 199, 198, 893, 26, 507, 198, 70, 275, 1551, 4769, 4687, 15, 32483, 401, 298, 82, 531, 507, 198, 604, 835, 275, 378, 507, 198, 509, 1004, 315, 289, 26, 686, 198, 604, 835, 275, 1004, 835, 11, 17, 507, 198, 70, 14, 5507, 8, 16, 9, 199, 198, 2590, 26, 507, 198, 1107, 4388, 198, 74, 275, 378, 199, 198, 509, 1004, 315, 289, 26, 507, 198, 2102, 275, 1109, 8, 604, 14, 1294, 3430, 16, 467, 3193, 9, 507, 198, 354, 275, 1004, 14, 1294, 3430, 18, 61, 507, 198, 74, 275, 1335, 435, 17, 507, 198, 692, 3666, 74, 450, 2948, 9, 508, 378, 304, 686, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 395, 507, 198, 32483, 14, 740, 2561, 283, 2102, 356, 4355, 12, 283, 354, 7, 520, 536, 1552, 421, 198, 1361, 1867, 82, 2, 435, 620, 8, 74, 9, 435, 10609, 435, 620, 8, 604, 835, 9, 199, 198, 32483, 14, 3191, 342, 199, 198, 1107, 199, 199, 318, 664, 63, 3840, 8, 83, 2102, 304, 199, 198, 2102, 275, 1109, 8, 83, 2102, 9, 199, 198, 509, 284, 315, 1022, 452, 13807, 26, 507, 198, 692, 334, 73, 459, 2102, 418, 2356, 4355, 304, 686, 198, 1107, 334, 73, 459, 354, 995, 284, 459, 2102, 418, 13, 2102, 9, 199, 198, 1107, 334, 403, 12, 378, 9, 199, 199, 318, 870, 63, 4824, 63, 1224, 837, 199, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 1689, 16575, 401, 298, 14839, 401, 298, 8760, 531, 199, 198, 509, 284, 315, 5978, 63, 793, 14, 1612, 837, 507, 198, 8, 3840, 12, 2331, 9, 275, 664, 63, 3840, 8, 73, 9, 507, 198, 692, 4678, 508, 488, 26, 686, 198, 3840, 275, 284, 507, 198, 1361, 2071, 821, 83, 450, 821, 83, 450, 821, 83, 2, 450, 334, 3840, 12, 2331, 12, 5978, 63, 793, 59, 73, 566, 421, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14139, 3307, 334, 9778, 13, 35, 370, 5461, 2058, 2924, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 39, 7404, 316, 1022, 452, 13807, 666, 2, 199, 198, 362, 63, 32483, 63, 1224, 342, 199, 198, 1361, 63, 4824, 63, 1224, 342, 199, 199, 3, 2797, 687, 8582, 12, 1380, 652, 17651, 282, 1970, 470, 555, 688, 316, 1566, 199, 318, 11448, 363, 22197, 63, 6852, 8, 354, 12, 1067, 12, 5033, 12, 6513, 12, 14256, 12, 4422, 12, 1923, 12, 686, 198, 13664, 12, 4113, 12, 2909, 304, 199, 198, 83, 1985, 275, 620, 8, 1985, 9, 199, 198, 893, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 5978, 63, 793, 59, 83, 1985, 61, 435, 413, 199, 198, 2590, 26, 507, 198, 4824, 63, 793, 59, 83, 1985, 61, 275, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
trevor/mailman3
src/mailman/core/chains.py
2
4764
# Copyright (C) 2007-2014 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # # GNU Mailman 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. # # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. """Application support for chain processing.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'initialize', 'process', ] from zope.interface.verify import verifyObject from mailman.chains.base import Chain, TerminalChainBase from mailman.config import config from mailman.interfaces.chain import LinkAction, IChain from mailman.utilities.modules import find_components def process(mlist, msg, msgdata, start_chain='default-posting-chain'): """Process the message through a chain. :param mlist: the IMailingList for this message. :param msg: The Message object. :param msgdata: The message metadata dictionary. :param start_chain: The name of the chain to start the processing with. """ # Set up some bookkeeping. chain_stack = [] msgdata['rule_hits'] = hits = [] msgdata['rule_misses'] = misses = [] # Find the starting chain and begin iterating through its links. chain = config.chains[start_chain] chain_iter = chain.get_links(mlist, msg, msgdata) # Loop until we've reached the end of all processing chains. while chain: # Iterate over all links in the chain. Do this outside a for-loop so # we can capture a chain's link iterator in mid-flight. This supports # the 'detour' link action. try: link = next(chain_iter) except StopIteration: # This chain is exhausted. Pop the last chain on the stack and # continue iterating through it. If there's nothing left on the # chain stack then we're completely finished processing. if len(chain_stack) == 0: return chain, chain_iter = chain_stack.pop() continue if link.rule.check(mlist, msg, msgdata): if link.rule.record: hits.append(link.rule.name) # The rule matched so run its action. if link.action is LinkAction.jump: chain = link.chain chain_iter = chain.get_links(mlist, msg, msgdata) continue elif link.action is LinkAction.detour: # Push the current chain so that we can return to it when # the next chain is finished. chain_stack.append((chain, chain_iter)) chain = link.chain chain_iter = chain.get_links(mlist, msg, msgdata) continue elif link.action is LinkAction.stop: # Stop all processing. return elif link.action is LinkAction.defer: # Just process the next link in the chain. pass elif link.action is LinkAction.run: link.function(mlist, msg, msgdata) else: raise AssertionError( 'Bad link action: {0}'.format(link.action)) else: # The rule did not match; keep going. if link.rule.record: misses.append(link.rule.name) def initialize(): """Set up chains, both built-in and from the database.""" for chain_class in find_components('mailman.chains', IChain): # FIXME 2010-12-28 barry: We need a generic way to disable automatic # instantiation of discovered classes. This is useful not just for # chains, but also for rules, handlers, etc. Ideally it should be # part of find_components(). For now, hard code the ones we do not # want to instantiate. if chain_class in (Chain, TerminalChainBase): continue chain = chain_class() verifyObject(IChain, chain) assert chain.name not in config.chains, ( 'Duplicate chain "{0}" found in {1} (previously: {2}'.format( chain.name, chain_class, config.chains[chain.name])) config.chains[chain.name] = chain # XXX Read chains from the database and initialize them. pass
gpl-3.0
[ 3, 1898, 334, 35, 9, 10219, 13, 7280, 701, 314, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 18027, 1237, 14, 199, 3, 199, 3, 1664, 18027, 1237, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 18027, 1237, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 199, 3, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 1664, 18027, 1237, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 5039, 2291, 367, 6036, 6661, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 363, 6577, 363, 275, 730, 199, 363, 452, 363, 275, 359, 272, 283, 8489, 297, 272, 283, 1412, 297, 272, 1622, 421, 199, 504, 20110, 14, 3266, 14, 4712, 492, 4911, 1692, 199, 199, 504, 6016, 1237, 14, 17419, 14, 1095, 492, 25384, 12, 20429, 279, 10720, 1563, 199, 504, 6016, 1237, 14, 888, 492, 1101, 199, 504, 6016, 1237, 14, 7436, 14, 4429, 492, 10967, 3310, 12, 473, 10720, 199, 504, 6016, 1237, 14, 16355, 14, 3112, 492, 2342, 63, 4608, 4388, 201, 199, 318, 2112, 8, 77, 513, 12, 1499, 12, 1499, 576, 12, 1343, 63, 4429, 534, 885, 13, 23980, 13, 4429, 735, 272, 408, 3498, 314, 1245, 4012, 282, 6036, 14, 339, 520, 635, 333, 513, 26, 314, 473, 13681, 316, 1296, 367, 642, 1245, 14, 272, 520, 635, 1499, 26, 710, 6430, 909, 14, 272, 520, 635, 1499, 576, 26, 710, 1245, 3341, 2600, 14, 272, 520, 635, 1343, 63, 4429, 26, 710, 536, 402, 314, 6036, 370, 1343, 314, 6661, 543, 14, 272, 408, 272, 327, 2494, 1536, 2005, 6719, 3250, 316, 14, 272, 6036, 63, 2340, 275, 942, 272, 1499, 576, 459, 2200, 63, 16595, 418, 275, 19745, 275, 942, 272, 1499, 576, 459, 2200, 63, 1292, 874, 418, 275, 3201, 874, 275, 942, 272, 327, 6668, 314, 6617, 6036, 436, 5386, 25012, 4012, 2399, 6220, 14, 272, 6036, 275, 1101, 14, 17419, 59, 928, 63, 4429, 61, 272, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 272, 327, 18175, 5133, 781, 9064, 13075, 314, 1284, 402, 1006, 6661, 30640, 14, 272, 1830, 6036, 26, 267, 327, 23989, 1806, 1006, 6220, 315, 314, 6036, 14, 221, 4226, 642, 9682, 282, 367, 13, 3813, 880, 267, 327, 781, 883, 12296, 282, 6036, 1159, 2142, 6122, 315, 10887, 13, 28807, 14, 221, 961, 5171, 267, 327, 314, 283, 271, 10808, 7, 2142, 1595, 14, 267, 862, 26, 288, 2142, 275, 2163, 8, 4429, 63, 1661, 9, 267, 871, 10852, 26, 288, 327, 961, 6036, 365, 31103, 14, 221, 13244, 314, 2061, 6036, 641, 314, 3464, 436, 288, 327, 1980, 25012, 4012, 652, 14, 221, 982, 2337, 1159, 6548, 3602, 641, 314, 288, 327, 6036, 3464, 2066, 781, 3984, 14793, 9158, 6661, 14, 288, 340, 822, 8, 4429, 63, 2340, 9, 508, 378, 26, 355, 372, 288, 6036, 12, 6036, 63, 1661, 275, 6036, 63, 2340, 14, 1935, 342, 288, 1980, 267, 340, 2142, 14, 2200, 14, 1074, 8, 77, 513, 12, 1499, 12, 1499, 576, 304, 288, 340, 2142, 14, 2200, 14, 3059, 26, 355, 19745, 14, 740, 8, 1073, 14, 2200, 14, 354, 9, 288, 327, 710, 2332, 7838, 880, 1255, 2399, 1595, 14, 288, 340, 2142, 14, 1287, 365, 10967, 3310, 14, 11126, 26, 355, 6036, 275, 2142, 14, 4429, 355, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 355, 1980, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 271, 10808, 26, 355, 327, 22643, 314, 1453, 6036, 880, 626, 781, 883, 372, 370, 652, 1380, 355, 327, 314, 2163, 6036, 365, 9158, 14, 355, 6036, 63, 2340, 14, 740, 1332, 4429, 12, 6036, 63, 1661, 430, 355, 6036, 275, 2142, 14, 4429, 355, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 355, 1980, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 2379, 26, 355, 327, 8015, 1006, 6661, 14, 355, 372, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 11610, 26, 355, 327, 13870, 2112, 314, 2163, 2142, 315, 314, 6036, 14, 355, 986, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 1065, 26, 355, 2142, 14, 1593, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 288, 587, 26, 355, 746, 9070, 8, 490, 283, 5725, 2142, 1595, 26, 469, 16, 5285, 908, 8, 1073, 14, 1287, 430, 267, 587, 26, 288, 327, 710, 2332, 8103, 440, 1336, 27, 4215, 9995, 14, 288, 340, 2142, 14, 2200, 14, 3059, 26, 355, 3201, 874, 14, 740, 8, 1073, 14, 2200, 14, 354, 9, 4388, 201, 199, 318, 8265, 837, 272, 408, 1084, 1536, 30640, 12, 3865, 6137, 13, 262, 436, 687, 314, 3050, 1041, 272, 367, 6036, 63, 533, 315, 2342, 63, 4608, 360, 1198, 1237, 14, 17419, 297, 473, 10720, 304, 267, 327, 7600, 7129, 13, 713, 13, 1651, 4681, 651, 26, 2136, 1929, 282, 7809, 4340, 370, 3507, 4834, 267, 327, 26621, 402, 24983, 3992, 14, 221, 961, 365, 2997, 440, 2951, 367, 267, 327, 30640, 12, 1325, 2597, 367, 4713, 12, 8297, 12, 5423, 14, 221, 473, 271, 1183, 652, 1077, 506, 267, 327, 1777, 402, 2342, 63, 4608, 1252, 221, 2104, 3063, 12, 7508, 1233, 314, 7869, 781, 886, 440, 267, 327, 2934, 370, 17321, 14, 267, 340, 6036, 63, 533, 315, 334, 10720, 12, 20429 ]
[ 1898, 334, 35, 9, 10219, 13, 7280, 701, 314, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 18027, 1237, 14, 199, 3, 199, 3, 1664, 18027, 1237, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 18027, 1237, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 199, 3, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 199, 3, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 1664, 18027, 1237, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 5039, 2291, 367, 6036, 6661, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 363, 6577, 363, 275, 730, 199, 363, 452, 363, 275, 359, 272, 283, 8489, 297, 272, 283, 1412, 297, 272, 1622, 421, 199, 504, 20110, 14, 3266, 14, 4712, 492, 4911, 1692, 199, 199, 504, 6016, 1237, 14, 17419, 14, 1095, 492, 25384, 12, 20429, 279, 10720, 1563, 199, 504, 6016, 1237, 14, 888, 492, 1101, 199, 504, 6016, 1237, 14, 7436, 14, 4429, 492, 10967, 3310, 12, 473, 10720, 199, 504, 6016, 1237, 14, 16355, 14, 3112, 492, 2342, 63, 4608, 4388, 201, 199, 318, 2112, 8, 77, 513, 12, 1499, 12, 1499, 576, 12, 1343, 63, 4429, 534, 885, 13, 23980, 13, 4429, 735, 272, 408, 3498, 314, 1245, 4012, 282, 6036, 14, 339, 520, 635, 333, 513, 26, 314, 473, 13681, 316, 1296, 367, 642, 1245, 14, 272, 520, 635, 1499, 26, 710, 6430, 909, 14, 272, 520, 635, 1499, 576, 26, 710, 1245, 3341, 2600, 14, 272, 520, 635, 1343, 63, 4429, 26, 710, 536, 402, 314, 6036, 370, 1343, 314, 6661, 543, 14, 272, 408, 272, 327, 2494, 1536, 2005, 6719, 3250, 316, 14, 272, 6036, 63, 2340, 275, 942, 272, 1499, 576, 459, 2200, 63, 16595, 418, 275, 19745, 275, 942, 272, 1499, 576, 459, 2200, 63, 1292, 874, 418, 275, 3201, 874, 275, 942, 272, 327, 6668, 314, 6617, 6036, 436, 5386, 25012, 4012, 2399, 6220, 14, 272, 6036, 275, 1101, 14, 17419, 59, 928, 63, 4429, 61, 272, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 272, 327, 18175, 5133, 781, 9064, 13075, 314, 1284, 402, 1006, 6661, 30640, 14, 272, 1830, 6036, 26, 267, 327, 23989, 1806, 1006, 6220, 315, 314, 6036, 14, 221, 4226, 642, 9682, 282, 367, 13, 3813, 880, 267, 327, 781, 883, 12296, 282, 6036, 1159, 2142, 6122, 315, 10887, 13, 28807, 14, 221, 961, 5171, 267, 327, 314, 283, 271, 10808, 7, 2142, 1595, 14, 267, 862, 26, 288, 2142, 275, 2163, 8, 4429, 63, 1661, 9, 267, 871, 10852, 26, 288, 327, 961, 6036, 365, 31103, 14, 221, 13244, 314, 2061, 6036, 641, 314, 3464, 436, 288, 327, 1980, 25012, 4012, 652, 14, 221, 982, 2337, 1159, 6548, 3602, 641, 314, 288, 327, 6036, 3464, 2066, 781, 3984, 14793, 9158, 6661, 14, 288, 340, 822, 8, 4429, 63, 2340, 9, 508, 378, 26, 355, 372, 288, 6036, 12, 6036, 63, 1661, 275, 6036, 63, 2340, 14, 1935, 342, 288, 1980, 267, 340, 2142, 14, 2200, 14, 1074, 8, 77, 513, 12, 1499, 12, 1499, 576, 304, 288, 340, 2142, 14, 2200, 14, 3059, 26, 355, 19745, 14, 740, 8, 1073, 14, 2200, 14, 354, 9, 288, 327, 710, 2332, 7838, 880, 1255, 2399, 1595, 14, 288, 340, 2142, 14, 1287, 365, 10967, 3310, 14, 11126, 26, 355, 6036, 275, 2142, 14, 4429, 355, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 355, 1980, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 271, 10808, 26, 355, 327, 22643, 314, 1453, 6036, 880, 626, 781, 883, 372, 370, 652, 1380, 355, 327, 314, 2163, 6036, 365, 9158, 14, 355, 6036, 63, 2340, 14, 740, 1332, 4429, 12, 6036, 63, 1661, 430, 355, 6036, 275, 2142, 14, 4429, 355, 6036, 63, 1661, 275, 6036, 14, 362, 63, 4614, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 355, 1980, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 2379, 26, 355, 327, 8015, 1006, 6661, 14, 355, 372, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 11610, 26, 355, 327, 13870, 2112, 314, 2163, 2142, 315, 314, 6036, 14, 355, 986, 288, 916, 2142, 14, 1287, 365, 10967, 3310, 14, 1065, 26, 355, 2142, 14, 1593, 8, 77, 513, 12, 1499, 12, 1499, 576, 9, 288, 587, 26, 355, 746, 9070, 8, 490, 283, 5725, 2142, 1595, 26, 469, 16, 5285, 908, 8, 1073, 14, 1287, 430, 267, 587, 26, 288, 327, 710, 2332, 8103, 440, 1336, 27, 4215, 9995, 14, 288, 340, 2142, 14, 2200, 14, 3059, 26, 355, 3201, 874, 14, 740, 8, 1073, 14, 2200, 14, 354, 9, 4388, 201, 199, 318, 8265, 837, 272, 408, 1084, 1536, 30640, 12, 3865, 6137, 13, 262, 436, 687, 314, 3050, 1041, 272, 367, 6036, 63, 533, 315, 2342, 63, 4608, 360, 1198, 1237, 14, 17419, 297, 473, 10720, 304, 267, 327, 7600, 7129, 13, 713, 13, 1651, 4681, 651, 26, 2136, 1929, 282, 7809, 4340, 370, 3507, 4834, 267, 327, 26621, 402, 24983, 3992, 14, 221, 961, 365, 2997, 440, 2951, 367, 267, 327, 30640, 12, 1325, 2597, 367, 4713, 12, 8297, 12, 5423, 14, 221, 473, 271, 1183, 652, 1077, 506, 267, 327, 1777, 402, 2342, 63, 4608, 1252, 221, 2104, 3063, 12, 7508, 1233, 314, 7869, 781, 886, 440, 267, 327, 2934, 370, 17321, 14, 267, 340, 6036, 63, 533, 315, 334, 10720, 12, 20429, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
183amir/workrave
common/bin/create_locale.py
9
1580
# LoclaeInfo.py (c) 2006 Canonical, released under the GPL # # a helper class to get locale info import string import re import subprocess import gettext from gettext import gettext as _ from xml.etree.ElementTree import ElementTree languages = {} countries = {} et = ElementTree(file = "/usr/share/xml/iso-codes/iso_639.xml") it = et.getiterator('iso_639_entry') for elm in it: lang = elm.attrib["name"] if elm.attrib.has_key("iso_639_1_code"): code = elm.attrib["iso_639_1_code"] else: code = elm.attrib["iso_639_2T_code"] languages[code] = lang et = ElementTree(file="/usr/share/xml/iso-codes/iso_3166.xml") it = et.getiterator('iso_3166_entry') for elm in it: if elm.attrib.has_key("common_name"): descr = elm.attrib["common_name"] else: descr = elm.attrib["name"] if elm.attrib.has_key("alpha_2_code"): code = elm.attrib["alpha_2_code"] else: code = elm.attrib["alpha_3_code"] countries[code] = descr print "struct language_t" print "{" print " const char *code;" print " const char *lang;" print "} languages []= " print "{" keys = languages.keys() keys.sort(); for k in keys: txt = "{ \"%s\", \"%s\" }," % (k, languages[k]) print txt.encode('utf-8') print "};" print print "struct country_t" print "{" print " const char *code;" print " const char *country;" print "} countries []= " print "{" keys = countries.keys() keys.sort(); for k in keys: txt = "{ \"%s\", \"%s\" }," % (k, countries[k]) print txt.encode('utf-8') print "};"
gpl-3.0
[ 3, 6263, 416, 69, 2354, 14, 647, 334, 67, 9, 8315, 6855, 7174, 12, 14286, 1334, 314, 14629, 199, 3, 199, 3, 282, 5922, 1021, 370, 664, 5867, 2256, 199, 199, 646, 1059, 199, 646, 295, 3777, 199, 646, 3873, 199, 646, 9796, 199, 199, 504, 9796, 492, 9796, 465, 485, 199, 504, 2748, 14, 9464, 14, 15325, 492, 13139, 199, 199, 13209, 275, 1052, 199, 23598, 275, 1052, 199, 199, 386, 275, 13139, 8, 493, 275, 3286, 2647, 15, 6251, 15, 1652, 15, 4595, 13, 6021, 15, 4595, 63, 26723, 14, 1652, 531, 199, 390, 275, 10844, 14, 303, 280, 351, 707, 360, 4595, 63, 26723, 63, 2373, 358, 199, 509, 579, 77, 315, 652, 26, 272, 6339, 275, 579, 77, 14, 6640, 905, 354, 937, 272, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 4595, 63, 26723, 63, 17, 63, 600, 2349, 267, 1233, 275, 579, 77, 14, 6640, 905, 4595, 63, 26723, 63, 17, 63, 600, 937, 272, 587, 26, 267, 1233, 275, 579, 77, 14, 6640, 905, 4595, 63, 26723, 63, 18, 52, 63, 600, 937, 339, 10815, 59, 600, 61, 275, 6339, 199, 199, 386, 275, 13139, 8, 493, 9555, 2647, 15, 6251, 15, 1652, 15, 4595, 13, 6021, 15, 4595, 63, 19, 10642, 14, 1652, 531, 199, 390, 275, 10844, 14, 303, 280, 351, 707, 360, 4595, 63, 19, 10642, 63, 2373, 358, 199, 509, 579, 77, 315, 652, 26, 272, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 2330, 63, 354, 2349, 267, 16193, 275, 579, 77, 14, 6640, 905, 2330, 63, 354, 937, 272, 587, 26, 267, 16193, 275, 579, 77, 14, 6640, 905, 354, 937, 339, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 4468, 63, 18, 63, 600, 2349, 267, 1233, 275, 579, 77, 14, 6640, 905, 4468, 63, 18, 63, 600, 937, 272, 587, 26, 267, 1233, 275, 579, 77, 14, 6640, 905, 4468, 63, 19, 63, 600, 937, 339, 26013, 59, 600, 61, 275, 16193, 199, 199, 1361, 298, 1820, 2637, 63, 84, 2, 199, 1361, 5310, 2, 199, 1361, 298, 257, 950, 1495, 627, 600, 9426, 199, 1361, 298, 257, 950, 1495, 627, 4159, 9426, 199, 1361, 298, 93, 10815, 942, 29, 298, 199, 1361, 5310, 2, 199, 199, 1612, 275, 10815, 14, 1612, 342, 199, 1612, 14, 3191, 7303, 199, 199, 509, 1022, 315, 2883, 26, 272, 9444, 275, 5310, 18321, 83, 20756, 18321, 83, 4451, 1660, 2, 450, 334, 75, 12, 10815, 59, 75, 566, 272, 870, 9444, 14, 2143, 360, 1624, 13, 24, 358, 199, 199, 1361, 298, 93, 9426, 199, 1361, 199, 199, 1361, 298, 1820, 9023, 63, 84, 2, 199, 1361, 5310, 2, 199, 1361, 298, 257, 950, 1495, 627, 600, 9426, 199, 1361, 298, 257, 950, 1495, 627, 6063, 9426, 199, 1361, 298, 93, 26013, 942, 29, 298, 199, 1361, 5310, 2, 421, 199, 1612, 275, 26013, 14, 1612, 342, 199, 1612, 14, 3191, 7303, 199, 199, 509, 1022, 315, 2883, 26, 272, 9444, 275, 5310, 18321, 83, 20756, 18321, 83, 4451, 1660, 2, 450, 334, 75, 12, 26013, 59, 75, 566, 272, 870, 9444, 14, 2143, 360, 1624, 13, 24, 358, 10813, 199, 1361, 298, 93, 9426, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6263, 416, 69, 2354, 14, 647, 334, 67, 9, 8315, 6855, 7174, 12, 14286, 1334, 314, 14629, 199, 3, 199, 3, 282, 5922, 1021, 370, 664, 5867, 2256, 199, 199, 646, 1059, 199, 646, 295, 3777, 199, 646, 3873, 199, 646, 9796, 199, 199, 504, 9796, 492, 9796, 465, 485, 199, 504, 2748, 14, 9464, 14, 15325, 492, 13139, 199, 199, 13209, 275, 1052, 199, 23598, 275, 1052, 199, 199, 386, 275, 13139, 8, 493, 275, 3286, 2647, 15, 6251, 15, 1652, 15, 4595, 13, 6021, 15, 4595, 63, 26723, 14, 1652, 531, 199, 390, 275, 10844, 14, 303, 280, 351, 707, 360, 4595, 63, 26723, 63, 2373, 358, 199, 509, 579, 77, 315, 652, 26, 272, 6339, 275, 579, 77, 14, 6640, 905, 354, 937, 272, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 4595, 63, 26723, 63, 17, 63, 600, 2349, 267, 1233, 275, 579, 77, 14, 6640, 905, 4595, 63, 26723, 63, 17, 63, 600, 937, 272, 587, 26, 267, 1233, 275, 579, 77, 14, 6640, 905, 4595, 63, 26723, 63, 18, 52, 63, 600, 937, 339, 10815, 59, 600, 61, 275, 6339, 199, 199, 386, 275, 13139, 8, 493, 9555, 2647, 15, 6251, 15, 1652, 15, 4595, 13, 6021, 15, 4595, 63, 19, 10642, 14, 1652, 531, 199, 390, 275, 10844, 14, 303, 280, 351, 707, 360, 4595, 63, 19, 10642, 63, 2373, 358, 199, 509, 579, 77, 315, 652, 26, 272, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 2330, 63, 354, 2349, 267, 16193, 275, 579, 77, 14, 6640, 905, 2330, 63, 354, 937, 272, 587, 26, 267, 16193, 275, 579, 77, 14, 6640, 905, 354, 937, 339, 340, 579, 77, 14, 6640, 14, 1989, 63, 498, 480, 4468, 63, 18, 63, 600, 2349, 267, 1233, 275, 579, 77, 14, 6640, 905, 4468, 63, 18, 63, 600, 937, 272, 587, 26, 267, 1233, 275, 579, 77, 14, 6640, 905, 4468, 63, 19, 63, 600, 937, 339, 26013, 59, 600, 61, 275, 16193, 199, 199, 1361, 298, 1820, 2637, 63, 84, 2, 199, 1361, 5310, 2, 199, 1361, 298, 257, 950, 1495, 627, 600, 9426, 199, 1361, 298, 257, 950, 1495, 627, 4159, 9426, 199, 1361, 298, 93, 10815, 942, 29, 298, 199, 1361, 5310, 2, 199, 199, 1612, 275, 10815, 14, 1612, 342, 199, 1612, 14, 3191, 7303, 199, 199, 509, 1022, 315, 2883, 26, 272, 9444, 275, 5310, 18321, 83, 20756, 18321, 83, 4451, 1660, 2, 450, 334, 75, 12, 10815, 59, 75, 566, 272, 870, 9444, 14, 2143, 360, 1624, 13, 24, 358, 199, 199, 1361, 298, 93, 9426, 199, 1361, 199, 199, 1361, 298, 1820, 9023, 63, 84, 2, 199, 1361, 5310, 2, 199, 1361, 298, 257, 950, 1495, 627, 600, 9426, 199, 1361, 298, 257, 950, 1495, 627, 6063, 9426, 199, 1361, 298, 93, 26013, 942, 29, 298, 199, 1361, 5310, 2, 421, 199, 1612, 275, 26013, 14, 1612, 342, 199, 1612, 14, 3191, 7303, 199, 199, 509, 1022, 315, 2883, 26, 272, 9444, 275, 5310, 18321, 83, 20756, 18321, 83, 4451, 1660, 2, 450, 334, 75, 12, 26013, 59, 75, 566, 272, 870, 9444, 14, 2143, 360, 1624, 13, 24, 358, 10813, 199, 1361, 298, 93, 9426, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
mprat/learningjulia
nbconvert_config.py
1
7416
from nbconvert.preprocessors import ExecutePreprocessor, Preprocessor import numpy as np def jekyllurl(path): """ Take the filepath of an image output by the ExportOutputProcessor and convert it into a URL we can use with Jekyll """ return path.replace("../..", "") def svg_filter(svg_xml): """ Remove the DOCTYPE and XML version lines from the inline XML SVG """ svgstr = "".join(svg_xml) start_index = svgstr.index("<svg") end_index = svgstr.index("</svg>") return svgstr[start_index:end_index + 6] def var_def_to_var_list(var_def): if 'linspace' in var_def: v = var_def.replace("linspace(", "") v = v.replace(")", "") start, stop, num = v.split(",") return np.linspace( float(start.strip()), float(stop.strip()), float(num.strip())) elif '[' in var_def and ']' in var_def: v = var_def.replace("[", "") v = v.replace("]", "") v = v.split(",") return [x.strip() for x in v] else: raise TypeError("not implemented for {}".format(var_def)) class ExecuteWithInteractPreprocessor(ExecutePreprocessor): def preprocess_cell(self, cell, resources, cell_index): if cell.cell_type != 'code': return cell, resources if "@manipulate" in cell.source: original_source = cell.source cell_manipulate = cell.copy() cell_source = original_source.split("\n") cell_manipulate.source = "\n".join([cell_source[0], cell_source[-1]]) manipulate_output = self.run_cell(cell_manipulate) outs = [] outs.extend(manipulate_output) main_source = "\n".join(cell_source[1:-1]) var_def = cell_source[0].replace("@manipulate", "") var_def = var_def.replace("for", "").strip().split("=") var_name, var_list = var_def # currently this only works for a single for loop # turn all the variables into a loop all_vars = var_def_to_var_list(var_list) for next_var in all_vars: var_defs = "{}={}".format(var_name, next_var) cell_copy = cell.copy() cell_copy.source = "\n".join([var_defs, main_source.strip()]) outputs = self.run_cell(cell_copy) outs.extend(outputs) cell.source = original_source cell.outputs = outs # fix the outputs # probably better done at the postprocessing step # import ipdb; ipdb.set_trace() # raise TypeError("stopping") else: outputs = self.run_cell(cell) cell.outputs = outputs return cell, resources # if 'Interact' in cell.outputs[0]['data']['text/plain']: # there should be a widget here class RemoveInteractJsShimPreprocessor(Preprocessor): def preprocess(self, nb, resources): """ make sure the widgets resources get put into the resources """ if 'widgets' in nb['metadata'].keys(): resources['metadata']['widgets'] = nb['metadata']['widgets'] return super(RemoveInteractJsShimPreprocessor, self).preprocess(nb, resources) def preprocess_cell(self, cell, resources, cell_index): """ remove any outputs that have interact-js-shim """ if 'outputs' in cell: outputs = cell['outputs'] new_outputs = [] for output in outputs: new_output = output.copy() if "data" in output.keys(): data_output = output["data"] new_data_output = data_output.copy() if 'text/html' in data_output.keys(): text_html = data_output['text/html'] if text_html.startswith('<div id=\"interact-js-shim\">'): start_index = text_html.find('<div id=\"interact-js-shim\">') end_index = text_html.find('</div>') new_html = "" if start_index > 0: new_html += text_html[0:start_index] if end_index + 6 < len(text_html): new_html += text_html[end_index+6:] new_html = new_html.strip() if len(new_html) > 0: new_data_output['text/html'] = new_html else: del new_data_output['text/html'] else: new_data_output['text/html'] = text_html if len(new_data_output.keys()) > 0: new_output['data'] = new_data_output else: del new_output['data'] if 'data' in new_output: new_outputs.append(new_output) else: new_outputs.append(new_output) cell['outputs'] = new_outputs return cell, resources class InsertWidgetsPreprocessor(Preprocessor): def preprocess_cell(self, cell, resources, cell_index): """ if the cell is a cell with @manipulate, add the appropriate widget script into the output """ if cell.cell_type != 'code': return cell, resources if "@manipulate" in cell.source: widget_state = resources['metadata']['widgets']['application/vnd.jupyter.widget-state+json']['state'] interact_options = cell.outputs[0]['data']['text/plain'] start_index = interact_options.find('"') model_name = interact_options[start_index + 1:] next_index = model_name.find('"') model_name = model_name[:next_index] # match the widget based on the descriptions matched_model_id = None for model_id in widget_state.keys(): if widget_state[model_id]['state']['description'] == model_name: matched_model_id = model_id break # construct the script tag script_tag = '<script type="application/vnd.jupyter.widget-view+json">{"model_id": "' + matched_model_id + '"}</script>' cell.outputs[0]['data']['text/html'] = script_tag return cell, resources c = get_config() c.NbConvertApp.export_format = 'html' c.NbConvertApp.output_files_dir = '../../assets/imgs/{notebook_name}' c.HTMLExporter.preprocessors = [ 'nbconvert.preprocessors.ExecutePreprocessor', # ExecuteWithInteractPreprocessor, 'nbconvert.preprocessors.coalesce_streams', 'nbconvert.preprocessors.ExtractOutputPreprocessor', RemoveInteractJsShimPreprocessor, InsertWidgetsPreprocessor] c.HTMLExporter.template_file = 'notebooks/jekyll.tpl' c.HTMLExporter.filters = {"jekyllimgurl": jekyllurl, "svg_filter": svg_filter} # if there's an error in one of the cells let the execution keep going c.ExecutePreprocessor.allow_errors = True # disable the timeout c.ExecutePreprocessor.timeout = -1 c.ExecutePreprocessor.iopub_timeout = 10 # write the final HTML files into the _include/notebooks directory c.FilesWriter.build_directory = "_includes/notebooks/"
mit
[ 504, 8526, 3916, 14, 657, 10547, 492, 17009, 16482, 12, 5543, 6459, 199, 646, 2680, 465, 980, 421, 199, 318, 1335, 5711, 89, 914, 633, 8, 515, 304, 272, 408, 272, 18146, 314, 9911, 402, 376, 1834, 1072, 701, 314, 20220, 2959, 10438, 272, 436, 3957, 652, 1901, 282, 2851, 781, 883, 675, 543, 1603, 5711, 89, 914, 272, 408, 272, 372, 931, 14, 1814, 480, 5093, 703, 401, 6899, 421, 199, 318, 21218, 63, 1541, 8, 10273, 63, 1652, 304, 272, 408, 272, 5852, 314, 3506, 7540, 436, 4692, 1015, 2385, 687, 272, 314, 8308, 4692, 32062, 272, 408, 272, 21218, 495, 275, 10587, 904, 8, 10273, 63, 1652, 9, 272, 1343, 63, 1080, 275, 21218, 495, 14, 1080, 6757, 10273, 531, 272, 1284, 63, 1080, 275, 21218, 495, 14, 1080, 23790, 10273, 9579, 272, 372, 21218, 495, 59, 928, 63, 1080, 26, 500, 63, 1080, 435, 1227, 61, 421, 199, 318, 2729, 63, 318, 63, 475, 63, 1391, 63, 513, 8, 1391, 63, 318, 304, 272, 340, 283, 11649, 7, 315, 2729, 63, 318, 26, 267, 373, 275, 2729, 63, 318, 14, 1814, 480, 11649, 11854, 6899, 267, 373, 275, 373, 14, 1814, 480, 4186, 6899, 267, 1343, 12, 3631, 12, 1967, 275, 373, 14, 1294, 20324, 267, 372, 980, 14, 11649, 8, 288, 2069, 8, 928, 14, 1913, 4000, 288, 2069, 8, 2379, 14, 1913, 4000, 288, 2069, 8, 1507, 14, 1913, 4059, 272, 916, 22640, 315, 2729, 63, 318, 436, 24840, 315, 2729, 63, 318, 26, 267, 373, 275, 2729, 63, 318, 14, 1814, 10994, 401, 6899, 267, 373, 275, 373, 14, 1814, 480, 11472, 6899, 267, 373, 275, 373, 14, 1294, 20324, 267, 372, 359, 88, 14, 1913, 342, 367, 671, 315, 373, 61, 272, 587, 26, 267, 746, 3146, 480, 1397, 6366, 367, 8352, 908, 8, 1391, 63, 318, 430, 421, 199, 533, 17009, 3007, 8309, 1957, 16482, 8, 12049, 16482, 304, 272, 347, 23351, 63, 3890, 8, 277, 12, 4917, 12, 5944, 12, 4917, 63, 1080, 304, 267, 340, 4917, 14, 3890, 63, 466, 1137, 283, 600, 356, 288, 372, 4917, 12, 5944, 398, 340, 9244, 29798, 5434, 2, 315, 4917, 14, 1365, 26, 288, 3379, 63, 1365, 275, 4917, 14, 1365, 953, 4917, 63, 29798, 5434, 275, 4917, 14, 1574, 342, 288, 4917, 63, 1365, 275, 3379, 63, 1365, 14, 1294, 4582, 78, 531, 288, 4917, 63, 29798, 5434, 14, 1365, 275, 1867, 78, 1674, 904, 779, 3890, 63, 1365, 59, 16, 467, 4917, 63, 1365, 1988, 17, 3934, 288, 27232, 63, 1199, 275, 291, 14, 1065, 63, 3890, 8, 3890, 63, 29798, 5434, 9, 288, 31557, 275, 942, 288, 31557, 14, 2880, 8, 29798, 5434, 63, 1199, 9, 953, 2446, 63, 1365, 275, 1867, 78, 1674, 904, 8, 3890, 63, 1365, 59, 17, 6809, 17, 566, 288, 2729, 63, 318, 275, 4917, 63, 1365, 59, 16, 1055, 1814, 25915, 29798, 5434, 401, 6899, 288, 2729, 63, 318, 275, 2729, 63, 318, 14, 1814, 480, 509, 401, 25354, 1913, 1252, 1294, 480, 23758, 288, 2729, 63, 354, 12, 2729, 63, 513, 275, 2729, 63, 318, 288, 327, 5544, 642, 1454, 5419, 367, 282, 2849, 367, 4438, 288, 327, 7485, 1006, 314, 2860, 1901, 282, 4438, 288, 1006, 63, 2936, 275, 2729, 63, 318, 63, 475, 63, 1391, 63, 513, 8, 1391, 63, 513, 9, 288, 367, 2163, 63, 1391, 315, 1006, 63, 2936, 26, 355, 2729, 63, 8710, 275, 11491, 7622, 1674, 908, 8, 1391, 63, 354, 12, 2163, 63, 1391, 9, 355, 4917, 63, 1574, 275, 4917, 14, 1574, 342, 355, 4917, 63, 1574, 14, 1365, 275, 1867, 78, 1674, 904, 779, 1391, 63, 8710, 12, 2446, 63, 1365, 14, 1913, 9383, 355, 4704, 275, 291, 14, 1065, 63, 3890, 8, 3890, 63, 1574, 9, 355, 31557, 14, 2880, 8, 4467, 9, 953, 4917, 14, 1365, 275, 3379, 63, 1365, 288, 4917, 14, 4467, 275, 31557, 953, 327, 5325, 314, 4704, 288, 327, 8646, 8034, 4224, 737, 314, 2963, 6338, 3650, 288, 327, 492, 3384, 697, 27, 3384, 697, 14, 409, 63, 3446, 342, 288, 327, 746, 3146, 480, 2379, 4073, 531, 267, 587, 26, 288, 4704, 275, 291, 14, 1065, 63, 3890, 8, 3890, 9, 288, 4917, 14, 4467, 275, 4704, 398, 372, 4917, 12, 5944, 953, 327, 340, 283, 8309, 1957, 7, 315, 4917, 14, 4467, 59, 16, 2733, 576, 2545, 505, 15, 6104, 2565, 355, 327, 2337, 1077, 506, 282, 3938, 2348, 421, 199, 533, 5852, 8309, 1957, 16633, 2662, 1017, 16482, 8, 16482, 304, 272, 347, 23351, 8, 277, 12, 8526, 12, 5944, 304, 267, 408, 267, 1852, 3238, 314, 11114, 5944, 664, 5324, 1901, 314, 5944, 267, 408, 267, 340, 283, 8583, 7, 315, 8526, 459, 2343, 2278, 1612, 837, 288, 5944, 459, 2343, 2545, 8583, 418, 275, 8526, 459, 2343, 2545, 8583, 418, 267, 372, 1613, 8, 5587, 8309, 1957, 16633, 2662, 1017, 16482, 12, 291, 680, 17677, 8, 4994, 12, 5944, 9, 339, 347, 23351, 63, 3890, 8, 277, 12, 4917, 12, 5944, 12, 4917, 63, 1080, 304, 267, 408, 267, 2813, 1263, 4704, 626, 1172, 17232, 13, 3596, 13, 28238, 267, 408, 267, 340, 283, 4467, 7, 315, 4917, 26, 288, 4704, 275, 4917, 459, 4467, 418, 288, 892, 63, 4467, 275, 942, 288, 367, 1072, 315, 4704, 26, 355, 892, 63, 1199, 275, 1072, 14, 1574, 342, 355, 340, 298, 576, 2, 315, 1072, 14, 1612, 837, 490, 666, 63, 1199, 275, 1072, 905, 576, 937, 490, 892, 63, 576, 63, 1199, 275, 666, 63, 1199, 14, 1574, 342, 490, 340, 283, 505, 15, 1360, 7, 315, 666, 63, 1199, 14, 1612, 837, 717, 1318, 63, 1360, 275, 666, 63, 1199, 459, 505, 15, 1360, 418, 717, 340, 1318, 63, 1360, 14, 2460, 4827, 3015, 1305, 8178, 25850, 13, 3596, 13, 28238, 60, 1743, 735, 1169, 1343, 63, 1080, 275, 1318, 63, 1360, 14, 1623, 4827, 3015, 1305, 8178, 25850, 13, 3596, 13, 28238, 60, 1743, 358, 1169, 1284, 63, 1080, 275, 1318, 63, 1360, 14, 1623, 14264, 3015, 5971, 1169, 892, 63, 1360, 275, 3087, 1169, 340, 1343, 63, 1080, 690, 378, 26, 1816, 892, 63, 1360, 847, 1318, 63, 1360, 59, 16, 26, 928 ]
[ 8526, 3916, 14, 657, 10547, 492, 17009, 16482, 12, 5543, 6459, 199, 646, 2680, 465, 980, 421, 199, 318, 1335, 5711, 89, 914, 633, 8, 515, 304, 272, 408, 272, 18146, 314, 9911, 402, 376, 1834, 1072, 701, 314, 20220, 2959, 10438, 272, 436, 3957, 652, 1901, 282, 2851, 781, 883, 675, 543, 1603, 5711, 89, 914, 272, 408, 272, 372, 931, 14, 1814, 480, 5093, 703, 401, 6899, 421, 199, 318, 21218, 63, 1541, 8, 10273, 63, 1652, 304, 272, 408, 272, 5852, 314, 3506, 7540, 436, 4692, 1015, 2385, 687, 272, 314, 8308, 4692, 32062, 272, 408, 272, 21218, 495, 275, 10587, 904, 8, 10273, 63, 1652, 9, 272, 1343, 63, 1080, 275, 21218, 495, 14, 1080, 6757, 10273, 531, 272, 1284, 63, 1080, 275, 21218, 495, 14, 1080, 23790, 10273, 9579, 272, 372, 21218, 495, 59, 928, 63, 1080, 26, 500, 63, 1080, 435, 1227, 61, 421, 199, 318, 2729, 63, 318, 63, 475, 63, 1391, 63, 513, 8, 1391, 63, 318, 304, 272, 340, 283, 11649, 7, 315, 2729, 63, 318, 26, 267, 373, 275, 2729, 63, 318, 14, 1814, 480, 11649, 11854, 6899, 267, 373, 275, 373, 14, 1814, 480, 4186, 6899, 267, 1343, 12, 3631, 12, 1967, 275, 373, 14, 1294, 20324, 267, 372, 980, 14, 11649, 8, 288, 2069, 8, 928, 14, 1913, 4000, 288, 2069, 8, 2379, 14, 1913, 4000, 288, 2069, 8, 1507, 14, 1913, 4059, 272, 916, 22640, 315, 2729, 63, 318, 436, 24840, 315, 2729, 63, 318, 26, 267, 373, 275, 2729, 63, 318, 14, 1814, 10994, 401, 6899, 267, 373, 275, 373, 14, 1814, 480, 11472, 6899, 267, 373, 275, 373, 14, 1294, 20324, 267, 372, 359, 88, 14, 1913, 342, 367, 671, 315, 373, 61, 272, 587, 26, 267, 746, 3146, 480, 1397, 6366, 367, 8352, 908, 8, 1391, 63, 318, 430, 421, 199, 533, 17009, 3007, 8309, 1957, 16482, 8, 12049, 16482, 304, 272, 347, 23351, 63, 3890, 8, 277, 12, 4917, 12, 5944, 12, 4917, 63, 1080, 304, 267, 340, 4917, 14, 3890, 63, 466, 1137, 283, 600, 356, 288, 372, 4917, 12, 5944, 398, 340, 9244, 29798, 5434, 2, 315, 4917, 14, 1365, 26, 288, 3379, 63, 1365, 275, 4917, 14, 1365, 953, 4917, 63, 29798, 5434, 275, 4917, 14, 1574, 342, 288, 4917, 63, 1365, 275, 3379, 63, 1365, 14, 1294, 4582, 78, 531, 288, 4917, 63, 29798, 5434, 14, 1365, 275, 1867, 78, 1674, 904, 779, 3890, 63, 1365, 59, 16, 467, 4917, 63, 1365, 1988, 17, 3934, 288, 27232, 63, 1199, 275, 291, 14, 1065, 63, 3890, 8, 3890, 63, 29798, 5434, 9, 288, 31557, 275, 942, 288, 31557, 14, 2880, 8, 29798, 5434, 63, 1199, 9, 953, 2446, 63, 1365, 275, 1867, 78, 1674, 904, 8, 3890, 63, 1365, 59, 17, 6809, 17, 566, 288, 2729, 63, 318, 275, 4917, 63, 1365, 59, 16, 1055, 1814, 25915, 29798, 5434, 401, 6899, 288, 2729, 63, 318, 275, 2729, 63, 318, 14, 1814, 480, 509, 401, 25354, 1913, 1252, 1294, 480, 23758, 288, 2729, 63, 354, 12, 2729, 63, 513, 275, 2729, 63, 318, 288, 327, 5544, 642, 1454, 5419, 367, 282, 2849, 367, 4438, 288, 327, 7485, 1006, 314, 2860, 1901, 282, 4438, 288, 1006, 63, 2936, 275, 2729, 63, 318, 63, 475, 63, 1391, 63, 513, 8, 1391, 63, 513, 9, 288, 367, 2163, 63, 1391, 315, 1006, 63, 2936, 26, 355, 2729, 63, 8710, 275, 11491, 7622, 1674, 908, 8, 1391, 63, 354, 12, 2163, 63, 1391, 9, 355, 4917, 63, 1574, 275, 4917, 14, 1574, 342, 355, 4917, 63, 1574, 14, 1365, 275, 1867, 78, 1674, 904, 779, 1391, 63, 8710, 12, 2446, 63, 1365, 14, 1913, 9383, 355, 4704, 275, 291, 14, 1065, 63, 3890, 8, 3890, 63, 1574, 9, 355, 31557, 14, 2880, 8, 4467, 9, 953, 4917, 14, 1365, 275, 3379, 63, 1365, 288, 4917, 14, 4467, 275, 31557, 953, 327, 5325, 314, 4704, 288, 327, 8646, 8034, 4224, 737, 314, 2963, 6338, 3650, 288, 327, 492, 3384, 697, 27, 3384, 697, 14, 409, 63, 3446, 342, 288, 327, 746, 3146, 480, 2379, 4073, 531, 267, 587, 26, 288, 4704, 275, 291, 14, 1065, 63, 3890, 8, 3890, 9, 288, 4917, 14, 4467, 275, 4704, 398, 372, 4917, 12, 5944, 953, 327, 340, 283, 8309, 1957, 7, 315, 4917, 14, 4467, 59, 16, 2733, 576, 2545, 505, 15, 6104, 2565, 355, 327, 2337, 1077, 506, 282, 3938, 2348, 421, 199, 533, 5852, 8309, 1957, 16633, 2662, 1017, 16482, 8, 16482, 304, 272, 347, 23351, 8, 277, 12, 8526, 12, 5944, 304, 267, 408, 267, 1852, 3238, 314, 11114, 5944, 664, 5324, 1901, 314, 5944, 267, 408, 267, 340, 283, 8583, 7, 315, 8526, 459, 2343, 2278, 1612, 837, 288, 5944, 459, 2343, 2545, 8583, 418, 275, 8526, 459, 2343, 2545, 8583, 418, 267, 372, 1613, 8, 5587, 8309, 1957, 16633, 2662, 1017, 16482, 12, 291, 680, 17677, 8, 4994, 12, 5944, 9, 339, 347, 23351, 63, 3890, 8, 277, 12, 4917, 12, 5944, 12, 4917, 63, 1080, 304, 267, 408, 267, 2813, 1263, 4704, 626, 1172, 17232, 13, 3596, 13, 28238, 267, 408, 267, 340, 283, 4467, 7, 315, 4917, 26, 288, 4704, 275, 4917, 459, 4467, 418, 288, 892, 63, 4467, 275, 942, 288, 367, 1072, 315, 4704, 26, 355, 892, 63, 1199, 275, 1072, 14, 1574, 342, 355, 340, 298, 576, 2, 315, 1072, 14, 1612, 837, 490, 666, 63, 1199, 275, 1072, 905, 576, 937, 490, 892, 63, 576, 63, 1199, 275, 666, 63, 1199, 14, 1574, 342, 490, 340, 283, 505, 15, 1360, 7, 315, 666, 63, 1199, 14, 1612, 837, 717, 1318, 63, 1360, 275, 666, 63, 1199, 459, 505, 15, 1360, 418, 717, 340, 1318, 63, 1360, 14, 2460, 4827, 3015, 1305, 8178, 25850, 13, 3596, 13, 28238, 60, 1743, 735, 1169, 1343, 63, 1080, 275, 1318, 63, 1360, 14, 1623, 4827, 3015, 1305, 8178, 25850, 13, 3596, 13, 28238, 60, 1743, 358, 1169, 1284, 63, 1080, 275, 1318, 63, 1360, 14, 1623, 14264, 3015, 5971, 1169, 892, 63, 1360, 275, 3087, 1169, 340, 1343, 63, 1080, 690, 378, 26, 1816, 892, 63, 1360, 847, 1318, 63, 1360, 59, 16, 26, 928, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Peerunity/Peerunity
contrib/pyminer/pyminer.py
1257
6438
#!/usr/bin/python # # Copyright (c) 2011 The Bitcoin developers # Distributed under the MIT/X11 software license, see the accompanying # file license.txt or http://www.opensource.org/licenses/mit-license.php. # import time import json import pprint import hashlib import struct import re import base64 import httplib import sys from multiprocessing import Process ERR_SLEEP = 15 MAX_NONCE = 1000000L settings = {} pp = pprint.PrettyPrinter(indent=4) class BitcoinRPC: OBJID = 1 def __init__(self, host, port, username, password): authpair = "%s:%s" % (username, password) self.authhdr = "Basic %s" % (base64.b64encode(authpair)) self.conn = httplib.HTTPConnection(host, port, False, 30) def rpc(self, method, params=None): self.OBJID += 1 obj = { 'version' : '1.1', 'method' : method, 'id' : self.OBJID } if params is None: obj['params'] = [] else: obj['params'] = params self.conn.request('POST', '/', json.dumps(obj), { 'Authorization' : self.authhdr, 'Content-type' : 'application/json' }) resp = self.conn.getresponse() if resp is None: print "JSON-RPC: no response" return None body = resp.read() resp_obj = json.loads(body) if resp_obj is None: print "JSON-RPC: cannot JSON-decode body" return None if 'error' in resp_obj and resp_obj['error'] != None: return resp_obj['error'] if 'result' not in resp_obj: print "JSON-RPC: no result in object" return None return resp_obj['result'] def getblockcount(self): return self.rpc('getblockcount') def getwork(self, data=None): return self.rpc('getwork', data) def uint32(x): return x & 0xffffffffL def bytereverse(x): return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) | (((x) >> 8) & 0x0000ff00) | ((x) >> 24) )) def bufreverse(in_buf): out_words = [] for i in range(0, len(in_buf), 4): word = struct.unpack('@I', in_buf[i:i+4])[0] out_words.append(struct.pack('@I', bytereverse(word))) return ''.join(out_words) def wordreverse(in_buf): out_words = [] for i in range(0, len(in_buf), 4): out_words.append(in_buf[i:i+4]) out_words.reverse() return ''.join(out_words) class Miner: def __init__(self, id): self.id = id self.max_nonce = MAX_NONCE def work(self, datastr, targetstr): # decode work data hex string to binary static_data = datastr.decode('hex') static_data = bufreverse(static_data) # the first 76b of 80b do not change blk_hdr = static_data[:76] # decode 256-bit target value targetbin = targetstr.decode('hex') targetbin = targetbin[::-1] # byte-swap and dword-swap targetbin_str = targetbin.encode('hex') target = long(targetbin_str, 16) # pre-hash first 76b of block header static_hash = hashlib.sha256() static_hash.update(blk_hdr) for nonce in xrange(self.max_nonce): # encode 32-bit nonce value nonce_bin = struct.pack("<I", nonce) # hash final 4b, the nonce value hash1_o = static_hash.copy() hash1_o.update(nonce_bin) hash1 = hash1_o.digest() # sha256 hash of sha256 hash hash_o = hashlib.sha256() hash_o.update(hash1) hash = hash_o.digest() # quick test for winning solution: high 32 bits zero? if hash[-4:] != '\0\0\0\0': continue # convert binary hash to 256-bit Python long hash = bufreverse(hash) hash = wordreverse(hash) hash_str = hash.encode('hex') l = long(hash_str, 16) # proof-of-work test: hash < target if l < target: print time.asctime(), "PROOF-OF-WORK found: %064x" % (l,) return (nonce + 1, nonce_bin) else: print time.asctime(), "PROOF-OF-WORK false positive %064x" % (l,) # return (nonce + 1, nonce_bin) return (nonce + 1, None) def submit_work(self, rpc, original_data, nonce_bin): nonce_bin = bufreverse(nonce_bin) nonce = nonce_bin.encode('hex') solution = original_data[:152] + nonce + original_data[160:256] param_arr = [ solution ] result = rpc.getwork(param_arr) print time.asctime(), "--> Upstream RPC result:", result def iterate(self, rpc): work = rpc.getwork() if work is None: time.sleep(ERR_SLEEP) return if 'data' not in work or 'target' not in work: time.sleep(ERR_SLEEP) return time_start = time.time() (hashes_done, nonce_bin) = self.work(work['data'], work['target']) time_end = time.time() time_diff = time_end - time_start self.max_nonce = long( (hashes_done * settings['scantime']) / time_diff) if self.max_nonce > 0xfffffffaL: self.max_nonce = 0xfffffffaL if settings['hashmeter']: print "HashMeter(%d): %d hashes, %.2f Khash/sec" % ( self.id, hashes_done, (hashes_done / 1000.0) / time_diff) if nonce_bin is not None: self.submit_work(rpc, work['data'], nonce_bin) def loop(self): rpc = BitcoinRPC(settings['host'], settings['port'], settings['rpcuser'], settings['rpcpass']) if rpc is None: return while True: self.iterate(rpc) def miner_thread(id): miner = Miner(id) miner.loop() if __name__ == '__main__': if len(sys.argv) != 2: print "Usage: pyminer.py CONFIG-FILE" sys.exit(1) f = open(sys.argv[1]) for line in f: # skip comment lines m = re.search('^\s*#', line) if m: continue # parse key=value lines m = re.search('^(\w+)\s*=\s*(\S.*)$', line) if m is None: continue settings[m.group(1)] = m.group(2) f.close() if 'host' not in settings: settings['host'] = '127.0.0.1' if 'port' not in settings: settings['port'] = 8332 if 'threads' not in settings: settings['threads'] = 1 if 'hashmeter' not in settings: settings['hashmeter'] = 0 if 'scantime' not in settings: settings['scantime'] = 30L if 'rpcuser' not in settings or 'rpcpass' not in settings: print "Missing username and/or password in cfg file" sys.exit(1) settings['port'] = int(settings['port']) settings['threads'] = int(settings['threads']) settings['hashmeter'] = int(settings['hashmeter']) settings['scantime'] = long(settings['scantime']) thr_list = [] for thr_id in range(settings['threads']): p = Process(target=miner_thread, args=(thr_id,)) p.start() thr_list.append(p) time.sleep(1) # stagger threads print settings['threads'], "mining threads started" print time.asctime(), "Miner Starts - %s:%s" % (settings['host'], settings['port']) try: for thr_proc in thr_list: thr_proc.join() except KeyboardInterrupt: pass print time.asctime(), "Miner Stops - %s:%s" % (settings['host'], settings['port'])
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 710, 21158, 19782, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 4190, 14, 2424, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 3, 199, 199, 646, 900, 199, 646, 2022, 199, 646, 10933, 199, 646, 8337, 199, 646, 2702, 199, 646, 295, 199, 646, 1300, 772, 199, 646, 8809, 199, 646, 984, 199, 504, 12866, 492, 7132, 199, 199, 2666, 63, 51, 906, 6102, 275, 4114, 199, 4283, 63, 13887, 2089, 275, 19492, 44, 199, 199, 1751, 275, 1052, 199, 802, 275, 10933, 14, 27153, 14131, 8, 3724, 29, 20, 9, 199, 199, 533, 21158, 8171, 26, 199, 198, 15862, 998, 275, 413, 421, 198, 318, 636, 826, 721, 277, 12, 1591, 12, 1844, 12, 3434, 12, 2505, 304, 507, 198, 1178, 3852, 275, 2071, 83, 2689, 83, 2, 450, 334, 2473, 12, 2505, 9, 507, 198, 277, 14, 1178, 11244, 275, 298, 6845, 450, 83, 2, 450, 334, 1095, 772, 14, 66, 772, 2143, 8, 1178, 3852, 430, 507, 198, 277, 14, 1631, 275, 8809, 14, 19114, 8, 1102, 12, 1844, 12, 756, 12, 4233, 9, 199, 198, 318, 8985, 8, 277, 12, 1083, 12, 1862, 29, 403, 304, 507, 198, 277, 14, 15862, 998, 847, 413, 507, 198, 1113, 275, 469, 283, 1023, 7, 520, 283, 17, 14, 17, 297, 686, 198, 6704, 69, 594, 7, 520, 1083, 12, 686, 198, 7, 344, 7, 520, 291, 14, 15862, 998, 789, 507, 198, 692, 1862, 365, 488, 26, 686, 198, 1113, 459, 1162, 418, 275, 942, 507, 198, 2836, 26, 686, 198, 1113, 459, 1162, 418, 275, 1862, 507, 198, 277, 14, 1631, 14, 1069, 360, 4030, 297, 17220, 2022, 14, 4180, 8, 1113, 395, 686, 198, 91, 283, 11626, 7, 520, 291, 14, 1178, 11244, 12, 1585, 221, 283, 2714, 13, 466, 7, 520, 283, 3578, 15, 1001, 7, 3828, 2742, 198, 4518, 275, 291, 14, 1631, 14, 25006, 342, 507, 198, 692, 3085, 365, 488, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 949, 1177, 2, 686, 198, 1107, 488, 2742, 198, 2030, 275, 3085, 14, 739, 342, 507, 198, 4518, 63, 1113, 275, 2022, 14, 3640, 8, 2030, 9, 507, 198, 692, 3085, 63, 1113, 365, 488, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 3913, 4840, 13, 2708, 2396, 2, 686, 198, 1107, 488, 507, 198, 692, 283, 705, 7, 315, 3085, 63, 1113, 436, 3085, 63, 1113, 459, 705, 418, 1137, 488, 26, 686, 198, 1107, 3085, 63, 1113, 459, 705, 418, 507, 198, 692, 283, 1099, 7, 440, 315, 3085, 63, 1113, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 949, 754, 315, 909, 2, 686, 198, 1107, 488, 2742, 198, 1107, 3085, 63, 1113, 459, 1099, 418, 199, 198, 318, 664, 1457, 835, 8, 277, 304, 507, 198, 1107, 291, 14, 4354, 360, 30710, 358, 199, 198, 318, 664, 800, 8, 277, 12, 666, 29, 403, 304, 507, 198, 1107, 291, 14, 4354, 360, 362, 800, 297, 666, 9, 199, 199, 318, 3152, 708, 8, 88, 304, 199, 198, 1107, 671, 1253, 378, 21870, 44, 199, 199, 318, 3696, 4471, 8, 88, 304, 199, 198, 1107, 3152, 708, 1332, 3666, 88, 9, 5213, 5504, 9, 1204, 20337, 88, 9, 5213, 1695, 9, 1253, 378, 88, 383, 556, 993, 9, 1204, 686, 198, 12925, 88, 9, 4331, 1695, 9, 1253, 378, 88, 993, 556, 383, 9, 1204, 3666, 88, 9, 4331, 5504, 9, 5082, 199, 199, 318, 4123, 4471, 8, 262, 63, 1436, 304, 199, 198, 548, 63, 3148, 275, 942, 199, 198, 509, 284, 315, 1425, 8, 16, 12, 822, 8, 262, 63, 1436, 395, 841, 304, 507, 198, 1027, 275, 2702, 14, 5301, 16591, 41, 297, 315, 63, 1436, 59, 73, 26, 73, 11, 20, 11057, 16, 61, 507, 198, 548, 63, 3148, 14, 740, 8, 1820, 14, 1389, 16591, 41, 297, 3696, 4471, 8, 1027, 1724, 199, 198, 1107, 6522, 904, 8, 548, 63, 3148, 9, 199, 199, 318, 4349, 4471, 8, 262, 63, 1436, 304, 199, 198, 548, 63, 3148, 275, 942, 199, 198, 509, 284, 315, 1425, 8, 16, 12, 822, 8, 262, 63, 1436, 395, 841, 304, 507, 198, 548, 63, 3148, 14, 740, 8, 262, 63, 1436, 59, 73, 26, 73, 11, 20, 566, 199, 198, 548, 63, 3148, 14, 4471, 342, 199, 198, 1107, 6522, 904, 8, 548, 63, 3148, 9, 199, 199, 533, 10195, 281, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1305, 304, 507, 198, 277, 14, 344, 275, 1305, 507, 198, 277, 14, 988, 63, 10667, 275, 9141, 63, 13887, 2089, 421, 198, 318, 1736, 8, 277, 12, 666, 495, 12, 1347, 495, 304, 507, 198, 3, 4849, 1736, 666, 6318, 1059, 370, 3366, 507, 198, 1986, 63, 576, 275, 666, 495, 14, 2708, 360, 4097, 358, 507, 198, 1986, 63, 576, 275, 4123, 4471, 8, 1986, 63, 576, 9, 2742, 198, 3, 314, 1642, 14646, 66, 402, 5939, 66, 886, 440, 1570, 507, 198, 14023, 63, 11244, 275, 2955, 63, 576, 1491, 2114, 61, 2742, 198, 3, 4849, 7633, 13, 2075, 1347, 574, 507, 198, 1375, 1393, 275, 1347, 495, 14, 2708, 360, 4097, 358, 507, 198, 1375, 1393, 275, 1347, 1393, 14172, 17, 61, 198, 3, 3696, 13, 9286, 436, 366, 1027, 13, 9286, 507, 198, 1375, 1393, 63, 495, 275, 1347, 1393, 14, 2143, 360, 4097, 358, 507, 198, 1375, 275, 1846, 8, 1375, 1393, 63, 495, 12, 3193, 9, 2742, 198, 3, 876, 13, 2227, 1642, 14646, 66, 402, 1853, 1406, 507, 198, 1986, 63, 2227, 275, 8337, 14, 4835, 3912, 342, 507, 198, 1986, 63, 2227, 14, 873, 8, 14023, 63, 11244, 9, 2742, 198, 509, 13711, 315, 4945, 8, 277, 14, 988, 63, 10667, 304, 6319, 198, 3, 3752, 4337, 13, 2075, 13711, 574, 686, 198, 10667, 63, 1393, 275, 2702, 14, 1389, 6757, 41, 401, 13711, 9, 6319, 198, 3, 2631, 4242, 841, 66, 12, 314, 13711, 574, 686, 198, 2227, 17, 63, 79, 275, 2955, 63, 2227, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 710, 21158, 19782, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 4190, 14, 2424, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 3, 199, 199, 646, 900, 199, 646, 2022, 199, 646, 10933, 199, 646, 8337, 199, 646, 2702, 199, 646, 295, 199, 646, 1300, 772, 199, 646, 8809, 199, 646, 984, 199, 504, 12866, 492, 7132, 199, 199, 2666, 63, 51, 906, 6102, 275, 4114, 199, 4283, 63, 13887, 2089, 275, 19492, 44, 199, 199, 1751, 275, 1052, 199, 802, 275, 10933, 14, 27153, 14131, 8, 3724, 29, 20, 9, 199, 199, 533, 21158, 8171, 26, 199, 198, 15862, 998, 275, 413, 421, 198, 318, 636, 826, 721, 277, 12, 1591, 12, 1844, 12, 3434, 12, 2505, 304, 507, 198, 1178, 3852, 275, 2071, 83, 2689, 83, 2, 450, 334, 2473, 12, 2505, 9, 507, 198, 277, 14, 1178, 11244, 275, 298, 6845, 450, 83, 2, 450, 334, 1095, 772, 14, 66, 772, 2143, 8, 1178, 3852, 430, 507, 198, 277, 14, 1631, 275, 8809, 14, 19114, 8, 1102, 12, 1844, 12, 756, 12, 4233, 9, 199, 198, 318, 8985, 8, 277, 12, 1083, 12, 1862, 29, 403, 304, 507, 198, 277, 14, 15862, 998, 847, 413, 507, 198, 1113, 275, 469, 283, 1023, 7, 520, 283, 17, 14, 17, 297, 686, 198, 6704, 69, 594, 7, 520, 1083, 12, 686, 198, 7, 344, 7, 520, 291, 14, 15862, 998, 789, 507, 198, 692, 1862, 365, 488, 26, 686, 198, 1113, 459, 1162, 418, 275, 942, 507, 198, 2836, 26, 686, 198, 1113, 459, 1162, 418, 275, 1862, 507, 198, 277, 14, 1631, 14, 1069, 360, 4030, 297, 17220, 2022, 14, 4180, 8, 1113, 395, 686, 198, 91, 283, 11626, 7, 520, 291, 14, 1178, 11244, 12, 1585, 221, 283, 2714, 13, 466, 7, 520, 283, 3578, 15, 1001, 7, 3828, 2742, 198, 4518, 275, 291, 14, 1631, 14, 25006, 342, 507, 198, 692, 3085, 365, 488, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 949, 1177, 2, 686, 198, 1107, 488, 2742, 198, 2030, 275, 3085, 14, 739, 342, 507, 198, 4518, 63, 1113, 275, 2022, 14, 3640, 8, 2030, 9, 507, 198, 692, 3085, 63, 1113, 365, 488, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 3913, 4840, 13, 2708, 2396, 2, 686, 198, 1107, 488, 507, 198, 692, 283, 705, 7, 315, 3085, 63, 1113, 436, 3085, 63, 1113, 459, 705, 418, 1137, 488, 26, 686, 198, 1107, 3085, 63, 1113, 459, 705, 418, 507, 198, 692, 283, 1099, 7, 440, 315, 3085, 63, 1113, 26, 686, 198, 1361, 298, 6243, 13, 8171, 26, 949, 754, 315, 909, 2, 686, 198, 1107, 488, 2742, 198, 1107, 3085, 63, 1113, 459, 1099, 418, 199, 198, 318, 664, 1457, 835, 8, 277, 304, 507, 198, 1107, 291, 14, 4354, 360, 30710, 358, 199, 198, 318, 664, 800, 8, 277, 12, 666, 29, 403, 304, 507, 198, 1107, 291, 14, 4354, 360, 362, 800, 297, 666, 9, 199, 199, 318, 3152, 708, 8, 88, 304, 199, 198, 1107, 671, 1253, 378, 21870, 44, 199, 199, 318, 3696, 4471, 8, 88, 304, 199, 198, 1107, 3152, 708, 1332, 3666, 88, 9, 5213, 5504, 9, 1204, 20337, 88, 9, 5213, 1695, 9, 1253, 378, 88, 383, 556, 993, 9, 1204, 686, 198, 12925, 88, 9, 4331, 1695, 9, 1253, 378, 88, 993, 556, 383, 9, 1204, 3666, 88, 9, 4331, 5504, 9, 5082, 199, 199, 318, 4123, 4471, 8, 262, 63, 1436, 304, 199, 198, 548, 63, 3148, 275, 942, 199, 198, 509, 284, 315, 1425, 8, 16, 12, 822, 8, 262, 63, 1436, 395, 841, 304, 507, 198, 1027, 275, 2702, 14, 5301, 16591, 41, 297, 315, 63, 1436, 59, 73, 26, 73, 11, 20, 11057, 16, 61, 507, 198, 548, 63, 3148, 14, 740, 8, 1820, 14, 1389, 16591, 41, 297, 3696, 4471, 8, 1027, 1724, 199, 198, 1107, 6522, 904, 8, 548, 63, 3148, 9, 199, 199, 318, 4349, 4471, 8, 262, 63, 1436, 304, 199, 198, 548, 63, 3148, 275, 942, 199, 198, 509, 284, 315, 1425, 8, 16, 12, 822, 8, 262, 63, 1436, 395, 841, 304, 507, 198, 548, 63, 3148, 14, 740, 8, 262, 63, 1436, 59, 73, 26, 73, 11, 20, 566, 199, 198, 548, 63, 3148, 14, 4471, 342, 199, 198, 1107, 6522, 904, 8, 548, 63, 3148, 9, 199, 199, 533, 10195, 281, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1305, 304, 507, 198, 277, 14, 344, 275, 1305, 507, 198, 277, 14, 988, 63, 10667, 275, 9141, 63, 13887, 2089, 421, 198, 318, 1736, 8, 277, 12, 666, 495, 12, 1347, 495, 304, 507, 198, 3, 4849, 1736, 666, 6318, 1059, 370, 3366, 507, 198, 1986, 63, 576, 275, 666, 495, 14, 2708, 360, 4097, 358, 507, 198, 1986, 63, 576, 275, 4123, 4471, 8, 1986, 63, 576, 9, 2742, 198, 3, 314, 1642, 14646, 66, 402, 5939, 66, 886, 440, 1570, 507, 198, 14023, 63, 11244, 275, 2955, 63, 576, 1491, 2114, 61, 2742, 198, 3, 4849, 7633, 13, 2075, 1347, 574, 507, 198, 1375, 1393, 275, 1347, 495, 14, 2708, 360, 4097, 358, 507, 198, 1375, 1393, 275, 1347, 1393, 14172, 17, 61, 198, 3, 3696, 13, 9286, 436, 366, 1027, 13, 9286, 507, 198, 1375, 1393, 63, 495, 275, 1347, 1393, 14, 2143, 360, 4097, 358, 507, 198, 1375, 275, 1846, 8, 1375, 1393, 63, 495, 12, 3193, 9, 2742, 198, 3, 876, 13, 2227, 1642, 14646, 66, 402, 1853, 1406, 507, 198, 1986, 63, 2227, 275, 8337, 14, 4835, 3912, 342, 507, 198, 1986, 63, 2227, 14, 873, 8, 14023, 63, 11244, 9, 2742, 198, 509, 13711, 315, 4945, 8, 277, 14, 988, 63, 10667, 304, 6319, 198, 3, 3752, 4337, 13, 2075, 13711, 574, 686, 198, 10667, 63, 1393, 275, 2702, 14, 1389, 6757, 41, 401, 13711, 9, 6319, 198, 3, 2631, 4242, 841, 66, 12, 314, 13711, 574, 686, 198, 2227, 17, 63, 79, 275, 2955, 63, 2227, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
KmolYuan/pyslvs
test/test_core.py
1
3764
# -*- coding: utf-8 -*- """Pyslvs core module test.""" __author__ = "Yuan Chang" __copyright__ = "Copyright (C) 2016-2021" __license__ = "AGPL" __email__ = "pyslvs@gmail.com" from math import sqrt, radians from pyslvs import ( Coord, SolverSystem, pxy, ppp, plap, pllp, plpp, palp, expr_solving, t_config, parse_vpoints, example_list, ) from . import TestBase class CoreTest(TestBase): def test_pxy(self): """Test for pxy function.""" coord = pxy(Coord(80, 90), 40, -20) self.assertAlmostEqual(120, coord.x) self.assertAlmostEqual(70, coord.y) def test_ppp(self): """Test for ppp function.""" coord = ppp(Coord(0, 0), Coord(0, 90), Coord(90, 0)) self.assertAlmostEqual(90, coord.x) self.assertAlmostEqual(90, coord.y) def test_plap(self): """Test for plap function.""" coord = plap(Coord(0, 0), 50 * sqrt(2), radians(45), Coord(50, 0)) self.assertAlmostEqual(50, coord.x) self.assertAlmostEqual(50, coord.y) def test_pllp(self): """Test for pllp function.""" c1 = Coord(-30, 0) c2 = Coord(30, 0) coord = pllp(c1, 50, 50, c2) self.assertAlmostEqual(0, coord.x) self.assertAlmostEqual(40, coord.y) coord = pllp(c1, 30, 30, c2) self.assertAlmostEqual(coord.x, 0) self.assertAlmostEqual(coord.y, 0) coord = pllp(c1, 90, 30, c2) self.assertAlmostEqual(60, coord.x) self.assertAlmostEqual(0, coord.y) def test_plpp(self): """Test for plpp function.""" coord = plpp(Coord(0, 0), sqrt(5), Coord(0, -3), Coord(3 / 2, 0)) self.assertAlmostEqual(2, coord.x) self.assertAlmostEqual(1, coord.y) def test_palp(self): """Test for palp function.""" coord = palp(Coord(0, 0), radians(15), 20, Coord(60, 10)) self.assertAlmostEqual(42.253221, coord.x, 6) self.assertAlmostEqual(19.222356, coord.y, 6) def test_solving(self): """Test triangular formula solving. + Test for PMKS parser. + Test data collecting function. + Test expression solving function. """ def test_case(name: str): expr, inputs = example_list(name) vpoints = parse_vpoints(expr) exprs = t_config(vpoints, inputs) result = expr_solving(exprs, vpoints, {pair: 0. for pair in inputs}) return result[-1] x, y = test_case("Jansen's linkage (Single)") self.assertAlmostEqual(-43.170055, x, 6) self.assertAlmostEqual(-91.753226, y, 6) x, y = test_case("Crank slider (RP joint)") self.assertAlmostEqual(103.801126, x, 6) self.assertAlmostEqual(78.393173, y, 6) x, y = test_case("Parallel Linkage") self.assertAlmostEqual(200, x, 6) self.assertAlmostEqual(0, y, 6) # TODO: New test case for Inverted slider def test_solving_bfgs(self): """Test Sketch Solve kernel.""" expr, _ = example_list("Jansen's linkage (Single)") system = SolverSystem(parse_vpoints(expr), {(0, 1): 0.}) result = system.solve() x, y = result[7] self.assertAlmostEqual(-43.170055, x, 6) self.assertAlmostEqual(-91.753226, y, 6) # Test if angle value changed system.set_inputs({(0, 1): 45.}) result = system.solve() x, y = result[7] self.assertAlmostEqual(-24.406394, x, 6) self.assertAlmostEqual(-91.789596, y, 6) # Test if link length changed system.set_data({(0, 1): 16.}) result = system.solve() x, y = result[7] self.assertAlmostEqual(-24.117994, x, 6) self.assertAlmostEqual(-91.198072, y, 6)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 48, 588, 76, 3122, 6170, 859, 511, 1041, 199, 199, 363, 2502, 363, 275, 298, 57, 7856, 2799, 621, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 35, 9, 7800, 13, 22150, 2, 199, 363, 1682, 363, 275, 298, 1254, 2749, 2, 199, 363, 2123, 363, 275, 298, 15983, 76, 3122, 32, 6799, 14, 957, 2, 199, 199, 504, 3473, 492, 7452, 12, 26874, 199, 504, 10382, 76, 3122, 492, 334, 272, 1849, 2181, 12, 428, 3725, 3989, 12, 299, 1702, 12, 299, 802, 12, 299, 4762, 12, 299, 914, 80, 12, 1620, 802, 12, 299, 279, 80, 12, 5348, 63, 7873, 4007, 12, 272, 307, 63, 888, 12, 2198, 63, 86, 3438, 12, 2893, 63, 513, 12, 199, 9, 199, 504, 1275, 492, 1379, 1563, 421, 199, 533, 11672, 774, 8, 14440, 304, 339, 347, 511, 63, 80, 1702, 8, 277, 304, 267, 408, 774, 367, 299, 1702, 805, 1041, 267, 11021, 275, 299, 1702, 8, 14957, 8, 1257, 12, 9137, 395, 6335, 12, 446, 1165, 9, 267, 291, 14, 7904, 8, 6708, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2760, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 802, 80, 8, 277, 304, 267, 408, 774, 367, 299, 802, 805, 1041, 267, 11021, 275, 299, 802, 8, 14957, 8, 16, 12, 378, 395, 1849, 2181, 8, 16, 12, 9137, 395, 1849, 2181, 8, 2710, 12, 378, 430, 267, 291, 14, 7904, 8, 2710, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2710, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 80, 4762, 8, 277, 304, 267, 408, 774, 367, 299, 4762, 805, 1041, 267, 11021, 275, 299, 4762, 8, 14957, 8, 16, 12, 378, 395, 5238, 627, 7452, 8, 18, 395, 26874, 8, 2322, 395, 1849, 2181, 8, 1400, 12, 378, 430, 267, 291, 14, 7904, 8, 1400, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 1400, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 80, 914, 80, 8, 277, 304, 267, 408, 774, 367, 299, 914, 80, 805, 1041, 267, 286, 17, 275, 1849, 2181, 2801, 1216, 12, 378, 9, 267, 286, 18, 275, 1849, 2181, 8, 1216, 12, 378, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 5238, 12, 5238, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 16, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2167, 12, 11021, 14, 89, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 4233, 12, 4233, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 7988, 14, 88, 12, 378, 9, 267, 291, 14, 7904, 8, 7988, 14, 89, 12, 378, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 9137, 12, 4233, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 2259, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 16, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 1168, 802, 8, 277, 304, 267, 408, 774, 367, 1620, 802, 805, 1041, 267, 11021, 275, 1620, 802, 8, 14957, 8, 16, 12, 378, 395, 7452, 8, 21, 395, 1849, 2181, 8, 16, 12, 446, 19, 395, 1849, 2181, 8, 19, 1182, 499, 12, 378, 430, 267, 291, 14, 7904, 8, 18, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 17, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 21516, 80, 8, 277, 304, 267, 408, 774, 367, 299, 279, 80, 805, 1041, 267, 11021, 275, 299, 279, 80, 8, 14957, 8, 16, 12, 378, 395, 26874, 8, 1046, 395, 3388, 12, 1849, 2181, 8, 2259, 12, 1616, 430, 267, 291, 14, 7904, 8, 2260, 14, 821, 708, 2025, 12, 11021, 14, 88, 12, 1227, 9, 267, 291, 14, 7904, 8, 1167, 14, 1081, 8276, 22, 12, 11021, 14, 89, 12, 1227, 9, 339, 347, 511, 63, 7873, 4007, 8, 277, 304, 267, 408, 774, 3229, 11572, 15723, 8597, 4007, 14, 398, 435, 1379, 367, 510, 18379, 51, 1798, 14, 267, 435, 1379, 666, 32223, 805, 14, 267, 435, 1379, 3965, 8597, 4007, 805, 14, 267, 408, 398, 347, 511, 63, 2546, 8, 354, 26, 620, 304, 288, 5348, 12, 4153, 275, 2893, 63, 513, 8, 354, 9, 288, 373, 3438, 275, 2198, 63, 86, 3438, 8, 3684, 9, 288, 23770, 275, 307, 63, 888, 8, 86, 3438, 12, 4153, 9, 288, 754, 275, 5348, 63, 7873, 4007, 8, 16006, 12, 373, 3438, 12, 469, 3852, 26, 378, 14, 367, 4092, 315, 4153, 1552, 288, 372, 754, 1988, 17, 61, 398, 671, 12, 612, 275, 511, 63, 2546, 480, 19825, 2464, 1159, 26087, 334, 7200, 6320, 267, 291, 14, 7904, 2801, 2824, 14, 1196, 30760, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 2801, 3328, 14, 2194, 708, 1479, 12, 612, 12, 1227, 9, 267, 671, 12, 612, 275, 511, 63, 2546, 480, 35, 4648, 31608, 334, 18612, 22211, 6320, 267, 291, 14, 7904, 8, 8845, 14, 26172, 7957, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 8, 2277, 14, 15490, 12478, 12, 612, 12, 1227, 9, 267, 671, 12, 612, 275, 511, 63, 2546, 480, 25721, 10967, 474, 531, 267, 291, 14, 7904, 8, 1840, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 8, 16, 12, 612, 12, 1227, 9, 267, 327, 3254, 26, 7053, 511, 1930, 367, 1010, 16542, 31608, 339, 347, 511, 63, 7873, 4007, 63, 31372, 8, 277, 304, 267, 408, 774, 29201, 2367, 428, 3344, 5114, 1041, 267, 5348, 12, 485, 275, 2893, 63, 513, 480, 19825, 2464, 1159, 26087, 334, 7200, 6320, 267, 2656, 275, 428, 3725, 3989, 8, 1122, 63, 86, 3438, 8, 3684, 395, 26458, 16, 12, 413, 304, 378, 14, 1552, 267, 754, 275, 2656, 14, 11356, 342, 267, 671, 12, 612, 275, 754, 59, 23, 61, 267, 291, 14, 7904, 2801, 2824, 14, 1196, 30760, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 2801, 3328, 14, 2194, 708, 1479, 12, 612, 12, 1227, 9, 267, 327, 1379, 340, 9324, 574, 2896, 267, 2656, 14, 409, 63, 3711, 2561, 8, 16, 12, 413, 304, 10416, 14, 1552, 267, 754, 275, 2656 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 48, 588, 76, 3122, 6170, 859, 511, 1041, 199, 199, 363, 2502, 363, 275, 298, 57, 7856, 2799, 621, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 35, 9, 7800, 13, 22150, 2, 199, 363, 1682, 363, 275, 298, 1254, 2749, 2, 199, 363, 2123, 363, 275, 298, 15983, 76, 3122, 32, 6799, 14, 957, 2, 199, 199, 504, 3473, 492, 7452, 12, 26874, 199, 504, 10382, 76, 3122, 492, 334, 272, 1849, 2181, 12, 428, 3725, 3989, 12, 299, 1702, 12, 299, 802, 12, 299, 4762, 12, 299, 914, 80, 12, 1620, 802, 12, 299, 279, 80, 12, 5348, 63, 7873, 4007, 12, 272, 307, 63, 888, 12, 2198, 63, 86, 3438, 12, 2893, 63, 513, 12, 199, 9, 199, 504, 1275, 492, 1379, 1563, 421, 199, 533, 11672, 774, 8, 14440, 304, 339, 347, 511, 63, 80, 1702, 8, 277, 304, 267, 408, 774, 367, 299, 1702, 805, 1041, 267, 11021, 275, 299, 1702, 8, 14957, 8, 1257, 12, 9137, 395, 6335, 12, 446, 1165, 9, 267, 291, 14, 7904, 8, 6708, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2760, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 802, 80, 8, 277, 304, 267, 408, 774, 367, 299, 802, 805, 1041, 267, 11021, 275, 299, 802, 8, 14957, 8, 16, 12, 378, 395, 1849, 2181, 8, 16, 12, 9137, 395, 1849, 2181, 8, 2710, 12, 378, 430, 267, 291, 14, 7904, 8, 2710, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2710, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 80, 4762, 8, 277, 304, 267, 408, 774, 367, 299, 4762, 805, 1041, 267, 11021, 275, 299, 4762, 8, 14957, 8, 16, 12, 378, 395, 5238, 627, 7452, 8, 18, 395, 26874, 8, 2322, 395, 1849, 2181, 8, 1400, 12, 378, 430, 267, 291, 14, 7904, 8, 1400, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 1400, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 80, 914, 80, 8, 277, 304, 267, 408, 774, 367, 299, 914, 80, 805, 1041, 267, 286, 17, 275, 1849, 2181, 2801, 1216, 12, 378, 9, 267, 286, 18, 275, 1849, 2181, 8, 1216, 12, 378, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 5238, 12, 5238, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 16, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 2167, 12, 11021, 14, 89, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 4233, 12, 4233, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 7988, 14, 88, 12, 378, 9, 267, 291, 14, 7904, 8, 7988, 14, 89, 12, 378, 9, 267, 11021, 275, 299, 914, 80, 8, 67, 17, 12, 9137, 12, 4233, 12, 286, 18, 9, 267, 291, 14, 7904, 8, 2259, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 16, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 1168, 802, 8, 277, 304, 267, 408, 774, 367, 1620, 802, 805, 1041, 267, 11021, 275, 1620, 802, 8, 14957, 8, 16, 12, 378, 395, 7452, 8, 21, 395, 1849, 2181, 8, 16, 12, 446, 19, 395, 1849, 2181, 8, 19, 1182, 499, 12, 378, 430, 267, 291, 14, 7904, 8, 18, 12, 11021, 14, 88, 9, 267, 291, 14, 7904, 8, 17, 12, 11021, 14, 89, 9, 339, 347, 511, 63, 21516, 80, 8, 277, 304, 267, 408, 774, 367, 299, 279, 80, 805, 1041, 267, 11021, 275, 299, 279, 80, 8, 14957, 8, 16, 12, 378, 395, 26874, 8, 1046, 395, 3388, 12, 1849, 2181, 8, 2259, 12, 1616, 430, 267, 291, 14, 7904, 8, 2260, 14, 821, 708, 2025, 12, 11021, 14, 88, 12, 1227, 9, 267, 291, 14, 7904, 8, 1167, 14, 1081, 8276, 22, 12, 11021, 14, 89, 12, 1227, 9, 339, 347, 511, 63, 7873, 4007, 8, 277, 304, 267, 408, 774, 3229, 11572, 15723, 8597, 4007, 14, 398, 435, 1379, 367, 510, 18379, 51, 1798, 14, 267, 435, 1379, 666, 32223, 805, 14, 267, 435, 1379, 3965, 8597, 4007, 805, 14, 267, 408, 398, 347, 511, 63, 2546, 8, 354, 26, 620, 304, 288, 5348, 12, 4153, 275, 2893, 63, 513, 8, 354, 9, 288, 373, 3438, 275, 2198, 63, 86, 3438, 8, 3684, 9, 288, 23770, 275, 307, 63, 888, 8, 86, 3438, 12, 4153, 9, 288, 754, 275, 5348, 63, 7873, 4007, 8, 16006, 12, 373, 3438, 12, 469, 3852, 26, 378, 14, 367, 4092, 315, 4153, 1552, 288, 372, 754, 1988, 17, 61, 398, 671, 12, 612, 275, 511, 63, 2546, 480, 19825, 2464, 1159, 26087, 334, 7200, 6320, 267, 291, 14, 7904, 2801, 2824, 14, 1196, 30760, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 2801, 3328, 14, 2194, 708, 1479, 12, 612, 12, 1227, 9, 267, 671, 12, 612, 275, 511, 63, 2546, 480, 35, 4648, 31608, 334, 18612, 22211, 6320, 267, 291, 14, 7904, 8, 8845, 14, 26172, 7957, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 8, 2277, 14, 15490, 12478, 12, 612, 12, 1227, 9, 267, 671, 12, 612, 275, 511, 63, 2546, 480, 25721, 10967, 474, 531, 267, 291, 14, 7904, 8, 1840, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 8, 16, 12, 612, 12, 1227, 9, 267, 327, 3254, 26, 7053, 511, 1930, 367, 1010, 16542, 31608, 339, 347, 511, 63, 7873, 4007, 63, 31372, 8, 277, 304, 267, 408, 774, 29201, 2367, 428, 3344, 5114, 1041, 267, 5348, 12, 485, 275, 2893, 63, 513, 480, 19825, 2464, 1159, 26087, 334, 7200, 6320, 267, 2656, 275, 428, 3725, 3989, 8, 1122, 63, 86, 3438, 8, 3684, 395, 26458, 16, 12, 413, 304, 378, 14, 1552, 267, 754, 275, 2656, 14, 11356, 342, 267, 671, 12, 612, 275, 754, 59, 23, 61, 267, 291, 14, 7904, 2801, 2824, 14, 1196, 30760, 12, 671, 12, 1227, 9, 267, 291, 14, 7904, 2801, 3328, 14, 2194, 708, 1479, 12, 612, 12, 1227, 9, 267, 327, 1379, 340, 9324, 574, 2896, 267, 2656, 14, 409, 63, 3711, 2561, 8, 16, 12, 413, 304, 10416, 14, 1552, 267, 754, 275, 2656, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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--help show this help message and exit -m MODE, --mode=MODE may be: 'refcount' (default - count up all foreignkey references for sort orders and such); 'index' (assign each record a sequential integer index); 'urlsafekeys' (update all key/keylist properties to use urlsafe keys introduced in ct 0.8); 'cleanup' (delete zero-count reference counters). Note regarding 'index' mode: it _must_ happen remotely; it's generally unnecessary unless you're trying to migrate an unindexed database away from gae and need an index/key per record; it should be invoked from _outside_ -- that's right, outside -- of your project's directory (to avoid loading up a bunch of google network tools that may be crappy or cause issues outside of their normal 'dev_appserver' environment) -d DOMAIN, --domain=DOMAIN ('index' mode only) what's the domain of the target server? (default: localhost) -p PORT, --port=PORT ('index' mode only) what's the port of the target server? (default: 8080) -s SKIP, --skip=SKIP skip these tables ('index' mode only) - use '|' as separator, such as 'table1|table2|table3' (default: none) -i INDEX, --index=INDEX start with this index ('index' mode only) (default: 0) As you can see, this script's behavior changes according to the backend of the target project. ### dez Run this if your CTRefCount records get messed up for some reason. It will go through and recount everything (in the default 'refcount' mode -- the other modes, 'urlsafekeys' and 'cleanup', are for migrating a CT-mediated database from an older deployment to CT 0.8 or newer). ### gae Run this in 'index' mode on a database with lots of missing index values. """ from getpass import getpass from optparse import OptionParser from cantools.util import error, log, batch from cantools.db import get_schema, get_model, put_multi, delete_multi, unpad_key from cantools.web import fetch from cantools import config if config.web.server == "dez": from cantools.db import session, func, refresh_counter try: input = raw_input # py2/3 compatibility except NameError: pass counts = { "_counters": 0 } RETRIES = 5 # # dez # def get_keys(kind, reference): log("acquiring %s (%s) keys"%(kind, reference), 1) mod = get_model(kind) q = session.query(getattr(mod, "key")) qcount = q.count() log("found %s"%(qcount,), 2) fname, fkey = reference.split(".") fmod = get_model(fname) fprop = getattr(fmod, fkey) sub = session.query(fprop, func.count("*").label("sub_count")).group_by(fprop).subquery() q = q.join(sub, mod.key==getattr(sub.c, fkey)) newcount = q.count() log("filtering out %s untargetted entities"%(qcount - newcount), 2) qcount = newcount log("returning %s keys"%(qcount,), 2) return q.all() def refmap(): log("compiling back reference map") rmap = {} for tname, schema in list(get_schema().items()): for pname, kinds in list(schema["_kinds"].items()): reference = "%s.%s"%(tname, pname) counts[reference] = 0 for kind in [k for k in kinds if k != "*"]: # skip wildcard for now if kind not in rmap: rmap[kind] = {} rmap[kind][reference] = get_keys(kind, reference) return rmap def do_batch(chunk, reference): log("refreshing %s %s keys"%(len(chunk), reference), 1) i = 0 rc = [] for item in chunk: # item is single-member tuple rc.append(refresh_counter(item[0], reference)) i += 1 if not i % 100: log("processed %s"%(i,), 3) counts[reference] += len(chunk) counts["_counters"] += len(rc) log("refreshed %s total"%(counts[reference],), 2) log("updated %s counters"%(counts["_counters"],), 2) put_multi(rc) log("saved", 2) def refcount(): log("indexing foreignkey references throughout database", important=True) import model # load schema for kind, references in list(refmap().items()): log("processing table: %s"%(kind,), important=True) for reference, keys in list(references.items()): batch(keys, do_batch, reference) tcount = sum(counts.values()) - counts["_counters"] log("refreshed %s rows and updated %s counters"%(tcount, counts["_counters"]), important=True) # # gae # def _log_fetch(host, url, port): res = fetch(host, url, port) log(res) return res def _index_kind(kind, host, port, pw, index): log("indexing %s"%(kind,), important=True) retry = 0 while "Error" in _log_fetch(host, "/_db?action=index&pw=%s&kind=%s&index=%s"%(pw, kind, index), port): log("error indexing %s"%(kind,), important=True) if retry == RETRIES: error("tried %s times! sorry."%(retry,)) retry += 1 log("trying again (retry: %s)"%(retry,)) def index(host, port, skips, index): pw = getpass("what's the admin password? ") log("indexing db at %s:%s"%(host, port), important=True) # log(fetch(host, "/_db?action=index&pw=%s"%(pw,), port)) log("acquiring schema") schema = fetch(host, "/_db?action=schema", port, ctjson=True) for kind in schema: if kind in skips: log("skipping %s"%(kind,), important=True) else: _index_kind(kind, host, port, pw, index) # # url safety # def urlsafe(): log("updating key/keylist properties with urlsafe keys", important=True) import model schema = get_schema() puts = [] for mod in schema: mods = get_model(mod).query().all() log("%s (%s)"%(mod, len(mods)), 1) for m in mods: if m.polytype != mod: log("skipping! (%s != %s)"%(m.polytype, mod), 2) continue m.key = unpad_key(m.key.urlsafe()) for prop in schema[mod]["_kinds"]: if schema[mod][prop] == "key": setattr(m, prop, unpad_key(getattr(m, prop).urlsafe())) else: # keylist setattr(m, prop, [unpad_key(k.urlsafe()) for k in getattr(m, prop)]) puts.append(m) log("saving records") put_multi(puts) log("updated %s keys"%(len(puts),), important=True) if input("want to prune zero-count reference counters? (y/N)").lower().startswith("y"): cleanup() def cleanup(): log("cleaning up zero-count reference counters", important=True) from cantools.db import lookup ctrz = lookup.CTRefCount.query(lookup.CTRefCount.count == 0).all() log("deleting %s zero-count reference counters"%(len(ctrz),)) delete_multi(ctrz) log("all gone!") def go(): parser = OptionParser("ctindex [--mode=MODE] [--domain=DOMAIN] [--port=PORT] [--skip=SKIP]") parser.add_option("-m", "--mode", dest="mode", default="refcount", help="may be: 'refcount' (default - count up all foreignkey references for sort " "orders and such); 'index' (assign each record a sequential integer index); " "'urlsafekeys' (update all key/keylist properties to use urlsafe keys " "introduced in ct 0.8); 'cleanup' (delete zero-count reference counters). " "Note regarding 'index' mode: it _must_ happen remotely; it's generally " "unnecessary unless you're trying to migrate an unindexed database away from " "gae and need an index/key per record; it should be invoked from _outside_ " "-- that's right, outside -- of your project's directory (to avoid loading " "up a bunch of google network tools that may be crappy or cause issues outside " "of their normal 'dev_appserver' environment)") parser.add_option("-d", "--domain", dest="domain", default="localhost", help="('index' mode only) what's the domain of the target server? (default: localhost)") parser.add_option("-p", "--port", dest="port", default="8080", help="('index' mode only) what's the port of the target server? (default: 8080)") parser.add_option("-s", "--skip", dest="skip", default="", help="skip these tables ('index' mode only) - use '|' as separator, such as 'table1|table2|table3' (default: none)") parser.add_option("-i", "--index", dest="index", default=0, help="start with this index ('index' mode only) (default: 0)") options, args = parser.parse_args() log("mode: %s"%(options.mode,), important=True) if options.mode == "refcount": refcount() elif options.mode == "index": index(options.domain, int(options.port), options.skip and options.skip.split("|") or [], options.index) elif options.mode == "urlsafekeys": urlsafe() elif options.mode == "cleanup": cleanup() else: error("unknown mode: %s"%(options.mode,)) log("goodbye") if __name__ == "__main__": go()
mit
[ 624, 199, 5680, 11028, 26, 9428, 1080, 19344, 632, 29, 6963, 61, 19344, 2261, 29, 7378, 61, 19344, 719, 29, 3657, 61, 19344, 2759, 29, 13525, 61, 199, 199, 5680, 8394, 26, 199, 198, 13, 72, 12, 1553, 3437, 3322, 2498, 642, 1720, 1245, 436, 4458, 199, 198, 13, 77, 27065, 12, 1553, 632, 29, 6963, 221, 1443, 506, 26, 283, 16497, 7, 334, 885, 446, 2338, 1536, 1006, 11608, 498, 507, 10473, 6941, 367, 4069, 15460, 436, 4066, 2736, 283, 1080, 7, 334, 5038, 507, 10473, 1924, 2777, 282, 23381, 3000, 1478, 2736, 283, 28201, 1612, 7, 507, 10473, 334, 873, 1006, 790, 15, 498, 513, 4382, 370, 675, 8187, 6504, 2883, 507, 10473, 21399, 315, 9428, 378, 14, 24, 2736, 283, 7661, 7, 334, 1807, 4697, 13, 835, 507, 10473, 3659, 21272, 680, 3390, 12602, 283, 1080, 7, 818, 26, 652, 507, 10473, 485, 7790, 63, 5992, 3982, 590, 27, 652, 1159, 16711, 23361, 507, 10473, 7444, 1265, 3984, 9936, 370, 12810, 376, 625, 16821, 3050, 507, 10473, 13437, 687, 486, 3624, 436, 1929, 376, 1478, 15, 498, 1126, 2777, 27, 652, 507, 10473, 1077, 506, 10302, 687, 485, 22431, 63, 1553, 626, 1159, 2451, 12, 507, 10473, 9682, 1553, 402, 2195, 2199, 1159, 2082, 334, 475, 5126, 507, 10473, 8697, 1536, 282, 22219, 402, 6233, 2784, 7249, 626, 1443, 506, 507, 10473, 286, 1330, 647, 503, 7675, 10876, 9682, 402, 3932, 3293, 507, 10473, 283, 2374, 63, 571, 1000, 7, 3734, 9, 199, 198, 13, 68, 15265, 12, 1553, 2261, 29, 7378, 507, 10473, 661, 1080, 7, 818, 1454, 9, 4052, 1159, 314, 2881, 402, 314, 1347, 507, 10473, 1654, 31, 334, 885, 26, 11667, 9, 199, 198, 13, 80, 25562, 12, 1553, 719, 29, 3657, 221, 661, 1080, 7, 818, 1454, 9, 4052, 1159, 314, 1844, 402, 314, 1347, 507, 10473, 1654, 31, 334, 885, 26, 30220, 9, 199, 198, 13, 83, 27885, 12, 1553, 2759, 29, 13525, 221, 3372, 3520, 6716, 661, 1080, 7, 818, 1454, 9, 446, 675, 24628, 465, 507, 10473, 9432, 12, 4066, 465, 283, 1224, 17, 92, 1224, 18, 92, 1224, 19, 7, 334, 885, 26, 507, 10473, 7179, 9, 199, 198, 13, 73, 17055, 12, 1553, 1080, 29, 10215, 2079, 1343, 543, 642, 1478, 661, 1080, 7, 818, 1454, 9, 334, 885, 26, 378, 9, 199, 199, 2822, 1265, 883, 1937, 12, 642, 2884, 1159, 5953, 4493, 7182, 370, 314, 4865, 402, 314, 1347, 2199, 14, 199, 199, 5680, 477, 90, 199, 2540, 642, 340, 2195, 24990, 4394, 5767, 664, 26560, 939, 1536, 367, 199, 3972, 4499, 14, 2779, 911, 2621, 4012, 436, 295, 835, 8137, 199, 8, 262, 314, 849, 283, 16497, 7, 818, 1553, 314, 1163, 12404, 12, 199, 7, 28201, 1612, 7, 436, 283, 7661, 297, 787, 367, 3952, 10417, 282, 24990, 13, 3700, 972, 199, 4659, 687, 376, 12731, 14295, 370, 24990, 378, 14, 24, 503, 15666, 680, 199, 199, 5680, 486, 3624, 199, 2540, 642, 315, 283, 1080, 7, 818, 641, 282, 3050, 543, 24213, 402, 4124, 1478, 1338, 14, 199, 624, 199, 199, 504, 18354, 492, 18354, 199, 504, 8691, 492, 13491, 199, 504, 883, 2537, 14, 1974, 492, 1125, 12, 943, 12, 3522, 199, 504, 883, 2537, 14, 697, 492, 664, 63, 3629, 12, 664, 63, 1238, 12, 5324, 63, 3029, 12, 3145, 63, 3029, 12, 625, 6226, 63, 498, 199, 504, 883, 2537, 14, 2520, 492, 5267, 199, 504, 883, 2537, 492, 1101, 199, 692, 1101, 14, 2520, 14, 1000, 508, 298, 271, 90, 582, 199, 198, 504, 883, 2537, 14, 697, 492, 2351, 12, 2562, 12, 9236, 63, 5337, 199, 199, 893, 26, 272, 1324, 275, 3066, 63, 1210, 327, 1134, 18, 15, 19, 7163, 199, 2590, 12746, 26, 272, 986, 199, 199, 6851, 275, 469, 2668, 16558, 582, 378, 789, 199, 32528, 275, 959, 199, 199, 3, 199, 3, 477, 90, 199, 3, 199, 199, 318, 664, 63, 1612, 8, 5091, 12, 3659, 304, 199, 198, 793, 480, 645, 23729, 450, 83, 4366, 83, 9, 2883, 14007, 5091, 12, 3659, 395, 413, 9, 199, 198, 1494, 275, 664, 63, 1238, 8, 5091, 9, 199, 198, 81, 275, 2351, 14, 1131, 8, 5675, 8, 1494, 12, 298, 498, 2237, 199, 198, 81, 835, 275, 1894, 14, 835, 342, 199, 198, 793, 480, 4214, 450, 83, 14007, 81, 835, 4706, 499, 9, 199, 198, 5252, 12, 289, 498, 275, 3659, 14, 1294, 15857, 199, 198, 70, 1494, 275, 664, 63, 1238, 8, 5252, 9, 199, 198, 70, 4469, 275, 2519, 8, 70, 1494, 12, 289, 498, 9, 199, 198, 954, 275, 2351, 14, 1131, 8, 70, 4469, 12, 2562, 14, 835, 23124, 3471, 1302, 480, 954, 63, 835, 21688, 923, 63, 991, 8, 70, 4469, 680, 23912, 342, 199, 198, 81, 275, 1894, 14, 904, 8, 954, 12, 3413, 14, 498, 389, 5675, 8, 954, 14, 67, 12, 289, 498, 430, 199, 198, 1222, 835, 275, 1894, 14, 835, 342, 199, 198, 793, 480, 24133, 734, 450, 83, 625, 1375, 471, 9045, 14007, 81, 835, 446, 892, 835, 395, 499, 9, 199, 198, 81, 835, 275, 892, 835, 199, 198, 793, 480, 24112, 450, 83, 2883, 14007, 81, 835, 4706, 499, 9, 199, 198, 1107, 1894, 14, 452, 342, 199, 199, 318, 2984, 1130, 837, 199, 198, 793, 480, 863, 5662, 1771, 3659, 2341, 531, 199, 198, 82, 1130, 275, 1052, 199, 198, 509, 307, 354, 12, 4177, 315, 769, 8, 362, 63, 3629, 1252, 1744, 5109, 507, 198, 509, 27700, 12, 24241, 315, 769, 8, 3629, 18524, 5091, 83, 4140, 1744, 5109, 686, 198, 4443, 275, 2071, 83, 4111, 83, 14007, 31383, 12, 27700, 9, 686, 198, 6851, 59, 4443, 61, 275, 378, 686, 198, 509, 4928, 315, 359, 75, 367, 1022, 315, 24241, 340, 1022, 1137, 8969, 6229, 327, 3372, 16792, 367, 3063, 1585, 198, 692, 4928, 440, 315, 519, 1130, 26, 1871, 198, 82, 1130, 59, 5091, 61, 275, 1052, 1585, 198, 82, 1130, 59, 5091, 1527, 4443, 61, 275, 664, 63, 1612, 8, 5091, 12, 3659, 9, 199, 198, 1107, 519, 1130, 199, 199, 318, 886, 63, 2912, 8, 4604, 12, 3659, 304, 199, 198, 793, 480, 6635, 316, 450, 83, 450 ]
[ 199, 5680, 11028, 26, 9428, 1080, 19344, 632, 29, 6963, 61, 19344, 2261, 29, 7378, 61, 19344, 719, 29, 3657, 61, 19344, 2759, 29, 13525, 61, 199, 199, 5680, 8394, 26, 199, 198, 13, 72, 12, 1553, 3437, 3322, 2498, 642, 1720, 1245, 436, 4458, 199, 198, 13, 77, 27065, 12, 1553, 632, 29, 6963, 221, 1443, 506, 26, 283, 16497, 7, 334, 885, 446, 2338, 1536, 1006, 11608, 498, 507, 10473, 6941, 367, 4069, 15460, 436, 4066, 2736, 283, 1080, 7, 334, 5038, 507, 10473, 1924, 2777, 282, 23381, 3000, 1478, 2736, 283, 28201, 1612, 7, 507, 10473, 334, 873, 1006, 790, 15, 498, 513, 4382, 370, 675, 8187, 6504, 2883, 507, 10473, 21399, 315, 9428, 378, 14, 24, 2736, 283, 7661, 7, 334, 1807, 4697, 13, 835, 507, 10473, 3659, 21272, 680, 3390, 12602, 283, 1080, 7, 818, 26, 652, 507, 10473, 485, 7790, 63, 5992, 3982, 590, 27, 652, 1159, 16711, 23361, 507, 10473, 7444, 1265, 3984, 9936, 370, 12810, 376, 625, 16821, 3050, 507, 10473, 13437, 687, 486, 3624, 436, 1929, 376, 1478, 15, 498, 1126, 2777, 27, 652, 507, 10473, 1077, 506, 10302, 687, 485, 22431, 63, 1553, 626, 1159, 2451, 12, 507, 10473, 9682, 1553, 402, 2195, 2199, 1159, 2082, 334, 475, 5126, 507, 10473, 8697, 1536, 282, 22219, 402, 6233, 2784, 7249, 626, 1443, 506, 507, 10473, 286, 1330, 647, 503, 7675, 10876, 9682, 402, 3932, 3293, 507, 10473, 283, 2374, 63, 571, 1000, 7, 3734, 9, 199, 198, 13, 68, 15265, 12, 1553, 2261, 29, 7378, 507, 10473, 661, 1080, 7, 818, 1454, 9, 4052, 1159, 314, 2881, 402, 314, 1347, 507, 10473, 1654, 31, 334, 885, 26, 11667, 9, 199, 198, 13, 80, 25562, 12, 1553, 719, 29, 3657, 221, 661, 1080, 7, 818, 1454, 9, 4052, 1159, 314, 1844, 402, 314, 1347, 507, 10473, 1654, 31, 334, 885, 26, 30220, 9, 199, 198, 13, 83, 27885, 12, 1553, 2759, 29, 13525, 221, 3372, 3520, 6716, 661, 1080, 7, 818, 1454, 9, 446, 675, 24628, 465, 507, 10473, 9432, 12, 4066, 465, 283, 1224, 17, 92, 1224, 18, 92, 1224, 19, 7, 334, 885, 26, 507, 10473, 7179, 9, 199, 198, 13, 73, 17055, 12, 1553, 1080, 29, 10215, 2079, 1343, 543, 642, 1478, 661, 1080, 7, 818, 1454, 9, 334, 885, 26, 378, 9, 199, 199, 2822, 1265, 883, 1937, 12, 642, 2884, 1159, 5953, 4493, 7182, 370, 314, 4865, 402, 314, 1347, 2199, 14, 199, 199, 5680, 477, 90, 199, 2540, 642, 340, 2195, 24990, 4394, 5767, 664, 26560, 939, 1536, 367, 199, 3972, 4499, 14, 2779, 911, 2621, 4012, 436, 295, 835, 8137, 199, 8, 262, 314, 849, 283, 16497, 7, 818, 1553, 314, 1163, 12404, 12, 199, 7, 28201, 1612, 7, 436, 283, 7661, 297, 787, 367, 3952, 10417, 282, 24990, 13, 3700, 972, 199, 4659, 687, 376, 12731, 14295, 370, 24990, 378, 14, 24, 503, 15666, 680, 199, 199, 5680, 486, 3624, 199, 2540, 642, 315, 283, 1080, 7, 818, 641, 282, 3050, 543, 24213, 402, 4124, 1478, 1338, 14, 199, 624, 199, 199, 504, 18354, 492, 18354, 199, 504, 8691, 492, 13491, 199, 504, 883, 2537, 14, 1974, 492, 1125, 12, 943, 12, 3522, 199, 504, 883, 2537, 14, 697, 492, 664, 63, 3629, 12, 664, 63, 1238, 12, 5324, 63, 3029, 12, 3145, 63, 3029, 12, 625, 6226, 63, 498, 199, 504, 883, 2537, 14, 2520, 492, 5267, 199, 504, 883, 2537, 492, 1101, 199, 692, 1101, 14, 2520, 14, 1000, 508, 298, 271, 90, 582, 199, 198, 504, 883, 2537, 14, 697, 492, 2351, 12, 2562, 12, 9236, 63, 5337, 199, 199, 893, 26, 272, 1324, 275, 3066, 63, 1210, 327, 1134, 18, 15, 19, 7163, 199, 2590, 12746, 26, 272, 986, 199, 199, 6851, 275, 469, 2668, 16558, 582, 378, 789, 199, 32528, 275, 959, 199, 199, 3, 199, 3, 477, 90, 199, 3, 199, 199, 318, 664, 63, 1612, 8, 5091, 12, 3659, 304, 199, 198, 793, 480, 645, 23729, 450, 83, 4366, 83, 9, 2883, 14007, 5091, 12, 3659, 395, 413, 9, 199, 198, 1494, 275, 664, 63, 1238, 8, 5091, 9, 199, 198, 81, 275, 2351, 14, 1131, 8, 5675, 8, 1494, 12, 298, 498, 2237, 199, 198, 81, 835, 275, 1894, 14, 835, 342, 199, 198, 793, 480, 4214, 450, 83, 14007, 81, 835, 4706, 499, 9, 199, 198, 5252, 12, 289, 498, 275, 3659, 14, 1294, 15857, 199, 198, 70, 1494, 275, 664, 63, 1238, 8, 5252, 9, 199, 198, 70, 4469, 275, 2519, 8, 70, 1494, 12, 289, 498, 9, 199, 198, 954, 275, 2351, 14, 1131, 8, 70, 4469, 12, 2562, 14, 835, 23124, 3471, 1302, 480, 954, 63, 835, 21688, 923, 63, 991, 8, 70, 4469, 680, 23912, 342, 199, 198, 81, 275, 1894, 14, 904, 8, 954, 12, 3413, 14, 498, 389, 5675, 8, 954, 14, 67, 12, 289, 498, 430, 199, 198, 1222, 835, 275, 1894, 14, 835, 342, 199, 198, 793, 480, 24133, 734, 450, 83, 625, 1375, 471, 9045, 14007, 81, 835, 446, 892, 835, 395, 499, 9, 199, 198, 81, 835, 275, 892, 835, 199, 198, 793, 480, 24112, 450, 83, 2883, 14007, 81, 835, 4706, 499, 9, 199, 198, 1107, 1894, 14, 452, 342, 199, 199, 318, 2984, 1130, 837, 199, 198, 793, 480, 863, 5662, 1771, 3659, 2341, 531, 199, 198, 82, 1130, 275, 1052, 199, 198, 509, 307, 354, 12, 4177, 315, 769, 8, 362, 63, 3629, 1252, 1744, 5109, 507, 198, 509, 27700, 12, 24241, 315, 769, 8, 3629, 18524, 5091, 83, 4140, 1744, 5109, 686, 198, 4443, 275, 2071, 83, 4111, 83, 14007, 31383, 12, 27700, 9, 686, 198, 6851, 59, 4443, 61, 275, 378, 686, 198, 509, 4928, 315, 359, 75, 367, 1022, 315, 24241, 340, 1022, 1137, 8969, 6229, 327, 3372, 16792, 367, 3063, 1585, 198, 692, 4928, 440, 315, 519, 1130, 26, 1871, 198, 82, 1130, 59, 5091, 61, 275, 1052, 1585, 198, 82, 1130, 59, 5091, 1527, 4443, 61, 275, 664, 63, 1612, 8, 5091, 12, 3659, 9, 199, 198, 1107, 519, 1130, 199, 199, 318, 886, 63, 2912, 8, 4604, 12, 3659, 304, 199, 198, 793, 480, 6635, 316, 450, 83, 450, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
FRC-Team-3140/north-american-happiness
lib/python2.7/site-packages/jinja2/visitor.py
1401
3316
# -*- coding: utf-8 -*- """ jinja2.visitor ~~~~~~~~~~~~~~ This module implements a visitor for the nodes. :copyright: (c) 2010 by the Jinja Team. :license: BSD. """ from jinja2.nodes import Node class NodeVisitor(object): """Walks the abstract syntax tree and call visitor functions for every node found. The visitor functions may return values which will be forwarded by the `visit` method. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `get_visitor` function. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. """ def get_visitor(self, node): """Return the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead. """ method = 'visit_' + node.__class__.__name__ return getattr(self, method, None) def visit(self, node, *args, **kwargs): """Visit a node.""" f = self.get_visitor(node) if f is not None: return f(node, *args, **kwargs) return self.generic_visit(node, *args, **kwargs) def generic_visit(self, node, *args, **kwargs): """Called if no explicit visitor function exists for a node.""" for node in node.iter_child_nodes(): self.visit(node, *args, **kwargs) class NodeTransformer(NodeVisitor): """Walks the abstract syntax tree and allows modifications of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor functions to replace or remove the old node. If the return value of the visitor function is `None` the node will be removed from the previous location otherwise it's replaced with the return value. The return value may be the original node in which case no replacement takes place. """ def generic_visit(self, node, *args, **kwargs): for field, old_value in node.iter_fields(): if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, Node): value = self.visit(value, *args, **kwargs) if value is None: continue elif not isinstance(value, Node): new_values.extend(value) continue new_values.append(value) old_value[:] = new_values elif isinstance(old_value, Node): new_node = self.visit(old_value, *args, **kwargs) if new_node is None: delattr(node, field) else: setattr(node, field, new_node) return node def visit_list(self, node, *args, **kwargs): """As transformers may return lists in some places this method can be used to enforce a list as return value. """ rv = self.visit(node, *args, **kwargs) if not isinstance(rv, list): rv = [rv] return rv
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 19863, 272, 32202, 1714, 339, 961, 859, 9031, 282, 18040, 367, 314, 3380, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 14, 2415, 492, 5013, 421, 199, 533, 5013, 18324, 8, 785, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 1240, 18040, 3423, 367, 4036, 272, 1031, 1911, 14, 221, 710, 18040, 3423, 1443, 372, 1338, 1314, 911, 506, 272, 24172, 701, 314, 658, 5427, 64, 1083, 14, 339, 3492, 849, 314, 18040, 3423, 367, 314, 3380, 787, 12692, 5427, 8650, 1040, 435, 272, 1021, 536, 402, 314, 1031, 14, 221, 2002, 282, 658, 12357, 8694, 1183, 64, 1031, 5684, 805, 3955, 272, 506, 658, 5427, 63, 12357, 8694, 1183, 2313, 221, 961, 5953, 883, 506, 2896, 701, 18972, 272, 314, 658, 362, 63, 19863, 64, 805, 14, 221, 982, 949, 18040, 805, 3495, 367, 282, 1031, 272, 334, 1107, 574, 658, 403, 10522, 314, 658, 6767, 63, 5427, 64, 18040, 365, 1202, 3140, 14, 272, 408, 339, 347, 664, 63, 19863, 8, 277, 12, 1031, 304, 267, 408, 1767, 314, 18040, 805, 367, 642, 1031, 503, 658, 403, 64, 340, 949, 18040, 267, 3495, 367, 642, 1031, 14, 221, 1010, 626, 1930, 314, 7809, 5684, 805, 365, 267, 1202, 3140, 14, 267, 408, 267, 1083, 275, 283, 5427, 8650, 435, 1031, 855, 533, 4914, 354, 363, 267, 372, 2519, 8, 277, 12, 1083, 12, 488, 9, 339, 347, 5684, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 15087, 282, 1031, 1041, 267, 289, 275, 291, 14, 362, 63, 19863, 8, 932, 9, 267, 340, 289, 365, 440, 488, 26, 288, 372, 289, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 372, 291, 14, 6767, 63, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 10474, 340, 949, 5027, 18040, 805, 3495, 367, 282, 1031, 1041, 267, 367, 1031, 315, 1031, 14, 1661, 63, 1739, 63, 2415, 837, 288, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 5013, 19761, 8, 1716, 18324, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 6127, 23070, 402, 3380, 14, 339, 710, 658, 1716, 19761, 64, 911, 12778, 314, 20788, 436, 675, 314, 372, 574, 402, 314, 272, 18040, 3423, 370, 3350, 503, 2813, 314, 2269, 1031, 14, 221, 982, 314, 372, 272, 574, 402, 314, 18040, 805, 365, 658, 403, 64, 314, 1031, 911, 506, 4829, 272, 687, 314, 4136, 2909, 4257, 652, 1159, 8717, 543, 314, 372, 272, 574, 14, 221, 710, 372, 574, 1443, 506, 314, 3379, 1031, 315, 1314, 1930, 949, 272, 8343, 6181, 4192, 14, 272, 408, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 901, 12, 2269, 63, 585, 315, 1031, 14, 1661, 63, 955, 837, 288, 340, 1228, 8, 1753, 63, 585, 12, 769, 304, 355, 892, 63, 1459, 275, 942, 355, 367, 574, 315, 2269, 63, 585, 26, 490, 340, 1228, 8, 585, 12, 5013, 304, 717, 574, 275, 291, 14, 5427, 8, 585, 12, 627, 589, 12, 1011, 958, 9, 717, 340, 574, 365, 488, 26, 1169, 1980, 717, 916, 440, 1228, 8, 585, 12, 5013, 304, 1169, 892, 63, 1459, 14, 2880, 8, 585, 9, 1169, 1980, 490, 892, 63, 1459, 14, 740, 8, 585, 9, 355, 2269, 63, 585, 5873, 275, 892, 63, 1459, 288, 916, 1228, 8, 1753, 63, 585, 12, 5013, 304, 355, 892, 63, 932, 275, 291, 14, 5427, 8, 1753, 63, 585, 12, 627, 589, 12, 1011, 958, 9, 355, 340, 892, 63, 932, 365, 488, 26, 490, 24358, 8, 932, 12, 901, 9, 355, 587, 26, 490, 5371, 8, 932, 12, 901, 12, 892, 63, 932, 9, 267, 372, 1031, 339, 347, 5684, 63, 513, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 2822, 1752, 22932, 1443, 372, 5548, 315, 2005, 9825, 642, 1083, 267, 883, 506, 1202, 370, 15814, 282, 769, 465, 372, 574, 14, 267, 408, 267, 4336, 275, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 440, 1228, 8, 6310, 12, 769, 304, 288, 4336, 275, 359, 6310, 61, 267, 372, 4336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 19863, 272, 32202, 1714, 339, 961, 859, 9031, 282, 18040, 367, 314, 3380, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 14, 2415, 492, 5013, 421, 199, 533, 5013, 18324, 8, 785, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 1240, 18040, 3423, 367, 4036, 272, 1031, 1911, 14, 221, 710, 18040, 3423, 1443, 372, 1338, 1314, 911, 506, 272, 24172, 701, 314, 658, 5427, 64, 1083, 14, 339, 3492, 849, 314, 18040, 3423, 367, 314, 3380, 787, 12692, 5427, 8650, 1040, 435, 272, 1021, 536, 402, 314, 1031, 14, 221, 2002, 282, 658, 12357, 8694, 1183, 64, 1031, 5684, 805, 3955, 272, 506, 658, 5427, 63, 12357, 8694, 1183, 2313, 221, 961, 5953, 883, 506, 2896, 701, 18972, 272, 314, 658, 362, 63, 19863, 64, 805, 14, 221, 982, 949, 18040, 805, 3495, 367, 282, 1031, 272, 334, 1107, 574, 658, 403, 10522, 314, 658, 6767, 63, 5427, 64, 18040, 365, 1202, 3140, 14, 272, 408, 339, 347, 664, 63, 19863, 8, 277, 12, 1031, 304, 267, 408, 1767, 314, 18040, 805, 367, 642, 1031, 503, 658, 403, 64, 340, 949, 18040, 267, 3495, 367, 642, 1031, 14, 221, 1010, 626, 1930, 314, 7809, 5684, 805, 365, 267, 1202, 3140, 14, 267, 408, 267, 1083, 275, 283, 5427, 8650, 435, 1031, 855, 533, 4914, 354, 363, 267, 372, 2519, 8, 277, 12, 1083, 12, 488, 9, 339, 347, 5684, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 15087, 282, 1031, 1041, 267, 289, 275, 291, 14, 362, 63, 19863, 8, 932, 9, 267, 340, 289, 365, 440, 488, 26, 288, 372, 289, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 372, 291, 14, 6767, 63, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 10474, 340, 949, 5027, 18040, 805, 3495, 367, 282, 1031, 1041, 267, 367, 1031, 315, 1031, 14, 1661, 63, 1739, 63, 2415, 837, 288, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 5013, 19761, 8, 1716, 18324, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 6127, 23070, 402, 3380, 14, 339, 710, 658, 1716, 19761, 64, 911, 12778, 314, 20788, 436, 675, 314, 372, 574, 402, 314, 272, 18040, 3423, 370, 3350, 503, 2813, 314, 2269, 1031, 14, 221, 982, 314, 372, 272, 574, 402, 314, 18040, 805, 365, 658, 403, 64, 314, 1031, 911, 506, 4829, 272, 687, 314, 4136, 2909, 4257, 652, 1159, 8717, 543, 314, 372, 272, 574, 14, 221, 710, 372, 574, 1443, 506, 314, 3379, 1031, 315, 1314, 1930, 949, 272, 8343, 6181, 4192, 14, 272, 408, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 901, 12, 2269, 63, 585, 315, 1031, 14, 1661, 63, 955, 837, 288, 340, 1228, 8, 1753, 63, 585, 12, 769, 304, 355, 892, 63, 1459, 275, 942, 355, 367, 574, 315, 2269, 63, 585, 26, 490, 340, 1228, 8, 585, 12, 5013, 304, 717, 574, 275, 291, 14, 5427, 8, 585, 12, 627, 589, 12, 1011, 958, 9, 717, 340, 574, 365, 488, 26, 1169, 1980, 717, 916, 440, 1228, 8, 585, 12, 5013, 304, 1169, 892, 63, 1459, 14, 2880, 8, 585, 9, 1169, 1980, 490, 892, 63, 1459, 14, 740, 8, 585, 9, 355, 2269, 63, 585, 5873, 275, 892, 63, 1459, 288, 916, 1228, 8, 1753, 63, 585, 12, 5013, 304, 355, 892, 63, 932, 275, 291, 14, 5427, 8, 1753, 63, 585, 12, 627, 589, 12, 1011, 958, 9, 355, 340, 892, 63, 932, 365, 488, 26, 490, 24358, 8, 932, 12, 901, 9, 355, 587, 26, 490, 5371, 8, 932, 12, 901, 12, 892, 63, 932, 9, 267, 372, 1031, 339, 347, 5684, 63, 513, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 2822, 1752, 22932, 1443, 372, 5548, 315, 2005, 9825, 642, 1083, 267, 883, 506, 1202, 370, 15814, 282, 769, 465, 372, 574, 14, 267, 408, 267, 4336, 275, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 440, 1228, 8, 6310, 12, 769, 304, 288, 4336, 275, 359, 6310, 61, 267, 372, 4336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
joelddiaz/openshift-tools
openshift/installer/vendored/openshift-ansible-3.2.24/library/rpm_q.py
9
127102
<!DOCTYPE html> <html lang="en" class=""> <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#"> <meta charset='utf-8'> <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-98550932b9f11a849da143d2dbc9dfaa977a17656514d323ae9ce0d6fa688b60.css" media="all" rel="stylesheet" /> <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-b55c6a2db8c337849a80d2520fa0b213d8486d35ace9b6b15d84c381ea8bb696.css" media="all" rel="stylesheet" /> <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/site-becbb68a5e0ae3f94214b9e9edea2c49974f6d60b9eae715b70e5d017ff1b935.css" media="all" rel="stylesheet" /> <link as="script" href="https://assets-cdn.github.com/assets/frameworks-88471af1fec40ff9418efbe2ddd15b6896af8d772f8179004c254dffc25ea490.js" rel="preload" /> <link as="script" href="https://assets-cdn.github.com/assets/github-c4177fc28385bc04fc26a831fe1f9d69d5d7a3242566683a9daac147e1280847.js" rel="preload" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="Content-Language" content="en"> <meta name="viewport" content="width=device-width"> <title>openshift-ansible/rpm_q.py at master · openshift/openshift-ansible · GitHub</title> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png"> <meta property="fb:app_id" content="1401488693436528"> <meta content="https://avatars0.githubusercontent.com/u/792337?v=3&amp;s=400" name="twitter:image:src" /><meta content="@github" name="twitter:site" /><meta content="summary" name="twitter:card" /><meta content="openshift/openshift-ansible" name="twitter:title" /><meta content="openshift-ansible - OpenShift Ansible Code" name="twitter:description" /> <meta content="https://avatars0.githubusercontent.com/u/792337?v=3&amp;s=400" property="og:image" /><meta content="GitHub" property="og:site_name" /><meta content="object" property="og:type" /><meta content="openshift/openshift-ansible" property="og:title" /><meta content="https://github.com/openshift/openshift-ansible" property="og:url" /><meta content="openshift-ansible - OpenShift Ansible Code" property="og:description" /> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <link rel="assets" href="https://assets-cdn.github.com/"> <meta name="pjax-timeout" content="1000"> <meta name="request-id" content="340600F0:40E4:5C0C495:57CED387" data-pjax-transient> <meta name="msapplication-TileImage" content="/windows-tile.png"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="selected-link" value="repo_source" data-pjax-transient> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-analytics" content="UA-3769691-2"> <meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="340600F0:40E4:5C0C495:57CED387" name="octolytics-dimension-request_id" /> <meta content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" name="analytics-location" /> <meta class="js-ga-set" name="dimension1" content="Logged Out"> <meta name="hostname" content="github.com"> <meta name="user-login" content=""> <meta name="expected-hostname" content="github.com"> <meta name="js-proxy-site-detection-payload" content="ZWNhYmZkYzE3OWM4MTE1ZTY3ZTBhMGEyZjYwYjU2MDRhMDQzY2JkZmRlZTFhODRhZWQ5ZDk3MTE3YjI3M2NlYnx7InJlbW90ZV9hZGRyZXNzIjoiNTIuNi4wLjI0MCIsInJlcXVlc3RfaWQiOiIzNDA2MDBGMDo0MEU0OjVDMEM0OTU6NTdDRUQzODciLCJ0aW1lc3RhbXAiOjE0NzMxNzIzNTl9"> <link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#4078c0"> <link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favicon.ico"> <meta name="html-safe-nonce" content="def7b9de2f8fef27920459ee4b3cc9f5a6843a34"> <meta content="3701de654fec0d4d220a3412ad1bc6ef2e8258de" name="form-nonce" /> <meta http-equiv="x-pjax-version" content="13cab7f77477644fc72f582220d901c4"> <meta name="description" content="openshift-ansible - OpenShift Ansible Code"> <meta name="go-import" content="github.com/openshift/openshift-ansible git https://github.com/openshift/openshift-ansible.git"> <meta content="792337" name="octolytics-dimension-user_id" /><meta content="openshift" name="octolytics-dimension-user_login" /><meta content="24109199" name="octolytics-dimension-repository_id" /><meta content="openshift/openshift-ansible" name="octolytics-dimension-repository_nwo" /><meta content="true" name="octolytics-dimension-repository_public" /><meta content="false" name="octolytics-dimension-repository_is_fork" /><meta content="24109199" name="octolytics-dimension-repository_network_root_id" /><meta content="openshift/openshift-ansible" name="octolytics-dimension-repository_network_root_nwo" /> <link href="https://github.com/openshift/openshift-ansible/commits/master.atom" rel="alternate" title="Recent Commits to openshift-ansible:master" type="application/atom+xml"> <link rel="canonical" href="https://github.com/openshift/openshift-ansible/blob/master/library/rpm_q.py" data-pjax-transient> </head> <body class="logged-out env-production vis-public page-blob"> <div id="js-pjax-loader-bar" class="pjax-loader-bar"><div class="progress"></div></div> <a href="#start-of-content" tabindex="1" class="accessibility-aid js-skip-to-content">Skip to content</a> <header class="site-header js-details-container" role="banner"> <div class="container-responsive"> <a class="header-logo-invertocat" href="https://github.com/" aria-label="Homepage" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark"> <svg aria-hidden="true" class="octicon octicon-mark-github" height="32" version="1.1" viewBox="0 0 16 16" width="32"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg> </a> <button class="btn-link float-right site-header-toggle js-details-target" type="button" aria-label="Toggle navigation"> <svg aria-hidden="true" class="octicon octicon-three-bars" height="24" version="1.1" viewBox="0 0 12 16" width="18"><path d="M11.41 9H.59C0 9 0 8.59 0 8c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zm0-4H.59C0 5 0 4.59 0 4c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zM.59 11H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1H.59C0 13 0 12.59 0 12c0-.59 0-1 .59-1z"></path></svg> </button> <div class="site-header-menu"> <nav class="site-header-nav site-header-nav-main"> <a href="/personal" class="js-selected-navigation-item nav-item nav-item-personal" data-ga-click="Header, click, Nav menu - item:personal" data-selected-links="/personal /personal"> Personal </a> <a href="/open-source" class="js-selected-navigation-item nav-item nav-item-opensource" data-ga-click="Header, click, Nav menu - item:opensource" data-selected-links="/open-source /open-source"> Open source </a> <a href="/business" class="js-selected-navigation-item nav-item nav-item-business" data-ga-click="Header, click, Nav menu - item:business" data-selected-links="/business /business/partners /business/features /business/customers /business"> Business </a> <a href="/explore" class="js-selected-navigation-item nav-item nav-item-explore" data-ga-click="Header, click, Nav menu - item:explore" data-selected-links="/explore /trending /trending/developers /integrations /integrations/feature/code /integrations/feature/collaborate /integrations/feature/ship /explore"> Explore </a> </nav> <div class="site-header-actions"> <a class="btn btn-primary site-header-actions-btn" href="/join?source=header-repo" data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up">Sign up</a> <a class="btn site-header-actions-btn mr-2" href="/login?return_to=%2Fopenshift%2Fopenshift-ansible%2Fblob%2Fmaster%2Flibrary%2Frpm_q.py" data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in">Sign in</a> </div> <nav class="site-header-nav site-header-nav-secondary"> <a class="nav-item" href="/pricing">Pricing</a> <a class="nav-item" href="/blog">Blog</a> <a class="nav-item" href="https://help.github.com">Support</a> <a class="nav-item header-search-link" href="https://github.com/search">Search GitHub</a> <div class="header-search scoped-search site-scoped-search js-site-search" role="search"> <!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/openshift/openshift-ansible/search" class="js-site-search-form" data-scoped-search-url="/openshift/openshift-ansible/search" data-unscoped-search-url="/search" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div> <label class="form-control header-search-wrapper js-chromeless-input-container"> <div class="header-search-scope">This repository</div> <input type="text" class="form-control header-search-input js-site-search-focus js-site-search-field is-clearable" data-hotkey="s" name="q" placeholder="Search" aria-label="Search this repository" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off"> </label> </form></div> </nav> </div> </div> </header> <div id="start-of-content" class="accessibility-aid"></div> <div id="js-flash-container"> </div> <div role="main"> <div itemscope itemtype="http://schema.org/SoftwareSourceCode"> <div id="js-repo-pjax-container" data-pjax-container> <div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav"> <div class="container repohead-details-container"> <ul class="pagehead-actions"> <li> <a href="/login?return_to=%2Fopenshift%2Fopenshift-ansible" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to watch a repository" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-eye" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg> Watch </a> <a class="social-count" href="/openshift/openshift-ansible/watchers" aria-label="66 users are watching this repository"> 66 </a> </li> <li> <a href="/login?return_to=%2Fopenshift%2Fopenshift-ansible" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to star a repository" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-star" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"></path></svg> Star </a> <a class="social-count js-social-count" href="/openshift/openshift-ansible/stargazers" aria-label="236 users starred this repository"> 236 </a> </li> <li> <a href="/login?return_to=%2Fopenshift%2Fopenshift-ansible" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to fork a repository" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" version="1.1" viewBox="0 0 10 16" width="10"><path d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> Fork </a> <a href="/openshift/openshift-ansible/network" class="social-count" aria-label="378 users are forked this repository"> 378 </a> </li> </ul> <h1 class="public "> <svg aria-hidden="true" class="octicon octicon-repo" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <span class="author" itemprop="author"><a href="/openshift" class="url fn" rel="author">openshift</a></span><!-- --><span class="path-divider">/</span><!-- --><strong itemprop="name"><a href="/openshift/openshift-ansible" data-pjax="#js-repo-pjax-container">openshift-ansible</a></strong> </h1> </div> <div class="container"> <nav class="reponav js-repo-nav js-sidenav-container-pjax" itemscope itemtype="http://schema.org/BreadcrumbList" role="navigation" data-pjax="#js-repo-pjax-container"> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a href="/openshift/openshift-ansible" aria-selected="true" class="js-selected-navigation-item selected reponav-item" data-hotkey="g c" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches /openshift/openshift-ansible" itemprop="url"> <svg aria-hidden="true" class="octicon octicon-code" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg> <span itemprop="name">Code</span> <meta itemprop="position" content="1"> </a> </span> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a href="/openshift/openshift-ansible/issues" class="js-selected-navigation-item reponav-item" data-hotkey="g i" data-selected-links="repo_issues repo_labels repo_milestones /openshift/openshift-ansible/issues" itemprop="url"> <svg aria-hidden="true" class="octicon octicon-issue-opened" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg> <span itemprop="name">Issues</span> <span class="counter">268</span> <meta itemprop="position" content="2"> </a> </span> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a href="/openshift/openshift-ansible/pulls" class="js-selected-navigation-item reponav-item" data-hotkey="g p" data-selected-links="repo_pulls /openshift/openshift-ansible/pulls" itemprop="url"> <svg aria-hidden="true" class="octicon octicon-git-pull-request" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> <span itemprop="name">Pull requests</span> <span class="counter">60</span> <meta itemprop="position" content="3"> </a> </span> <a href="/openshift/openshift-ansible/pulse" class="js-selected-navigation-item reponav-item" data-selected-links="pulse /openshift/openshift-ansible/pulse"> <svg aria-hidden="true" class="octicon octicon-pulse" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M11.5 8L8.8 5.4 6.6 8.5 5.5 1.6 2.38 8H0v2h3.6l.9-1.8.9 5.4L9 8.5l1.6 1.5H14V8z"></path></svg> Pulse </a> <a href="/openshift/openshift-ansible/graphs" class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors /openshift/openshift-ansible/graphs"> <svg aria-hidden="true" class="octicon octicon-graph" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg> Graphs </a> </nav> </div> </div> <div class="container new-discussion-timeline experiment-repo-nav"> <div class="repository-content"> <a href="/openshift/openshift-ansible/blob/5ca0a74fb271678708268c940fd52ccd15d207ca/library/rpm_q.py" class="d-none js-permalink-shortcut" data-hotkey="y">Permalink</a> <!-- blob contrib key: blob_contributors:v21:a7fe4f4023a6b59519e9c7599bf3f9f5 --> <div class="file-navigation js-zeroclipboard-container"> <div class="select-menu branch-select-menu js-menu-container js-select-menu float-left"> <button class="btn btn-sm select-menu-button js-menu-target css-truncate" data-hotkey="w" type="button" aria-label="Switch branches or tags" tabindex="0" aria-haspopup="true"> <i>Branch:</i> <span class="js-select-button css-truncate-target">master</span> </button> <div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax aria-hidden="true"> <div class="select-menu-modal"> <div class="select-menu-header"> <svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg> <span class="select-menu-title">Switch branches/tags</span> </div> <div class="select-menu-filters"> <div class="select-menu-text-filter"> <input type="text" aria-label="Filter branches/tags" id="context-commitish-filter-field" class="form-control js-filterable-field js-navigation-enable" placeholder="Filter branches/tags"> </div> <div class="select-menu-tabs"> <ul> <li class="select-menu-tab"> <a href="#" data-tab-filter="branches" data-filter-placeholder="Filter branches/tags" class="js-select-menu-tab" role="tab">Branches</a> </li> <li class="select-menu-tab"> <a href="#" data-tab-filter="tags" data-filter-placeholder="Find a tag…" class="js-select-menu-tab" role="tab">Tags</a> </li> </ul> </div> </div> <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches" role="menu"> <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring"> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/README-updates/library/rpm_q.py" data-name="README-updates" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> README-updates </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/enterprise-3.0/library/rpm_q.py" data-name="enterprise-3.0" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> enterprise-3.0 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/enterprise-3.1/library/rpm_q.py" data-name="enterprise-3.1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> enterprise-3.1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/enterprise-3.2/library/rpm_q.py" data-name="enterprise-3.2" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> enterprise-3.2 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/enterprise-3.3/library/rpm_q.py" data-name="enterprise-3.3" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> enterprise-3.3 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/hotfix/library/rpm_q.py" data-name="hotfix" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> hotfix </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/logging_fix/library/rpm_q.py" data-name="logging_fix" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> logging_fix </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open selected" href="/openshift/openshift-ansible/blob/master/library/rpm_q.py" data-name="master" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> master </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/next/library/rpm_q.py" data-name="next" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> next </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/revert-2238-no-network-plugin/library/rpm_q.py" data-name="revert-2238-no-network-plugin" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> revert-2238-no-network-plugin </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/revert-2325-fileglobglob/library/rpm_q.py" data-name="revert-2325-fileglobglob" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> revert-2325-fileglobglob </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/sdodson-patch-1/library/rpm_q.py" data-name="sdodson-patch-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> sdodson-patch-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/blob/sdodson-patch-2/library/rpm_q.py" data-name="sdodson-patch-2" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text"> sdodson-patch-2 </span> </a> </div> <div class="select-menu-no-results">Nothing to show</div> </div> <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags"> <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring"> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.2-2/library/rpm_q.py" data-name="v3.0.2-2" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.2-2"> v3.0.2-2 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.2-1/library/rpm_q.py" data-name="v3.0.2-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.2-1"> v3.0.2-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.1-1/library/rpm_q.py" data-name="v3.0.1-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.1-1"> v3.0.1-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0/library/rpm_q.py" data-name="v3.0.0" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0"> v3.0.0 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-rc/library/rpm_q.py" data-name="v3.0.0-rc" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-rc"> v3.0.0-rc </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-8/library/rpm_q.py" data-name="v3.0.0-8" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-8"> v3.0.0-8 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-7/library/rpm_q.py" data-name="v3.0.0-7" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-7"> v3.0.0-7 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-6/library/rpm_q.py" data-name="v3.0.0-6" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-6"> v3.0.0-6 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-5/library/rpm_q.py" data-name="v3.0.0-5" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-5"> v3.0.0-5 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-4/library/rpm_q.py" data-name="v3.0.0-4" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-4"> v3.0.0-4 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-3/library/rpm_q.py" data-name="v3.0.0-3" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-3"> v3.0.0-3 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-2/library/rpm_q.py" data-name="v3.0.0-2" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-2"> v3.0.0-2 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/v3.0.0-1/library/rpm_q.py" data-name="v3.0.0-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="v3.0.0-1"> v3.0.0-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.4.1-1/library/rpm_q.py" data-name="openshift-ansible-3.4.1-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.4.1-1"> openshift-ansible-3.4.1-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.22-1/library/rpm_q.py" data-name="openshift-ansible-3.3.22-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.22-1"> openshift-ansible-3.3.22-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.21-1/library/rpm_q.py" data-name="openshift-ansible-3.3.21-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.21-1"> openshift-ansible-3.3.21-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.20-1/library/rpm_q.py" data-name="openshift-ansible-3.3.20-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.20-1"> openshift-ansible-3.3.20-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.19-1/library/rpm_q.py" data-name="openshift-ansible-3.3.19-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.19-1"> openshift-ansible-3.3.19-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.18-1/library/rpm_q.py" data-name="openshift-ansible-3.3.18-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.18-1"> openshift-ansible-3.3.18-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.17-1/library/rpm_q.py" data-name="openshift-ansible-3.3.17-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.17-1"> openshift-ansible-3.3.17-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.16-1/library/rpm_q.py" data-name="openshift-ansible-3.3.16-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.16-1"> openshift-ansible-3.3.16-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.15-1/library/rpm_q.py" data-name="openshift-ansible-3.3.15-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.15-1"> openshift-ansible-3.3.15-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.14-1/library/rpm_q.py" data-name="openshift-ansible-3.3.14-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.14-1"> openshift-ansible-3.3.14-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.13-1/library/rpm_q.py" data-name="openshift-ansible-3.3.13-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.13-1"> openshift-ansible-3.3.13-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.12-1/library/rpm_q.py" data-name="openshift-ansible-3.3.12-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.12-1"> openshift-ansible-3.3.12-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.11-1/library/rpm_q.py" data-name="openshift-ansible-3.3.11-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.11-1"> openshift-ansible-3.3.11-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.10-1/library/rpm_q.py" data-name="openshift-ansible-3.3.10-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.10-1"> openshift-ansible-3.3.10-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.9-1/library/rpm_q.py" data-name="openshift-ansible-3.3.9-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.9-1"> openshift-ansible-3.3.9-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.8-1/library/rpm_q.py" data-name="openshift-ansible-3.3.8-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.8-1"> openshift-ansible-3.3.8-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.7-1/library/rpm_q.py" data-name="openshift-ansible-3.3.7-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.7-1"> openshift-ansible-3.3.7-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.6-1/library/rpm_q.py" data-name="openshift-ansible-3.3.6-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.6-1"> openshift-ansible-3.3.6-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.5-1/library/rpm_q.py" data-name="openshift-ansible-3.3.5-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.5-1"> openshift-ansible-3.3.5-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.4-1/library/rpm_q.py" data-name="openshift-ansible-3.3.4-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.4-1"> openshift-ansible-3.3.4-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.3-1/library/rpm_q.py" data-name="openshift-ansible-3.3.3-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.3-1"> openshift-ansible-3.3.3-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.2-1/library/rpm_q.py" data-name="openshift-ansible-3.3.2-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.2-1"> openshift-ansible-3.3.2-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.1-1/library/rpm_q.py" data-name="openshift-ansible-3.3.1-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.1-1"> openshift-ansible-3.3.1-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.3.0-1/library/rpm_q.py" data-name="openshift-ansible-3.3.0-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.3.0-1"> openshift-ansible-3.3.0-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.28-1/library/rpm_q.py" data-name="openshift-ansible-3.2.28-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.28-1"> openshift-ansible-3.2.28-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.27-1/library/rpm_q.py" data-name="openshift-ansible-3.2.27-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.27-1"> openshift-ansible-3.2.27-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.26-1/library/rpm_q.py" data-name="openshift-ansible-3.2.26-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.26-1"> openshift-ansible-3.2.26-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.25-1/library/rpm_q.py" data-name="openshift-ansible-3.2.25-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.25-1"> openshift-ansible-3.2.25-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.24-1/library/rpm_q.py" data-name="openshift-ansible-3.2.24-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.24-1"> openshift-ansible-3.2.24-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.23-1/library/rpm_q.py" data-name="openshift-ansible-3.2.23-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.23-1"> openshift-ansible-3.2.23-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.22-1/library/rpm_q.py" data-name="openshift-ansible-3.2.22-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.22-1"> openshift-ansible-3.2.22-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.21-1/library/rpm_q.py" data-name="openshift-ansible-3.2.21-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.21-1"> openshift-ansible-3.2.21-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.20-1/library/rpm_q.py" data-name="openshift-ansible-3.2.20-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.20-1"> openshift-ansible-3.2.20-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.19-1/library/rpm_q.py" data-name="openshift-ansible-3.2.19-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.19-1"> openshift-ansible-3.2.19-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.18-1/library/rpm_q.py" data-name="openshift-ansible-3.2.18-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.18-1"> openshift-ansible-3.2.18-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.17-1/library/rpm_q.py" data-name="openshift-ansible-3.2.17-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.17-1"> openshift-ansible-3.2.17-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.15-1/library/rpm_q.py" data-name="openshift-ansible-3.2.15-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.15-1"> openshift-ansible-3.2.15-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.14-1/library/rpm_q.py" data-name="openshift-ansible-3.2.14-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.14-1"> openshift-ansible-3.2.14-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.13-1/library/rpm_q.py" data-name="openshift-ansible-3.2.13-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.13-1"> openshift-ansible-3.2.13-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.12-1/library/rpm_q.py" data-name="openshift-ansible-3.2.12-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.12-1"> openshift-ansible-3.2.12-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.11-1/library/rpm_q.py" data-name="openshift-ansible-3.2.11-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.11-1"> openshift-ansible-3.2.11-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.9-1/library/rpm_q.py" data-name="openshift-ansible-3.2.9-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.9-1"> openshift-ansible-3.2.9-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.8-1/library/rpm_q.py" data-name="openshift-ansible-3.2.8-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.8-1"> openshift-ansible-3.2.8-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.7-1/library/rpm_q.py" data-name="openshift-ansible-3.2.7-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.7-1"> openshift-ansible-3.2.7-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.6-1/library/rpm_q.py" data-name="openshift-ansible-3.2.6-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.6-1"> openshift-ansible-3.2.6-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.5-1/library/rpm_q.py" data-name="openshift-ansible-3.2.5-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.5-1"> openshift-ansible-3.2.5-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.4-1/library/rpm_q.py" data-name="openshift-ansible-3.2.4-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.4-1"> openshift-ansible-3.2.4-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.3-1/library/rpm_q.py" data-name="openshift-ansible-3.2.3-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.3-1"> openshift-ansible-3.2.3-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.2-1/library/rpm_q.py" data-name="openshift-ansible-3.2.2-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.2-1"> openshift-ansible-3.2.2-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.1-1/library/rpm_q.py" data-name="openshift-ansible-3.2.1-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.1-1"> openshift-ansible-3.2.1-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.2.0-1/library/rpm_q.py" data-name="openshift-ansible-3.2.0-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.2.0-1"> openshift-ansible-3.2.0-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.97-1/library/rpm_q.py" data-name="openshift-ansible-3.0.97-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.97-1"> openshift-ansible-3.0.97-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.96-1/library/rpm_q.py" data-name="openshift-ansible-3.0.96-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.96-1"> openshift-ansible-3.0.96-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.95-1/library/rpm_q.py" data-name="openshift-ansible-3.0.95-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.95-1"> openshift-ansible-3.0.95-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.94-1/library/rpm_q.py" data-name="openshift-ansible-3.0.94-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.94-1"> openshift-ansible-3.0.94-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.93-1/library/rpm_q.py" data-name="openshift-ansible-3.0.93-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.93-1"> openshift-ansible-3.0.93-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.92-1/library/rpm_q.py" data-name="openshift-ansible-3.0.92-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.92-1"> openshift-ansible-3.0.92-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.90-1/library/rpm_q.py" data-name="openshift-ansible-3.0.90-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.90-1"> openshift-ansible-3.0.90-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.89-1/library/rpm_q.py" data-name="openshift-ansible-3.0.89-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.89-1"> openshift-ansible-3.0.89-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.88-1/library/rpm_q.py" data-name="openshift-ansible-3.0.88-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.88-1"> openshift-ansible-3.0.88-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.87-1/library/rpm_q.py" data-name="openshift-ansible-3.0.87-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.87-1"> openshift-ansible-3.0.87-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.86-1/library/rpm_q.py" data-name="openshift-ansible-3.0.86-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.86-1"> openshift-ansible-3.0.86-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.85-1/library/rpm_q.py" data-name="openshift-ansible-3.0.85-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.85-1"> openshift-ansible-3.0.85-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.84-1/library/rpm_q.py" data-name="openshift-ansible-3.0.84-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.84-1"> openshift-ansible-3.0.84-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.83-1/library/rpm_q.py" data-name="openshift-ansible-3.0.83-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.83-1"> openshift-ansible-3.0.83-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.82-1/library/rpm_q.py" data-name="openshift-ansible-3.0.82-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.82-1"> openshift-ansible-3.0.82-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.81-1/library/rpm_q.py" data-name="openshift-ansible-3.0.81-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.81-1"> openshift-ansible-3.0.81-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.80-1/library/rpm_q.py" data-name="openshift-ansible-3.0.80-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.80-1"> openshift-ansible-3.0.80-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.79-1/library/rpm_q.py" data-name="openshift-ansible-3.0.79-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.79-1"> openshift-ansible-3.0.79-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.78-1/library/rpm_q.py" data-name="openshift-ansible-3.0.78-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.78-1"> openshift-ansible-3.0.78-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.77-1/library/rpm_q.py" data-name="openshift-ansible-3.0.77-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.77-1"> openshift-ansible-3.0.77-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.76-1/library/rpm_q.py" data-name="openshift-ansible-3.0.76-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.76-1"> openshift-ansible-3.0.76-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.75-1/library/rpm_q.py" data-name="openshift-ansible-3.0.75-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.75-1"> openshift-ansible-3.0.75-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.74-1/library/rpm_q.py" data-name="openshift-ansible-3.0.74-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.74-1"> openshift-ansible-3.0.74-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.73-1/library/rpm_q.py" data-name="openshift-ansible-3.0.73-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.73-1"> openshift-ansible-3.0.73-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.72-1/library/rpm_q.py" data-name="openshift-ansible-3.0.72-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.72-1"> openshift-ansible-3.0.72-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.71-1/library/rpm_q.py" data-name="openshift-ansible-3.0.71-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.71-1"> openshift-ansible-3.0.71-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.70-1/library/rpm_q.py" data-name="openshift-ansible-3.0.70-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.70-1"> openshift-ansible-3.0.70-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.69-1/library/rpm_q.py" data-name="openshift-ansible-3.0.69-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.69-1"> openshift-ansible-3.0.69-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.68-1/library/rpm_q.py" data-name="openshift-ansible-3.0.68-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.68-1"> openshift-ansible-3.0.68-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.67-1/library/rpm_q.py" data-name="openshift-ansible-3.0.67-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.67-1"> openshift-ansible-3.0.67-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.66-1/library/rpm_q.py" data-name="openshift-ansible-3.0.66-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.66-1"> openshift-ansible-3.0.66-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.65-1/library/rpm_q.py" data-name="openshift-ansible-3.0.65-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.65-1"> openshift-ansible-3.0.65-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.64-1/library/rpm_q.py" data-name="openshift-ansible-3.0.64-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.64-1"> openshift-ansible-3.0.64-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.63-1/library/rpm_q.py" data-name="openshift-ansible-3.0.63-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.63-1"> openshift-ansible-3.0.63-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.62-1/library/rpm_q.py" data-name="openshift-ansible-3.0.62-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.62-1"> openshift-ansible-3.0.62-1 </span> </a> <a class="select-menu-item js-navigation-item js-navigation-open " href="/openshift/openshift-ansible/tree/openshift-ansible-3.0.61-1/library/rpm_q.py" data-name="openshift-ansible-3.0.61-1" data-skip-pjax="true" rel="nofollow"> <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg> <span class="select-menu-item-text css-truncate-target" title="openshift-ansible-3.0.61-1"> openshift-ansible-3.0.61-1 </span> </a> </div> <div class="select-menu-no-results">Nothing to show</div> </div> </div> </div> </div> <div class="btn-group float-right"> <a href="/openshift/openshift-ansible/find/master" class="js-pjax-capture-input btn btn-sm" data-pjax data-hotkey="t"> Find file </a> <button aria-label="Copy file path to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button">Copy path</button> </div> <div class="breadcrumb js-zeroclipboard-target"> <span class="repo-root js-repo-root"><span class="js-path-segment"><a href="/openshift/openshift-ansible"><span>openshift-ansible</span></a></span></span><span class="separator">/</span><span class="js-path-segment"><a href="/openshift/openshift-ansible/tree/master/library"><span>library</span></a></span><span class="separator">/</span><strong class="final-path">rpm_q.py</strong> </div> </div> <div class="commit-tease"> <span class="float-right"> <a class="commit-tease-sha" href="/openshift/openshift-ansible/commit/f834279d5010f5a8b1a1cd7c75adaa7b0dce7fed" data-pjax> f834279 </a> <relative-time datetime="2016-07-18T08:10:52Z">Jul 18, 2016</relative-time> </span> <div> <img alt="" class="avatar" data-canonical-src="https://1.gravatar.com/avatar/6616a4a17cf9ab34e284f83936103c9b?d=https%3A%2F%2Fassets-cdn.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png&amp;r=x&amp;s=140" height="20" src="https://camo.githubusercontent.com/98706179b01273be3b6e5b8a411a6cab07e382b8/68747470733a2f2f312e67726176617461722e636f6d2f6176617461722f36363136613461313763663961623334653238346638333933363130336339623f643d68747470732533412532462532466173736574732d63646e2e6769746875622e636f6d253246696d6167657325324667726176617461727325324667726176617461722d757365722d3432302e706e6726723d7826733d313430" width="20" /> <span class="user-mention">Tobias Florek</span> <a href="/openshift/openshift-ansible/commit/f834279d5010f5a8b1a1cd7c75adaa7b0dce7fed" class="message" data-pjax="true" title="make rpm-q module pylint warning-free">make rpm-q module pylint warning-free</a> </div> <div class="commit-tease-contributors"> <button type="button" class="btn-link muted-link contributors-toggle" data-facebox="#blob_contributors_box"> <strong>0</strong> contributors </button> </div> <div id="blob_contributors_box" style="display:none"> <h2 class="facebox-header" data-facebox-id="facebox-header">Users who have contributed to this file</h2> <ul class="facebox-user-list" data-facebox-id="facebox-description"> </ul> </div> </div> <div class="file"> <div class="file-header"> <div class="file-actions"> <div class="btn-group"> <a href="/openshift/openshift-ansible/raw/master/library/rpm_q.py" class="btn btn-sm " id="raw-url">Raw</a> <a href="/openshift/openshift-ansible/blame/master/library/rpm_q.py" class="btn btn-sm js-update-url-with-hash">Blame</a> <a href="/openshift/openshift-ansible/commits/master/library/rpm_q.py" class="btn btn-sm " rel="nofollow">History</a> </div> <button type="button" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg aria-hidden="true" class="octicon octicon-pencil" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 0 1 1.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"></path></svg> </button> <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg aria-hidden="true" class="octicon octicon-trashcan" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"></path></svg> </button> </div> <div class="file-info"> 71 lines (59 sloc) <span class="file-info-divider"></span> 1.75 KB </div> </div> <div itemprop="text" class="blob-wrapper data type-python"> <table class="highlight tab-size js-file-line-container" data-tab-size="8"> <tr> <td id="L1" class="blob-num js-line-number" data-line-number="1"></td> <td id="LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-c">#!/usr/bin/python</span></td> </tr> <tr> <td id="L2" class="blob-num js-line-number" data-line-number="2"></td> <td id="LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># -*- coding: utf-8 -*-</span></td> </tr> <tr> <td id="L3" class="blob-num js-line-number" data-line-number="3"></td> <td id="LC3" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L4" class="blob-num js-line-number" data-line-number="4"></td> <td id="LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># (c) 2015, Tobias Florek &lt;tob@butter.sh&gt;</span></td> </tr> <tr> <td id="L5" class="blob-num js-line-number" data-line-number="5"></td> <td id="LC5" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># Licensed under the terms of the MIT License</span></td> </tr> <tr> <td id="L6" class="blob-num js-line-number" data-line-number="6"></td> <td id="LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L7" class="blob-num js-line-number" data-line-number="7"></td> <td id="LC7" class="blob-code blob-code-inner js-file-line"><span class="pl-s">An ansible module to query the RPM database. For use, when yum/dnf are not</span></td> </tr> <tr> <td id="L8" class="blob-num js-line-number" data-line-number="8"></td> <td id="LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-s">available.</span></td> </tr> <tr> <td id="L9" class="blob-num js-line-number" data-line-number="9"></td> <td id="LC9" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L10" class="blob-num js-line-number" data-line-number="10"></td> <td id="LC10" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L11" class="blob-num js-line-number" data-line-number="11"></td> <td id="LC11" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># pylint: disable=redefined-builtin,wildcard-import,unused-wildcard-import</span></td> </tr> <tr> <td id="L12" class="blob-num js-line-number" data-line-number="12"></td> <td id="LC12" class="blob-code blob-code-inner js-file-line"><span class="pl-k">from</span> ansible.module_utils.basic <span class="pl-k">import</span> <span class="pl-k">*</span></td> </tr> <tr> <td id="L13" class="blob-num js-line-number" data-line-number="13"></td> <td id="LC13" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L14" class="blob-num js-line-number" data-line-number="14"></td> <td id="LC14" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">DOCUMENTATION</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L15" class="blob-num js-line-number" data-line-number="15"></td> <td id="LC15" class="blob-code blob-code-inner js-file-line"><span class="pl-s">---</span></td> </tr> <tr> <td id="L16" class="blob-num js-line-number" data-line-number="16"></td> <td id="LC16" class="blob-code blob-code-inner js-file-line"><span class="pl-s">module: rpm_q</span></td> </tr> <tr> <td id="L17" class="blob-num js-line-number" data-line-number="17"></td> <td id="LC17" class="blob-code blob-code-inner js-file-line"><span class="pl-s">short_description: Query the RPM database</span></td> </tr> <tr> <td id="L18" class="blob-num js-line-number" data-line-number="18"></td> <td id="LC18" class="blob-code blob-code-inner js-file-line"><span class="pl-s">author: Tobias Florek</span></td> </tr> <tr> <td id="L19" class="blob-num js-line-number" data-line-number="19"></td> <td id="LC19" class="blob-code blob-code-inner js-file-line"><span class="pl-s">options:</span></td> </tr> <tr> <td id="L20" class="blob-num js-line-number" data-line-number="20"></td> <td id="LC20" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> name:</span></td> </tr> <tr> <td id="L21" class="blob-num js-line-number" data-line-number="21"></td> <td id="LC21" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> description:</span></td> </tr> <tr> <td id="L22" class="blob-num js-line-number" data-line-number="22"></td> <td id="LC22" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> - The name of the package to query</span></td> </tr> <tr> <td id="L23" class="blob-num js-line-number" data-line-number="23"></td> <td id="LC23" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> required: true</span></td> </tr> <tr> <td id="L24" class="blob-num js-line-number" data-line-number="24"></td> <td id="LC24" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> state:</span></td> </tr> <tr> <td id="L25" class="blob-num js-line-number" data-line-number="25"></td> <td id="LC25" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> description:</span></td> </tr> <tr> <td id="L26" class="blob-num js-line-number" data-line-number="26"></td> <td id="LC26" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> - Whether the package is supposed to be installed or not</span></td> </tr> <tr> <td id="L27" class="blob-num js-line-number" data-line-number="27"></td> <td id="LC27" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> choices: [present, absent]</span></td> </tr> <tr> <td id="L28" class="blob-num js-line-number" data-line-number="28"></td> <td id="LC28" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> default: present</span></td> </tr> <tr> <td id="L29" class="blob-num js-line-number" data-line-number="29"></td> <td id="LC29" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L30" class="blob-num js-line-number" data-line-number="30"></td> <td id="LC30" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L31" class="blob-num js-line-number" data-line-number="31"></td> <td id="LC31" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">EXAMPLES</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L32" class="blob-num js-line-number" data-line-number="32"></td> <td id="LC32" class="blob-code blob-code-inner js-file-line"><span class="pl-s">- rpm_q: name=ansible state=present</span></td> </tr> <tr> <td id="L33" class="blob-num js-line-number" data-line-number="33"></td> <td id="LC33" class="blob-code blob-code-inner js-file-line"><span class="pl-s">- rpm_q: name=ansible state=absent</span></td> </tr> <tr> <td id="L34" class="blob-num js-line-number" data-line-number="34"></td> <td id="LC34" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L35" class="blob-num js-line-number" data-line-number="35"></td> <td id="LC35" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L36" class="blob-num js-line-number" data-line-number="36"></td> <td id="LC36" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">RPM_BINARY</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">&#39;</span>/bin/rpm<span class="pl-pds">&#39;</span></span></td> </tr> <tr> <td id="L37" class="blob-num js-line-number" data-line-number="37"></td> <td id="LC37" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L38" class="blob-num js-line-number" data-line-number="38"></td> <td id="LC38" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">main</span>():</td> </tr> <tr> <td id="L39" class="blob-num js-line-number" data-line-number="39"></td> <td id="LC39" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L40" class="blob-num js-line-number" data-line-number="40"></td> <td id="LC40" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Checks rpm -q for the named package and returns the installed packages</span></td> </tr> <tr> <td id="L41" class="blob-num js-line-number" data-line-number="41"></td> <td id="LC41" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> or None if not installed.</span></td> </tr> <tr> <td id="L42" class="blob-num js-line-number" data-line-number="42"></td> <td id="LC42" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">&quot;&quot;&quot;</span></span></td> </tr> <tr> <td id="L43" class="blob-num js-line-number" data-line-number="43"></td> <td id="LC43" class="blob-code blob-code-inner js-file-line"> module <span class="pl-k">=</span> AnsibleModule(</td> </tr> <tr> <td id="L44" class="blob-num js-line-number" data-line-number="44"></td> <td id="LC44" class="blob-code blob-code-inner js-file-line"> <span class="pl-v">argument_spec</span><span class="pl-k">=</span><span class="pl-c1">dict</span>(</td> </tr> <tr> <td id="L45" class="blob-num js-line-number" data-line-number="45"></td> <td id="LC45" class="blob-code blob-code-inner js-file-line"> <span class="pl-v">name</span><span class="pl-k">=</span><span class="pl-c1">dict</span>(<span class="pl-v">required</span><span class="pl-k">=</span><span class="pl-c1">True</span>),</td> </tr> <tr> <td id="L46" class="blob-num js-line-number" data-line-number="46"></td> <td id="LC46" class="blob-code blob-code-inner js-file-line"> <span class="pl-v">state</span><span class="pl-k">=</span><span class="pl-c1">dict</span>(<span class="pl-v">default</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">&#39;</span>present<span class="pl-pds">&#39;</span></span>, <span class="pl-v">choices</span><span class="pl-k">=</span>[<span class="pl-s"><span class="pl-pds">&#39;</span>present<span class="pl-pds">&#39;</span></span>, <span class="pl-s"><span class="pl-pds">&#39;</span>absent<span class="pl-pds">&#39;</span></span>])</td> </tr> <tr> <td id="L47" class="blob-num js-line-number" data-line-number="47"></td> <td id="LC47" class="blob-code blob-code-inner js-file-line"> ),</td> </tr> <tr> <td id="L48" class="blob-num js-line-number" data-line-number="48"></td> <td id="LC48" class="blob-code blob-code-inner js-file-line"> <span class="pl-v">supports_check_mode</span><span class="pl-k">=</span><span class="pl-c1">True</span></td> </tr> <tr> <td id="L49" class="blob-num js-line-number" data-line-number="49"></td> <td id="LC49" class="blob-code blob-code-inner js-file-line"> )</td> </tr> <tr> <td id="L50" class="blob-num js-line-number" data-line-number="50"></td> <td id="LC50" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L51" class="blob-num js-line-number" data-line-number="51"></td> <td id="LC51" class="blob-code blob-code-inner js-file-line"> name <span class="pl-k">=</span> module.params[<span class="pl-s"><span class="pl-pds">&#39;</span>name<span class="pl-pds">&#39;</span></span>]</td> </tr> <tr> <td id="L52" class="blob-num js-line-number" data-line-number="52"></td> <td id="LC52" class="blob-code blob-code-inner js-file-line"> state <span class="pl-k">=</span> module.params[<span class="pl-s"><span class="pl-pds">&#39;</span>state<span class="pl-pds">&#39;</span></span>]</td> </tr> <tr> <td id="L53" class="blob-num js-line-number" data-line-number="53"></td> <td id="LC53" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L54" class="blob-num js-line-number" data-line-number="54"></td> <td id="LC54" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># pylint: disable=invalid-name</span></td> </tr> <tr> <td id="L55" class="blob-num js-line-number" data-line-number="55"></td> <td id="LC55" class="blob-code blob-code-inner js-file-line"> rc, out, err <span class="pl-k">=</span> module.run_command([<span class="pl-c1">RPM_BINARY</span>, <span class="pl-s"><span class="pl-pds">&#39;</span>-q<span class="pl-pds">&#39;</span></span>, name])</td> </tr> <tr> <td id="L56" class="blob-num js-line-number" data-line-number="56"></td> <td id="LC56" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L57" class="blob-num js-line-number" data-line-number="57"></td> <td id="LC57" class="blob-code blob-code-inner js-file-line"> installed <span class="pl-k">=</span> out.rstrip(<span class="pl-s"><span class="pl-pds">&#39;</span><span class="pl-cce">\n</span><span class="pl-pds">&#39;</span></span>).split(<span class="pl-s"><span class="pl-pds">&#39;</span><span class="pl-cce">\n</span><span class="pl-pds">&#39;</span></span>)</td> </tr> <tr> <td id="L58" class="blob-num js-line-number" data-line-number="58"></td> <td id="LC58" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L59" class="blob-num js-line-number" data-line-number="59"></td> <td id="LC59" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> rc <span class="pl-k">!=</span> <span class="pl-c1">0</span>:</td> </tr> <tr> <td id="L60" class="blob-num js-line-number" data-line-number="60"></td> <td id="LC60" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> state <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">&#39;</span>present<span class="pl-pds">&#39;</span></span>:</td> </tr> <tr> <td id="L61" class="blob-num js-line-number" data-line-number="61"></td> <td id="LC61" class="blob-code blob-code-inner js-file-line"> module.fail_json(<span class="pl-v">msg</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">&quot;</span><span class="pl-c1">%s</span> is not installed<span class="pl-pds">&quot;</span></span> <span class="pl-k">%</span> name, <span class="pl-v">stdout</span><span class="pl-k">=</span>out, <span class="pl-v">stderr</span><span class="pl-k">=</span>err, <span class="pl-v">rc</span><span class="pl-k">=</span>rc)</td> </tr> <tr> <td id="L62" class="blob-num js-line-number" data-line-number="62"></td> <td id="LC62" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">else</span>:</td> </tr> <tr> <td id="L63" class="blob-num js-line-number" data-line-number="63"></td> <td id="LC63" class="blob-code blob-code-inner js-file-line"> module.exit_json(<span class="pl-v">changed</span><span class="pl-k">=</span><span class="pl-c1">False</span>)</td> </tr> <tr> <td id="L64" class="blob-num js-line-number" data-line-number="64"></td> <td id="LC64" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> state <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">&#39;</span>present<span class="pl-pds">&#39;</span></span>:</td> </tr> <tr> <td id="L65" class="blob-num js-line-number" data-line-number="65"></td> <td id="LC65" class="blob-code blob-code-inner js-file-line"> module.exit_json(<span class="pl-v">changed</span><span class="pl-k">=</span><span class="pl-c1">False</span>, <span class="pl-v">installed_versions</span><span class="pl-k">=</span>installed)</td> </tr> <tr> <td id="L66" class="blob-num js-line-number" data-line-number="66"></td> <td id="LC66" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">else</span>:</td> </tr> <tr> <td id="L67" class="blob-num js-line-number" data-line-number="67"></td> <td id="LC67" class="blob-code blob-code-inner js-file-line"> module.fail_json(<span class="pl-v">msg</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">&quot;</span><span class="pl-c1">%s</span> is installed<span class="pl-pds">&quot;</span></span>, <span class="pl-v">installed_versions</span><span class="pl-k">=</span>installed)</td> </tr> <tr> <td id="L68" class="blob-num js-line-number" data-line-number="68"></td> <td id="LC68" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L69" class="blob-num js-line-number" data-line-number="69"></td> <td id="LC69" class="blob-code blob-code-inner js-file-line"><span class="pl-k">if</span> <span class="pl-c1">__name__</span> <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">&#39;</span>__main__<span class="pl-pds">&#39;</span></span>:</td> </tr> <tr> <td id="L70" class="blob-num js-line-number" data-line-number="70"></td> <td id="LC70" class="blob-code blob-code-inner js-file-line"> main()</td> </tr> </table> </div> </div> <button type="button" data-facebox="#jump-to-line" data-facebox-class="linejump" data-hotkey="l" class="d-none">Jump to Line</button> <div id="jump-to-line" style="display:none"> <!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="" class="js-jump-to-line-form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div> <input class="form-control linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" aria-label="Jump to line" autofocus> <button type="submit" class="btn">Go</button> </form></div> </div> <div class="modal-backdrop js-touch-events"></div> </div> </div> </div> </div> <div class="container site-footer-container"> <div class="site-footer" role="contentinfo"> <ul class="site-footer-links float-right"> <li><a href="https://github.com/contact" data-ga-click="Footer, go to contact, text:contact">Contact GitHub</a></li> <li><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li> <li><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li> <li><a href="https://shop.github.com" data-ga-click="Footer, go to shop, text:shop">Shop</a></li> <li><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li> <li><a href="https://github.com/about" data-ga-click="Footer, go to about, text:about">About</a></li> </ul> <a href="https://github.com" aria-label="Homepage" class="site-footer-mark" title="GitHub"> <svg aria-hidden="true" class="octicon octicon-mark-github" height="24" version="1.1" viewBox="0 0 16 16" width="24"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg> </a> <ul class="site-footer-links"> <li>&copy; 2016 <span title="0.05330s from github-fe164-cp1-prd.iad.github.net">GitHub</span>, Inc.</li> <li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li> <li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li> <li><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li> <li><a href="https://status.github.com/" data-ga-click="Footer, go to status, text:status">Status</a></li> <li><a href="https://help.github.com" data-ga-click="Footer, go to help, text:help">Help</a></li> </ul> </div> </div> <div id="ajax-error-message" class="ajax-error-message flash flash-error"> <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg> <button type="button" class="flash-close js-flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg> </button> You can't perform that action at this time. </div> <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/compat-40e365359d1c4db1e36a55be458e60f2b7c24d58b5a00ae13398480e7ba768e0.js"></script> <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/frameworks-88471af1fec40ff9418efbe2ddd15b6896af8d772f8179004c254dffc25ea490.js"></script> <script async="async" crossorigin="anonymous" src="https://assets-cdn.github.com/assets/github-c4177fc28385bc04fc26a831fe1f9d69d5d7a3242566683a9daac147e1280847.js"></script> <div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner d-none"> <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg> <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span> <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span> </div> <div class="facebox" id="facebox" style="display:none;"> <div class="facebox-popup"> <div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description"> </div> <button type="button" class="facebox-close js-facebox-close" aria-label="Close modal"> <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg> </button> </div> </div> </body> </html>
apache-2.0
[ 4388, 199, 11230, 16556, 3517, 30, 199, 28, 1360, 6339, 628, 287, 2, 1021, 9287, 30, 523, 665, 2993, 2403, 628, 974, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 3, 24209, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 4675, 3, 909, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 785, 3, 9772, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 6934, 3, 4690, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 2913, 3, 1743, 272, 665, 2024, 5960, 534, 1624, 13, 24, 8423, 1362, 339, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 32037, 13, 2905, 1229, 1643, 708, 66, 25, 70, 845, 65, 14866, 983, 12289, 68, 18, 16845, 25, 26520, 65, 30605, 65, 10216, 15670, 1079, 68, 13905, 3624, 25, 301, 16, 68, 22, 667, 27697, 66, 2259, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 272, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 5031, 13, 66, 1229, 67, 22, 65, 18, 697, 24, 67, 11062, 14866, 65, 1257, 68, 821, 1165, 667, 16, 66, 14271, 68, 1349, 1184, 68, 1276, 7984, 25, 66, 22, 66, 1046, 68, 1349, 67, 16706, 4489, 24, 2501, 15154, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 17635, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 2124, 13, 24554, 2501, 2333, 65, 21, 69, 16, 3624, 19, 70, 25, 2260, 1079, 66, 25, 69, 25, 69, 25395, 18, 67, 22402, 1342, 70, 22, 68, 2259, 66, 25, 69, 3624, 30028, 66, 2760, 69, 21, 68, 9570, 556, 17, 66, 32258, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 1362, 339, 665, 1073, 465, 628, 1579, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 32037, 13, 1299, 26012, 2756, 17, 27848, 2167, 556, 2635, 1085, 2829, 1235, 18, 15389, 1046, 66, 22, 12031, 2756, 24, 68, 19518, 70, 24, 10699, 7979, 67, 8306, 23425, 67, 821, 4489, 26410, 14, 3596, 2, 4668, 628, 28795, 2, 7082, 2286, 665, 1073, 465, 628, 1579, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 5031, 13, 67, 2953, 1138, 3003, 1651, 13846, 3776, 966, 3003, 1479, 65, 24, 2192, 771, 17, 70, 25, 68, 1876, 68, 21, 68, 23, 65, 12744, 28317, 25689, 65, 25, 983, 645, 11160, 69, 713, 1257, 15883, 14, 3596, 2, 4668, 628, 28795, 2, 7082, 339, 665, 2024, 1455, 13, 20146, 628, 56, 13, 21659, 13, 25921, 2, 1564, 628, 4332, 29, 5173, 1743, 272, 665, 2024, 1455, 13, 20146, 628, 2714, 13, 8493, 2, 1564, 628, 287, 1743, 272, 665, 2024, 536, 628, 25484, 2, 1564, 628, 2063, 29, 1782, 13, 2063, 1743, 2286, 665, 1213, 30, 22858, 13, 4853, 15, 14191, 63, 81, 14, 647, 737, 5288, 22405, 116, 1551, 4723, 15, 22858, 13, 4853, 22405, 116, 25141, 1108, 1213, 30, 272, 665, 1073, 4668, 628, 1733, 2, 730, 628, 3578, 15, 27285, 1802, 11, 1652, 2, 4369, 9555, 27285, 14, 1652, 2, 2538, 628, 14686, 15338, 1743, 272, 665, 1073, 4668, 628, 31515, 13, 4677, 2, 4369, 628, 2859, 921, 5031, 14, 957, 15, 2327, 1907, 328, 388, 14, 4524, 2, 2538, 628, 14686, 15338, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 1641, 88, 1641, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 1641, 88, 1641, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2259, 88, 2259, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2259, 88, 2259, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2819, 88, 2819, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2819, 88, 2819, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2114, 88, 2114, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2114, 88, 2114, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 7636, 88, 7636, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 7636, 88, 7636, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 6708, 88, 6708, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 6708, 88, 6708, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 9862, 88, 9862, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 9862, 88, 9862, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 11024, 88, 11024, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 11024, 88, 11024, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 7663, 88, 7663, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 7663, 88, 7663, 14, 4524, 1743, 272, 665, 2024, 3324, 628, 4675, 26, 571, 63, 344, 2, 1564, 628, 1079, 614, 2006, 13254, 1082, 12664, 1651, 1743, 2541, 665, 2024, 1564, 628, 2859, 921, 1214, 292, 4291, 16, 14, 5031, 751, 1317, 14, 957, 15, 85, 15, 1965, 10034, 23, 31, 86, 29, 19, 6, 5282, 27, 83, 29, 5303, 2, 536, 628, 13746, 26, 1569, 26, 2164, 2, 21671, 2024, 1564, 628, 32, 5031, 2, 536, 628, 13746, 26, 2124, 2, 21671, 2024, 1564, 628, 4705, 2, 536, 628, 13746, 26, 5841, 2, 21671, 2024, 1564, 628, 22858, 15, 22858, 13, 4853, 2, 536, 628, 13746, 26, 1213, 2, 21671, 2024, 1564, 628, 22858, 13, 4853, 446, 3232, 14379, 2622, 5495, 2, 536, 628, 13746, 26, 1802, 2, 7082, 489, 665, 2024, 1564, 628, 2859, 921, 1214, 292, 4291, 16, 14, 5031, 751, 1317, 14 ]
[ 199, 11230, 16556, 3517, 30, 199, 28, 1360, 6339, 628, 287, 2, 1021, 9287, 30, 523, 665, 2993, 2403, 628, 974, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 3, 24209, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 4675, 3, 909, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 785, 3, 9772, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 6934, 3, 4690, 26, 1455, 921, 974, 80, 14, 278, 15, 561, 15, 2913, 3, 1743, 272, 665, 2024, 5960, 534, 1624, 13, 24, 8423, 1362, 339, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 32037, 13, 2905, 1229, 1643, 708, 66, 25, 70, 845, 65, 14866, 983, 12289, 68, 18, 16845, 25, 26520, 65, 30605, 65, 10216, 15670, 1079, 68, 13905, 3624, 25, 301, 16, 68, 22, 667, 27697, 66, 2259, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 272, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 5031, 13, 66, 1229, 67, 22, 65, 18, 697, 24, 67, 11062, 14866, 65, 1257, 68, 821, 1165, 667, 16, 66, 14271, 68, 1349, 1184, 68, 1276, 7984, 25, 66, 22, 66, 1046, 68, 1349, 67, 16706, 4489, 24, 2501, 15154, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 17635, 665, 1073, 8059, 6493, 628, 12628, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 2124, 13, 24554, 2501, 2333, 65, 21, 69, 16, 3624, 19, 70, 25, 2260, 1079, 66, 25, 69, 25, 69, 25395, 18, 67, 22402, 1342, 70, 22, 68, 2259, 66, 25, 69, 3624, 30028, 66, 2760, 69, 21, 68, 9570, 556, 17, 66, 32258, 14, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 1362, 339, 665, 1073, 465, 628, 1579, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 32037, 13, 1299, 26012, 2756, 17, 27848, 2167, 556, 2635, 1085, 2829, 1235, 18, 15389, 1046, 66, 22, 12031, 2756, 24, 68, 19518, 70, 24, 10699, 7979, 67, 8306, 23425, 67, 821, 4489, 26410, 14, 3596, 2, 4668, 628, 28795, 2, 7082, 2286, 665, 1073, 465, 628, 1579, 2, 4369, 628, 2859, 921, 12186, 13, 23982, 14, 5031, 14, 957, 15, 12186, 15, 5031, 13, 67, 2953, 1138, 3003, 1651, 13846, 3776, 966, 3003, 1479, 65, 24, 2192, 771, 17, 70, 25, 68, 1876, 68, 21, 68, 23, 65, 12744, 28317, 25689, 65, 25, 983, 645, 11160, 69, 713, 1257, 15883, 14, 3596, 2, 4668, 628, 28795, 2, 7082, 339, 665, 2024, 1455, 13, 20146, 628, 56, 13, 21659, 13, 25921, 2, 1564, 628, 4332, 29, 5173, 1743, 272, 665, 2024, 1455, 13, 20146, 628, 2714, 13, 8493, 2, 1564, 628, 287, 1743, 272, 665, 2024, 536, 628, 25484, 2, 1564, 628, 2063, 29, 1782, 13, 2063, 1743, 2286, 665, 1213, 30, 22858, 13, 4853, 15, 14191, 63, 81, 14, 647, 737, 5288, 22405, 116, 1551, 4723, 15, 22858, 13, 4853, 22405, 116, 25141, 1108, 1213, 30, 272, 665, 1073, 4668, 628, 1733, 2, 730, 628, 3578, 15, 27285, 1802, 11, 1652, 2, 4369, 9555, 27285, 14, 1652, 2, 2538, 628, 14686, 15338, 1743, 272, 665, 1073, 4668, 628, 31515, 13, 4677, 2, 4369, 628, 2859, 921, 5031, 14, 957, 15, 2327, 1907, 328, 388, 14, 4524, 2, 2538, 628, 14686, 15338, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 1641, 88, 1641, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 1641, 88, 1641, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2259, 88, 2259, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2259, 88, 2259, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2819, 88, 2819, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2819, 88, 2819, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 2114, 88, 2114, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 2114, 88, 2114, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 7636, 88, 7636, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 7636, 88, 7636, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 6708, 88, 6708, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 6708, 88, 6708, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 9862, 88, 9862, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 9862, 88, 9862, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 11024, 88, 11024, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 11024, 88, 11024, 14, 4524, 1743, 272, 665, 1073, 4668, 628, 12820, 13, 12376, 13, 4677, 2, 10627, 628, 7663, 88, 7663, 2, 4369, 9555, 12820, 13, 12376, 13, 4677, 13, 7663, 88, 7663, 14, 4524, 1743, 272, 665, 2024, 3324, 628, 4675, 26, 571, 63, 344, 2, 1564, 628, 1079, 614, 2006, 13254, 1082, 12664, 1651, 1743, 2541, 665, 2024, 1564, 628, 2859, 921, 1214, 292, 4291, 16, 14, 5031, 751, 1317, 14, 957, 15, 85, 15, 1965, 10034, 23, 31, 86, 29, 19, 6, 5282, 27, 83, 29, 5303, 2, 536, 628, 13746, 26, 1569, 26, 2164, 2, 21671, 2024, 1564, 628, 32, 5031, 2, 536, 628, 13746, 26, 2124, 2, 21671, 2024, 1564, 628, 4705, 2, 536, 628, 13746, 26, 5841, 2, 21671, 2024, 1564, 628, 22858, 15, 22858, 13, 4853, 2, 536, 628, 13746, 26, 1213, 2, 21671, 2024, 1564, 628, 22858, 13, 4853, 446, 3232, 14379, 2622, 5495, 2, 536, 628, 13746, 26, 1802, 2, 7082, 489, 665, 2024, 1564, 628, 2859, 921, 1214, 292, 4291, 16, 14, 5031, 751, 1317, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
asajeffrey/servo
tests/wpt/web-platform-tests/tools/third_party/pytest/src/_pytest/setuponly.py
32
2623
from __future__ import absolute_import, division, print_function import pytest import sys def pytest_addoption(parser): group = parser.getgroup("debugconfig") group.addoption( "--setuponly", "--setup-only", action="store_true", help="only setup fixtures, do not execute tests.", ) group.addoption( "--setupshow", "--setup-show", action="store_true", help="show setup of fixtures while executing tests.", ) @pytest.hookimpl(hookwrapper=True) def pytest_fixture_setup(fixturedef, request): yield config = request.config if config.option.setupshow: if hasattr(request, "param"): # Save the fixture parameter so ._show_fixture_action() can # display it now and during the teardown (in .finish()). if fixturedef.ids: if callable(fixturedef.ids): fixturedef.cached_param = fixturedef.ids(request.param) else: fixturedef.cached_param = fixturedef.ids[request.param_index] else: fixturedef.cached_param = request.param _show_fixture_action(fixturedef, "SETUP") def pytest_fixture_post_finalizer(fixturedef): if hasattr(fixturedef, "cached_result"): config = fixturedef._fixturemanager.config if config.option.setupshow: _show_fixture_action(fixturedef, "TEARDOWN") if hasattr(fixturedef, "cached_param"): del fixturedef.cached_param def _show_fixture_action(fixturedef, msg): config = fixturedef._fixturemanager.config capman = config.pluginmanager.getplugin("capturemanager") if capman: out, err = capman.suspend_global_capture() tw = config.get_terminal_writer() tw.line() tw.write(" " * 2 * fixturedef.scopenum) tw.write( "{step} {scope} {fixture}".format( step=msg.ljust(8), # align the output to TEARDOWN scope=fixturedef.scope[0].upper(), fixture=fixturedef.argname, ) ) if msg == "SETUP": deps = sorted(arg for arg in fixturedef.argnames if arg != "request") if deps: tw.write(" (fixtures used: {})".format(", ".join(deps))) if hasattr(fixturedef, "cached_param"): tw.write("[{}]".format(fixturedef.cached_param)) if capman: capman.resume_global_capture() sys.stdout.write(out) sys.stderr.write(err) @pytest.hookimpl(tryfirst=True) def pytest_cmdline_main(config): if config.option.setuponly: config.option.setupshow = True
mpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 646, 984, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1572, 275, 1798, 14, 362, 923, 480, 1757, 888, 531, 272, 1572, 14, 525, 1422, 8, 267, 4320, 2758, 2118, 401, 267, 4320, 2758, 13, 2118, 401, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 2118, 3272, 15188, 12, 886, 440, 5341, 2295, 4765, 272, 776, 272, 1572, 14, 525, 1422, 8, 267, 4320, 2758, 2384, 401, 267, 4320, 2758, 13, 2384, 401, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 2384, 3272, 402, 15188, 1830, 14043, 2295, 4765, 272, 776, 421, 199, 32, 4462, 14, 3664, 5472, 8, 3664, 5029, 29, 549, 9, 199, 318, 4613, 63, 5997, 63, 2758, 8, 5997, 318, 12, 1056, 304, 272, 1995, 272, 1101, 275, 1056, 14, 888, 272, 340, 1101, 14, 1422, 14, 2758, 2384, 26, 267, 340, 2688, 8, 1069, 12, 298, 635, 2349, 288, 327, 11063, 314, 10949, 2725, 880, 13653, 2384, 63, 5997, 63, 1287, 342, 883, 288, 327, 2929, 652, 3063, 436, 5309, 314, 17558, 334, 262, 1275, 8192, 8801, 288, 340, 10949, 318, 14, 1580, 26, 355, 340, 4550, 8, 5997, 318, 14, 1580, 304, 490, 10949, 318, 14, 5245, 63, 635, 275, 10949, 318, 14, 1580, 8, 1069, 14, 635, 9, 355, 587, 26, 490, 10949, 318, 14, 5245, 63, 635, 275, 10949, 318, 14, 1580, 59, 1069, 14, 635, 63, 1080, 61, 288, 587, 26, 355, 10949, 318, 14, 5245, 63, 635, 275, 1056, 14, 635, 267, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 298, 20836, 531, 421, 199, 318, 4613, 63, 5997, 63, 1932, 63, 30092, 8, 5997, 318, 304, 272, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 1099, 2349, 267, 1101, 275, 10949, 318, 423, 5997, 2609, 14, 888, 267, 340, 1101, 14, 1422, 14, 2758, 2384, 26, 288, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 298, 3727, 689, 8819, 531, 288, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 635, 2349, 355, 2150, 10949, 318, 14, 5245, 63, 635, 421, 199, 318, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 1499, 304, 272, 1101, 275, 10949, 318, 423, 5997, 2609, 14, 888, 272, 4021, 1237, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12685, 2609, 531, 272, 340, 4021, 1237, 26, 267, 734, 12, 2329, 275, 4021, 1237, 14, 14480, 63, 2966, 63, 12685, 342, 339, 8900, 275, 1101, 14, 362, 63, 12010, 63, 5491, 342, 272, 8900, 14, 604, 342, 272, 8900, 14, 952, 480, 298, 627, 499, 627, 10949, 318, 14, 20845, 897, 453, 9, 272, 8900, 14, 952, 8, 267, 5310, 2926, 93, 469, 2645, 93, 469, 5997, 5469, 908, 8, 288, 3650, 29, 1328, 14, 19996, 8, 24, 395, 221, 327, 6998, 314, 1072, 370, 10686, 689, 8819, 288, 4194, 29, 5997, 318, 14, 2645, 59, 16, 1055, 4142, 1062, 288, 10949, 29, 5997, 318, 14, 1273, 354, 12, 267, 776, 272, 776, 339, 340, 1499, 508, 298, 20836, 582, 267, 10140, 275, 3355, 8, 1273, 367, 1680, 315, 10949, 318, 14, 1273, 1247, 340, 1680, 1137, 298, 1069, 531, 267, 340, 10140, 26, 288, 8900, 14, 952, 480, 334, 8769, 1202, 26, 5009, 1674, 908, 11854, 3680, 904, 8, 5846, 1724, 339, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 635, 2349, 267, 8900, 14, 952, 10994, 27922, 1674, 908, 8, 5997, 318, 14, 5245, 63, 635, 430, 339, 340, 4021, 1237, 26, 267, 4021, 1237, 14, 9964, 63, 2966, 63, 12685, 342, 267, 984, 14, 2703, 14, 952, 8, 548, 9, 267, 984, 14, 3083, 14, 952, 8, 1508, 9, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2246, 29, 549, 9, 199, 318, 4613, 63, 15612, 63, 973, 8, 888, 304, 272, 340, 1101, 14, 1422, 14, 2758, 2118, 26, 267, 1101, 14, 1422, 14, 2758, 2384, 275, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 4613, 199, 646, 984, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 1572, 275, 1798, 14, 362, 923, 480, 1757, 888, 531, 272, 1572, 14, 525, 1422, 8, 267, 4320, 2758, 2118, 401, 267, 4320, 2758, 13, 2118, 401, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 2118, 3272, 15188, 12, 886, 440, 5341, 2295, 4765, 272, 776, 272, 1572, 14, 525, 1422, 8, 267, 4320, 2758, 2384, 401, 267, 4320, 2758, 13, 2384, 401, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 2384, 3272, 402, 15188, 1830, 14043, 2295, 4765, 272, 776, 421, 199, 32, 4462, 14, 3664, 5472, 8, 3664, 5029, 29, 549, 9, 199, 318, 4613, 63, 5997, 63, 2758, 8, 5997, 318, 12, 1056, 304, 272, 1995, 272, 1101, 275, 1056, 14, 888, 272, 340, 1101, 14, 1422, 14, 2758, 2384, 26, 267, 340, 2688, 8, 1069, 12, 298, 635, 2349, 288, 327, 11063, 314, 10949, 2725, 880, 13653, 2384, 63, 5997, 63, 1287, 342, 883, 288, 327, 2929, 652, 3063, 436, 5309, 314, 17558, 334, 262, 1275, 8192, 8801, 288, 340, 10949, 318, 14, 1580, 26, 355, 340, 4550, 8, 5997, 318, 14, 1580, 304, 490, 10949, 318, 14, 5245, 63, 635, 275, 10949, 318, 14, 1580, 8, 1069, 14, 635, 9, 355, 587, 26, 490, 10949, 318, 14, 5245, 63, 635, 275, 10949, 318, 14, 1580, 59, 1069, 14, 635, 63, 1080, 61, 288, 587, 26, 355, 10949, 318, 14, 5245, 63, 635, 275, 1056, 14, 635, 267, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 298, 20836, 531, 421, 199, 318, 4613, 63, 5997, 63, 1932, 63, 30092, 8, 5997, 318, 304, 272, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 1099, 2349, 267, 1101, 275, 10949, 318, 423, 5997, 2609, 14, 888, 267, 340, 1101, 14, 1422, 14, 2758, 2384, 26, 288, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 298, 3727, 689, 8819, 531, 288, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 635, 2349, 355, 2150, 10949, 318, 14, 5245, 63, 635, 421, 199, 318, 485, 2384, 63, 5997, 63, 1287, 8, 5997, 318, 12, 1499, 304, 272, 1101, 275, 10949, 318, 423, 5997, 2609, 14, 888, 272, 4021, 1237, 275, 1101, 14, 2718, 2609, 14, 362, 2718, 480, 12685, 2609, 531, 272, 340, 4021, 1237, 26, 267, 734, 12, 2329, 275, 4021, 1237, 14, 14480, 63, 2966, 63, 12685, 342, 339, 8900, 275, 1101, 14, 362, 63, 12010, 63, 5491, 342, 272, 8900, 14, 604, 342, 272, 8900, 14, 952, 480, 298, 627, 499, 627, 10949, 318, 14, 20845, 897, 453, 9, 272, 8900, 14, 952, 8, 267, 5310, 2926, 93, 469, 2645, 93, 469, 5997, 5469, 908, 8, 288, 3650, 29, 1328, 14, 19996, 8, 24, 395, 221, 327, 6998, 314, 1072, 370, 10686, 689, 8819, 288, 4194, 29, 5997, 318, 14, 2645, 59, 16, 1055, 4142, 1062, 288, 10949, 29, 5997, 318, 14, 1273, 354, 12, 267, 776, 272, 776, 339, 340, 1499, 508, 298, 20836, 582, 267, 10140, 275, 3355, 8, 1273, 367, 1680, 315, 10949, 318, 14, 1273, 1247, 340, 1680, 1137, 298, 1069, 531, 267, 340, 10140, 26, 288, 8900, 14, 952, 480, 334, 8769, 1202, 26, 5009, 1674, 908, 11854, 3680, 904, 8, 5846, 1724, 339, 340, 2688, 8, 5997, 318, 12, 298, 5245, 63, 635, 2349, 267, 8900, 14, 952, 10994, 27922, 1674, 908, 8, 5997, 318, 14, 5245, 63, 635, 430, 339, 340, 4021, 1237, 26, 267, 4021, 1237, 14, 9964, 63, 2966, 63, 12685, 342, 267, 984, 14, 2703, 14, 952, 8, 548, 9, 267, 984, 14, 3083, 14, 952, 8, 1508, 9, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2246, 29, 549, 9, 199, 318, 4613, 63, 15612, 63, 973, 8, 888, 304, 272, 340, 1101, 14, 1422, 14, 2758, 2118, 26, 267, 1101, 14, 1422, 14, 2758, 2384, 275, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vamsirajendra/nupic
tests/integration/nupic/opf/opf_checkpoint_test/experiments/non_temporal_multi_step/b/description.py
76
2102
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2011-2015, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- ## This file defines parameters for a prediction experiment. ############################################################################### # IMPORTANT!!! # This params file is dynamically generated by the RunExperimentPermutations # script. Any changes made manually will be over-written the next time # RunExperimentPermutations is run!!! ############################################################################### from nupic.frameworks.opf.expdescriptionhelpers import importBaseDescription # the sub-experiment configuration config ={ 'modelParams' : {'sensorParams': {'encoders': {u'c0_timeOfDay': None, u'c0_dayOfWeek': None, u'c1': {'name': 'c1', 'clipInput': True, 'n': 275, 'fieldname': 'c1', 'w': 21, 'type': 'AdaptiveScalarEncoder'}, u'c0_weekend': None}}, 'spParams': {'synPermInactiveDec': 0.052500000000000005}, 'tpParams': {'minThreshold': 11, 'activationThreshold': 14, 'pamLength': 3}, 'clParams': {'alpha': 0.050050000000000004}}, 'firstRecord': 250, 'lastRecord': 500, } mod = importBaseDescription('../base.py', config) locals().update(mod.__dict__)
agpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 7760, 13, 7806, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 11490, 199, 3, 13293, 5025, 2596, 1441, 21512, 199, 3, 961, 1862, 570, 365, 18774, 4046, 701, 314, 3378, 20781, 2623, 15974, 199, 3, 2884, 14, 6184, 4493, 6326, 10250, 911, 506, 1806, 13, 8938, 314, 2163, 900, 199, 3, 3378, 20781, 2623, 15974, 365, 1255, 21512, 199, 11490, 421, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 91, 523, 283, 1238, 6007, 7, 520, 791, 8956, 6007, 356, 791, 9347, 83, 356, 469, 85, 7, 67, 16, 63, 521, 3466, 12631, 356, 488, 12, 399, 7, 67, 16, 63, 2977, 3466, 20995, 356, 488, 12, 399, 7, 67, 17, 356, 791, 354, 356, 283, 67, 17, 297, 283, 7548, 3205, 356, 715, 12, 283, 78, 356, 499, 2194, 12, 283, 13646, 356, 283, 67, 17, 297, 283, 87, 356, 7829, 12, 283, 466, 356, 283, 2767, 22430, 13090, 6679, 2267, 399, 7, 67, 16, 63, 6419, 500, 356, 488, 13459, 283, 681, 6007, 356, 791, 9466, 23554, 31047, 8584, 356, 378, 14, 1717, 821, 15672, 1717, 1386, 283, 683, 6007, 356, 791, 827, 12109, 356, 4119, 12, 283, 12312, 12109, 356, 4329, 12, 283, 28024, 4625, 356, 650, 1386, 283, 429, 6007, 356, 791, 4468, 356, 378, 14, 1717, 7972, 15672, 20, 13459, 12244, 283, 2246, 5433, 356, 16074, 12, 523, 283, 2019, 5433, 356, 6891, 12, 199, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 1095, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 7760, 13, 7806, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 11490, 199, 3, 13293, 5025, 2596, 1441, 21512, 199, 3, 961, 1862, 570, 365, 18774, 4046, 701, 314, 3378, 20781, 2623, 15974, 199, 3, 2884, 14, 6184, 4493, 6326, 10250, 911, 506, 1806, 13, 8938, 314, 2163, 900, 199, 3, 3378, 20781, 2623, 15974, 365, 1255, 21512, 199, 11490, 421, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 91, 523, 283, 1238, 6007, 7, 520, 791, 8956, 6007, 356, 791, 9347, 83, 356, 469, 85, 7, 67, 16, 63, 521, 3466, 12631, 356, 488, 12, 399, 7, 67, 16, 63, 2977, 3466, 20995, 356, 488, 12, 399, 7, 67, 17, 356, 791, 354, 356, 283, 67, 17, 297, 283, 7548, 3205, 356, 715, 12, 283, 78, 356, 499, 2194, 12, 283, 13646, 356, 283, 67, 17, 297, 283, 87, 356, 7829, 12, 283, 466, 356, 283, 2767, 22430, 13090, 6679, 2267, 399, 7, 67, 16, 63, 6419, 500, 356, 488, 13459, 283, 681, 6007, 356, 791, 9466, 23554, 31047, 8584, 356, 378, 14, 1717, 821, 15672, 1717, 1386, 283, 683, 6007, 356, 791, 827, 12109, 356, 4119, 12, 283, 12312, 12109, 356, 4329, 12, 283, 28024, 4625, 356, 650, 1386, 283, 429, 6007, 356, 791, 4468, 356, 378, 14, 1717, 7972, 15672, 20, 13459, 12244, 283, 2246, 5433, 356, 16074, 12, 523, 283, 2019, 5433, 356, 6891, 12, 199, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 1095, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Sentient07/scikit-learn
sklearn/tests/test_grid_search.py
27
29492
""" Testing for grid search module (sklearn.grid_search) """ from collections import Iterable, Sized from sklearn.externals.six.moves import cStringIO as StringIO from sklearn.externals.six.moves import xrange from itertools import chain, product import pickle import warnings import sys import numpy as np import scipy.sparse as sp from sklearn.utils.testing import assert_equal from sklearn.utils.testing import assert_not_equal from sklearn.utils.testing import assert_raises from sklearn.utils.testing import assert_warns from sklearn.utils.testing import assert_raise_message from sklearn.utils.testing import assert_false, assert_true from sklearn.utils.testing import assert_array_equal from sklearn.utils.testing import assert_almost_equal from sklearn.utils.testing import assert_array_almost_equal from sklearn.utils.testing import assert_no_warnings from sklearn.utils.testing import ignore_warnings from sklearn.utils.mocking import CheckingClassifier, MockDataFrame from scipy.stats import bernoulli, expon, uniform from sklearn.externals.six.moves import zip from sklearn.base import BaseEstimator from sklearn.datasets import make_classification from sklearn.datasets import make_blobs from sklearn.datasets import make_multilabel_classification from sklearn.svm import LinearSVC, SVC from sklearn.tree import DecisionTreeRegressor from sklearn.tree import DecisionTreeClassifier from sklearn.cluster import KMeans from sklearn.neighbors import KernelDensity from sklearn.metrics import f1_score from sklearn.metrics import make_scorer from sklearn.metrics import roc_auc_score from sklearn.linear_model import Ridge from sklearn.exceptions import ChangedBehaviorWarning from sklearn.exceptions import FitFailedWarning with warnings.catch_warnings(): warnings.simplefilter('ignore') from sklearn.grid_search import (GridSearchCV, RandomizedSearchCV, ParameterGrid, ParameterSampler) from sklearn.cross_validation import KFold, StratifiedKFold from sklearn.preprocessing import Imputer from sklearn.pipeline import Pipeline # Neither of the following two estimators inherit from BaseEstimator, # to test hyperparameter search on user-defined classifiers. class MockClassifier(object): """Dummy classifier to test the cross-validation""" def __init__(self, foo_param=0): self.foo_param = foo_param def fit(self, X, Y): assert_true(len(X) == len(Y)) return self def predict(self, T): return T.shape[0] predict_proba = predict decision_function = predict transform = predict def score(self, X=None, Y=None): if self.foo_param > 1: score = 1. else: score = 0. return score def get_params(self, deep=False): return {'foo_param': self.foo_param} def set_params(self, **params): self.foo_param = params['foo_param'] return self class LinearSVCNoScore(LinearSVC): """An LinearSVC classifier that has no score method.""" @property def score(self): raise AttributeError X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]]) y = np.array([1, 1, 2, 2]) def assert_grid_iter_equals_getitem(grid): assert_equal(list(grid), [grid[i] for i in range(len(grid))]) def test_parameter_grid(): # Test basic properties of ParameterGrid. params1 = {"foo": [1, 2, 3]} grid1 = ParameterGrid(params1) assert_true(isinstance(grid1, Iterable)) assert_true(isinstance(grid1, Sized)) assert_equal(len(grid1), 3) assert_grid_iter_equals_getitem(grid1) params2 = {"foo": [4, 2], "bar": ["ham", "spam", "eggs"]} grid2 = ParameterGrid(params2) assert_equal(len(grid2), 6) # loop to assert we can iterate over the grid multiple times for i in xrange(2): # tuple + chain transforms {"a": 1, "b": 2} to ("a", 1, "b", 2) points = set(tuple(chain(*(sorted(p.items())))) for p in grid2) assert_equal(points, set(("bar", x, "foo", y) for x, y in product(params2["bar"], params2["foo"]))) assert_grid_iter_equals_getitem(grid2) # Special case: empty grid (useful to get default estimator settings) empty = ParameterGrid({}) assert_equal(len(empty), 1) assert_equal(list(empty), [{}]) assert_grid_iter_equals_getitem(empty) assert_raises(IndexError, lambda: empty[1]) has_empty = ParameterGrid([{'C': [1, 10]}, {}, {'C': [.5]}]) assert_equal(len(has_empty), 4) assert_equal(list(has_empty), [{'C': 1}, {'C': 10}, {}, {'C': .5}]) assert_grid_iter_equals_getitem(has_empty) def test_grid_search(): # Test that the best estimator contains the right value for foo_param clf = MockClassifier() grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}, verbose=3) # make sure it selects the smallest parameter in case of ties old_stdout = sys.stdout sys.stdout = StringIO() grid_search.fit(X, y) sys.stdout = old_stdout assert_equal(grid_search.best_estimator_.foo_param, 2) for i, foo_i in enumerate([1, 2, 3]): assert_true(grid_search.grid_scores_[i][0] == {'foo_param': foo_i}) # Smoke test the score etc: grid_search.score(X, y) grid_search.predict_proba(X) grid_search.decision_function(X) grid_search.transform(X) # Test exception handling on scoring grid_search.scoring = 'sklearn' assert_raises(ValueError, grid_search.fit, X, y) @ignore_warnings def test_grid_search_no_score(): # Test grid-search on classifier that has no score function. clf = LinearSVC(random_state=0) X, y = make_blobs(random_state=0, centers=2) Cs = [.1, 1, 10] clf_no_score = LinearSVCNoScore(random_state=0) grid_search = GridSearchCV(clf, {'C': Cs}, scoring='accuracy') grid_search.fit(X, y) grid_search_no_score = GridSearchCV(clf_no_score, {'C': Cs}, scoring='accuracy') # smoketest grid search grid_search_no_score.fit(X, y) # check that best params are equal assert_equal(grid_search_no_score.best_params_, grid_search.best_params_) # check that we can call score and that it gives the correct result assert_equal(grid_search.score(X, y), grid_search_no_score.score(X, y)) # giving no scoring function raises an error grid_search_no_score = GridSearchCV(clf_no_score, {'C': Cs}) assert_raise_message(TypeError, "no scoring", grid_search_no_score.fit, [[1]]) def test_grid_search_score_method(): X, y = make_classification(n_samples=100, n_classes=2, flip_y=.2, random_state=0) clf = LinearSVC(random_state=0) grid = {'C': [.1]} search_no_scoring = GridSearchCV(clf, grid, scoring=None).fit(X, y) search_accuracy = GridSearchCV(clf, grid, scoring='accuracy').fit(X, y) search_no_score_method_auc = GridSearchCV(LinearSVCNoScore(), grid, scoring='roc_auc').fit(X, y) search_auc = GridSearchCV(clf, grid, scoring='roc_auc').fit(X, y) # Check warning only occurs in situation where behavior changed: # estimator requires score method to compete with scoring parameter score_no_scoring = assert_no_warnings(search_no_scoring.score, X, y) score_accuracy = assert_warns(ChangedBehaviorWarning, search_accuracy.score, X, y) score_no_score_auc = assert_no_warnings(search_no_score_method_auc.score, X, y) score_auc = assert_warns(ChangedBehaviorWarning, search_auc.score, X, y) # ensure the test is sane assert_true(score_auc < 1.0) assert_true(score_accuracy < 1.0) assert_not_equal(score_auc, score_accuracy) assert_almost_equal(score_accuracy, score_no_scoring) assert_almost_equal(score_auc, score_no_score_auc) def test_trivial_grid_scores(): # Test search over a "grid" with only one point. # Non-regression test: grid_scores_ wouldn't be set by GridSearchCV. clf = MockClassifier() grid_search = GridSearchCV(clf, {'foo_param': [1]}) grid_search.fit(X, y) assert_true(hasattr(grid_search, "grid_scores_")) random_search = RandomizedSearchCV(clf, {'foo_param': [0]}, n_iter=1) random_search.fit(X, y) assert_true(hasattr(random_search, "grid_scores_")) def test_no_refit(): # Test that grid search can be used for model selection only clf = MockClassifier() grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}, refit=False) grid_search.fit(X, y) assert_true(hasattr(grid_search, "best_params_")) def test_grid_search_error(): # Test that grid search will capture errors on data with different # length X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) clf = LinearSVC() cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) assert_raises(ValueError, cv.fit, X_[:180], y_) def test_grid_search_iid(): # test the iid parameter # noise-free simple 2d-data X, y = make_blobs(centers=[[0, 0], [1, 0], [0, 1], [1, 1]], random_state=0, cluster_std=0.1, shuffle=False, n_samples=80) # split dataset into two folds that are not iid # first one contains data of all 4 blobs, second only from two. mask = np.ones(X.shape[0], dtype=np.bool) mask[np.where(y == 1)[0][::2]] = 0 mask[np.where(y == 2)[0][::2]] = 0 # this leads to perfect classification on one fold and a score of 1/3 on # the other svm = SVC(kernel='linear') # create "cv" for splits cv = [[mask, ~mask], [~mask, mask]] # once with iid=True (default) grid_search = GridSearchCV(svm, param_grid={'C': [1, 10]}, cv=cv) grid_search.fit(X, y) first = grid_search.grid_scores_[0] assert_equal(first.parameters['C'], 1) assert_array_almost_equal(first.cv_validation_scores, [1, 1. / 3.]) # for first split, 1/4 of dataset is in test, for second 3/4. # take weighted average assert_almost_equal(first.mean_validation_score, 1 * 1. / 4. + 1. / 3. * 3. / 4.) # once with iid=False grid_search = GridSearchCV(svm, param_grid={'C': [1, 10]}, cv=cv, iid=False) grid_search.fit(X, y) first = grid_search.grid_scores_[0] assert_equal(first.parameters['C'], 1) # scores are the same as above assert_array_almost_equal(first.cv_validation_scores, [1, 1. / 3.]) # averaged score is just mean of scores assert_almost_equal(first.mean_validation_score, np.mean(first.cv_validation_scores)) def test_grid_search_one_grid_point(): X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) param_dict = {"C": [1.0], "kernel": ["rbf"], "gamma": [0.1]} clf = SVC() cv = GridSearchCV(clf, param_dict) cv.fit(X_, y_) clf = SVC(C=1.0, kernel="rbf", gamma=0.1) clf.fit(X_, y_) assert_array_equal(clf.dual_coef_, cv.best_estimator_.dual_coef_) def test_grid_search_bad_param_grid(): param_dict = {"C": 1.0} clf = SVC() assert_raises(ValueError, GridSearchCV, clf, param_dict) param_dict = {"C": []} clf = SVC() assert_raises(ValueError, GridSearchCV, clf, param_dict) param_dict = {"C": np.ones(6).reshape(3, 2)} clf = SVC() assert_raises(ValueError, GridSearchCV, clf, param_dict) def test_grid_search_sparse(): # Test that grid search works with both dense and sparse matrices X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) clf = LinearSVC() cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) cv.fit(X_[:180], y_[:180]) y_pred = cv.predict(X_[180:]) C = cv.best_estimator_.C X_ = sp.csr_matrix(X_) clf = LinearSVC() cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) cv.fit(X_[:180].tocoo(), y_[:180]) y_pred2 = cv.predict(X_[180:]) C2 = cv.best_estimator_.C assert_true(np.mean(y_pred == y_pred2) >= .9) assert_equal(C, C2) def test_grid_search_sparse_scoring(): X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) clf = LinearSVC() cv = GridSearchCV(clf, {'C': [0.1, 1.0]}, scoring="f1") cv.fit(X_[:180], y_[:180]) y_pred = cv.predict(X_[180:]) C = cv.best_estimator_.C X_ = sp.csr_matrix(X_) clf = LinearSVC() cv = GridSearchCV(clf, {'C': [0.1, 1.0]}, scoring="f1") cv.fit(X_[:180], y_[:180]) y_pred2 = cv.predict(X_[180:]) C2 = cv.best_estimator_.C assert_array_equal(y_pred, y_pred2) assert_equal(C, C2) # Smoke test the score # np.testing.assert_allclose(f1_score(cv.predict(X_[:180]), y[:180]), # cv.score(X_[:180], y[:180])) # test loss where greater is worse def f1_loss(y_true_, y_pred_): return -f1_score(y_true_, y_pred_) F1Loss = make_scorer(f1_loss, greater_is_better=False) cv = GridSearchCV(clf, {'C': [0.1, 1.0]}, scoring=F1Loss) cv.fit(X_[:180], y_[:180]) y_pred3 = cv.predict(X_[180:]) C3 = cv.best_estimator_.C assert_equal(C, C3) assert_array_equal(y_pred, y_pred3) def test_grid_search_precomputed_kernel(): # Test that grid search works when the input features are given in the # form of a precomputed kernel matrix X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) # compute the training kernel matrix corresponding to the linear kernel K_train = np.dot(X_[:180], X_[:180].T) y_train = y_[:180] clf = SVC(kernel='precomputed') cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) cv.fit(K_train, y_train) assert_true(cv.best_score_ >= 0) # compute the test kernel matrix K_test = np.dot(X_[180:], X_[:180].T) y_test = y_[180:] y_pred = cv.predict(K_test) assert_true(np.mean(y_pred == y_test) >= 0) # test error is raised when the precomputed kernel is not array-like # or sparse assert_raises(ValueError, cv.fit, K_train.tolist(), y_train) def test_grid_search_precomputed_kernel_error_nonsquare(): # Test that grid search returns an error with a non-square precomputed # training kernel matrix K_train = np.zeros((10, 20)) y_train = np.ones((10, )) clf = SVC(kernel='precomputed') cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) assert_raises(ValueError, cv.fit, K_train, y_train) def test_grid_search_precomputed_kernel_error_kernel_function(): # Test that grid search returns an error when using a kernel_function X_, y_ = make_classification(n_samples=200, n_features=100, random_state=0) kernel_function = lambda x1, x2: np.dot(x1, x2.T) clf = SVC(kernel=kernel_function) cv = GridSearchCV(clf, {'C': [0.1, 1.0]}) assert_raises(ValueError, cv.fit, X_, y_) class BrokenClassifier(BaseEstimator): """Broken classifier that cannot be fit twice""" def __init__(self, parameter=None): self.parameter = parameter def fit(self, X, y): assert_true(not hasattr(self, 'has_been_fit_')) self.has_been_fit_ = True def predict(self, X): return np.zeros(X.shape[0]) @ignore_warnings def test_refit(): # Regression test for bug in refitting # Simulates re-fitting a broken estimator; this used to break with # sparse SVMs. X = np.arange(100).reshape(10, 10) y = np.array([0] * 5 + [1] * 5) clf = GridSearchCV(BrokenClassifier(), [{'parameter': [0, 1]}], scoring="precision", refit=True) clf.fit(X, y) def test_gridsearch_nd(): # Pass X as list in GridSearchCV X_4d = np.arange(10 * 5 * 3 * 2).reshape(10, 5, 3, 2) y_3d = np.arange(10 * 7 * 11).reshape(10, 7, 11) check_X = lambda x: x.shape[1:] == (5, 3, 2) check_y = lambda x: x.shape[1:] == (7, 11) clf = CheckingClassifier(check_X=check_X, check_y=check_y) grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}) grid_search.fit(X_4d, y_3d).score(X, y) assert_true(hasattr(grid_search, "grid_scores_")) def test_X_as_list(): # Pass X as list in GridSearchCV X = np.arange(100).reshape(10, 10) y = np.array([0] * 5 + [1] * 5) clf = CheckingClassifier(check_X=lambda x: isinstance(x, list)) cv = KFold(n=len(X), n_folds=3) grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}, cv=cv) grid_search.fit(X.tolist(), y).score(X, y) assert_true(hasattr(grid_search, "grid_scores_")) def test_y_as_list(): # Pass y as list in GridSearchCV X = np.arange(100).reshape(10, 10) y = np.array([0] * 5 + [1] * 5) clf = CheckingClassifier(check_y=lambda x: isinstance(x, list)) cv = KFold(n=len(X), n_folds=3) grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}, cv=cv) grid_search.fit(X, y.tolist()).score(X, y) assert_true(hasattr(grid_search, "grid_scores_")) def test_pandas_input(): # check cross_val_score doesn't destroy pandas dataframe types = [(MockDataFrame, MockDataFrame)] try: from pandas import Series, DataFrame types.append((DataFrame, Series)) except ImportError: pass X = np.arange(100).reshape(10, 10) y = np.array([0] * 5 + [1] * 5) for InputFeatureType, TargetType in types: # X dataframe, y series X_df, y_ser = InputFeatureType(X), TargetType(y) check_df = lambda x: isinstance(x, InputFeatureType) check_series = lambda x: isinstance(x, TargetType) clf = CheckingClassifier(check_X=check_df, check_y=check_series) grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}) grid_search.fit(X_df, y_ser).score(X_df, y_ser) grid_search.predict(X_df) assert_true(hasattr(grid_search, "grid_scores_")) def test_unsupervised_grid_search(): # test grid-search with unsupervised estimator X, y = make_blobs(random_state=0) km = KMeans(random_state=0) grid_search = GridSearchCV(km, param_grid=dict(n_clusters=[2, 3, 4]), scoring='adjusted_rand_score') grid_search.fit(X, y) # ARI can find the right number :) assert_equal(grid_search.best_params_["n_clusters"], 3) # Now without a score, and without y grid_search = GridSearchCV(km, param_grid=dict(n_clusters=[2, 3, 4])) grid_search.fit(X) assert_equal(grid_search.best_params_["n_clusters"], 4) def test_gridsearch_no_predict(): # test grid-search with an estimator without predict. # slight duplication of a test from KDE def custom_scoring(estimator, X): return 42 if estimator.bandwidth == .1 else 0 X, _ = make_blobs(cluster_std=.1, random_state=1, centers=[[0, 1], [1, 0], [0, 0]]) search = GridSearchCV(KernelDensity(), param_grid=dict(bandwidth=[.01, .1, 1]), scoring=custom_scoring) search.fit(X) assert_equal(search.best_params_['bandwidth'], .1) assert_equal(search.best_score_, 42) def test_param_sampler(): # test basic properties of param sampler param_distributions = {"kernel": ["rbf", "linear"], "C": uniform(0, 1)} sampler = ParameterSampler(param_distributions=param_distributions, n_iter=10, random_state=0) samples = [x for x in sampler] assert_equal(len(samples), 10) for sample in samples: assert_true(sample["kernel"] in ["rbf", "linear"]) assert_true(0 <= sample["C"] <= 1) def test_randomized_search_grid_scores(): # Make a dataset with a lot of noise to get various kind of prediction # errors across CV folds and parameter settings X, y = make_classification(n_samples=200, n_features=100, n_informative=3, random_state=0) # XXX: as of today (scipy 0.12) it's not possible to set the random seed # of scipy.stats distributions: the assertions in this test should thus # not depend on the randomization params = dict(C=expon(scale=10), gamma=expon(scale=0.1)) n_cv_iter = 3 n_search_iter = 30 search = RandomizedSearchCV(SVC(), n_iter=n_search_iter, cv=n_cv_iter, param_distributions=params, iid=False) search.fit(X, y) assert_equal(len(search.grid_scores_), n_search_iter) # Check consistency of the structure of each cv_score item for cv_score in search.grid_scores_: assert_equal(len(cv_score.cv_validation_scores), n_cv_iter) # Because we set iid to False, the mean_validation score is the # mean of the fold mean scores instead of the aggregate sample-wise # mean score assert_almost_equal(np.mean(cv_score.cv_validation_scores), cv_score.mean_validation_score) assert_equal(list(sorted(cv_score.parameters.keys())), list(sorted(params.keys()))) # Check the consistency with the best_score_ and best_params_ attributes sorted_grid_scores = list(sorted(search.grid_scores_, key=lambda x: x.mean_validation_score)) best_score = sorted_grid_scores[-1].mean_validation_score assert_equal(search.best_score_, best_score) tied_best_params = [s.parameters for s in sorted_grid_scores if s.mean_validation_score == best_score] assert_true(search.best_params_ in tied_best_params, "best_params_={0} is not part of the" " tied best models: {1}".format( search.best_params_, tied_best_params)) def test_grid_search_score_consistency(): # test that correct scores are used clf = LinearSVC(random_state=0) X, y = make_blobs(random_state=0, centers=2) Cs = [.1, 1, 10] for score in ['f1', 'roc_auc']: grid_search = GridSearchCV(clf, {'C': Cs}, scoring=score) grid_search.fit(X, y) cv = StratifiedKFold(n_folds=3, y=y) for C, scores in zip(Cs, grid_search.grid_scores_): clf.set_params(C=C) scores = scores[2] # get the separate runs from grid scores i = 0 for train, test in cv: clf.fit(X[train], y[train]) if score == "f1": correct_score = f1_score(y[test], clf.predict(X[test])) elif score == "roc_auc": dec = clf.decision_function(X[test]) correct_score = roc_auc_score(y[test], dec) assert_almost_equal(correct_score, scores[i]) i += 1 def test_pickle(): # Test that a fit search can be pickled clf = MockClassifier() grid_search = GridSearchCV(clf, {'foo_param': [1, 2, 3]}, refit=True) grid_search.fit(X, y) pickle.dumps(grid_search) # smoke test random_search = RandomizedSearchCV(clf, {'foo_param': [1, 2, 3]}, refit=True, n_iter=3) random_search.fit(X, y) pickle.dumps(random_search) # smoke test def test_grid_search_with_multioutput_data(): # Test search with multi-output estimator X, y = make_multilabel_classification(random_state=0) est_parameters = {"max_depth": [1, 2, 3, 4]} cv = KFold(y.shape[0], random_state=0) estimators = [DecisionTreeRegressor(random_state=0), DecisionTreeClassifier(random_state=0)] # Test with grid search cv for est in estimators: grid_search = GridSearchCV(est, est_parameters, cv=cv) grid_search.fit(X, y) for parameters, _, cv_validation_scores in grid_search.grid_scores_: est.set_params(**parameters) for i, (train, test) in enumerate(cv): est.fit(X[train], y[train]) correct_score = est.score(X[test], y[test]) assert_almost_equal(correct_score, cv_validation_scores[i]) # Test with a randomized search for est in estimators: random_search = RandomizedSearchCV(est, est_parameters, cv=cv, n_iter=3) random_search.fit(X, y) for parameters, _, cv_validation_scores in random_search.grid_scores_: est.set_params(**parameters) for i, (train, test) in enumerate(cv): est.fit(X[train], y[train]) correct_score = est.score(X[test], y[test]) assert_almost_equal(correct_score, cv_validation_scores[i]) def test_predict_proba_disabled(): # Test predict_proba when disabled on estimator. X = np.arange(20).reshape(5, -1) y = [0, 0, 1, 1, 1] clf = SVC(probability=False) gs = GridSearchCV(clf, {}, cv=2).fit(X, y) assert_false(hasattr(gs, "predict_proba")) def test_grid_search_allows_nans(): # Test GridSearchCV with Imputer X = np.arange(20, dtype=np.float64).reshape(5, -1) X[2, :] = np.nan y = [0, 0, 1, 1, 1] p = Pipeline([ ('imputer', Imputer(strategy='mean', missing_values='NaN')), ('classifier', MockClassifier()), ]) GridSearchCV(p, {'classifier__foo_param': [1, 2, 3]}, cv=2).fit(X, y) class FailingClassifier(BaseEstimator): """Classifier that raises a ValueError on fit()""" FAILING_PARAMETER = 2 def __init__(self, parameter=None): self.parameter = parameter def fit(self, X, y=None): if self.parameter == FailingClassifier.FAILING_PARAMETER: raise ValueError("Failing classifier failed as required") def predict(self, X): return np.zeros(X.shape[0]) def test_grid_search_failing_classifier(): # GridSearchCV with on_error != 'raise' # Ensures that a warning is raised and score reset where appropriate. X, y = make_classification(n_samples=20, n_features=10, random_state=0) clf = FailingClassifier() # refit=False because we only want to check that errors caused by fits # to individual folds will be caught and warnings raised instead. If # refit was done, then an exception would be raised on refit and not # caught by grid_search (expected behavior), and this would cause an # error in this test. gs = GridSearchCV(clf, [{'parameter': [0, 1, 2]}], scoring='accuracy', refit=False, error_score=0.0) assert_warns(FitFailedWarning, gs.fit, X, y) # Ensure that grid scores were set to zero as required for those fits # that are expected to fail. assert all(np.all(this_point.cv_validation_scores == 0.0) for this_point in gs.grid_scores_ if this_point.parameters['parameter'] == FailingClassifier.FAILING_PARAMETER) gs = GridSearchCV(clf, [{'parameter': [0, 1, 2]}], scoring='accuracy', refit=False, error_score=float('nan')) assert_warns(FitFailedWarning, gs.fit, X, y) assert all(np.all(np.isnan(this_point.cv_validation_scores)) for this_point in gs.grid_scores_ if this_point.parameters['parameter'] == FailingClassifier.FAILING_PARAMETER) def test_grid_search_failing_classifier_raise(): # GridSearchCV with on_error == 'raise' raises the error X, y = make_classification(n_samples=20, n_features=10, random_state=0) clf = FailingClassifier() # refit=False because we want to test the behaviour of the grid search part gs = GridSearchCV(clf, [{'parameter': [0, 1, 2]}], scoring='accuracy', refit=False, error_score='raise') # FailingClassifier issues a ValueError so this is what we look for. assert_raises(ValueError, gs.fit, X, y) def test_parameters_sampler_replacement(): # raise error if n_iter too large params = {'first': [0, 1], 'second': ['a', 'b', 'c']} sampler = ParameterSampler(params, n_iter=7) assert_raises(ValueError, list, sampler) # degenerates to GridSearchCV if n_iter the same as grid_size sampler = ParameterSampler(params, n_iter=6) samples = list(sampler) assert_equal(len(samples), 6) for values in ParameterGrid(params): assert_true(values in samples) # test sampling without replacement in a large grid params = {'a': range(10), 'b': range(10), 'c': range(10)} sampler = ParameterSampler(params, n_iter=99, random_state=42) samples = list(sampler) assert_equal(len(samples), 99) hashable_samples = ["a%db%dc%d" % (p['a'], p['b'], p['c']) for p in samples] assert_equal(len(set(hashable_samples)), 99) # doesn't go into infinite loops params_distribution = {'first': bernoulli(.5), 'second': ['a', 'b', 'c']} sampler = ParameterSampler(params_distribution, n_iter=7) samples = list(sampler) assert_equal(len(samples), 7) def test_classes__property(): # Test that classes_ property matches best_esimator_.classes_ X = np.arange(100).reshape(10, 10) y = np.array([0] * 5 + [1] * 5) Cs = [.1, 1, 10] grid_search = GridSearchCV(LinearSVC(random_state=0), {'C': Cs}) grid_search.fit(X, y) assert_array_equal(grid_search.best_estimator_.classes_, grid_search.classes_) # Test that regressors do not have a classes_ attribute grid_search = GridSearchCV(Ridge(), {'alpha': [1.0, 2.0]}) grid_search.fit(X, y) assert_false(hasattr(grid_search, 'classes_'))
bsd-3-clause
[ 624, 199, 9029, 367, 6068, 2754, 859, 334, 27993, 14, 3825, 63, 1733, 9, 199, 199, 624, 199, 199, 504, 5055, 492, 19937, 12, 428, 1759, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 15073, 465, 5228, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 504, 7975, 492, 6036, 12, 3336, 199, 646, 5927, 199, 646, 3598, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1397, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3730, 63, 1188, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3910, 12, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 889, 63, 5451, 199, 504, 6357, 14, 1208, 14, 4776, 492, 3686, 63, 5451, 199, 504, 6357, 14, 1208, 14, 1805, 316, 492, 25109, 8508, 12, 4420, 9205, 199, 199, 504, 7026, 14, 3200, 492, 330, 281, 24992, 12, 444, 678, 12, 14818, 199, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 3482, 199, 504, 6357, 14, 1095, 492, 3523, 13183, 199, 504, 6357, 14, 12281, 492, 1852, 63, 14368, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 6357, 14, 12281, 492, 1852, 63, 3029, 1302, 63, 14368, 199, 504, 6357, 14, 16820, 492, 12489, 17675, 12, 428, 9454, 199, 504, 6357, 14, 2350, 492, 1487, 24116, 15155, 199, 504, 6357, 14, 2350, 492, 1487, 24116, 8508, 199, 504, 6357, 14, 4201, 492, 1804, 21190, 199, 504, 6357, 14, 11113, 492, 24901, 26211, 199, 504, 6357, 14, 6759, 492, 289, 17, 63, 3397, 199, 504, 6357, 14, 6759, 492, 1852, 63, 22135, 199, 504, 6357, 14, 6759, 492, 882, 67, 63, 19129, 63, 3397, 199, 504, 6357, 14, 6676, 63, 1238, 492, 31196, 199, 199, 504, 6357, 14, 3924, 492, 25649, 25361, 3849, 199, 504, 6357, 14, 3924, 492, 25971, 4276, 3849, 199, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 18815, 360, 4247, 358, 272, 687, 6357, 14, 3825, 63, 1733, 492, 334, 7900, 28971, 12, 9571, 1759, 28971, 12, 3660, 12009, 7900, 12, 12009, 27434, 9, 272, 687, 6357, 14, 7925, 63, 6136, 492, 1804, 27985, 12, 428, 1239, 8981, 17706, 1753, 199, 199, 504, 6357, 14, 21402, 492, 8362, 2699, 199, 504, 6357, 14, 7379, 492, 19090, 421, 199, 3, 11443, 402, 314, 2569, 2877, 23155, 8287, 687, 3523, 13183, 12, 199, 3, 370, 511, 10342, 5329, 2754, 641, 922, 13, 4037, 19137, 14, 199, 533, 4420, 8508, 8, 785, 304, 272, 408, 11324, 12429, 370, 511, 314, 8059, 13, 6136, 624, 272, 347, 636, 826, 721, 277, 12, 3925, 63, 635, 29, 16, 304, 267, 291, 14, 1421, 63, 635, 275, 3925, 63, 635, 339, 347, 5542, 8, 277, 12, 1323, 12, 1488, 304, 267, 702, 63, 2052, 8, 552, 8, 56, 9, 508, 822, 8, 57, 430, 267, 372, 291, 339, 347, 12610, 8, 277, 12, 377, 304, 267, 372, 377, 14, 1392, 59, 16, 61, 339, 12610, 63, 14417, 275, 12610, 272, 14692, 63, 1593, 275, 12610, 272, 5793, 275, 12610, 339, 347, 5396, 8, 277, 12, 1323, 29, 403, 12, 1488, 29, 403, 304, 267, 340, 291, 14, 1421, 63, 635, 690, 413, 26, 288, 5396, 275, 413, 14, 267, 587, 26, 288, 5396, 275, 378, 14, 267, 372, 5396, 339, 347, 664, 63, 1162, 8, 277, 12, 13217, 29, 797, 304, 267, 372, 791, 1421, 63, 635, 356, 291, 14, 1421, 63, 635, 93, 339, 347, 663, 63, 1162, 8, 277, 12, 1011, 1162, 304, 267, 291, 14, 1421, 63, 635, 275, 1862, 459, 1421, 63, 635, 418, 267, 372, 291, 421, 199, 533, 12489, 17675, 1944, 12642, 8, 10608, 17675, 304, 272, 408, 2493, 12489, 17675, 12429, 626, 965, 949, 5396, 1083, 1041, 272, 768, 1829, 272, 347, 5396, 8, 277, 304, 267, 746, 4281, 199, 199, 56, 275, 980, 14, 1144, 22844, 17, 12, 446, 17, 467, 5243, 18, 12, 446, 17, 467, 359, 17, 12, 413, 467, 359, 18, 12, 413, 3934, 199, 89, 275, 980, 14, 1144, 779, 17, 12, 413, 12, 499, 12, 499, 566, 421, 199, 318, 702, 63, 3825, 63, 1661, 63, 11332, 63, 6095, 8, 3825, 304, 272, 702, 63, 1452, 8, 513, 8, 3825, 395, 359, 3825, 59, 73, 61, 367, 284, 315, 1425, 8, 552, 8, 3825, 18229, 421, 199, 318, 511, 63, 5329, 63, 3825, 837, 272, 327, 1379, 5678, 4382, 402, 12009, 7900, 14, 272, 1862, 17, 275, 2420, 1421, 582, 359, 17, 12, 499, 12, 650, 9420, 272, 6068, 17, 275, 12009, 7900, 8, 1162, 17, 9, 272, 702, 63, 2052, 8, 6074, 8, 3825, 17, 12, 19937, 430, 272, 702, 63, 2052, 8, 6074, 8, 3825, 17, 12, 428, 1759, 430, 272, 702, 63, 1452, 8, 552, 8, 3825, 17, 395, 650, 9, 272, 702, 63, 3825, 63, 1661, 63, 11332, 63, 6095, 8, 3825, 17, 9, 339, 1862, 18, 275, 2420, 1421, 582, 359, 20, 12, 499, 467, 2049, 298, 1700, 582, 2097, 10670, 401, 298, 8283, 401, 298, 14488, 27635, 272, 6068, 18, 275, 12009, 7900, 8, 1162, 18, 9, 272, 702, 63, 1452, 8, 552, 8, 3825, 18, 395, 1227, 9, 339, 327, 4438, 370, 702, 781, 883, 13974, 1806, 314, 6068, 3663, 5431, 272, 367, 284, 315, 4945, 8, 18, 304, 267, 327, 2008, 435, 6036, 18501, 2420, 65, 582, 413, 12, 298, 66, 582, 499, 93, 370, 1689, 65, 401, 413, 12, 298, 66, 401, 499, 9, 267, 4501, 275, 663, 8, 2960, 8, 4429, 29316, 5917, 8, 80, 14, 1744, 4059, 430, 367, 299, 315, 6068, 18, 9, 267, 702, 63, 1452, 8 ]
[ 199, 9029, 367, 6068, 2754, 859, 334, 27993, 14, 3825, 63, 1733, 9, 199, 199, 624, 199, 199, 504, 5055, 492, 19937, 12, 428, 1759, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 15073, 465, 5228, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 504, 7975, 492, 6036, 12, 3336, 199, 646, 5927, 199, 646, 3598, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1397, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3730, 63, 1188, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3910, 12, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 889, 63, 5451, 199, 504, 6357, 14, 1208, 14, 4776, 492, 3686, 63, 5451, 199, 504, 6357, 14, 1208, 14, 1805, 316, 492, 25109, 8508, 12, 4420, 9205, 199, 199, 504, 7026, 14, 3200, 492, 330, 281, 24992, 12, 444, 678, 12, 14818, 199, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 3482, 199, 504, 6357, 14, 1095, 492, 3523, 13183, 199, 504, 6357, 14, 12281, 492, 1852, 63, 14368, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 6357, 14, 12281, 492, 1852, 63, 3029, 1302, 63, 14368, 199, 504, 6357, 14, 16820, 492, 12489, 17675, 12, 428, 9454, 199, 504, 6357, 14, 2350, 492, 1487, 24116, 15155, 199, 504, 6357, 14, 2350, 492, 1487, 24116, 8508, 199, 504, 6357, 14, 4201, 492, 1804, 21190, 199, 504, 6357, 14, 11113, 492, 24901, 26211, 199, 504, 6357, 14, 6759, 492, 289, 17, 63, 3397, 199, 504, 6357, 14, 6759, 492, 1852, 63, 22135, 199, 504, 6357, 14, 6759, 492, 882, 67, 63, 19129, 63, 3397, 199, 504, 6357, 14, 6676, 63, 1238, 492, 31196, 199, 199, 504, 6357, 14, 3924, 492, 25649, 25361, 3849, 199, 504, 6357, 14, 3924, 492, 25971, 4276, 3849, 199, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 18815, 360, 4247, 358, 272, 687, 6357, 14, 3825, 63, 1733, 492, 334, 7900, 28971, 12, 9571, 1759, 28971, 12, 3660, 12009, 7900, 12, 12009, 27434, 9, 272, 687, 6357, 14, 7925, 63, 6136, 492, 1804, 27985, 12, 428, 1239, 8981, 17706, 1753, 199, 199, 504, 6357, 14, 21402, 492, 8362, 2699, 199, 504, 6357, 14, 7379, 492, 19090, 421, 199, 3, 11443, 402, 314, 2569, 2877, 23155, 8287, 687, 3523, 13183, 12, 199, 3, 370, 511, 10342, 5329, 2754, 641, 922, 13, 4037, 19137, 14, 199, 533, 4420, 8508, 8, 785, 304, 272, 408, 11324, 12429, 370, 511, 314, 8059, 13, 6136, 624, 272, 347, 636, 826, 721, 277, 12, 3925, 63, 635, 29, 16, 304, 267, 291, 14, 1421, 63, 635, 275, 3925, 63, 635, 339, 347, 5542, 8, 277, 12, 1323, 12, 1488, 304, 267, 702, 63, 2052, 8, 552, 8, 56, 9, 508, 822, 8, 57, 430, 267, 372, 291, 339, 347, 12610, 8, 277, 12, 377, 304, 267, 372, 377, 14, 1392, 59, 16, 61, 339, 12610, 63, 14417, 275, 12610, 272, 14692, 63, 1593, 275, 12610, 272, 5793, 275, 12610, 339, 347, 5396, 8, 277, 12, 1323, 29, 403, 12, 1488, 29, 403, 304, 267, 340, 291, 14, 1421, 63, 635, 690, 413, 26, 288, 5396, 275, 413, 14, 267, 587, 26, 288, 5396, 275, 378, 14, 267, 372, 5396, 339, 347, 664, 63, 1162, 8, 277, 12, 13217, 29, 797, 304, 267, 372, 791, 1421, 63, 635, 356, 291, 14, 1421, 63, 635, 93, 339, 347, 663, 63, 1162, 8, 277, 12, 1011, 1162, 304, 267, 291, 14, 1421, 63, 635, 275, 1862, 459, 1421, 63, 635, 418, 267, 372, 291, 421, 199, 533, 12489, 17675, 1944, 12642, 8, 10608, 17675, 304, 272, 408, 2493, 12489, 17675, 12429, 626, 965, 949, 5396, 1083, 1041, 272, 768, 1829, 272, 347, 5396, 8, 277, 304, 267, 746, 4281, 199, 199, 56, 275, 980, 14, 1144, 22844, 17, 12, 446, 17, 467, 5243, 18, 12, 446, 17, 467, 359, 17, 12, 413, 467, 359, 18, 12, 413, 3934, 199, 89, 275, 980, 14, 1144, 779, 17, 12, 413, 12, 499, 12, 499, 566, 421, 199, 318, 702, 63, 3825, 63, 1661, 63, 11332, 63, 6095, 8, 3825, 304, 272, 702, 63, 1452, 8, 513, 8, 3825, 395, 359, 3825, 59, 73, 61, 367, 284, 315, 1425, 8, 552, 8, 3825, 18229, 421, 199, 318, 511, 63, 5329, 63, 3825, 837, 272, 327, 1379, 5678, 4382, 402, 12009, 7900, 14, 272, 1862, 17, 275, 2420, 1421, 582, 359, 17, 12, 499, 12, 650, 9420, 272, 6068, 17, 275, 12009, 7900, 8, 1162, 17, 9, 272, 702, 63, 2052, 8, 6074, 8, 3825, 17, 12, 19937, 430, 272, 702, 63, 2052, 8, 6074, 8, 3825, 17, 12, 428, 1759, 430, 272, 702, 63, 1452, 8, 552, 8, 3825, 17, 395, 650, 9, 272, 702, 63, 3825, 63, 1661, 63, 11332, 63, 6095, 8, 3825, 17, 9, 339, 1862, 18, 275, 2420, 1421, 582, 359, 20, 12, 499, 467, 2049, 298, 1700, 582, 2097, 10670, 401, 298, 8283, 401, 298, 14488, 27635, 272, 6068, 18, 275, 12009, 7900, 8, 1162, 18, 9, 272, 702, 63, 1452, 8, 552, 8, 3825, 18, 395, 1227, 9, 339, 327, 4438, 370, 702, 781, 883, 13974, 1806, 314, 6068, 3663, 5431, 272, 367, 284, 315, 4945, 8, 18,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
fpieper/py2neo
test/core/1-main/merge_test.py
2
2682
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Copyright 2011-2014, Nigel Small # # 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 unicode_literals from uuid import uuid4 from py2neo import Node def test_can_merge_on_label_only(graph): if not graph.supports_node_labels: return label = uuid4().hex merged = list(graph.merge(label)) assert len(merged) == 1 assert isinstance(merged[0], Node) assert merged[0].labels == {label} def test_can_merge_on_label_and_property(graph): if not graph.supports_node_labels: return label = uuid4().hex merged = list(graph.merge(label, "foo", "bar")) assert len(merged) == 1 assert isinstance(merged[0], Node) assert merged[0].labels == {label} assert merged[0].properties == {"foo": "bar"} def test_cannot_merge_empty_label(graph): if not graph.supports_node_labels: return try: _ = list(graph.merge("")) except ValueError: assert True else: assert False def test_cannot_merge_with_non_textual_property_key(graph): if not graph.supports_node_labels: return label = uuid4().hex try: _ = list(graph.merge(label, 123, 456)) except TypeError: assert True else: assert False def test_cannot_merge_with_dict_property_key(graph): if not graph.supports_node_labels: return label = uuid4().hex try: _ = list(graph.merge(label, {})) except TypeError: assert True else: assert False def test_cannot_merge_on_key_only(graph): if not graph.supports_node_labels: return label = uuid4().hex try: _ = list(graph.merge(label, "foo")) except ValueError: assert True else: assert False def test_can_merge_one_on_label_and_property(graph): if not graph.supports_node_labels: return label = uuid4().hex try: merged = graph.merge_one(label, "foo", "bar") assert isinstance(merged, Node) assert merged.labels == {label} assert merged.properties == {"foo": "bar"} finally: graph.delete(merged)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7760, 13, 7280, 12, 30650, 24920, 23704, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 1134, 18, 685, 79, 492, 5013, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 265, 63, 1302, 63, 2118, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 9545, 275, 769, 8, 2180, 14, 5628, 8, 1302, 430, 272, 702, 822, 8, 15269, 9, 508, 413, 272, 702, 1228, 8, 15269, 59, 16, 467, 5013, 9, 272, 702, 9545, 59, 16, 1055, 3512, 508, 469, 1302, 93, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 265, 63, 1302, 63, 460, 63, 1829, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 9545, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 298, 1421, 401, 298, 1700, 2237, 272, 702, 822, 8, 15269, 9, 508, 413, 272, 702, 1228, 8, 15269, 59, 16, 467, 5013, 9, 272, 702, 9545, 59, 16, 1055, 3512, 508, 469, 1302, 93, 272, 702, 9545, 59, 16, 1055, 3282, 508, 2420, 1421, 582, 298, 1700, 3570, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1667, 63, 1302, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 31348, 272, 871, 1722, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1045, 63, 2865, 63, 505, 1061, 63, 1829, 63, 498, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 11869, 12, 31944, 430, 272, 871, 3146, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1045, 63, 807, 63, 1829, 63, 498, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 17003, 272, 871, 3146, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 265, 63, 498, 63, 2118, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 298, 1421, 2237, 272, 871, 1722, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 368, 63, 265, 63, 1302, 63, 460, 63, 1829, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 9545, 275, 3343, 14, 5628, 63, 368, 8, 1302, 12, 298, 1421, 401, 298, 1700, 531, 267, 702, 1228, 8, 15269, 12, 5013, 9, 267, 702, 9545, 14, 3512, 508, 469, 1302, 93, 267, 702, 9545, 14, 3282, 508, 2420, 1421, 582, 298, 1700, 3570, 272, 3753, 26, 267, 3343, 14, 1807, 8, 15269, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7760, 13, 7280, 12, 30650, 24920, 23704, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 1134, 18, 685, 79, 492, 5013, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 265, 63, 1302, 63, 2118, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 9545, 275, 769, 8, 2180, 14, 5628, 8, 1302, 430, 272, 702, 822, 8, 15269, 9, 508, 413, 272, 702, 1228, 8, 15269, 59, 16, 467, 5013, 9, 272, 702, 9545, 59, 16, 1055, 3512, 508, 469, 1302, 93, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 265, 63, 1302, 63, 460, 63, 1829, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 9545, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 298, 1421, 401, 298, 1700, 2237, 272, 702, 822, 8, 15269, 9, 508, 413, 272, 702, 1228, 8, 15269, 59, 16, 467, 5013, 9, 272, 702, 9545, 59, 16, 1055, 3512, 508, 469, 1302, 93, 272, 702, 9545, 59, 16, 1055, 3282, 508, 2420, 1421, 582, 298, 1700, 3570, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1667, 63, 1302, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 31348, 272, 871, 1722, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1045, 63, 2865, 63, 505, 1061, 63, 1829, 63, 498, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 11869, 12, 31944, 430, 272, 871, 3146, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 1045, 63, 807, 63, 1829, 63, 498, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 17003, 272, 871, 3146, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 11250, 63, 5628, 63, 265, 63, 498, 63, 2118, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 485, 275, 769, 8, 2180, 14, 5628, 8, 1302, 12, 298, 1421, 2237, 272, 871, 1722, 26, 267, 702, 715, 272, 587, 26, 267, 702, 756, 421, 199, 318, 511, 63, 2425, 63, 5628, 63, 368, 63, 265, 63, 1302, 63, 460, 63, 1829, 8, 2180, 304, 272, 340, 440, 3343, 14, 9823, 63, 932, 63, 3512, 26, 267, 372, 272, 1768, 275, 5377, 20, 1252, 4097, 272, 862, 26, 267, 9545, 275, 3343, 14, 5628, 63, 368, 8, 1302, 12, 298, 1421, 401, 298, 1700, 531, 267, 702, 1228, 8, 15269, 12, 5013, 9, 267, 702, 9545, 14, 3512, 508, 469, 1302, 93, 267, 702, 9545, 14, 3282, 508, 2420, 1421, 582, 298, 1700, 3570, 272, 3753, 26, 267, 3343, 14, 1807, 8, 15269, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mpeuster/son-emu
src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
1
16828
# Copyright (c) 2015 SONATA-NFV and Paderborn University # 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. # # Neither the name of the SONATA-NFV, Paderborn University # nor the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # This work has been performed in the framework of the SONATA project, # funded by the European Commission under Grant number 671517 through # the Horizon 2020 and 5G-PPP programmes. The authors would like to # acknowledge the contributions of their colleagues of the SONATA # partner consortium (www.sonata-nfv.eu). from flask_restful import Resource from flask import request, Response from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy from emuvim.api.openstack.helper import get_host import logging import json LOG = logging.getLogger("api.openstack.keystone") class KeystoneDummyApi(BaseOpenstackDummy): def __init__(self, in_ip, in_port): super(KeystoneDummyApi, self).__init__(in_ip, in_port) self.api.add_resource(KeystoneListVersions, "/", resource_class_kwargs={'api': self}) self.api.add_resource(KeystoneShowAPIv2, "/v2.0", resource_class_kwargs={'api': self}) self.api.add_resource(KeystoneGetToken, "/v2.0/tokens", resource_class_kwargs={'api': self}) self.api.add_resource(KeystoneShowAPIv3, "/v3.0", resource_class_kwargs={'api': self}) self.api.add_resource( KeystoneGetTokenv3, "/v3.0/auth/tokens", resource_class_kwargs={'api': self}) class KeystoneListVersions(Resource): """ List all known keystone versions. Hardcoded for our version! """ def __init__(self, api): self.api = api def get(self): """ List API versions. :return: Returns the api versions. :rtype: :class:`flask.response` containing a static json encoded dict. """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) resp = dict() resp['versions'] = dict() version = [{ "id": "v2.0", "links": [ { "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port), "rel": "self" } ], "media-types": [ { "base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json" } ], "status": "stable", "updated": "2014-04-17T00:00:00Z" }] resp['versions']['values'] = version return Response(json.dumps(resp), status=200, mimetype='application/json') class KeystoneShowAPIv2(Resource): """ Entrypoint for all openstack clients. This returns all current entrypoints running on son-emu. """ def __init__(self, api): self.api = api def get(self): """ List API entrypoints. :return: Returns an openstack style response for all entrypoints. :rtype: :class:`flask.response` """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) # neutron_port = self.api.port + 4696 # heat_port = self.api.port + 3004 resp = dict() resp['version'] = { "status": "stable", "media-types": [ { "base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json" } ], "id": "v2.0", "links": [ { "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port), "rel": "self" } ] } LOG.debug(json.dumps(resp)) return Response(json.dumps(resp), status=200, mimetype='application/json') class KeystoneShowAPIv3(Resource): """ Entrypoint for all openstack clients. This returns all current entrypoints running on son-emu. """ def __init__(self, api): self.api = api def get(self): """ List API entrypoints. :return: Returns an openstack style response for all entrypoints. :rtype: :class:`flask.response` """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) # neutron_port = self.api.port + 4696 # heat_port = self.api.port + 3004 resp = dict() resp['version'] = { "status": "stable", "media-types": [ { "base": "application/json", "type": "application/vnd.openstack.identity-v3.0+json" } ], "id": "v3.0", "links": [ { "href": "http://%s:%d/v3.0" % (get_host(request), self.api.port), "rel": "self" } ] } return Response(json.dumps(resp), status=200, mimetype='application/json') class KeystoneGetToken(Resource): """ Returns a static keystone token. We don't do any validation so we don't care. """ def __init__(self, api): self.api = api def post(self): """ List API entrypoints. This is hardcoded. For a working "authentication" use these ENVVARS: * OS_AUTH_URL=http://<ip>:<port>/v2.0 * OS_IDENTITY_API_VERSION=2.0 * OS_TENANT_ID=fc394f2ab2df4114bde39905f800dc57 * OS_REGION_NAME=RegionOne * OS_USERNAME=bla * OS_PASSWORD=bla :return: Returns an openstack style response for all entrypoints. :rtype: :class:`flask.response` """ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__)) try: ret = dict() req = json.loads(request.data) ret['access'] = dict() ret['access']['token'] = dict() token = ret['access']['token'] token['issued_at'] = "2014-01-30T15:30:58.819Z" token['expires'] = "2999-01-30T15:30:58.819Z" token['id'] = req['auth'].get( 'token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id') token['tenant'] = dict() token['tenant']['description'] = None token['tenant']['enabled'] = True token['tenant']['id'] = req['auth'].get( 'tenantId', 'fc394f2ab2df4114bde39905f800dc57') token['tenant']['name'] = "tenantName" ret['access']['user'] = dict() user = ret['access']['user'] user['username'] = req.get('username', "username") user['name'] = "tenantName" user['roles_links'] = list() user['id'] = token['tenant'].get( 'id', "fc394f2ab2df4114bde39905f800dc57") user['roles'] = [{'name': 'Member'}] ret['access']['region_name'] = "RegionOne" ret['access']['serviceCatalog'] = [{ "endpoints": [ { "adminURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']), "region": "RegionOne", "internalURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']), "id": "2dad48f09e2a447a9bf852bcd93548ef", "publicURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']) } ], "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { "adminURL": "http://%s:%s/v2.0" % (get_host(request), self.api.port), "region": "RegionOne", "internalURL": "http://%s:%s/v2.0" % (get_host(request), self.api.port), "id": "2dad48f09e2a447a9bf852bcd93543fc", "publicURL": "http://%s:%s/v2" % (get_host(request), self.api.port) } ], "endpoints_links": [], "type": "identity", "name": "keystone" }, { "endpoints": [ { "adminURL": "http://%s:%s" % (get_host(request), self.api.port + 4696), "region": "RegionOne", "internalURL": "http://%s:%s" % (get_host(request), self.api.port + 4696), "id": "2dad48f09e2a447a9bf852bcd93548cf", "publicURL": "http://%s:%s" % (get_host(request), self.api.port + 4696) } ], "endpoints_links": [], "type": "network", "name": "neutron" }, { "endpoints": [ { "adminURL": "http://%s:%s" % (get_host(request), self.api.port + 4242), "region": "RegionOne", "internalURL": "http://%s:%s" % (get_host(request), self.api.port + 4242), "id": "2dad48f09e2a447a9bf852bcd93548cf", "publicURL": "http://%s:%s" % (get_host(request), self.api.port + 4242) } ], "endpoints_links": [], "type": "image", "name": "glance" }, { "endpoints": [ { "adminURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']), "region": "RegionOne", "internalURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']), "id": "2dad48f09e2a447a9bf852bcd93548bf", "publicURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']) } ], "endpoints_links": [], "type": "orchestration", "name": "heat" } ] ret['access']["metadata"] = { "is_admin": 0, "roles": [ "7598ac3c634d4c3da4b9126a5f67ca2b" ] }, ret['access']['trust'] = { "id": "394998fa61f14736b1f0c1f322882949", "trustee_user_id": "269348fdd9374b8885da1418e0730af1", "trustor_user_id": "3ec3164f750146be97f21559ee4d9c51", "impersonation": False } return Response(json.dumps(ret), status=200, mimetype='application/json') except Exception as ex: logging.exception("Keystone: Get token failed.") return ex.message, 500 class KeystoneGetTokenv3(Resource): """ Returns a static keystone token. We don't do any validation so we don't care. """ def __init__(self, api): self.api = api def post(self): """ List API entrypoints. This is hardcoded. For a working "authentication" use these ENVVARS: * OS_AUTH_URL=http://<ip>:<port>/v3 * OS_IDENTITY_API_VERSION=2.0 * OS_TENANT_ID=fc394f2ab2df4114bde39905f800dc57 * OS_REGION_NAME=RegionOne * OS_USERNAME=bla * OS_PASSWORD=bla :return: Returns an openstack style response for all entrypoints. :rtype: :class:`flask.response` """ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__)) try: ret = dict() req = json.loads(request.data) ret['token'] = dict() token = ret['token'] token['issued_at'] = "2014-01-30T15:30:58.819Z" token['expires_at'] = "2999-01-30T15:30:58.819Z" token['methods'] = ["password"] token['extras'] = dict() token['user'] = dict() user = token['user'] user['id'] = req['auth'].get( 'token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id') user['name'] = "tenantName" user['password_expires_at'] = None user['domain'] = {"id": "default", "name": "Default"} token['audit_ids'] = ["ZzZwkUflQfygX7pdYDBCQQ"] # project token['project'] = { "domain": { "id": "default", "name": "Default" }, "id": "8538a3f13f9541b28c2620eb19065e45", "name": "tenantName" } # catalog token['catalog'] = [{ "endpoints": [ { "url": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']), "region": "RegionOne", "interface": "public", "id": "2dad48f09e2a447a9bf852bcd93548ef" } ], "id": "2dad48f09e2a447a9bf852bcd93548ef", "type": "compute", "name": "nova" }, { "endpoints": [ { "url": "http://%s:%s/v2.0" % (get_host(request), self.api.port), "region": "RegionOne", "interface": "public", "id": "2dad48f09e2a447a9bf852bcd93543fc" } ], "id": "2dad48f09e2a447a9bf852bcd93543fc", "type": "identity", "name": "keystone" }, { "endpoints": [ { "url": "http://%s:%s" % (get_host(request), self.api.port + 4696), "region": "RegionOne", "interface": "public", "id": "2dad48f09e2a447a9bf852bcd93548cf" } ], "id": "2dad48f09e2a447a9bf852bcd93548cf", "type": "network", "name": "neutron" }, { "endpoints": [ { "url": "http://%s:%s" % (get_host(request), self.api.port + 4242), "region": "RegionOne", "interface": "public", "id": "2dad48f09e2a447a9bf852bcd93548cf" } ], "id": "2dad48f09e2a447a9bf852bcd93548cf", "type": "image", "name": "glance" }, { "endpoints": [ { "url": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']), "region": "RegionOne", "interface": "public", "id": "2dad48f09e2a447a9bf852bcd93548bf" } ], "id": "2dad48f09e2a447a9bf852bcd93548bf", "type": "orchestration", "name": "heat" } ] return Response(json.dumps(ret), status=201, mimetype='application/json') except Exception as ex: logging.exception("Keystone: Get token failed.") return ex.message, 500
apache-2.0
[ 3, 1898, 334, 67, 9, 6900, 428, 615, 2751, 13, 19749, 54, 436, 510, 669, 66, 6161, 15904, 199, 3, 11727, 7052, 51, 12565, 540, 14112, 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, 3, 11443, 314, 536, 402, 314, 428, 615, 2751, 13, 19749, 54, 12, 510, 669, 66, 6161, 15904, 199, 3, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 4983, 14, 199, 3, 199, 3, 961, 1736, 965, 2757, 10585, 315, 314, 10059, 402, 314, 428, 615, 2751, 2199, 12, 199, 3, 289, 4585, 701, 314, 31615, 290, 7046, 27973, 1334, 598, 17633, 1329, 13296, 1046, 1196, 4012, 199, 3, 314, 869, 11925, 25455, 436, 959, 39, 13, 7701, 48, 2240, 6415, 14, 710, 11462, 3955, 2839, 370, 199, 3, 19807, 23504, 314, 406, 26675, 402, 3932, 1048, 274, 643, 10138, 402, 314, 428, 615, 2751, 199, 3, 5854, 406, 1509, 280, 453, 334, 1544, 14, 834, 419, 13, 9914, 86, 14, 16913, 680, 199, 504, 7209, 63, 3911, 1893, 492, 7337, 199, 504, 7209, 492, 1056, 12, 7232, 199, 504, 325, 6553, 16361, 14, 1246, 14, 8512, 14, 8512, 63, 27512, 31284, 14, 1095, 63, 8512, 63, 5869, 492, 3523, 4299, 2340, 11324, 199, 504, 325, 6553, 16361, 14, 1246, 14, 8512, 14, 3676, 492, 664, 63, 1102, 199, 646, 2050, 199, 646, 2022, 199, 199, 4947, 275, 2050, 14, 5572, 480, 1246, 14, 8512, 14, 19143, 531, 421, 199, 533, 2606, 8361, 11324, 7394, 8, 1563, 4299, 2340, 11324, 304, 272, 347, 636, 826, 721, 277, 12, 315, 63, 711, 12, 315, 63, 719, 304, 267, 1613, 8, 1197, 8361, 11324, 7394, 12, 291, 2843, 826, 721, 262, 63, 711, 12, 315, 63, 719, 9, 398, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 1296, 21167, 12, 3286, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 6824, 3735, 86, 18, 12, 3286, 86, 18, 14, 16, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 1002, 3264, 12, 3286, 86, 18, 14, 16, 15, 4504, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 6824, 3735, 86, 19, 12, 3286, 86, 19, 14, 16, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 288, 2606, 8361, 1002, 29117, 1813, 19, 12, 3286, 86, 19, 14, 16, 15, 1178, 15, 4504, 401, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 421, 199, 533, 2606, 8361, 1296, 21167, 8, 4031, 304, 272, 408, 272, 3820, 1006, 6040, 19395, 5459, 14, 272, 22825, 15282, 367, 4154, 1015, 1, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2986, 304, 267, 291, 14, 1246, 275, 2986, 339, 347, 664, 8, 277, 304, 267, 408, 267, 3820, 3261, 5459, 14, 398, 520, 1107, 26, 1803, 314, 2986, 5459, 14, 267, 520, 4500, 26, 520, 533, 1705, 15720, 14, 1310, 64, 3035, 282, 2955, 2022, 5737, 1211, 14, 267, 408, 267, 5051, 14, 1757, 480, 3735, 24251, 26, 450, 83, 9576, 2, 450, 620, 8, 277, 855, 533, 4914, 354, 8964, 267, 3085, 275, 1211, 342, 267, 3085, 459, 6234, 418, 275, 1211, 342, 398, 1015, 275, 8910, 288, 298, 344, 582, 298, 86, 18, 14, 16, 401, 288, 298, 4614, 582, 359, 355, 469, 490, 298, 6399, 582, 298, 1014, 13827, 83, 2689, 68, 15, 86, 18, 14, 16, 2, 450, 334, 362, 63, 1102, 8, 1069, 395, 291, 14, 1246, 14, 719, 395, 490, 298, 3369, 582, 298, 277, 2, 355, 789, 288, 2156, 288, 298, 4603, 13, 1313, 582, 359, 355, 469, 490, 298, 1095, 582, 298, 3578, 15, 1001, 401, 490, 298, 466, 582, 298, 3578, 15, 26379, 14, 8512, 14, 5582, 13, 86, 18, 14, 16, 11, 1001, 2, 355, 789, 288, 2156, 288, 298, 1205, 582, 298, 11989, 401, 288, 298, 5334, 582, 298, 7280, 13, 966, 13, 1196, 52, 383, 26, 383, 26, 383, 58, 2, 267, 14877, 267, 3085, 459, 6234, 2545, 1459, 418, 275, 1015, 398, 372, 7232, 8, 1001, 14, 4180, 8, 4518, 395, 2004, 29, 1840, 12, 717, 12200, 534, 3578, 15, 1001, 358, 421, 199, 533, 2606, 8361, 6824, 3735, 86, 18, 8, 4031, 304, 272, 408, 272, 11855, 1403, 367, 1006, 13869, 13431, 14, 272, 961, 2529, 1006, 1453, 2397, 3438, 3879, 641, 27970, 13, 14756, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2986, 304, 267, 291, 14, 1246, 275, 2986, 339, 347, 664, 8, 277, 304, 267, 408, 267, 3820, 3261, 2397, 3438, 14, 398, 520, 1107, 26, 1803, 376, 13869, 3449, 1177, 367, 1006, 2397, 3438, 14, 267, 520, 4500, 26, 520, 533, 1705, 15720, 14, 1310, 64, 267, 408, 267, 5051, 14, 1757, 480, 3735, 24251, 26, 450, 83, 9576, 2, 450, 620, 8, 277, 855, 533, 4914, 354, 8964, 398, 327, 8224, 63, 719, 275, 291, 14, 1246, 14, 719, 435, 841, 15154, 267, 327, 20408, 63, 719, 275, 291, 14, 1246, 14, 719, 435, 650, 7979, 398, 3085, 275, 1211, 342, 267, 3085, 459, 1023, 418, 275, 469, 288, 298 ]
[ 1898, 334, 67, 9, 6900, 428, 615, 2751, 13, 19749, 54, 436, 510, 669, 66, 6161, 15904, 199, 3, 11727, 7052, 51, 12565, 540, 14112, 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, 3, 11443, 314, 536, 402, 314, 428, 615, 2751, 13, 19749, 54, 12, 510, 669, 66, 6161, 15904, 199, 3, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 4983, 14, 199, 3, 199, 3, 961, 1736, 965, 2757, 10585, 315, 314, 10059, 402, 314, 428, 615, 2751, 2199, 12, 199, 3, 289, 4585, 701, 314, 31615, 290, 7046, 27973, 1334, 598, 17633, 1329, 13296, 1046, 1196, 4012, 199, 3, 314, 869, 11925, 25455, 436, 959, 39, 13, 7701, 48, 2240, 6415, 14, 710, 11462, 3955, 2839, 370, 199, 3, 19807, 23504, 314, 406, 26675, 402, 3932, 1048, 274, 643, 10138, 402, 314, 428, 615, 2751, 199, 3, 5854, 406, 1509, 280, 453, 334, 1544, 14, 834, 419, 13, 9914, 86, 14, 16913, 680, 199, 504, 7209, 63, 3911, 1893, 492, 7337, 199, 504, 7209, 492, 1056, 12, 7232, 199, 504, 325, 6553, 16361, 14, 1246, 14, 8512, 14, 8512, 63, 27512, 31284, 14, 1095, 63, 8512, 63, 5869, 492, 3523, 4299, 2340, 11324, 199, 504, 325, 6553, 16361, 14, 1246, 14, 8512, 14, 3676, 492, 664, 63, 1102, 199, 646, 2050, 199, 646, 2022, 199, 199, 4947, 275, 2050, 14, 5572, 480, 1246, 14, 8512, 14, 19143, 531, 421, 199, 533, 2606, 8361, 11324, 7394, 8, 1563, 4299, 2340, 11324, 304, 272, 347, 636, 826, 721, 277, 12, 315, 63, 711, 12, 315, 63, 719, 304, 267, 1613, 8, 1197, 8361, 11324, 7394, 12, 291, 2843, 826, 721, 262, 63, 711, 12, 315, 63, 719, 9, 398, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 1296, 21167, 12, 3286, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 6824, 3735, 86, 18, 12, 3286, 86, 18, 14, 16, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 1002, 3264, 12, 3286, 86, 18, 14, 16, 15, 4504, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 1197, 8361, 6824, 3735, 86, 19, 12, 3286, 86, 19, 14, 16, 401, 2892, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 267, 291, 14, 1246, 14, 525, 63, 1927, 8, 288, 2606, 8361, 1002, 29117, 1813, 19, 12, 3286, 86, 19, 14, 16, 15, 1178, 15, 4504, 401, 2073, 63, 533, 63, 958, 3713, 1246, 356, 291, 1552, 421, 199, 533, 2606, 8361, 1296, 21167, 8, 4031, 304, 272, 408, 272, 3820, 1006, 6040, 19395, 5459, 14, 272, 22825, 15282, 367, 4154, 1015, 1, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2986, 304, 267, 291, 14, 1246, 275, 2986, 339, 347, 664, 8, 277, 304, 267, 408, 267, 3820, 3261, 5459, 14, 398, 520, 1107, 26, 1803, 314, 2986, 5459, 14, 267, 520, 4500, 26, 520, 533, 1705, 15720, 14, 1310, 64, 3035, 282, 2955, 2022, 5737, 1211, 14, 267, 408, 267, 5051, 14, 1757, 480, 3735, 24251, 26, 450, 83, 9576, 2, 450, 620, 8, 277, 855, 533, 4914, 354, 8964, 267, 3085, 275, 1211, 342, 267, 3085, 459, 6234, 418, 275, 1211, 342, 398, 1015, 275, 8910, 288, 298, 344, 582, 298, 86, 18, 14, 16, 401, 288, 298, 4614, 582, 359, 355, 469, 490, 298, 6399, 582, 298, 1014, 13827, 83, 2689, 68, 15, 86, 18, 14, 16, 2, 450, 334, 362, 63, 1102, 8, 1069, 395, 291, 14, 1246, 14, 719, 395, 490, 298, 3369, 582, 298, 277, 2, 355, 789, 288, 2156, 288, 298, 4603, 13, 1313, 582, 359, 355, 469, 490, 298, 1095, 582, 298, 3578, 15, 1001, 401, 490, 298, 466, 582, 298, 3578, 15, 26379, 14, 8512, 14, 5582, 13, 86, 18, 14, 16, 11, 1001, 2, 355, 789, 288, 2156, 288, 298, 1205, 582, 298, 11989, 401, 288, 298, 5334, 582, 298, 7280, 13, 966, 13, 1196, 52, 383, 26, 383, 26, 383, 58, 2, 267, 14877, 267, 3085, 459, 6234, 2545, 1459, 418, 275, 1015, 398, 372, 7232, 8, 1001, 14, 4180, 8, 4518, 395, 2004, 29, 1840, 12, 717, 12200, 534, 3578, 15, 1001, 358, 421, 199, 533, 2606, 8361, 6824, 3735, 86, 18, 8, 4031, 304, 272, 408, 272, 11855, 1403, 367, 1006, 13869, 13431, 14, 272, 961, 2529, 1006, 1453, 2397, 3438, 3879, 641, 27970, 13, 14756, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2986, 304, 267, 291, 14, 1246, 275, 2986, 339, 347, 664, 8, 277, 304, 267, 408, 267, 3820, 3261, 2397, 3438, 14, 398, 520, 1107, 26, 1803, 376, 13869, 3449, 1177, 367, 1006, 2397, 3438, 14, 267, 520, 4500, 26, 520, 533, 1705, 15720, 14, 1310, 64, 267, 408, 267, 5051, 14, 1757, 480, 3735, 24251, 26, 450, 83, 9576, 2, 450, 620, 8, 277, 855, 533, 4914, 354, 8964, 398, 327, 8224, 63, 719, 275, 291, 14, 1246, 14, 719, 435, 841, 15154, 267, 327, 20408, 63, 719, 275, 291, 14, 1246, 14, 719, 435, 650, 7979, 398, 3085, 275, 1211, 342, 267, 3085, 459, 1023, 418, 275, 469, 288, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
thicklizard/AwesomeSauce1_1
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
11088
3246
# Core.py - Python extension for perf script, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string def taskState(state): states = { 0 : "R", 1 : "S", 2 : "D", 64: "DEAD" } if state not in states: return "Unknown" return states[state] class EventHeaders: def __init__(self, common_cpu, common_secs, common_nsecs, common_pid, common_comm): self.cpu = common_cpu self.secs = common_secs self.nsecs = common_nsecs self.pid = common_pid self.comm = common_comm def ts(self): return (self.secs * (10 ** 9)) + self.nsecs def ts_format(self): return "%d.%d" % (self.secs, int(self.nsecs / 1000))
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wuher/diablo
test/test_resource.py
1
23625
# -*- coding: utf-8 -*- # test_resource.py --- # import json import base64 from twisted.internet import defer, reactor from twisted.web import server from twisted.web.test.test_web import DummyRequest from twisted.trial import unittest from twisted.internet.defer import succeed from twisted.python import log from twisted.web.http import OK, NOT_FOUND, INTERNAL_SERVER_ERROR, CONFLICT from diablo.resource import Resource from diablo.api import RESTApi from diablo.auth import HttpBasic, register_authenticator from diablo.mappers.xmlmapper import XmlMapper from diablo.mappers.jsonmapper import JsonMapper from diablo.mappers.yamlmapper import YamlMapper from diablo.http import NotFound, Response, Conflict class DiabloDummyRequest(DummyRequest): code = OK data = '' def __init__(self, *args, **kw): DummyRequest.__init__(self, *args, **kw) self.content = self def read(self): return self.data class UnaccessibleResource(Resource): allow_anonymous = False def get(self, request): return 'you will never see this' class AuthenticatedResource(Resource): allow_anonymous = False authentication = HttpBasic() def get(self, request): return 'hello %s' % (request.user,) class DiabloTestResource(Resource): collection = {} def get(self, request, *args, **kw): if 'key' in kw: key = kw.get('key') if key in self.collection: return self.collection[key] else: raise NotFound() else: return self.collection def put(self, data, request, *args, **kw): for k in data: self.collection[k] = data[k] def post(self, data, request, *args, **kw): for k in data: self.collection[k] = data[k] def delete(self, request, *args, **kw): if 'key' in kw: key = kw.get('key') if key in self.collection: removed = self.collection.pop(kw['key']) log.msg('removed', removed) else: raise NotFound() else: log.msg('removing entire collection') self.collection = {} class RouteTestResource1(Resource): def get(self, request, *args, **kw): return {'nothing': 'something'} class RouteTestResource2(Resource): def get(self, request, *args, **kw): return {'something': 'nothing'} regular_result = {'name': 'luke skywalker', 'occupation': 'jedi'} class RegularTestResource(Resource): def get(self, request, *args, **kw): return regular_result deferred_result = [1, 2, 3, 4, 5] class DeferredTestResource(Resource): def get(self, request, *args, **kw): d = defer.Deferred() reactor.callLater(0, d.callback, deferred_result) return d class ErrorResource(Resource): """ Resource to test error scenarios. """ def get(self, request, id, *args, **kw): self.error_id = int(id) if self.error_id is 1: raise NotFound("Can't find it, sorry.") elif self.error_id is 2: raise Exception('Unknown exception.') else: return {'id': 9} def _processResponse(self, request, response): if self.error_id is 3: raise Conflict("There's a conflict my friend.") elif self.error_id is 4: raise TypeError('Bad type.') else: return Response(code=OK, content='hiihoo') def _render(resource, request): result = resource.render(request) if isinstance(result, str): request.write(result) request.finish() return succeed(None) elif result is server.NOT_DONE_YET: if request.finished: return succeed(None) else: return request.notifyFinish() else: raise ValueError("Unexpected return value: %r" % (result,)) routes = [ ('/auth/unaccessible', 'test_resource.UnaccessibleResource'), ('/auth/normal', 'test_resource.AuthenticatedResource'), ('/testregular(?P<format>\.?\w{1,8})?$', 'test_resource.RegularTestResource'), ('/testdeferred(?P<format>\.?\w{1,8})?$', 'test_resource.DeferredTestResource'), ('/a/useless/path$', 'test_resource.RouteTestResource1'), ('/a/useful/path(/)?(?P<tendigit>\d{10})?$', 'test_resource.RouteTestResource2'), ('/a/test/resource(/)?(?P<key>\w{1,10})?$', 'test_resource.DiabloTestResource'), ('/error/(?P<err_id>\d{1,2})', 'test_resource.ErrorResource'), ] params = { 'indent': 4, 'ensure_ascii': False, 'encoding': 'utf-8', } xmlMapper = XmlMapper() jsonMapper = JsonMapper() yamlMapper = YamlMapper() class AuthResourceTest(unittest.TestCase): passwd = { 'jedi': 'jedixx', 'sith': 'sithxx' } def check_creds(self, username, password): passwd = self.passwd.get(username, None) return passwd == password def get_auth_header(self, username, password): credsz = base64.b64encode('%s:%s' % (username, password)) return { 'authorization': 'Basic %s' % (credsz,) } def setUp(self): self.api = RESTApi(routes) register_authenticator(self.check_creds) def test_get_unaccessible(self): request = DiabloDummyRequest(['']) request.method = 'GET' request.path = '/auth/unaccessible' resource = self.api.getChild('/', request) d = _render(resource, request) def renderer(ignored): self.assertEquals(request.responseCode, 403) d.addCallback(renderer) def test_get_jedi_fail(self): request = DiabloDummyRequest(['']) request.method = 'GET' request.path = '/auth/normal' request.headers = self.get_auth_header('jedi', 'jedi') resource = self.api.getChild('/', request) d = _render(resource, request) def renderer(ignored): self.assertEquals(403, request.responseCode) d.addCallback(renderer) def test_get_jedi_ok(self): request = DiabloDummyRequest(['']) request.method = 'GET' request.path = '/auth/normal' request.headers = self.get_auth_header('jedi', 'jedixx') resource = self.api.getChild('/', request) d = _render(resource, request) def renderer(ignored): self.assertEquals(200, request.responseCode) d.addCallback(renderer) def test_get_anonymous(self): request = DiabloDummyRequest(['']) request.method = 'GET' request.path = '/auth/normal' # request.headers = self.get_auth_header('jedi', 'jedixx') resource = self.api.getChild('/', request) d = _render(resource, request) def renderer(ignored): self.assertEquals(401, request.responseCode) d.addCallback(renderer) class PutResourceTest(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_put_resource(self): request = DiabloDummyRequest(['']) request.method = 'PUT' request.path = '/a/test/resource' request.headers = {'content-type': 'application/json'} request.data = json.dumps({'key1': 'value1'}) resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): self.assertEquals(request.responseCode, OK) d.addCallback(rendered) request2 = DiabloDummyRequest(['']) request2.path = '/a/test/resource/key1' request2.headers = {'content-type': 'application/json'} resource2 = self.api.getChild('/ignored', request2) def doGet(ignored): d2 = _render(resource2, request2) def get_rendered(ignored): response = ''.join(request2.written) response_obj = json.loads(response) self.assertEquals(response_obj, 'value1') d2.addCallback(get_rendered) return d2 d.addCallback(doGet) return d class PostResourceTest(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_post_resource(self): request = DiabloDummyRequest(['']) request.method = 'POST' request.path = '/a/test/resource' request.headers = {'content-type': 'application/json'} request.data = json.dumps({'key2': 'value2'}) resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): self.assertEquals(request.responseCode, OK) self.assertEquals({'key2': 'value2'}, resource.collection) d.addCallback(rendered) request2 = DiabloDummyRequest(['']) request2.path = '/a/test/resource/key2' request2.headers = {'content-type': 'application/json'} resource2 = self.api.getChild('/ignored', request2) def doGet(ignored): d2 = _render(resource2, request2) def get_rendered(ignored): response = ''.join(request2.written) response_obj = json.loads(response) self.assertEquals(response_obj, 'value2') d2.addCallback(get_rendered) return d2 d.addCallback(doGet) return d class DeleteResourceTest(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def _put_something(self, key, val): request = DiabloDummyRequest(['']) request.method = 'PUT' request.path = '/a/test/resource' request.headers = {'content-type': 'application/json'} request.data = json.dumps({key: val}) resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): self.assertEquals(request.responseCode, OK) d.addCallback(rendered) return d def _delete_it(self, ignored, key): request = DiabloDummyRequest(['']) request.method = 'DELETE' request.path = '/a/test/resource/key3' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): self.assertEquals(request.responseCode, OK) d.addCallback(rendered) return d def _get_it(self, ignored, key): request = DiabloDummyRequest(['']) request.path = '/a/test/resource/key3' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): self.assertEquals(request.responseCode, NotFound().code) d.addCallback(rendered) def test_delete_resource(self): key, val = 'key3', 'val3' d = self._put_something(key, val) d.addCallback(self._delete_it, key) d.addCallback(self._get_it, key) return d class ResourceRoutingTest(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_basic_route(self): request = DiabloDummyRequest(['']) request.path = '/a/useless/path' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = json.loads(response) self.assertEquals(response_obj, {'nothing': 'something'}) d.addCallback(rendered) return d def test_re_group_route_wo_group(self): request = DiabloDummyRequest(['']) request.path = '/a/useful/path' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = json.loads(response) self.assertEquals(response_obj, {'something': 'nothing'}) d.addCallback(rendered) return d def test_re_group_route_w_group(self): request = DiabloDummyRequest(['']) request.path = '/a/useful/path/1234567890' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = json.loads(response) self.assertEquals(response_obj, {'something': 'nothing'}) d.addCallback(rendered) return d def test_re_group_route_w_invalid_group(self): request = DiabloDummyRequest(['']) request.path = '/a/useful/path/1invalid01' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/ignored', request) d = _render(resource, request) def rendered(ignored): log.msg('ignored', ignored) self.assertEquals(request.responseCode, NotFound().code) d.addCallback(rendered) return d class ResourceTestCase(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_regular_response(self): request = DiabloDummyRequest(['']) request.path = '/testregular' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = json.loads(response) self.assertEquals(response_obj, regular_result) d.addCallback(rendered) return d def test_deferred_response(self): request = DiabloDummyRequest(['']) request.path = '/testdeferred' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/testdeferred', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = json.loads(response) self.assertEquals(response_obj, deferred_result) d.addCallback(rendered) return d class ContentTypeFormatterTestCase(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_json_formatter(self): request = DiabloDummyRequest(['']) request.path = '/testregular' request.headers = {'content-type': 'application/json'} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = jsonMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/json') d.addCallback(rendered) return d def test_xml_formatter(self): request = DiabloDummyRequest(['']) request.path = '/testregular' request.headers = {'content-type': 'text/xml'} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = xmlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'text/xml') d.addCallback(rendered) return d def test_yaml_formatter(self): request = DiabloDummyRequest(['']) request.path = '/testregular' request.headers = {'content-type': 'application/yaml'} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = yamlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/yaml') d.addCallback(rendered) return d class FormatArgTestCase(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_json_arg(self): request = DiabloDummyRequest([]) request.path = '/testregular' request.args = {'format': ['json']} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = jsonMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/json') d.addCallback(rendered) return d def test_xml_arg(self): request = DiabloDummyRequest([]) request.path = '/testregular' request.args = {'format': ['xml']} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = xmlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'text/xml') d.addCallback(rendered) return d def test_yaml_arg(self): request = DiabloDummyRequest([]) request.path = '/testregular' request.args = {'format': ['yaml']} resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) response_obj = yamlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/yaml') d.addCallback(rendered) return d class UrlFormatTestCase(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_json_url(self): request = DiabloDummyRequest([]) request.path = '/testregular.json' resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) log.msg('Response', response) response_obj = jsonMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/json') d.addCallback(rendered) return d def test_xml_url(self): request = DiabloDummyRequest([]) request.path = '/testregular.xml' resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) log.msg('Response', response) response_obj = xmlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'text/xml') d.addCallback(rendered) return d def test_yaml_url(self): request = DiabloDummyRequest([]) request.method = 'GET' request.path = '/testregular.yaml' resource = self.api.getChild('/testregular', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) log.msg('Response', response) response_obj = yamlMapper._parse_data(response, 'utf-8') self.assertEquals(response_obj, regular_result) content_header = request.outgoingHeaders.get('content-type', None) content_type = content_header.split(';')[0] if content_header else None self.assertEquals(content_type, 'application/yaml') d.addCallback(rendered) return d class TestErrors(unittest.TestCase): def setUp(self): self.api = RESTApi(routes) def test_exec_handler_fails_http(self): request = DiabloDummyRequest([]) request.method = 'GET' request.path = '/error/1' resource = self.api.getChild('/error/1', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) self.assertEquals(NOT_FOUND, request.responseCode) self.assertEquals("Can't find it, sorry.", response) d.addCallback(rendered) return d def test_exec_handler_fails_unknown(self): request = DiabloDummyRequest([]) request.method = 'GET' request.path = '/error/2' resource = self.api.getChild('/error/2', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) self.assertEquals(INTERNAL_SERVER_ERROR, request.responseCode) self.assertEquals("Unknown exception.", response) d.addCallback(rendered) return d def test_processing_fails_http(self): request = DiabloDummyRequest([]) request.method = 'GET' request.path = '/error/3' resource = self.api.getChild('/error/3', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) self.assertEquals(CONFLICT, request.responseCode) self.assertEquals("There's a conflict my friend.", response) d.addCallback(rendered) return d def test_processing_fails_unknown(self): request = DiabloDummyRequest([]) request.method = 'GET' request.path = '/error/4' resource = self.api.getChild('/error/4', request) d = _render(resource, request) def rendered(ignored): response = ''.join(request.written) self.assertEquals(INTERNAL_SERVER_ERROR, request.responseCode) self.assertEquals("Bad type.", response) d.addCallback(rendered) return d # # test_resource.py ends here
mit
[ 3, 221, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 221, 511, 63, 1927, 14, 647, 10894, 199, 3, 199, 199, 646, 2022, 199, 646, 1300, 772, 199, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 199, 504, 7390, 14, 2520, 492, 1654, 199, 504, 7390, 14, 2520, 14, 396, 14, 396, 63, 2520, 492, 9762, 2017, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 2520, 14, 1014, 492, 9949, 12, 2845, 63, 13945, 12, 1621, 17071, 63, 6613, 63, 3170, 12, 6392, 2507, 52, 199, 199, 504, 487, 371, 320, 14, 1927, 492, 7337, 199, 504, 487, 371, 320, 14, 1246, 492, 14880, 7394, 199, 504, 487, 371, 320, 14, 1178, 492, 4760, 6845, 12, 2274, 63, 1178, 21345, 199, 504, 487, 371, 320, 14, 24469, 14, 1652, 7153, 492, 24881, 11880, 199, 504, 487, 371, 320, 14, 24469, 14, 1001, 7153, 492, 14587, 11880, 199, 504, 487, 371, 320, 14, 24469, 14, 5963, 7153, 492, 1488, 3935, 11880, 199, 504, 487, 371, 320, 14, 1014, 492, 21909, 12, 7232, 12, 32539, 6960, 421, 199, 533, 3757, 371, 320, 11324, 2017, 8, 11324, 2017, 304, 339, 1233, 275, 9949, 272, 666, 275, 2125, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 9762, 2017, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 291, 14, 1317, 275, 291, 339, 347, 1586, 8, 277, 304, 267, 372, 291, 14, 576, 421, 199, 533, 1910, 24669, 4031, 8, 4031, 304, 339, 2040, 63, 12628, 275, 756, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 283, 13297, 911, 7078, 1937, 642, 7, 421, 199, 533, 3590, 8080, 4031, 8, 4031, 304, 339, 2040, 63, 12628, 275, 756, 272, 6299, 275, 4760, 6845, 342, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 283, 5006, 450, 83, 7, 450, 334, 1069, 14, 751, 4258, 421, 199, 533, 3757, 371, 320, 774, 4031, 8, 4031, 304, 339, 3245, 275, 1052, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 283, 498, 7, 315, 4775, 26, 288, 790, 275, 4775, 14, 362, 360, 498, 358, 288, 340, 790, 315, 291, 14, 3627, 26, 355, 372, 291, 14, 3627, 59, 498, 61, 288, 587, 26, 355, 746, 21909, 342, 267, 587, 26, 288, 372, 291, 14, 3627, 339, 347, 5324, 8, 277, 12, 666, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 367, 1022, 315, 666, 26, 288, 291, 14, 3627, 59, 75, 61, 275, 666, 59, 75, 61, 339, 347, 2963, 8, 277, 12, 666, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 367, 1022, 315, 666, 26, 288, 291, 14, 3627, 59, 75, 61, 275, 666, 59, 75, 61, 339, 347, 3145, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 283, 498, 7, 315, 4775, 26, 288, 790, 275, 4775, 14, 362, 360, 498, 358, 288, 340, 790, 315, 291, 14, 3627, 26, 355, 4829, 275, 291, 14, 3627, 14, 1935, 8, 829, 459, 498, 1105, 355, 943, 14, 1328, 360, 10649, 297, 4829, 9, 288, 587, 26, 355, 746, 21909, 342, 267, 587, 26, 288, 943, 14, 1328, 360, 264, 7665, 8039, 3245, 358, 288, 291, 14, 3627, 275, 1052, 421, 199, 533, 24244, 774, 4031, 17, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 791, 16323, 356, 283, 10297, 936, 421, 199, 533, 24244, 774, 4031, 18, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 791, 10297, 356, 283, 16323, 936, 421, 199, 7898, 63, 1099, 275, 791, 354, 356, 283, 10836, 415, 2386, 89, 87, 14976, 297, 283, 27256, 425, 356, 283, 74, 6297, 936, 421, 199, 533, 18528, 774, 4031, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 5578, 63, 1099, 421, 199, 12116, 63, 1099, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 61, 421, 199, 533, 17448, 774, 4031, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 366, 275, 10133, 14, 9937, 342, 267, 9655, 14, 1250, 22028, 8, 16, 12, 366, 14, 3058, 12, 12309, 63, 1099, 9, 267, 372, 366, 421, 199, 533, 4520, 4031, 8, 4031, 304, 272, 408, 7337, 370, 511, 1125, 28444, 14, 408, 339, 347, 664, 8, 277, 12, 1056, 12, 1305, 12, 627, 589, 12, 1011, 829, 304, 267, 291, 14, 705, 63, 344, 275, 1109, 8, 344, 9, 267, 340, 291, 14, 705, 63, 344, 365, 413, 26, 288, 746, 21909, 480, 6049, 1133, 2342, 652, 12, 308, 21342, 2685, 267, 916, 291, 14, 705, 63, 344, 365, 499, 26, 288, 746, 2186, 360, 5912, 1919, 2659, 267, 587, 26, 288, 372, 791, 344, 356, 1749, 93, 339, 347, 485, 1412, 2364, 8, 277, 12, 1056, 12, 1177, 304, 267, 340, 291, 14, 705, 63, 344, 365, 650, 26, 288, 746, 32539, 6960, 480, 10924, 1159, 282, 12395, 3002, 32506, 2685, 267, 916, 291, 14, 705, 63, 344, 365, 841, 26, 288, 746, 3146, 360, 5725, 730, 2659, 267, 587, 26, 288, 372, 7232, 8, 600, 29, 3593, 12, 1564, 534, 5812, 73, 19112, 358, 421, 199, 318, 485, 3352, 8, 1927, 12, 1056, 304, 272, 754, 275, 2073, 14, 3352, 8, 1069, 9, 272, 340, 1228, 8, 1099, 12, 620, 304, 267, 1056, 14, 952, 8, 1099, 9, 267, 1056, 14, 8192, 342, 267, 372, 17961, 8, 403, 9, 272, 916, 754, 365, 1654, 14, 4609, 63, 22162, 63, 57, 775, 26, 267, 340, 1056, 14, 8669, 26, 288, 372, 17961, 8, 403, 9, 267, 587, 26, 288, 372, 1056, 14, 6814, 22084, 342, 272, 587, 26, 267, 746, 1722, 480, 8708, 372, 574, 26, 450, 82, 2, 450, 334, 1099, 4641, 421, 199, 13243, 275, 359, 272, 14606, 1178, 15, 324, 24669, 297, 283, 396, 63, 1927, 14 ]
[ 221, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 221, 511, 63, 1927, 14, 647, 10894, 199, 3, 199, 199, 646, 2022, 199, 646, 1300, 772, 199, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 199, 504, 7390, 14, 2520, 492, 1654, 199, 504, 7390, 14, 2520, 14, 396, 14, 396, 63, 2520, 492, 9762, 2017, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 2520, 14, 1014, 492, 9949, 12, 2845, 63, 13945, 12, 1621, 17071, 63, 6613, 63, 3170, 12, 6392, 2507, 52, 199, 199, 504, 487, 371, 320, 14, 1927, 492, 7337, 199, 504, 487, 371, 320, 14, 1246, 492, 14880, 7394, 199, 504, 487, 371, 320, 14, 1178, 492, 4760, 6845, 12, 2274, 63, 1178, 21345, 199, 504, 487, 371, 320, 14, 24469, 14, 1652, 7153, 492, 24881, 11880, 199, 504, 487, 371, 320, 14, 24469, 14, 1001, 7153, 492, 14587, 11880, 199, 504, 487, 371, 320, 14, 24469, 14, 5963, 7153, 492, 1488, 3935, 11880, 199, 504, 487, 371, 320, 14, 1014, 492, 21909, 12, 7232, 12, 32539, 6960, 421, 199, 533, 3757, 371, 320, 11324, 2017, 8, 11324, 2017, 304, 339, 1233, 275, 9949, 272, 666, 275, 2125, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 9762, 2017, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 291, 14, 1317, 275, 291, 339, 347, 1586, 8, 277, 304, 267, 372, 291, 14, 576, 421, 199, 533, 1910, 24669, 4031, 8, 4031, 304, 339, 2040, 63, 12628, 275, 756, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 283, 13297, 911, 7078, 1937, 642, 7, 421, 199, 533, 3590, 8080, 4031, 8, 4031, 304, 339, 2040, 63, 12628, 275, 756, 272, 6299, 275, 4760, 6845, 342, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 283, 5006, 450, 83, 7, 450, 334, 1069, 14, 751, 4258, 421, 199, 533, 3757, 371, 320, 774, 4031, 8, 4031, 304, 339, 3245, 275, 1052, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 283, 498, 7, 315, 4775, 26, 288, 790, 275, 4775, 14, 362, 360, 498, 358, 288, 340, 790, 315, 291, 14, 3627, 26, 355, 372, 291, 14, 3627, 59, 498, 61, 288, 587, 26, 355, 746, 21909, 342, 267, 587, 26, 288, 372, 291, 14, 3627, 339, 347, 5324, 8, 277, 12, 666, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 367, 1022, 315, 666, 26, 288, 291, 14, 3627, 59, 75, 61, 275, 666, 59, 75, 61, 339, 347, 2963, 8, 277, 12, 666, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 367, 1022, 315, 666, 26, 288, 291, 14, 3627, 59, 75, 61, 275, 666, 59, 75, 61, 339, 347, 3145, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 283, 498, 7, 315, 4775, 26, 288, 790, 275, 4775, 14, 362, 360, 498, 358, 288, 340, 790, 315, 291, 14, 3627, 26, 355, 4829, 275, 291, 14, 3627, 14, 1935, 8, 829, 459, 498, 1105, 355, 943, 14, 1328, 360, 10649, 297, 4829, 9, 288, 587, 26, 355, 746, 21909, 342, 267, 587, 26, 288, 943, 14, 1328, 360, 264, 7665, 8039, 3245, 358, 288, 291, 14, 3627, 275, 1052, 421, 199, 533, 24244, 774, 4031, 17, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 791, 16323, 356, 283, 10297, 936, 421, 199, 533, 24244, 774, 4031, 18, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 791, 10297, 356, 283, 16323, 936, 421, 199, 7898, 63, 1099, 275, 791, 354, 356, 283, 10836, 415, 2386, 89, 87, 14976, 297, 283, 27256, 425, 356, 283, 74, 6297, 936, 421, 199, 533, 18528, 774, 4031, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 5578, 63, 1099, 421, 199, 12116, 63, 1099, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 61, 421, 199, 533, 17448, 774, 4031, 8, 4031, 304, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 829, 304, 267, 366, 275, 10133, 14, 9937, 342, 267, 9655, 14, 1250, 22028, 8, 16, 12, 366, 14, 3058, 12, 12309, 63, 1099, 9, 267, 372, 366, 421, 199, 533, 4520, 4031, 8, 4031, 304, 272, 408, 7337, 370, 511, 1125, 28444, 14, 408, 339, 347, 664, 8, 277, 12, 1056, 12, 1305, 12, 627, 589, 12, 1011, 829, 304, 267, 291, 14, 705, 63, 344, 275, 1109, 8, 344, 9, 267, 340, 291, 14, 705, 63, 344, 365, 413, 26, 288, 746, 21909, 480, 6049, 1133, 2342, 652, 12, 308, 21342, 2685, 267, 916, 291, 14, 705, 63, 344, 365, 499, 26, 288, 746, 2186, 360, 5912, 1919, 2659, 267, 587, 26, 288, 372, 791, 344, 356, 1749, 93, 339, 347, 485, 1412, 2364, 8, 277, 12, 1056, 12, 1177, 304, 267, 340, 291, 14, 705, 63, 344, 365, 650, 26, 288, 746, 32539, 6960, 480, 10924, 1159, 282, 12395, 3002, 32506, 2685, 267, 916, 291, 14, 705, 63, 344, 365, 841, 26, 288, 746, 3146, 360, 5725, 730, 2659, 267, 587, 26, 288, 372, 7232, 8, 600, 29, 3593, 12, 1564, 534, 5812, 73, 19112, 358, 421, 199, 318, 485, 3352, 8, 1927, 12, 1056, 304, 272, 754, 275, 2073, 14, 3352, 8, 1069, 9, 272, 340, 1228, 8, 1099, 12, 620, 304, 267, 1056, 14, 952, 8, 1099, 9, 267, 1056, 14, 8192, 342, 267, 372, 17961, 8, 403, 9, 272, 916, 754, 365, 1654, 14, 4609, 63, 22162, 63, 57, 775, 26, 267, 340, 1056, 14, 8669, 26, 288, 372, 17961, 8, 403, 9, 267, 587, 26, 288, 372, 1056, 14, 6814, 22084, 342, 272, 587, 26, 267, 746, 1722, 480, 8708, 372, 574, 26, 450, 82, 2, 450, 334, 1099, 4641, 421, 199, 13243, 275, 359, 272, 14606, 1178, 15, 324, 24669, 297, 283, 396, 63, 1927, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dulems/hue
desktop/core/ext-py/guppy-0.1.10/guppy/gsl/Html.py
37
15304
#._cv_part guppy.gsl.Html class Node2Html: def __init__(self, mod, node=None, error_report = None, encode_name=None ): self.mod = mod self.valid_html40 = False self.encode = self.mod.encode if encode_name is None: encode_name = self.mod.encode_name self.encode_name = encode_name if error_report is not None: self.error_report = error_report self.document_lang = None self.header_nodes = [] self.indent = 0 self.indentstep = 1 self.set_out([]) # xxx where do this? charset = 'utf-8' self.header_nodes.append(self.mod.node_of_taci( 'meta', '', ( self.mod.node_of_taci('http-equiv=', 'Content-Type'), self.mod.node_of_taci('content=', 'text/html; charset=%s'%charset)))) if node is not None: node.accept(self) def _visit_children(self, node): node, attrs = node.split_attrs() # xxx handle attrs? E = self.mod.ReportedError for ch in node.children: try: ch.accept(self) except E: pass def begin(self, tag, arg=''): if arg: t = '<%s %s>'%(tag, arg) else: t = '<%s>'%tag if tag in self.mod.line_break_allowed: t = '\n'+self.indent * ' ' + t self.append(t) self.indent += self.indentstep def chg_out(self, out): oo = self.out self.set_out(out) return oo def encode_link_name(self, name): # 1. Make the name better looking for a html user's perspective # 2. Encode it by HTML rules if name.startswith(self.mod.tgt_prefix): name = name[len(self.mod.tgt_prefix):] else: # Should not happen often or at all assert 0 name = self.encode_name(name) return name def end(self, tag): self.indent -= self.indentstep self.append('</%s>'%tag) def error(self, msg, *args, **kwds): msg = 'Doc2Html: ' + msg self.error_report(msg, *args, **kwds) def error_report(self, msg, *args, **kwds): print 'HTML ENCODING ERROR: ', msg, 'args=',args, 'kwds=',kwds raise ValueError def gen_document_header(self, lang, header_nodes): # lang & title are nodes with text or char directives, to be encoded. # metas is a list of nodes, with data to be encoded self.append("""\ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> """) self.begin('html', 'lang=%s'%self.get_encoded_text(lang)) self.begin('head') for node in header_nodes: self.gen_stdhtml(node) self.end('head') self.begin('body') # Get around w3c restriction that character data are not allowed # directly in body, makes it easier to write compliant code # Arguably the restriction is there for a reason, but I dont know... self.begin('div') def gen_document_trailer(self): self.end('div') self.end('body') self.end('html') def gen_empty_elmt(self, tag, arg=''): self.begin(tag, arg) self.indent -= self.indentstep def gen_generated_from_gsl(self): self.gen_empty_elmt('hr') self.append('Generated by ') self.begin('a', 'href="http://guppy-pe.sourceforge.net/gsl.html"') #self.begin('a', 'href="gsl.html"') self.append('GSL-HTML 0.1.5') self.end('a') self.append(' on '+self.mod.time.asctime(self.mod.time.localtime())) def gen_meta(self, node, tag=None): mknode = self.mod.node_of_taci if tag is None: tag = node.tag self.header_nodes.append( mknode('meta', '', [mknode('name=', tag), mknode('content=', node.arg, node.children)])) def gen_stdhtml(self, node, tag=None, **options): if tag is None: tag = node.tag node, attrs = node.split_attrs(tag) self.begin(tag, ' '.join(['%s=%r'%(key, val) for (key, val) in attrs])) if tag in self.mod._no_end_tag_elements: if node.arg: self.error('No enclosed text allowed for Html tag: %r.'%node.tag) self.no_children(node) self.indent -= self.indentstep else: node.arg_accept(self) self.end(tag) def get_encoded_text(self, node): # From a node's arg and children that are text or characters old_out = self.chg_out([]) self.append(self.encode(node.arg)) for ch in node.children: if ch.tag in ('text', 'char'): ch.accept(self) else: self.error('Only text and char allowed here, not %r.'%ch.tag, ch) return ''.join(self.chg_out(old_out)) def get_html(self): return ''.join(self.out) def no_children(self, node): if node.children: self.error('No children allowed for %r. Got children nodes = %r.'%( node.tag, node.children)) def set_out(self, out): self.out = out self.extend = out.extend self.append = out.append def visit_author(self, node): self.gen_meta(node) def visit_block(self, node): self._visit_children(node) def visit_char(self, node): name = node.get_namearg() if name in self.mod.name2codepoint: name = '&%s;'%name else: if name[:2] == "0x": char = int(name[2:], 16) elif name.isdigit(): char = int(name) else: self.error('No such character: %r.'%name, node) name = self.mod.codepoint2name.get(char) if name is None: name = '&#%d;'%char else: name = '&%s;'%name self.append(name) self._visit_children(node) def visit_col_width(self, node): self.append('<col width="%s" />'%node.arg) def visit_comment(self, node): return #self.append('<!-- %s -->'%node.arg) def visit_default(self, node): if node.tag in self.mod.stdhtml: if node.tag in self.mod._head_elements: self.head_nodes.append(node) else: self.gen_stdhtml(node) else: self.error('I don\'t know what to generate for the tag %r.'%node.tag, node) def visit_define(self, node): name = self.encode_link_name(node.arg) self.begin('a', 'name=%r'%name) self._visit_children(node) self.end('a') def visit_document(self, node): self.indent = 2 # Known indentation of header to be generated later oldout = self.chg_out([]) self._visit_children(node) self.gen_generated_from_gsl() newout = self.chg_out(oldout) mknode = self.mod.node_of_taci lang = self.document_lang if not lang: lang = mknode('document_lang', 'en') self.indent = 0 self.gen_document_header(lang, self.header_nodes) self.out.extend(newout) self.gen_document_trailer() def visit_document_lang(self, node): if self.document_lang is not None: self.error('Duplicate document lang directive.', node) self.document_lang = node def visit_document_title(self, node): self.header_nodes.append(self.mod.node_of_taci('title', node.arg)) def visit_enumerate(self, node): self.begin('ol') for c in node.children: self.begin('li') c.accept(self) self.end('li') self.end('ol') def visit_exdefs(self, node): self.symplace = {} for ch in node.children: syms = [x.strip() for x in ch.arg.split(',')] for sym in syms: self.symplace[sym] = ch.tag def visit_header(self, node): self.header_nodes.extend(node.children) def visit_itemize(self, node): self.begin('ul') for c in node.children: self.begin('li') c.accept(self) self.end('li') self.end('ul') def visit_link_to_extern(self, node): name = node.arg docname = node.children[0].arg children = node.children[1:] uri = '%s.html#%s'%(docname, self.encode_link_name(name)) self.begin('a', 'href=%r'%uri) if not children: self.append(self.encode(name)) else: for ch in children: ch.accept(self) self.end('a') def visit_link_to_local(self, node): name = node.arg uri = '#%s'%self.encode_link_name(name) self.begin('a', 'href=%r'%uri) if not node.children: self.append(self.encode(name)) else: self._visit_children(node) self.end('a') def visit_link_to_unresolved(self, node): name = node.arg self.begin('em') if not node.children: self.append(self.encode(name)) else: self._visit_children(node) self.end('em') def visit_literal_block(self, node): self.gen_stdhtml(node, 'pre') def visit_man_page_mode(self, node): self._visit_children(node) def visit_meta(self, node): self.document_metas.append(node) def visit_spc_colonkind(self, node): #self.append('&nbsp;<strong>:</strong>&nbsp;') #self.append('&nbsp;<code>:</code>&nbsp;') self.append('<code>:</code>&nbsp;') def visit_spc_mapsto(self, node): self.append(' <strong>-></strong> ') def visit_string(self, node): self._visit_children(node) def visit_symbol(self, node): self.visit_text(node) def visit_text(self, node): text = self.encode(node.arg) if len(text) > 80 or '\n' in text: self.append('\n') self.append(text) self._visit_children(node) def visit_to_document_only(self, node): self._visit_children(node) def visit_to_html_only(self, node): self._visit_children(node) def visit_to_tester_only(self, node): pass def visit_valid_html40(self, node): self.valid_html40 = node node, attrs = self.valid_html40.split_attrs(attrdict=True) # XXX check allowed attrs but in a GENERAL way # Code taken from validator.w3.org self.append("""\ <a href="http://validator.w3.org/check?uri=referer"><img src="%s" alt="Valid HTML 4.0 Strict" height="31" width="88"></a> """%attrs.get('src', 'http://www.w3.org/Icons/valid-html40')) def visit_with(self, node): pass def visit_word(self, node): self._visit_children(node) class _GLUECLAMP_: _imports_ = ( '_parent:SpecNodes', '_parent.SpecNodes:node_of_taci', '_parent.Gsml:is_not_ascii', '_parent.Main:tgt_prefix', '_parent.Main:ReportedError', '_root.htmlentitydefs:name2codepoint', '_root.htmlentitydefs:codepoint2name', '_root:re', '_root:time', ) _chgable_ = ('tag_uppercase_name_chars',) # Set to make upper-case name characters tagged to make sure # no names in a file differ only in case as stated in HTML spec. # I believe this doesn't matter in practice in contemporary browsers, # since references are also said to be case sensitive! # -- I can't be bothered to solve this better now. See also Notes Aug 12 2005. tag_uppercase_name_chars = 0 _html3_2 = ( 'a', 'address', 'area', 'b', 'base', 'big', 'blockquote', 'body', 'br', 'caption', 'center', 'cite', 'code', 'dfn', 'dt','dl', 'dd','div', 'em', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'html', 'i', 'img', 'input', 'kbd', 'li', 'ol', 'option', 'p', 'param', 'pre', 'samp', 'select', 'small', 'strong', 'style', 'sub', 'sup', 'table', 'td', 'textarea', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var') # Included in Html 3.2 but 'deprecated' in Html 4.0 _html4_0_deprecated = ( 'applet', 'basefont', 'dir', 'font', 'isindex', 'strike', 'u', ) # Included in 3.2, not depreciated in 4.0 but one may want to avoid them _html_avoid = ( 'script', ) _html4_0 = ( 'abbr', 'acronym', 'bdo','button', 'col', 'colgroup', 'del', 'fieldset', 'frame', 'frameset', 'iframe', 'ins', 'label', 'legend', 'noframes', 'noscript', 'object','optgroup', 'q','s', 'span', 'tbody', 'tfoot', 'thead') _head_elements = ( 'base','isindex','link','meta','script','style','title' ) # The ones that can have no end tag # xxx are there more -style etc- look it up! _no_end_tag_elements = ( # Header elmts 'meta', 'link', # Other 'img') # The ones that we may generate line-break before # and hope it will not affect the insertion of spaces in rendering. _line_break_allowed = ( 'html','head','body','frameset', # Head Elements ) + _head_elements + ( # Generic Block-level Elements 'address','blockquote','center','del','div', 'h1','h2','h3','h4','h5','h6','hr','ins','isindex','noscript','p','pre', # Lists 'dir','dl','dt','dd','li','menu','ol','ul', # Tables 'table','caption','colgroup','col','thead','tfoot','tbody','tr','td','th', # Forms 'form','button','fieldset','legend','input','label', 'select','optgroup','option','textarea' ) # The attributes allowed in META elements meta_attributes = ('name', 'http-equiv', 'content', 'scheme', 'lang', 'dir') # This returns a function checking if a character is allowed to be used # as the first character in a NAME or ID attribute. # (I don't think this is the same as .isalpha() with unicode.) def _get_is_name_starter_char(self): return self.re.compile(r"[A-Za-z]").match # This returns a function checking if a character is allowed to be used # after the first character in a NAME or ID attribute. def _get_is_name_follower_char(self): return self.re.compile(r"[A-Za-z0-9\-_:\.]").match # A set of the ones we generate directly. # This includes the ones from html 3.2 and # I have also included the deprecated and the 4.0 only def _get_stdhtml(self): sh = {} for x in self._html3_2 + self._html4_0_deprecated + self._html4_0: sh[x] = 1 return sh def _get_line_break_allowed(self): sh = {} for x in self._line_break_allowed: sh[x] = 1 return sh def doc2filer(self, doc, node, name, dir, opts, IO): text = self.doc2text(doc, node) path = IO.path.join(dir, '%s.html'%name) node = self.node_of_taci('write_file', path, [self.node_of_taci('text', text)]) return node def doc2text(self, doc, node): d2h = Node2Html(self, node, doc.env.error) return d2h.get_html() def node2file(self, node, file): text = self.node2text(node) f = open(file, 'w') f.write(text) f.close() def node2text(self, node): text = Node2Html(self, node).get_html() return text # Adapted from html4css1.py in docutils def encode(self, text): """Encode special characters in `text` & return.""" # @@@ A codec to do these and all other HTML entities would be nice. text = text.replace("&", "&amp;") text = text.replace("<", "&lt;") text = text.replace('"', "&quot;") text = text.replace(">", "&gt;") text = text.replace("@", "&#64;") # may thwart some address harvesters return text # Encode a name according to HTML spec. See also Notes Aug 12 2005. # From wdghtml40/values.html#cdata : # Attribute values of type ID and NAME must begin with a letter in the # range A-Z or a-z and may be followed by letters (A-Za-z), digits # (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods # ("."). These values are case-sensitive. def encode_name(self, name): is_name_follower_char = self.is_name_follower_char ns = [] append = ns.append upperstate = 0 ch = name[:1] if ch == 'z' or not self.is_name_starter_char(ch): append('z') if ch == 'z': append('z') for ch in name: if ch == '-' or not is_name_follower_char(ch): if upperstate: append('-') upperstate = 0 append('-') if ch != '-': append('%d'%ord(ch)) append('-') elif ch.isupper() and self.tag_uppercase_name_chars: if not upperstate: append('-') upperstate = 1 append(ch) else: if upperstate: append('-') upperstate = 0 append(ch) if upperstate: append('-') return ''.join(ns)
apache-2.0
[ 3, 423, 5107, 63, 2064, 486, 384, 647, 14, 458, 76, 14, 12957, 199, 199, 533, 5013, 18, 12957, 26, 272, 347, 636, 826, 721, 277, 12, 3413, 12, 1031, 29, 403, 12, 1125, 63, 3070, 275, 488, 12, 3752, 63, 354, 29, 403, 326, 3461, 199, 198, 277, 14, 1494, 275, 3413, 267, 291, 14, 1078, 63, 1360, 2167, 275, 756, 421, 198, 277, 14, 2143, 275, 291, 14, 1494, 14, 2143, 199, 198, 692, 3752, 63, 354, 365, 488, 26, 6722, 3752, 63, 354, 275, 291, 14, 1494, 14, 2143, 63, 354, 199, 198, 277, 14, 2143, 63, 354, 275, 3752, 63, 354, 199, 198, 692, 1125, 63, 3070, 365, 440, 488, 26, 6722, 291, 14, 705, 63, 3070, 275, 1125, 63, 3070, 398, 291, 14, 3554, 63, 4159, 275, 488, 398, 291, 14, 1291, 63, 2415, 275, 942, 4388, 198, 277, 14, 3724, 275, 378, 199, 198, 277, 14, 3724, 2926, 275, 413, 421, 198, 277, 14, 409, 63, 548, 4157, 398, 327, 26571, 2382, 886, 642, 31, 267, 5960, 275, 283, 1624, 13, 24, 7, 267, 291, 14, 1291, 63, 2415, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 288, 283, 2024, 297, 3260, 334, 288, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1014, 13, 20146, 4009, 283, 2714, 13, 804, 659, 288, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1317, 4009, 3303, 283, 505, 15, 1360, 27, 5960, 2458, 83, 5956, 6043, 7845, 421, 198, 692, 1031, 365, 440, 488, 26, 6722, 1031, 14, 5694, 8, 277, 9, 507, 272, 347, 485, 5427, 63, 3223, 8, 277, 12, 1031, 304, 199, 198, 932, 12, 3290, 275, 1031, 14, 1294, 63, 3288, 342, 199, 198, 3, 26571, 2429, 3290, 31, 199, 198, 37, 275, 291, 14, 1494, 14, 497, 2315, 547, 199, 198, 509, 682, 315, 1031, 14, 3223, 26, 6722, 862, 26, 507, 198, 335, 14, 5694, 8, 277, 9, 6722, 871, 662, 26, 507, 198, 1529, 339, 347, 5386, 8, 277, 12, 1947, 12, 1680, 9280, 199, 198, 692, 1680, 26, 6722, 307, 275, 18342, 83, 450, 83, 3524, 2840, 1450, 12, 1680, 9, 199, 198, 2836, 26, 6722, 307, 275, 18342, 83, 3524, 5, 1450, 199, 198, 692, 1947, 315, 291, 14, 1494, 14, 604, 63, 4785, 63, 6541, 26, 6722, 307, 275, 1557, 78, 6828, 277, 14, 3724, 627, 283, 283, 435, 307, 199, 198, 277, 14, 740, 8, 84, 9, 199, 198, 277, 14, 3724, 847, 291, 14, 3724, 2926, 339, 347, 682, 71, 63, 548, 8, 277, 12, 734, 304, 199, 198, 1534, 275, 291, 14, 548, 199, 198, 277, 14, 409, 63, 548, 8, 548, 9, 199, 198, 1107, 16390, 339, 347, 3752, 63, 1073, 63, 354, 8, 277, 12, 536, 304, 199, 198, 3, 413, 14, 4155, 314, 536, 8034, 10023, 367, 282, 3517, 922, 1159, 1126, 16657, 199, 198, 3, 499, 14, 19244, 652, 701, 4163, 4713, 421, 198, 692, 536, 14, 2460, 8, 277, 14, 1494, 14, 15328, 63, 1861, 304, 6722, 536, 275, 536, 59, 552, 8, 277, 14, 1494, 14, 15328, 63, 1861, 15405, 199, 198, 2836, 26, 6722, 327, 7719, 440, 5992, 14115, 503, 737, 1006, 6722, 702, 378, 199, 198, 354, 275, 291, 14, 2143, 63, 354, 8, 354, 9, 199, 198, 1107, 536, 339, 347, 1284, 8, 277, 12, 1947, 304, 199, 198, 277, 14, 3724, 4862, 291, 14, 3724, 2926, 199, 198, 277, 14, 740, 26576, 83, 3524, 5, 1450, 9, 339, 347, 1125, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 10340, 304, 199, 198, 1328, 275, 283, 3768, 18, 12957, 26, 283, 435, 1499, 199, 198, 277, 14, 705, 63, 3070, 8, 1328, 12, 627, 589, 12, 1011, 10340, 9, 339, 347, 1125, 63, 3070, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 10340, 304, 199, 198, 1361, 283, 4943, 5070, 14878, 12539, 26, 1656, 1499, 12, 283, 589, 4009, 589, 12, 283, 10340, 4009, 10340, 199, 198, 3730, 1722, 339, 347, 3805, 63, 3554, 63, 1291, 8, 277, 12, 6339, 12, 1406, 63, 2415, 304, 199, 198, 3, 6339, 1253, 2538, 787, 3380, 543, 1318, 503, 1495, 13502, 12, 370, 506, 5737, 14, 199, 198, 3, 7647, 305, 365, 282, 769, 402, 3380, 12, 543, 666, 370, 506, 5737, 421, 198, 277, 14, 740, 21723, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 16, 501, 742, 2, 2043, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 9481, 13, 1360, 2167, 15, 4768, 14, 15662, 1743, 199, 6141, 421, 198, 277, 14, 5037, 360, 1360, 297, 283, 4159, 2458, 83, 5956, 277, 14, 362, 63, 8167, 63, 505, 8, 4159, 430, 199, 198, 277, 14, 5037, 360, 2993, 358, 267, 367, 1031, 315, 1406, 63, 2415, 26, 288, 291, 14, 2268, 63, 1516, 1360, 8, 932, 9, 421, 198, 277, 14, 500, 360, 2993, 358, 267, 291, 14, 5037, 360, 2030, 358, 398, 327, 2372, 6818, 336, 19, 67, 10588, 626, 4528, 666, 787, 440, 4370, 267, 327, 5370, 315, 2396, 12, 7704, 652, 14905, 370, 2218, 1013, 22676, 1233, 267, 327, 1952, 6051, 6665, 314, 10588, 365, 2337, 367, 282, 4499, 12, 1325, 473, 21542, 5715, 1396, 267, 291, 14, 5037, 360, 3015, 358, 339, 347, 3805, 63, 3554, 63, 21606, 8, 277, 304, 267, 291, 14, 500, 360, 3015, 358, 199, 198, 277, 14, 500, 360, 2030, 358, 199, 198, 277, 14, 500, 360, 1360, 358, 339, 347, 3805, 63, 1667, 63, 352, 2037, 8, 277, 12, 1947, 12, 1680, 9280, 199, 198, 277, 14, 5037, 8, 1450, 12, 1680, 9, 199, 198, 277, 14, 3724, 4862, 291, 14, 3724, 2926, 339, 347, 3805, 63, 10176, 63, 504, 63, 458, 76, 8, 277, 304, 199, 198, 277, 14, 2268, 63, 1667, 63, 352, 2037, 360, 6271, 358, 421, 198, 277, 14, 740, 360, 12706, 701, 5320, 199, 198, 277, 14, 5037, 360, 65, 297, 283, 6399, 628, 1014, 921, 71, 384, 647, 13, 321, 14, 22943, 14, 846, 15, 458, 76, 14, 1360, 9008, 199, 198, 3, 277, 14, 5037, 360, 65, 297, 283 ]
[ 423, 5107, 63, 2064, 486, 384, 647, 14, 458, 76, 14, 12957, 199, 199, 533, 5013, 18, 12957, 26, 272, 347, 636, 826, 721, 277, 12, 3413, 12, 1031, 29, 403, 12, 1125, 63, 3070, 275, 488, 12, 3752, 63, 354, 29, 403, 326, 3461, 199, 198, 277, 14, 1494, 275, 3413, 267, 291, 14, 1078, 63, 1360, 2167, 275, 756, 421, 198, 277, 14, 2143, 275, 291, 14, 1494, 14, 2143, 199, 198, 692, 3752, 63, 354, 365, 488, 26, 6722, 3752, 63, 354, 275, 291, 14, 1494, 14, 2143, 63, 354, 199, 198, 277, 14, 2143, 63, 354, 275, 3752, 63, 354, 199, 198, 692, 1125, 63, 3070, 365, 440, 488, 26, 6722, 291, 14, 705, 63, 3070, 275, 1125, 63, 3070, 398, 291, 14, 3554, 63, 4159, 275, 488, 398, 291, 14, 1291, 63, 2415, 275, 942, 4388, 198, 277, 14, 3724, 275, 378, 199, 198, 277, 14, 3724, 2926, 275, 413, 421, 198, 277, 14, 409, 63, 548, 4157, 398, 327, 26571, 2382, 886, 642, 31, 267, 5960, 275, 283, 1624, 13, 24, 7, 267, 291, 14, 1291, 63, 2415, 14, 740, 8, 277, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 8, 288, 283, 2024, 297, 3260, 334, 288, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1014, 13, 20146, 4009, 283, 2714, 13, 804, 659, 288, 291, 14, 1494, 14, 932, 63, 1618, 63, 502, 559, 360, 1317, 4009, 3303, 283, 505, 15, 1360, 27, 5960, 2458, 83, 5956, 6043, 7845, 421, 198, 692, 1031, 365, 440, 488, 26, 6722, 1031, 14, 5694, 8, 277, 9, 507, 272, 347, 485, 5427, 63, 3223, 8, 277, 12, 1031, 304, 199, 198, 932, 12, 3290, 275, 1031, 14, 1294, 63, 3288, 342, 199, 198, 3, 26571, 2429, 3290, 31, 199, 198, 37, 275, 291, 14, 1494, 14, 497, 2315, 547, 199, 198, 509, 682, 315, 1031, 14, 3223, 26, 6722, 862, 26, 507, 198, 335, 14, 5694, 8, 277, 9, 6722, 871, 662, 26, 507, 198, 1529, 339, 347, 5386, 8, 277, 12, 1947, 12, 1680, 9280, 199, 198, 692, 1680, 26, 6722, 307, 275, 18342, 83, 450, 83, 3524, 2840, 1450, 12, 1680, 9, 199, 198, 2836, 26, 6722, 307, 275, 18342, 83, 3524, 5, 1450, 199, 198, 692, 1947, 315, 291, 14, 1494, 14, 604, 63, 4785, 63, 6541, 26, 6722, 307, 275, 1557, 78, 6828, 277, 14, 3724, 627, 283, 283, 435, 307, 199, 198, 277, 14, 740, 8, 84, 9, 199, 198, 277, 14, 3724, 847, 291, 14, 3724, 2926, 339, 347, 682, 71, 63, 548, 8, 277, 12, 734, 304, 199, 198, 1534, 275, 291, 14, 548, 199, 198, 277, 14, 409, 63, 548, 8, 548, 9, 199, 198, 1107, 16390, 339, 347, 3752, 63, 1073, 63, 354, 8, 277, 12, 536, 304, 199, 198, 3, 413, 14, 4155, 314, 536, 8034, 10023, 367, 282, 3517, 922, 1159, 1126, 16657, 199, 198, 3, 499, 14, 19244, 652, 701, 4163, 4713, 421, 198, 692, 536, 14, 2460, 8, 277, 14, 1494, 14, 15328, 63, 1861, 304, 6722, 536, 275, 536, 59, 552, 8, 277, 14, 1494, 14, 15328, 63, 1861, 15405, 199, 198, 2836, 26, 6722, 327, 7719, 440, 5992, 14115, 503, 737, 1006, 6722, 702, 378, 199, 198, 354, 275, 291, 14, 2143, 63, 354, 8, 354, 9, 199, 198, 1107, 536, 339, 347, 1284, 8, 277, 12, 1947, 304, 199, 198, 277, 14, 3724, 4862, 291, 14, 3724, 2926, 199, 198, 277, 14, 740, 26576, 83, 3524, 5, 1450, 9, 339, 347, 1125, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 10340, 304, 199, 198, 1328, 275, 283, 3768, 18, 12957, 26, 283, 435, 1499, 199, 198, 277, 14, 705, 63, 3070, 8, 1328, 12, 627, 589, 12, 1011, 10340, 9, 339, 347, 1125, 63, 3070, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 10340, 304, 199, 198, 1361, 283, 4943, 5070, 14878, 12539, 26, 1656, 1499, 12, 283, 589, 4009, 589, 12, 283, 10340, 4009, 10340, 199, 198, 3730, 1722, 339, 347, 3805, 63, 3554, 63, 1291, 8, 277, 12, 6339, 12, 1406, 63, 2415, 304, 199, 198, 3, 6339, 1253, 2538, 787, 3380, 543, 1318, 503, 1495, 13502, 12, 370, 506, 5737, 14, 199, 198, 3, 7647, 305, 365, 282, 769, 402, 3380, 12, 543, 666, 370, 506, 5737, 421, 198, 277, 14, 740, 21723, 199, 11230, 16556, 4163, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 841, 14, 16, 501, 742, 2, 2043, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 1766, 15, 9481, 13, 1360, 2167, 15, 4768, 14, 15662, 1743, 199, 6141, 421, 198, 277, 14, 5037, 360, 1360, 297, 283, 4159, 2458, 83, 5956, 277, 14, 362, 63, 8167, 63, 505, 8, 4159, 430, 199, 198, 277, 14, 5037, 360, 2993, 358, 267, 367, 1031, 315, 1406, 63, 2415, 26, 288, 291, 14, 2268, 63, 1516, 1360, 8, 932, 9, 421, 198, 277, 14, 500, 360, 2993, 358, 267, 291, 14, 5037, 360, 2030, 358, 398, 327, 2372, 6818, 336, 19, 67, 10588, 626, 4528, 666, 787, 440, 4370, 267, 327, 5370, 315, 2396, 12, 7704, 652, 14905, 370, 2218, 1013, 22676, 1233, 267, 327, 1952, 6051, 6665, 314, 10588, 365, 2337, 367, 282, 4499, 12, 1325, 473, 21542, 5715, 1396, 267, 291, 14, 5037, 360, 3015, 358, 339, 347, 3805, 63, 3554, 63, 21606, 8, 277, 304, 267, 291, 14, 500, 360, 3015, 358, 199, 198, 277, 14, 500, 360, 2030, 358, 199, 198, 277, 14, 500, 360, 1360, 358, 339, 347, 3805, 63, 1667, 63, 352, 2037, 8, 277, 12, 1947, 12, 1680, 9280, 199, 198, 277, 14, 5037, 8, 1450, 12, 1680, 9, 199, 198, 277, 14, 3724, 4862, 291, 14, 3724, 2926, 339, 347, 3805, 63, 10176, 63, 504, 63, 458, 76, 8, 277, 304, 199, 198, 277, 14, 2268, 63, 1667, 63, 352, 2037, 360, 6271, 358, 421, 198, 277, 14, 740, 360, 12706, 701, 5320, 199, 198, 277, 14, 5037, 360, 65, 297, 283, 6399, 628, 1014, 921, 71, 384, 647, 13, 321, 14, 22943, 14, 846, 15, 458, 76, 14, 1360, 9008, 199, 198, 3, 277, 14, 5037, 360, 65, 297, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
arpadpe/plover
plover/machine/keyboard.py
1
4230
# Copyright (c) 2010 Joshua Harlan Lifton. # See LICENSE.txt for details. "For use with a computer keyboard (preferably NKRO) as a steno machine." from plover.machine.base import StenotypeBase from plover.oslayer.keyboardcontrol import KeyboardCapture class Keyboard(StenotypeBase): """Standard stenotype interface for a computer keyboard. This class implements the three methods necessary for a standard stenotype interface: start_capture, stop_capture, and add_callback. """ KEYS_LAYOUT = KeyboardCapture.SUPPORTED_KEYS_LAYOUT ACTIONS = StenotypeBase.ACTIONS + ('arpeggiate',) def __init__(self, params): """Monitor the keyboard's events.""" super(Keyboard, self).__init__() self.arpeggiate = params['arpeggiate'] self._bindings = {} self._down_keys = set() self._released_keys = set() self._keyboard_capture = None self._last_stroke_key_down_count = 0 self._update_bindings() def _update_bindings(self): self._bindings = dict(self.keymap.get_bindings()) for key, mapping in list(self._bindings.items()): if 'no-op' == mapping: self._bindings[key] = None elif 'arpeggiate' == mapping: if self.arpeggiate: self._bindings[key] = None self._arpeggiate_key = key else: # Don't suppress arpeggiate key if it's not used. del self._bindings[key] def set_mappings(self, mappings): super(Keyboard, self).set_mappings(mappings) self._update_bindings() def start_capture(self): """Begin listening for output from the stenotype machine.""" self._released_keys.clear() self._last_stroke_key_down_count = 0 self._initializing() try: self._keyboard_capture = KeyboardCapture() self._keyboard_capture.key_down = self._key_down self._keyboard_capture.key_up = self._key_up self._keyboard_capture.start() except: self._error() raise self._ready() def stop_capture(self): """Stop listening for output from the stenotype machine.""" if self._keyboard_capture is not None: self._keyboard_capture.cancel() self._keyboard_capture = None self._stopped() def set_suppression(self, enabled): suppressed_keys = self._bindings.keys() if enabled else () self._keyboard_capture.suppress_keyboard(suppressed_keys) def suppress_last_stroke(self, send_backspaces): send_backspaces(self._last_stroke_key_down_count) def _key_down(self, key): """Called when a key is pressed.""" assert key is not None if key in self._bindings: self._last_stroke_key_down_count += 1 steno_key = self._bindings.get(key) if steno_key is not None: self._down_keys.add(steno_key) def _key_up(self, key): """Called when a key is released.""" assert key is not None steno_key = self._bindings.get(key) if steno_key is not None: # Process the newly released key. self._released_keys.add(steno_key) # Remove invalid released keys. self._released_keys = self._released_keys.intersection(self._down_keys) # A stroke is complete if all pressed keys have been released. # If we are in arpeggiate mode then only send stroke when spacebar is pressed. send_strokes = bool(self._down_keys and self._down_keys == self._released_keys) if self.arpeggiate: send_strokes &= key == self._arpeggiate_key if send_strokes: steno_keys = list(self._down_keys) if steno_keys: self._down_keys.clear() self._released_keys.clear() self._notify(steno_keys) self._last_stroke_key_down_count = 0 @classmethod def get_option_info(cls): bool_converter = lambda s: s == 'True' return { 'arpeggiate': (False, bool_converter), }
gpl-2.0
[ 3, 1898, 334, 67, 9, 7129, 7135, 609, 1458, 25378, 1502, 491, 692, 1860, 14, 199, 3, 1666, 5113, 14, 2424, 367, 2436, 14, 199, 199, 2, 1858, 675, 543, 282, 24189, 18716, 334, 24283, 6665, 653, 43, 1092, 9, 465, 282, 308, 724, 79, 6844, 2122, 199, 199, 504, 299, 21960, 14, 6744, 14, 1095, 492, 428, 724, 7818, 1563, 199, 504, 299, 21960, 14, 736, 1897, 14, 19553, 2785, 492, 2606, 3576, 16640, 421, 199, 533, 2606, 3576, 8, 51, 724, 7818, 1563, 304, 272, 408, 9232, 308, 724, 7818, 3217, 367, 282, 24189, 18716, 14, 339, 961, 1021, 9031, 314, 7795, 3102, 5784, 367, 282, 4465, 272, 308, 724, 7818, 3217, 26, 1343, 63, 12685, 12, 3631, 63, 12685, 12, 436, 272, 1050, 63, 3058, 14, 339, 408, 339, 9301, 51, 63, 16897, 1877, 275, 2606, 3576, 16640, 14, 15925, 63, 17434, 63, 16897, 1877, 272, 437, 19560, 275, 428, 724, 7818, 1563, 14, 25194, 435, 661, 285, 321, 2721, 73, 323, 9538, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 13189, 314, 18716, 1159, 4474, 1041, 267, 1613, 8, 28377, 12, 291, 2843, 826, 4533, 267, 291, 14, 285, 321, 2721, 73, 323, 275, 1862, 459, 285, 321, 2721, 73, 323, 418, 267, 291, 423, 10880, 275, 1052, 267, 291, 423, 2110, 63, 1612, 275, 663, 342, 267, 291, 423, 26267, 63, 1612, 275, 663, 342, 267, 291, 423, 19553, 63, 12685, 275, 488, 267, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 267, 291, 423, 873, 63, 10880, 342, 339, 347, 485, 873, 63, 10880, 8, 277, 304, 267, 291, 423, 10880, 275, 1211, 8, 277, 14, 19624, 14, 362, 63, 10880, 1012, 267, 367, 790, 12, 4412, 315, 769, 8, 277, 423, 10880, 14, 1744, 5109, 288, 340, 283, 889, 13, 411, 7, 508, 4412, 26, 355, 291, 423, 10880, 59, 498, 61, 275, 488, 288, 916, 283, 285, 321, 2721, 73, 323, 7, 508, 4412, 26, 355, 340, 291, 14, 285, 321, 2721, 73, 323, 26, 490, 291, 423, 10880, 59, 498, 61, 275, 488, 490, 291, 423, 285, 321, 2721, 73, 323, 63, 498, 275, 790, 355, 587, 26, 490, 327, 7529, 1133, 15678, 601, 321, 2721, 73, 323, 790, 340, 652, 1159, 440, 1202, 14, 490, 2150, 291, 423, 10880, 59, 498, 61, 339, 347, 663, 63, 14632, 8, 277, 12, 13546, 304, 267, 1613, 8, 28377, 12, 291, 680, 409, 63, 14632, 8, 14632, 9, 267, 291, 423, 873, 63, 10880, 342, 339, 347, 1343, 63, 12685, 8, 277, 304, 267, 408, 5595, 22721, 367, 1072, 687, 314, 308, 724, 7818, 6844, 1041, 267, 291, 423, 26267, 63, 1612, 14, 3584, 342, 267, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 267, 291, 423, 2747, 9147, 342, 267, 862, 26, 288, 291, 423, 19553, 63, 12685, 275, 2606, 3576, 16640, 342, 288, 291, 423, 19553, 63, 12685, 14, 498, 63, 2110, 275, 291, 423, 498, 63, 2110, 288, 291, 423, 19553, 63, 12685, 14, 498, 63, 384, 275, 291, 423, 498, 63, 384, 288, 291, 423, 19553, 63, 12685, 14, 928, 342, 267, 871, 26, 288, 291, 423, 705, 342, 288, 746, 267, 291, 423, 2179, 342, 339, 347, 3631, 63, 12685, 8, 277, 304, 267, 408, 6293, 22721, 367, 1072, 687, 314, 308, 724, 7818, 6844, 1041, 267, 340, 291, 423, 19553, 63, 12685, 365, 440, 488, 26, 288, 291, 423, 19553, 63, 12685, 14, 6406, 342, 288, 291, 423, 19553, 63, 12685, 275, 488, 267, 291, 423, 14661, 342, 339, 347, 663, 63, 8621, 1941, 8, 277, 12, 5223, 304, 267, 30581, 63, 1612, 275, 291, 423, 10880, 14, 1612, 342, 340, 5223, 587, 6248, 267, 291, 423, 19553, 63, 12685, 14, 17381, 63, 19553, 8, 8621, 5111, 63, 1612, 9, 339, 347, 15678, 63, 2019, 63, 11473, 8, 277, 12, 3222, 63, 894, 10749, 304, 267, 3222, 63, 894, 10749, 8, 277, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 9, 339, 347, 485, 498, 63, 2110, 8, 277, 12, 790, 304, 267, 408, 10474, 1380, 282, 790, 365, 25167, 1041, 267, 702, 790, 365, 440, 488, 267, 340, 790, 315, 291, 423, 10880, 26, 288, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 847, 413, 267, 308, 724, 79, 63, 498, 275, 291, 423, 10880, 14, 362, 8, 498, 9, 267, 340, 308, 724, 79, 63, 498, 365, 440, 488, 26, 288, 291, 423, 2110, 63, 1612, 14, 525, 8, 4081, 79, 63, 498, 9, 339, 347, 485, 498, 63, 384, 8, 277, 12, 790, 304, 267, 408, 10474, 1380, 282, 790, 365, 14286, 1041, 267, 702, 790, 365, 440, 488, 267, 308, 724, 79, 63, 498, 275, 291, 423, 10880, 14, 362, 8, 498, 9, 267, 340, 308, 724, 79, 63, 498, 365, 440, 488, 26, 288, 327, 7132, 314, 13903, 14286, 790, 14, 288, 291, 423, 26267, 63, 1612, 14, 525, 8, 4081, 79, 63, 498, 9, 288, 327, 5852, 3866, 14286, 2883, 14, 288, 291, 423, 26267, 63, 1612, 275, 291, 423, 26267, 63, 1612, 14, 12569, 8, 277, 423, 2110, 63, 1612, 9, 398, 327, 437, 22824, 365, 4890, 340, 1006, 25167, 2883, 1172, 2757, 14286, 14, 267, 327, 982, 781, 787, 315, 601, 321, 2721, 73, 323, 818, 2066, 1454, 3222, 22824, 1380, 4601, 1700, 365, 25167, 14, 267, 3222, 63, 24627, 9246, 275, 2155, 8, 277, 423, 2110, 63, 1612, 436, 1169, 291, 423, 2110, 63, 1612, 508, 291, 423, 26267, 63, 1612, 9, 267, 340, 291, 14, 285, 321, 2721, 73, 323, 26, 288, 3222, 63, 24627, 9246, 18415, 790, 508, 291, 423, 285, 321, 2721, 73, 323, 63, 498, 267, 340, 3222, 63, 24627, 9246, 26, 288, 308, 724, 79, 63, 1612, 275, 769, 8, 277, 423, 2110, 63, 1612, 9, 288, 340, 308, 724, 79, 63, 1612, 26, 355, 291, 423, 2110, 63, 1612, 14, 3584, 342, 355, 291, 423, 26267, 63, 1612, 14, 3584, 342, 355, 291, 423, 6814, 8, 4081, 79, 63, 1612, 9, 288, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 339, 768, 3744 ]
[ 1898, 334, 67, 9, 7129, 7135, 609, 1458, 25378, 1502, 491, 692, 1860, 14, 199, 3, 1666, 5113, 14, 2424, 367, 2436, 14, 199, 199, 2, 1858, 675, 543, 282, 24189, 18716, 334, 24283, 6665, 653, 43, 1092, 9, 465, 282, 308, 724, 79, 6844, 2122, 199, 199, 504, 299, 21960, 14, 6744, 14, 1095, 492, 428, 724, 7818, 1563, 199, 504, 299, 21960, 14, 736, 1897, 14, 19553, 2785, 492, 2606, 3576, 16640, 421, 199, 533, 2606, 3576, 8, 51, 724, 7818, 1563, 304, 272, 408, 9232, 308, 724, 7818, 3217, 367, 282, 24189, 18716, 14, 339, 961, 1021, 9031, 314, 7795, 3102, 5784, 367, 282, 4465, 272, 308, 724, 7818, 3217, 26, 1343, 63, 12685, 12, 3631, 63, 12685, 12, 436, 272, 1050, 63, 3058, 14, 339, 408, 339, 9301, 51, 63, 16897, 1877, 275, 2606, 3576, 16640, 14, 15925, 63, 17434, 63, 16897, 1877, 272, 437, 19560, 275, 428, 724, 7818, 1563, 14, 25194, 435, 661, 285, 321, 2721, 73, 323, 9538, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 408, 13189, 314, 18716, 1159, 4474, 1041, 267, 1613, 8, 28377, 12, 291, 2843, 826, 4533, 267, 291, 14, 285, 321, 2721, 73, 323, 275, 1862, 459, 285, 321, 2721, 73, 323, 418, 267, 291, 423, 10880, 275, 1052, 267, 291, 423, 2110, 63, 1612, 275, 663, 342, 267, 291, 423, 26267, 63, 1612, 275, 663, 342, 267, 291, 423, 19553, 63, 12685, 275, 488, 267, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 267, 291, 423, 873, 63, 10880, 342, 339, 347, 485, 873, 63, 10880, 8, 277, 304, 267, 291, 423, 10880, 275, 1211, 8, 277, 14, 19624, 14, 362, 63, 10880, 1012, 267, 367, 790, 12, 4412, 315, 769, 8, 277, 423, 10880, 14, 1744, 5109, 288, 340, 283, 889, 13, 411, 7, 508, 4412, 26, 355, 291, 423, 10880, 59, 498, 61, 275, 488, 288, 916, 283, 285, 321, 2721, 73, 323, 7, 508, 4412, 26, 355, 340, 291, 14, 285, 321, 2721, 73, 323, 26, 490, 291, 423, 10880, 59, 498, 61, 275, 488, 490, 291, 423, 285, 321, 2721, 73, 323, 63, 498, 275, 790, 355, 587, 26, 490, 327, 7529, 1133, 15678, 601, 321, 2721, 73, 323, 790, 340, 652, 1159, 440, 1202, 14, 490, 2150, 291, 423, 10880, 59, 498, 61, 339, 347, 663, 63, 14632, 8, 277, 12, 13546, 304, 267, 1613, 8, 28377, 12, 291, 680, 409, 63, 14632, 8, 14632, 9, 267, 291, 423, 873, 63, 10880, 342, 339, 347, 1343, 63, 12685, 8, 277, 304, 267, 408, 5595, 22721, 367, 1072, 687, 314, 308, 724, 7818, 6844, 1041, 267, 291, 423, 26267, 63, 1612, 14, 3584, 342, 267, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 267, 291, 423, 2747, 9147, 342, 267, 862, 26, 288, 291, 423, 19553, 63, 12685, 275, 2606, 3576, 16640, 342, 288, 291, 423, 19553, 63, 12685, 14, 498, 63, 2110, 275, 291, 423, 498, 63, 2110, 288, 291, 423, 19553, 63, 12685, 14, 498, 63, 384, 275, 291, 423, 498, 63, 384, 288, 291, 423, 19553, 63, 12685, 14, 928, 342, 267, 871, 26, 288, 291, 423, 705, 342, 288, 746, 267, 291, 423, 2179, 342, 339, 347, 3631, 63, 12685, 8, 277, 304, 267, 408, 6293, 22721, 367, 1072, 687, 314, 308, 724, 7818, 6844, 1041, 267, 340, 291, 423, 19553, 63, 12685, 365, 440, 488, 26, 288, 291, 423, 19553, 63, 12685, 14, 6406, 342, 288, 291, 423, 19553, 63, 12685, 275, 488, 267, 291, 423, 14661, 342, 339, 347, 663, 63, 8621, 1941, 8, 277, 12, 5223, 304, 267, 30581, 63, 1612, 275, 291, 423, 10880, 14, 1612, 342, 340, 5223, 587, 6248, 267, 291, 423, 19553, 63, 12685, 14, 17381, 63, 19553, 8, 8621, 5111, 63, 1612, 9, 339, 347, 15678, 63, 2019, 63, 11473, 8, 277, 12, 3222, 63, 894, 10749, 304, 267, 3222, 63, 894, 10749, 8, 277, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 9, 339, 347, 485, 498, 63, 2110, 8, 277, 12, 790, 304, 267, 408, 10474, 1380, 282, 790, 365, 25167, 1041, 267, 702, 790, 365, 440, 488, 267, 340, 790, 315, 291, 423, 10880, 26, 288, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 847, 413, 267, 308, 724, 79, 63, 498, 275, 291, 423, 10880, 14, 362, 8, 498, 9, 267, 340, 308, 724, 79, 63, 498, 365, 440, 488, 26, 288, 291, 423, 2110, 63, 1612, 14, 525, 8, 4081, 79, 63, 498, 9, 339, 347, 485, 498, 63, 384, 8, 277, 12, 790, 304, 267, 408, 10474, 1380, 282, 790, 365, 14286, 1041, 267, 702, 790, 365, 440, 488, 267, 308, 724, 79, 63, 498, 275, 291, 423, 10880, 14, 362, 8, 498, 9, 267, 340, 308, 724, 79, 63, 498, 365, 440, 488, 26, 288, 327, 7132, 314, 13903, 14286, 790, 14, 288, 291, 423, 26267, 63, 1612, 14, 525, 8, 4081, 79, 63, 498, 9, 288, 327, 5852, 3866, 14286, 2883, 14, 288, 291, 423, 26267, 63, 1612, 275, 291, 423, 26267, 63, 1612, 14, 12569, 8, 277, 423, 2110, 63, 1612, 9, 398, 327, 437, 22824, 365, 4890, 340, 1006, 25167, 2883, 1172, 2757, 14286, 14, 267, 327, 982, 781, 787, 315, 601, 321, 2721, 73, 323, 818, 2066, 1454, 3222, 22824, 1380, 4601, 1700, 365, 25167, 14, 267, 3222, 63, 24627, 9246, 275, 2155, 8, 277, 423, 2110, 63, 1612, 436, 1169, 291, 423, 2110, 63, 1612, 508, 291, 423, 26267, 63, 1612, 9, 267, 340, 291, 14, 285, 321, 2721, 73, 323, 26, 288, 3222, 63, 24627, 9246, 18415, 790, 508, 291, 423, 285, 321, 2721, 73, 323, 63, 498, 267, 340, 3222, 63, 24627, 9246, 26, 288, 308, 724, 79, 63, 1612, 275, 769, 8, 277, 423, 2110, 63, 1612, 9, 288, 340, 308, 724, 79, 63, 1612, 26, 355, 291, 423, 2110, 63, 1612, 14, 3584, 342, 355, 291, 423, 26267, 63, 1612, 14, 3584, 342, 355, 291, 423, 6814, 8, 4081, 79, 63, 1612, 9, 288, 291, 423, 2019, 63, 11473, 63, 498, 63, 2110, 63, 835, 275, 378, 339, 768, 3744, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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