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
PtrMan/wusstrace
pywuss/visitor/htmlify.py
4
3918
# Copyright notice # ================ # # Copyright (C) 2010 # Lorenzo Martignoni <martignlo@gmail.com> # Roberto Paleari <roberto.paleari@gmail.com> # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import visitor from syscall import * class VisitorHTML(visitor.Visitor): """Outputs the syscall trace in HTML format.""" def accept_SyscallTrace(self, trace, *params, **extraparams): r = \ """ <html> <head> <title>Syscall trace for %s</title> <script type="text/javascript"> function toggleArg(id) { var tr = document.getElementById(id); if (tr == null) { return; } var bExpand = tr.style.display == ''; tr.style.display = (bExpand ? 'none' : ''); } </script> <style type="text/css"> table.arg { font-size: 10px; } </style> </head> <body> <h1>Syscall trace for %s (PID: %d)</h1> <p> <em>Click on a system call to show/collapse its arguments.</em> </p> <table> <tr> <th>ID</th> <th>Name</th> <th>Direction</th> <th>Thread</th> </tr> """ % (trace.getFilename(), trace.getFilename(), trace.getPID()) for s in trace.getSyscalls(): r += s.visit(self, *params, **extraparams) r += \ """ </table> </body> </html> """ return r def accept_Syscall(self, syscall, *params, **extraparams): style = "" if syscall.isPre(): direction = "PRE" else: direction = "POST" argid = "%s-%s" % (syscall.getID(), direction) r = \ """ <tr style="%s" onclick="javascript:toggleArg('%s');"> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> </tr>""" % (style, argid, syscall.getID(), syscall.getName(), direction, syscall.getThreadID()) # build arguments row r += \ """ <tr id="%s" style="display: none;"> <td colspan="4"> <table class="arg" border="1">""" % (argid) if len(syscall.getArgument()) > 0: for i in syscall.getArgument(): r += "\n" + syscall.getArgument(i).visit(self, *params, **extraparams) else: # no arguments r += "<tr><td><em>no arguments</em></td></tr>" r += \ """ </table> </td> </tr> """ return r def accept_SyscallArg(self, arg, *params, **extraparams): r = "<tr>" r += "<td>%d</td>" % arg.getNum() r += "<td>%s (%s)</td>" % (arg.getVal().getName(), arg.getVal().getType()) r += "<td>%s</td>" % ((arg.isOptional() and "OPTIONAL") or "MANDATORY") r += "<td>%s</td>" % arg.getVal().visit(self, *params, **extraparams) r += "</tr>" return r def accept_BasicArgument(self, val, *params, **extraparams): return str(val.getValue()) def accept_StructArgument(self, val, *params, **extraparams): r = "<ul>" for n in val: f = val.getField(n) r += "<li>%s (%s)" % (f.getName(), f.getType()) if f.isBasic(): r += " = %s" % f.getValue() else: r += f.visit(self, *params, **extraparams) r += "</li>" r += "</ul>" return r
gpl-3.0
[ 3, 1898, 4245, 199, 3, 275, 16964, 199, 3, 221, 199, 3, 1898, 334, 35, 9, 7129, 199, 3, 258, 491, 720, 15291, 79, 16794, 280, 784, 265, 73, 665, 4584, 280, 784, 320, 32, 6799, 14, 957, 30, 199, 3, 258, 6848, 605, 475, 510, 1895, 759, 665, 293, 605, 475, 14, 387, 274, 759, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 2290, 199, 3, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 199, 3, 1015, 14, 257, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 199, 646, 18040, 199, 504, 257, 18901, 492, 627, 199, 199, 533, 29614, 269, 4943, 8, 19863, 14, 18324, 304, 272, 408, 18669, 314, 18901, 3307, 315, 4163, 1475, 1041, 339, 347, 4729, 63, 4323, 7189, 3921, 8, 277, 12, 3307, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 519, 275, 971, 199, 624, 199, 28, 1360, 30, 523, 665, 2993, 30, 272, 665, 1213, 30, 4323, 7189, 3307, 367, 450, 83, 1108, 1213, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 489, 805, 19420, 6373, 8, 344, 9, 469, 267, 2729, 5651, 275, 2213, 14, 26215, 8, 344, 2736, 267, 340, 334, 454, 508, 2973, 9, 469, 372, 27, 789, 398, 2729, 330, 12839, 275, 5651, 14, 2487, 14, 2918, 508, 2125, 27, 267, 5651, 14, 2487, 14, 2918, 275, 334, 66, 12839, 5805, 283, 3592, 7, 520, 4074, 27, 489, 789, 272, 3068, 1579, 30, 272, 665, 2487, 730, 628, 505, 15, 3919, 1743, 489, 1817, 14, 1273, 469, 267, 5023, 13, 890, 26, 1616, 5326, 27, 489, 789, 272, 3068, 2487, 30, 523, 3068, 2993, 30, 523, 665, 2030, 30, 272, 665, 72, 17, 30, 4323, 7189, 3307, 367, 450, 83, 334, 16098, 26, 450, 68, 15939, 72, 17, 30, 272, 665, 80, 30, 1362, 665, 5633, 30, 12040, 641, 282, 2656, 1240, 370, 2498, 15, 20681, 2399, 2368, 9758, 5633, 30, 272, 3068, 80, 30, 489, 665, 1224, 30, 267, 665, 454, 30, 881, 665, 273, 30, 998, 1108, 273, 30, 881, 665, 273, 30, 985, 1108, 273, 30, 881, 665, 273, 30, 17015, 1108, 273, 30, 881, 665, 273, 30, 4436, 1108, 273, 30, 267, 3068, 454, 30, 199, 624, 450, 334, 3446, 14, 362, 8117, 1062, 3307, 14, 362, 8117, 1062, 3307, 14, 362, 16098, 1012, 398, 367, 308, 315, 3307, 14, 362, 4323, 10920, 837, 288, 519, 847, 308, 14, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 398, 519, 847, 971, 199, 624, 489, 3068, 1224, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 624, 267, 372, 519, 339, 347, 4729, 63, 4323, 7189, 8, 277, 12, 18901, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 3449, 275, 3087, 398, 340, 18901, 14, 374, 2398, 837, 288, 7581, 275, 298, 4225, 2, 267, 587, 26, 288, 7581, 275, 298, 4030, 2, 267, 1680, 344, 275, 2071, 83, 3295, 83, 2, 450, 334, 19444, 14, 362, 998, 1062, 7581, 9, 398, 519, 275, 971, 199, 624, 199, 28, 454, 3449, 5961, 83, 2, 31156, 628, 9554, 26, 13396, 6373, 3508, 83, 11339, 1743, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 199, 1108, 454, 11193, 450, 334, 2487, 12, 1680, 344, 12, 18901, 14, 362, 998, 1062, 18901, 14, 16405, 1062, 7581, 12, 18901, 14, 362, 4436, 998, 1012, 398, 327, 1900, 2368, 1962, 267, 519, 847, 971, 199, 624, 199, 28, 454, 1305, 5961, 83, 2, 3449, 628, 2918, 26, 7179, 31328, 523, 665, 2076, 26384, 628, 20, 1743, 272, 665, 1224, 1021, 628, 1273, 2, 9162, 628, 17, 1743, 624, 450, 334, 1273, 344, 9, 398, 340, 822, 8, 19444, 14, 362, 5201, 1012, 690, 378, 26, 288, 367, 284, 315, 18901, 14, 362, 5201, 837, 355, 519, 847, 1867, 78, 2, 435, 18901, 14, 362, 5201, 8, 73, 680, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 267, 587, 26, 288, 327, 949, 2368, 288, 519, 847, 3886, 454, 2535, 2076, 2535, 5633, 30, 889, 2368, 1108, 5633, 2957, 2076, 2957, 454, 4335, 398, 519, 847, 971, 199, 624, 272, 3068, 1224, 30, 523, 3068, 2076, 30, 199, 1108, 454, 30, 199, 624, 398, 372, 519, 339, 347, 4729, 63, 4323, 7189, 6373, 8, 277, 12, 1680, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 519, 221, 275, 3886, 454, 4335, 267, 519, 847, 3886, 2076, 6598, 68, 1108, 2076, 4335, 221, 450, 1680, 14, 362, 5667, 342, 267, 519, 847, 3886, 2076, 6598, 83, 4366, 83, 15939, 2076, 4335, 221, 450, 334, 1273, 14, 362, 7562, 1252, 16405, 1062, 1680, 14, 362, 7562, 1252, 28005, 1012, 267, 519, 847, 3886, 2076, 6598, 83, 1108, 2076, 4335, 450, 3666, 1273, 14, 374, 7012, 342, 436, 298, 21008, 531, 503, 298, 45, 3649, 619, 5347, 531, 267, 519, 847, 3886, 2076, 6598, 83, 1108, 2076, 4335, 450, 1680, 14, 362, 7562, 1252, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 267, 519, 847, 15683, 454, 4335, 398, 372, 519, 339, 347, 4729, 63, 6845, 5201, 8, 277, 12, 1139, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 372, 620, 8, 637, 14, 17186, 1012, 339, 347 ]
[ 1898, 4245, 199, 3, 275, 16964, 199, 3, 221, 199, 3, 1898, 334, 35, 9, 7129, 199, 3, 258, 491, 720, 15291, 79, 16794, 280, 784, 265, 73, 665, 4584, 280, 784, 320, 32, 6799, 14, 957, 30, 199, 3, 258, 6848, 605, 475, 510, 1895, 759, 665, 293, 605, 475, 14, 387, 274, 759, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 2290, 199, 3, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 199, 3, 1015, 14, 257, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 199, 646, 18040, 199, 504, 257, 18901, 492, 627, 199, 199, 533, 29614, 269, 4943, 8, 19863, 14, 18324, 304, 272, 408, 18669, 314, 18901, 3307, 315, 4163, 1475, 1041, 339, 347, 4729, 63, 4323, 7189, 3921, 8, 277, 12, 3307, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 519, 275, 971, 199, 624, 199, 28, 1360, 30, 523, 665, 2993, 30, 272, 665, 1213, 30, 4323, 7189, 3307, 367, 450, 83, 1108, 1213, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 489, 805, 19420, 6373, 8, 344, 9, 469, 267, 2729, 5651, 275, 2213, 14, 26215, 8, 344, 2736, 267, 340, 334, 454, 508, 2973, 9, 469, 372, 27, 789, 398, 2729, 330, 12839, 275, 5651, 14, 2487, 14, 2918, 508, 2125, 27, 267, 5651, 14, 2487, 14, 2918, 275, 334, 66, 12839, 5805, 283, 3592, 7, 520, 4074, 27, 489, 789, 272, 3068, 1579, 30, 272, 665, 2487, 730, 628, 505, 15, 3919, 1743, 489, 1817, 14, 1273, 469, 267, 5023, 13, 890, 26, 1616, 5326, 27, 489, 789, 272, 3068, 2487, 30, 523, 3068, 2993, 30, 523, 665, 2030, 30, 272, 665, 72, 17, 30, 4323, 7189, 3307, 367, 450, 83, 334, 16098, 26, 450, 68, 15939, 72, 17, 30, 272, 665, 80, 30, 1362, 665, 5633, 30, 12040, 641, 282, 2656, 1240, 370, 2498, 15, 20681, 2399, 2368, 9758, 5633, 30, 272, 3068, 80, 30, 489, 665, 1224, 30, 267, 665, 454, 30, 881, 665, 273, 30, 998, 1108, 273, 30, 881, 665, 273, 30, 985, 1108, 273, 30, 881, 665, 273, 30, 17015, 1108, 273, 30, 881, 665, 273, 30, 4436, 1108, 273, 30, 267, 3068, 454, 30, 199, 624, 450, 334, 3446, 14, 362, 8117, 1062, 3307, 14, 362, 8117, 1062, 3307, 14, 362, 16098, 1012, 398, 367, 308, 315, 3307, 14, 362, 4323, 10920, 837, 288, 519, 847, 308, 14, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 398, 519, 847, 971, 199, 624, 489, 3068, 1224, 30, 523, 3068, 2030, 30, 199, 1108, 1360, 30, 199, 624, 267, 372, 519, 339, 347, 4729, 63, 4323, 7189, 8, 277, 12, 18901, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 3449, 275, 3087, 398, 340, 18901, 14, 374, 2398, 837, 288, 7581, 275, 298, 4225, 2, 267, 587, 26, 288, 7581, 275, 298, 4030, 2, 267, 1680, 344, 275, 2071, 83, 3295, 83, 2, 450, 334, 19444, 14, 362, 998, 1062, 7581, 9, 398, 519, 275, 971, 199, 624, 199, 28, 454, 3449, 5961, 83, 2, 31156, 628, 9554, 26, 13396, 6373, 3508, 83, 11339, 1743, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 523, 665, 2076, 6598, 83, 1108, 2076, 30, 199, 1108, 454, 11193, 450, 334, 2487, 12, 1680, 344, 12, 18901, 14, 362, 998, 1062, 18901, 14, 16405, 1062, 7581, 12, 18901, 14, 362, 4436, 998, 1012, 398, 327, 1900, 2368, 1962, 267, 519, 847, 971, 199, 624, 199, 28, 454, 1305, 5961, 83, 2, 3449, 628, 2918, 26, 7179, 31328, 523, 665, 2076, 26384, 628, 20, 1743, 272, 665, 1224, 1021, 628, 1273, 2, 9162, 628, 17, 1743, 624, 450, 334, 1273, 344, 9, 398, 340, 822, 8, 19444, 14, 362, 5201, 1012, 690, 378, 26, 288, 367, 284, 315, 18901, 14, 362, 5201, 837, 355, 519, 847, 1867, 78, 2, 435, 18901, 14, 362, 5201, 8, 73, 680, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 267, 587, 26, 288, 327, 949, 2368, 288, 519, 847, 3886, 454, 2535, 2076, 2535, 5633, 30, 889, 2368, 1108, 5633, 2957, 2076, 2957, 454, 4335, 398, 519, 847, 971, 199, 624, 272, 3068, 1224, 30, 523, 3068, 2076, 30, 199, 1108, 454, 30, 199, 624, 398, 372, 519, 339, 347, 4729, 63, 4323, 7189, 6373, 8, 277, 12, 1680, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 519, 221, 275, 3886, 454, 4335, 267, 519, 847, 3886, 2076, 6598, 68, 1108, 2076, 4335, 221, 450, 1680, 14, 362, 5667, 342, 267, 519, 847, 3886, 2076, 6598, 83, 4366, 83, 15939, 2076, 4335, 221, 450, 334, 1273, 14, 362, 7562, 1252, 16405, 1062, 1680, 14, 362, 7562, 1252, 28005, 1012, 267, 519, 847, 3886, 2076, 6598, 83, 1108, 2076, 4335, 450, 3666, 1273, 14, 374, 7012, 342, 436, 298, 21008, 531, 503, 298, 45, 3649, 619, 5347, 531, 267, 519, 847, 3886, 2076, 6598, 83, 1108, 2076, 4335, 450, 1680, 14, 362, 7562, 1252, 5427, 8, 277, 12, 627, 1162, 12, 1011, 2911, 1162, 9, 267, 519, 847, 15683, 454, 4335, 398, 372, 519, 339, 347, 4729, 63, 6845, 5201, 8, 277, 12, 1139, 12, 627, 1162, 12, 1011, 2911, 1162, 304, 267, 372, 620, 8, 637, 14, 17186, 1012, 339, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
CINPLA/expipe-dev
phy/phy/cluster/views/trace.py
2
16379
# -*- coding: utf-8 -*- """Trace view.""" # ----------------------------------------------------------------------------- # Imports # ----------------------------------------------------------------------------- import logging import numpy as np from phy.plot.transform import NDC, Range from vispy.util.event import Event from phy.utils import Bunch from .base import ManualClusteringView logger = logging.getLogger(__name__) # ----------------------------------------------------------------------------- # Trace view # ----------------------------------------------------------------------------- def select_traces(traces, interval, sample_rate=None): """Load traces in an interval (in seconds).""" start, end = interval i, j = round(sample_rate * start), round(sample_rate * end) i, j = int(i), int(j) traces = traces[i:j, :] # traces = traces - np.mean(traces, axis=0) return traces def _iter_spike_waveforms(interval=None, traces_interval=None, model=None, supervisor=None, n_samples_waveforms=None, get_best_channels=None, show_all_spikes=False, color_selector=None, ): m = model p = supervisor cs = color_selector sr = m.sample_rate a, b = m.spike_times.searchsorted(interval) s0, s1 = int(round(interval[0] * sr)), int(round(interval[1] * sr)) ns = n_samples_waveforms k = ns // 2 for i in range(a, b): t = m.spike_times[i] c = m.spike_clusters[i] # Skip non-selected spikes if requested. if (not show_all_spikes and c not in supervisor.selected): continue cg = p.cluster_meta.get('group', c) channel_ids = get_best_channels(c) s = int(round(t * sr)) - s0 # Skip partial spikes. if s - k < 0 or s + k >= (s1 - s0): # pragma: no cover continue color = cs.get(c, cluster_ids=p.selected, cluster_group=cg) # Extract the waveform. wave = Bunch(data=traces_interval[s - k:s + ns - k, channel_ids], channel_ids=channel_ids, start_time=(s + s0 - k) / sr, color=color, spike_id=i, spike_time=t, spike_cluster=c, cluster_group=cg, ) assert wave.data.shape[0] == ns yield wave class SpikeClick(Event): def __init__(self, type, channel_id=None, spike_id=None, cluster_id=None): super(SpikeClick, self).__init__(type) self.channel_id = channel_id self.spike_id = spike_id self.cluster_id = cluster_id class TraceView(ManualClusteringView): interval_duration = .25 # default duration of the interval shift_amount = .1 scaling_coeff_x = 1.5 scaling_coeff_y = 1.1 default_trace_color = (.75, .75, .75, 1.) default_shortcuts = { 'go_left': 'alt+left', 'go_right': 'alt+right', 'decrease': 'alt+down', 'increase': 'alt+up', 'toggle_show_labels': 'alt+l', 'widen': 'alt+-', 'narrow': 'alt++', } def __init__(self, traces=None, sample_rate=None, duration=None, n_channels=None, channel_vertical_order=None, **kwargs): self.do_show_labels = None self._key_pressed = None # traces is a function interval => [traces] # spikes is a function interval => [Bunch(...)] # Sample rate. assert sample_rate > 0 self.sample_rate = float(sample_rate) self.dt = 1. / self.sample_rate # Traces and spikes. assert hasattr(traces, '__call__') self.traces = traces assert duration >= 0 self.duration = duration assert n_channels >= 0 self.n_channels = n_channels assert (channel_vertical_order is None or channel_vertical_order.shape == (n_channels,)) self._channel_perm = channel_vertical_order if self._channel_perm is not None: self._channel_perm = np.argsort(self._channel_perm) # Box and probe scaling. self._scaling = 1. self._origin = None # Initialize the view. super(TraceView, self).__init__(layout='stacked', origin=self.origin, n_plots=self.n_channels, **kwargs) # Make a copy of the initial box pos and size. We'll apply the scaling # to these quantities. self.box_size = np.array(self.stacked.box_size) self._update_boxes() # Initial interval. self._interval = None self.go_to(duration / 2.) self._waveform_times = [] self.events.add(spike_click=SpikeClick) def _permute_channels(self, x, inv=False): cp = self._channel_perm cp = np.argsort(cp) if inv and cp is not None else cp return cp[x] if cp is not None else x # Internal methods # ------------------------------------------------------------------------- def _plot_traces(self, traces, color=None, data_bounds=None): traces = traces.T n_samples = traces.shape[1] n_ch = self.n_channels assert traces.shape == (n_ch, n_samples) color = color or self.default_trace_color t = self._interval[0] + np.arange(n_samples) * self.dt t = np.tile(t, (n_ch, 1)) box_index = self._permute_channels(np.arange(n_ch)) box_index = np.repeat(box_index[:, np.newaxis], n_samples, axis=1) assert t.shape == (n_ch, n_samples) assert traces.shape == (n_ch, n_samples) assert box_index.shape == (n_ch, n_samples) self.uplot(t, traces, color=color, data_bounds=data_bounds, box_index=box_index, ) def _plot_waveforms(self, waveforms=None, channel_ids=None, start_time=None, color=None, data_bounds=None, ): # The spike time corresponds to the first sample of the waveform. n_samples, n_channels = waveforms.shape # Generate the x coordinates of the waveform. t = start_time + self.dt * np.arange(n_samples) t = np.tile(t, (n_channels, 1)) # (n_unmasked_channels, n_samples) # The box index depends on the channel. box_index = self._permute_channels(channel_ids) box_index = np.repeat(box_index[:, np.newaxis], n_samples, axis=0) self.plot(t, waveforms.T, color=color, box_index=box_index, data_bounds=data_bounds, ) def _plot_labels(self, traces, data_bounds=None): for ch in range(self.n_channels): bi = self._permute_channels(ch) ch_label = '%d' % ch self[bi].text(pos=[data_bounds[0], traces[0, ch]], text=ch_label, anchor=[+1., -.1], data_bounds=data_bounds, ) def _restrict_interval(self, interval): start, end = interval # Round the times to full samples to avoid subsampling shifts # in the traces. start = int(round(start * self.sample_rate)) / self.sample_rate end = int(round(end * self.sample_rate)) / self.sample_rate # Restrict the interval to the boundaries of the traces. if start < 0: end += (-start) start = 0 elif end >= self.duration: start -= (end - self.duration) end = self.duration start = np.clip(start, 0, end) end = np.clip(end, start, self.duration) assert 0 <= start < end <= self.duration return start, end # Public methods # ------------------------------------------------------------------------- def set_interval(self, interval=None, change_status=True, force_update=False): """Display the traces and spikes in a given interval.""" if interval is None: interval = self._interval interval = self._restrict_interval(interval) if not force_update and interval == self._interval: return self._interval = interval start, end = interval self.clear() # Set the status message. if change_status: self.set_status('Interval: {:.3f} s - {:.3f} s'.format(start, end)) # Load the traces. traces = self.traces(interval) # Find the data bounds. ymin, ymax = traces.data.min(), traces.data.max() data_bounds = (start, ymin, end, ymax) # Used for spike click. self._data_bounds = data_bounds self._waveform_times = [] # Plot the traces. self._plot_traces(traces.data, color=traces.get('color', None), data_bounds=data_bounds, ) # Plot the spikes. waveforms = traces.waveforms assert isinstance(waveforms, list) for w in waveforms: self._plot_waveforms(waveforms=w.data, color=w.color, channel_ids=w.get('channel_ids', None), start_time=w.start_time, data_bounds=data_bounds, ) self._waveform_times.append((w.start_time, w.spike_id, w.spike_cluster, w.get('channel_ids', None), )) # Plot the labels. if self.do_show_labels: self._plot_labels(traces.data, data_bounds=data_bounds) self.build() self.update() def on_select(self, cluster_ids=None, **kwargs): super(TraceView, self).on_select(cluster_ids, **kwargs) self.set_interval(self._interval, change_status=False, force_update=kwargs.get('force_update', None)) def attach(self, gui): """Attach the view to the GUI.""" super(TraceView, self).attach(gui) self.actions.add(self.go_to, alias='tg') self.actions.separator() self.actions.add(self.shift, alias='ts') self.actions.add(self.go_right) self.actions.add(self.go_left) self.actions.separator() self.actions.add(self.increase) self.actions.add(self.decrease) self.actions.separator() self.actions.add(self.widen) self.actions.add(self.narrow) self.actions.separator() self.actions.add(self.toggle_show_labels) # We forward the event from VisPy to the phy GUI. @self.connect def on_spike_click(e): logger.log(5, "Spike click on channel %s, spike %s, cluster %s.", e.channel_id, e.spike_id, e.cluster_id) gui.emit('spike_click', channel_id=e.channel_id, spike_id=e.spike_id, cluster_id=e.cluster_id, ) @property def state(self): return Bunch(scaling=self.scaling, origin=self.origin, interval=self._interval, do_show_labels=self.do_show_labels, ) # Scaling # ------------------------------------------------------------------------- @property def scaling(self): return self._scaling @scaling.setter def scaling(self, value): self._scaling = value self._update_boxes() # Origin # ------------------------------------------------------------------------- @property def origin(self): return self._origin @origin.setter def origin(self, value): self._origin = value self._update_boxes() # Navigation # ------------------------------------------------------------------------- @property def time(self): """Time at the center of the window.""" return sum(self._interval) * .5 @property def interval(self): return self._interval @interval.setter def interval(self, value): self.set_interval(value) @property def half_duration(self): """Half of the duration of the current interval.""" if self._interval is not None: a, b = self._interval return (b - a) * .5 else: return self.interval_duration * .5 def go_to(self, time): """Go to a specific time (in seconds).""" half_dur = self.half_duration self.set_interval((time - half_dur, time + half_dur)) def shift(self, delay): """Shift the interval by a given delay (in seconds).""" self.go_to(self.time + delay) def go_right(self): """Go to right.""" start, end = self._interval delay = (end - start) * .2 self.shift(delay) def go_left(self): """Go to left.""" start, end = self._interval delay = (end - start) * .2 self.shift(-delay) def widen(self): """Increase the interval size.""" t, h = self.time, self.half_duration h *= self.scaling_coeff_x self.set_interval((t - h, t + h)) def narrow(self): """Decrease the interval size.""" t, h = self.time, self.half_duration h /= self.scaling_coeff_x self.set_interval((t - h, t + h)) def toggle_show_labels(self): self.do_show_labels = not self.do_show_labels self.set_interval(force_update=True) # Channel scaling # ------------------------------------------------------------------------- def _update_boxes(self): self.stacked.box_size = self.box_size * self.scaling def increase(self): """Increase the scaling of the traces.""" self.scaling *= self.scaling_coeff_y self._update_boxes() def decrease(self): """Decrease the scaling of the traces.""" self.scaling /= self.scaling_coeff_y self._update_boxes() # Spike selection # ------------------------------------------------------------------------- def on_key_press(self, event): """Handle key press events.""" key = event.key self._key_pressed = key def on_mouse_press(self, e): key = self._key_pressed if 'Control' in e.modifiers or key in map(str, range(10)): key = int(key.name) if key in map(str, range(10)) else None # Get mouse position in NDC. mouse_pos = self.panzoom.get_mouse_pos(e.pos) box_id = self.stacked.get_closest_box(mouse_pos) channel_id = self._permute_channels(box_id, inv=True) # Find the spike and cluster closest to the mouse. db = self._data_bounds # Get the information about the displayed spikes. if not self._waveform_times: return # Get the time coordinate of the mouse position. mouse_time = Range(NDC, db).apply(mouse_pos)[0][0] # Get the closest spike id. times, spike_ids, spike_clusters, channel_ids = \ zip(*(_ for _ in self._waveform_times if channel_id in _[3])) i = np.argmin(np.abs(np.array(times) - mouse_time)) # Raise the spike_click event. spike_id = spike_ids[i] cluster_id = spike_clusters[i] self.events.spike_click(channel_id=channel_id, spike_id=spike_id, cluster_id=cluster_id ) def on_key_release(self, event): self._key_pressed = None
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 3921, 2455, 1041, 421, 199, 3, 13722, 199, 3, 24339, 199, 3, 13722, 199, 199, 646, 2050, 199, 199, 646, 2680, 465, 980, 199, 504, 11831, 14, 2798, 14, 4711, 492, 653, 5196, 12, 13114, 199, 504, 21370, 647, 14, 1974, 14, 1430, 492, 6763, 199, 199, 504, 11831, 14, 1208, 492, 699, 4689, 199, 504, 1275, 1095, 492, 30247, 31174, 2768, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 3, 13722, 199, 3, 11680, 2455, 199, 3, 13722, 199, 199, 318, 3504, 63, 28388, 8, 28388, 12, 6252, 12, 2690, 63, 1866, 29, 403, 304, 272, 408, 6200, 26365, 315, 376, 6252, 334, 262, 4696, 10477, 272, 1343, 12, 1284, 275, 6252, 272, 284, 12, 1335, 275, 6168, 8, 3271, 63, 1866, 627, 1343, 395, 6168, 8, 3271, 63, 1866, 627, 1284, 9, 272, 284, 12, 1335, 275, 1109, 8, 73, 395, 1109, 8, 74, 9, 272, 26365, 275, 26365, 59, 73, 26, 74, 12, 12228, 272, 327, 26365, 275, 26365, 446, 980, 14, 3670, 8, 28388, 12, 3114, 29, 16, 9, 272, 372, 26365, 421, 199, 318, 485, 1661, 63, 29774, 63, 10024, 3351, 8, 4284, 29, 403, 12, 2079, 26365, 63, 4284, 29, 403, 12, 2079, 1402, 29, 403, 12, 2079, 28223, 29, 403, 12, 2079, 302, 63, 3356, 63, 10024, 3351, 29, 403, 12, 2079, 664, 63, 7010, 63, 6324, 29, 403, 12, 2079, 2498, 63, 452, 63, 32757, 397, 29, 797, 12, 2079, 3164, 63, 6662, 29, 403, 12, 2079, 3461, 272, 333, 275, 1402, 272, 299, 275, 28223, 272, 7117, 275, 3164, 63, 6662, 272, 11483, 275, 333, 14, 3271, 63, 1866, 272, 282, 12, 330, 275, 333, 14, 29774, 63, 4508, 14, 31698, 8, 4284, 9, 272, 308, 16, 12, 308, 17, 275, 1109, 8, 2363, 8, 4284, 59, 16, 61, 627, 11483, 1826, 1109, 8, 2363, 8, 4284, 59, 17, 61, 627, 11483, 430, 272, 700, 275, 302, 63, 3356, 63, 10024, 3351, 272, 1022, 275, 700, 5001, 499, 272, 367, 284, 315, 1425, 8, 65, 12, 330, 304, 267, 307, 275, 333, 14, 29774, 63, 4508, 59, 73, 61, 267, 286, 275, 333, 14, 29774, 63, 9170, 59, 73, 61, 267, 327, 8232, 2222, 13, 5511, 19441, 9246, 340, 5839, 14, 267, 340, 334, 1397, 2498, 63, 452, 63, 32757, 397, 436, 286, 440, 315, 28223, 14, 5511, 304, 288, 1980, 267, 19711, 275, 299, 14, 4201, 63, 2024, 14, 362, 360, 923, 297, 286, 9, 267, 3623, 63, 1580, 275, 664, 63, 7010, 63, 6324, 8, 67, 9, 267, 308, 275, 1109, 8, 2363, 8, 84, 627, 11483, 430, 446, 308, 16, 267, 327, 8232, 7417, 19441, 9246, 14, 267, 340, 308, 446, 1022, 665, 378, 503, 308, 435, 1022, 2356, 334, 83, 17, 446, 308, 16, 304, 221, 327, 11942, 26, 949, 8486, 288, 1980, 267, 3164, 275, 7117, 14, 362, 8, 67, 12, 4350, 63, 1580, 29, 80, 14, 5511, 12, 4350, 63, 923, 29, 12595, 9, 267, 327, 12892, 314, 12204, 964, 14, 267, 12204, 275, 699, 4689, 8, 576, 29, 28388, 63, 4284, 59, 83, 446, 1022, 26, 83, 435, 700, 446, 1022, 12, 3623, 63, 1580, 467, 2151, 3623, 63, 1580, 29, 2775, 63, 1580, 12, 2151, 1343, 63, 521, 2687, 83, 435, 308, 16, 446, 1022, 9, 1182, 11483, 12, 2151, 3164, 29, 2326, 12, 2151, 19441, 415, 63, 344, 29, 73, 12, 2151, 19441, 415, 63, 521, 29, 84, 12, 2151, 19441, 415, 63, 4201, 29, 67, 12, 2151, 4350, 63, 923, 29, 12595, 12, 2151, 776, 267, 702, 12204, 14, 576, 14, 1392, 59, 16, 61, 508, 700, 267, 1995, 12204, 421, 199, 533, 428, 1038, 415, 12040, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 730, 12, 3623, 63, 344, 29, 403, 12, 19441, 415, 63, 344, 29, 403, 12, 4350, 63, 344, 29, 403, 304, 267, 1613, 8, 51, 1038, 415, 12040, 12, 291, 2843, 826, 721, 466, 9, 267, 291, 14, 2775, 63, 344, 275, 3623, 63, 344, 267, 291, 14, 29774, 63, 344, 275, 19441, 415, 63, 344, 267, 291, 14, 4201, 63, 344, 275, 4350, 63, 344, 421, 199, 533, 11680, 2768, 8, 22382, 31174, 2768, 304, 272, 6252, 63, 5553, 275, 1275, 821, 221, 327, 849, 7373, 402, 314, 6252, 272, 7706, 63, 4606, 275, 1275, 17, 272, 13690, 63, 8903, 63, 88, 275, 413, 14, 21, 272, 13690, 63, 8903, 63, 89, 275, 413, 14, 17, 272, 849, 63, 3446, 63, 2326, 275, 17048, 2194, 12, 1275, 2194, 12, 1275, 2194, 12, 413, 4959, 272, 849, 63, 17469, 275, 469, 267, 283, 1939, 63, 3039, 356, 283, 4478, 11, 3039, 297, 267, 283, 1939, 63, 1019, 356, 283, 4478, 11, 1019, 297, 267, 283, 271, 16772, 356, 283, 4478, 11, 2110, 297, 267, 283, 31687, 356, 283, 4478, 11, 384, 297, 267, 283, 13396, 63, 2384, 63, 3512, 356, 283, 4478, 11, 76, 297, 267, 283, 87, 9281, 356, 283, 4478, 11, 14382, 267, 283, 15485, 356, 283, 4478, 31249, 272, 789, 339, 347, 636, 826, 721, 277, 12, 326, 26365, 29, 403, 12, 326, 2690, 63, 1866, 29, 403, 12, 326, 7373, 29, 403, 12, 326, 302, 63, 6324, 29, 403, 12, 326, 3623, 63, 7870, 63, 1648, 29, 403, 12, 326, 1011, 958, 304, 398, 291, 14, 1117, 63, 2384, 63, 3512, 275, 488, 267, 291, 423, 498, 63, 30455, 275, 488, 398, 327, 26365, 365, 282, 805, 6252, 9265, 359, 28388, 61, 267, 327, 19441, 9246, 365, 282, 805, 6252, 9265, 359, 34, 4689, 29195, 1874, 398, 327, 15227, 6634, 14, 267, 702, 2690, 63, 1866, 690, 378, 267, 291, 14, 3271, 63, 1866, 275, 2069, 8, 3271, 63, 1866, 9, 267, 291, 14, 3583, 275, 413, 14, 1182, 291, 14, 3271, 63, 1866, 398, 327, 12643, 823, 436, 19441, 9246, 14, 267, 702, 2688, 8, 28388, 12, 2560, 1250, 13766, 267, 291, 14, 28388, 275, 26365, 398, 702, 7373, 2356, 378, 267, 291, 14, 5553, 275, 7373, 398, 702, 302, 63, 6324, 2356, 378, 267, 291, 14, 78, 63, 6324, 275, 302, 63, 6324, 398, 702, 334, 2775 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 3921, 2455, 1041, 421, 199, 3, 13722, 199, 3, 24339, 199, 3, 13722, 199, 199, 646, 2050, 199, 199, 646, 2680, 465, 980, 199, 504, 11831, 14, 2798, 14, 4711, 492, 653, 5196, 12, 13114, 199, 504, 21370, 647, 14, 1974, 14, 1430, 492, 6763, 199, 199, 504, 11831, 14, 1208, 492, 699, 4689, 199, 504, 1275, 1095, 492, 30247, 31174, 2768, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 3, 13722, 199, 3, 11680, 2455, 199, 3, 13722, 199, 199, 318, 3504, 63, 28388, 8, 28388, 12, 6252, 12, 2690, 63, 1866, 29, 403, 304, 272, 408, 6200, 26365, 315, 376, 6252, 334, 262, 4696, 10477, 272, 1343, 12, 1284, 275, 6252, 272, 284, 12, 1335, 275, 6168, 8, 3271, 63, 1866, 627, 1343, 395, 6168, 8, 3271, 63, 1866, 627, 1284, 9, 272, 284, 12, 1335, 275, 1109, 8, 73, 395, 1109, 8, 74, 9, 272, 26365, 275, 26365, 59, 73, 26, 74, 12, 12228, 272, 327, 26365, 275, 26365, 446, 980, 14, 3670, 8, 28388, 12, 3114, 29, 16, 9, 272, 372, 26365, 421, 199, 318, 485, 1661, 63, 29774, 63, 10024, 3351, 8, 4284, 29, 403, 12, 2079, 26365, 63, 4284, 29, 403, 12, 2079, 1402, 29, 403, 12, 2079, 28223, 29, 403, 12, 2079, 302, 63, 3356, 63, 10024, 3351, 29, 403, 12, 2079, 664, 63, 7010, 63, 6324, 29, 403, 12, 2079, 2498, 63, 452, 63, 32757, 397, 29, 797, 12, 2079, 3164, 63, 6662, 29, 403, 12, 2079, 3461, 272, 333, 275, 1402, 272, 299, 275, 28223, 272, 7117, 275, 3164, 63, 6662, 272, 11483, 275, 333, 14, 3271, 63, 1866, 272, 282, 12, 330, 275, 333, 14, 29774, 63, 4508, 14, 31698, 8, 4284, 9, 272, 308, 16, 12, 308, 17, 275, 1109, 8, 2363, 8, 4284, 59, 16, 61, 627, 11483, 1826, 1109, 8, 2363, 8, 4284, 59, 17, 61, 627, 11483, 430, 272, 700, 275, 302, 63, 3356, 63, 10024, 3351, 272, 1022, 275, 700, 5001, 499, 272, 367, 284, 315, 1425, 8, 65, 12, 330, 304, 267, 307, 275, 333, 14, 29774, 63, 4508, 59, 73, 61, 267, 286, 275, 333, 14, 29774, 63, 9170, 59, 73, 61, 267, 327, 8232, 2222, 13, 5511, 19441, 9246, 340, 5839, 14, 267, 340, 334, 1397, 2498, 63, 452, 63, 32757, 397, 436, 286, 440, 315, 28223, 14, 5511, 304, 288, 1980, 267, 19711, 275, 299, 14, 4201, 63, 2024, 14, 362, 360, 923, 297, 286, 9, 267, 3623, 63, 1580, 275, 664, 63, 7010, 63, 6324, 8, 67, 9, 267, 308, 275, 1109, 8, 2363, 8, 84, 627, 11483, 430, 446, 308, 16, 267, 327, 8232, 7417, 19441, 9246, 14, 267, 340, 308, 446, 1022, 665, 378, 503, 308, 435, 1022, 2356, 334, 83, 17, 446, 308, 16, 304, 221, 327, 11942, 26, 949, 8486, 288, 1980, 267, 3164, 275, 7117, 14, 362, 8, 67, 12, 4350, 63, 1580, 29, 80, 14, 5511, 12, 4350, 63, 923, 29, 12595, 9, 267, 327, 12892, 314, 12204, 964, 14, 267, 12204, 275, 699, 4689, 8, 576, 29, 28388, 63, 4284, 59, 83, 446, 1022, 26, 83, 435, 700, 446, 1022, 12, 3623, 63, 1580, 467, 2151, 3623, 63, 1580, 29, 2775, 63, 1580, 12, 2151, 1343, 63, 521, 2687, 83, 435, 308, 16, 446, 1022, 9, 1182, 11483, 12, 2151, 3164, 29, 2326, 12, 2151, 19441, 415, 63, 344, 29, 73, 12, 2151, 19441, 415, 63, 521, 29, 84, 12, 2151, 19441, 415, 63, 4201, 29, 67, 12, 2151, 4350, 63, 923, 29, 12595, 12, 2151, 776, 267, 702, 12204, 14, 576, 14, 1392, 59, 16, 61, 508, 700, 267, 1995, 12204, 421, 199, 533, 428, 1038, 415, 12040, 8, 2390, 304, 272, 347, 636, 826, 721, 277, 12, 730, 12, 3623, 63, 344, 29, 403, 12, 19441, 415, 63, 344, 29, 403, 12, 4350, 63, 344, 29, 403, 304, 267, 1613, 8, 51, 1038, 415, 12040, 12, 291, 2843, 826, 721, 466, 9, 267, 291, 14, 2775, 63, 344, 275, 3623, 63, 344, 267, 291, 14, 29774, 63, 344, 275, 19441, 415, 63, 344, 267, 291, 14, 4201, 63, 344, 275, 4350, 63, 344, 421, 199, 533, 11680, 2768, 8, 22382, 31174, 2768, 304, 272, 6252, 63, 5553, 275, 1275, 821, 221, 327, 849, 7373, 402, 314, 6252, 272, 7706, 63, 4606, 275, 1275, 17, 272, 13690, 63, 8903, 63, 88, 275, 413, 14, 21, 272, 13690, 63, 8903, 63, 89, 275, 413, 14, 17, 272, 849, 63, 3446, 63, 2326, 275, 17048, 2194, 12, 1275, 2194, 12, 1275, 2194, 12, 413, 4959, 272, 849, 63, 17469, 275, 469, 267, 283, 1939, 63, 3039, 356, 283, 4478, 11, 3039, 297, 267, 283, 1939, 63, 1019, 356, 283, 4478, 11, 1019, 297, 267, 283, 271, 16772, 356, 283, 4478, 11, 2110, 297, 267, 283, 31687, 356, 283, 4478, 11, 384, 297, 267, 283, 13396, 63, 2384, 63, 3512, 356, 283, 4478, 11, 76, 297, 267, 283, 87, 9281, 356, 283, 4478, 11, 14382, 267, 283, 15485, 356, 283, 4478, 31249, 272, 789, 339, 347, 636, 826, 721, 277, 12, 326, 26365, 29, 403, 12, 326, 2690, 63, 1866, 29, 403, 12, 326, 7373, 29, 403, 12, 326, 302, 63, 6324, 29, 403, 12, 326, 3623, 63, 7870, 63, 1648, 29, 403, 12, 326, 1011, 958, 304, 398, 291, 14, 1117, 63, 2384, 63, 3512, 275, 488, 267, 291, 423, 498, 63, 30455, 275, 488, 398, 327, 26365, 365, 282, 805, 6252, 9265, 359, 28388, 61, 267, 327, 19441, 9246, 365, 282, 805, 6252, 9265, 359, 34, 4689, 29195, 1874, 398, 327, 15227, 6634, 14, 267, 702, 2690, 63, 1866, 690, 378, 267, 291, 14, 3271, 63, 1866, 275, 2069, 8, 3271, 63, 1866, 9, 267, 291, 14, 3583, 275, 413, 14, 1182, 291, 14, 3271, 63, 1866, 398, 327, 12643, 823, 436, 19441, 9246, 14, 267, 702, 2688, 8, 28388, 12, 2560, 1250, 13766, 267, 291, 14, 28388, 275, 26365, 398, 702, 7373, 2356, 378, 267, 291, 14, 5553, 275, 7373, 398, 702, 302, 63, 6324, 2356, 378, 267, 291, 14, 78, 63, 6324, 275, 302, 63, 6324, 398, 702, 334, 2775, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
havard024/prego
crm/lib/python2.7/site-packages/pip/_vendor/distlib/markers.py
1261
6282
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2013 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # """Parser for the environment markers micro-language defined in PEP 345.""" import ast import os import sys import platform from .compat import python_implementation, string_types from .util import in_venv __all__ = ['interpret'] class Evaluator(object): """ A limited evaluator for Python expressions. """ operators = { 'eq': lambda x, y: x == y, 'gt': lambda x, y: x > y, 'gte': lambda x, y: x >= y, 'in': lambda x, y: x in y, 'lt': lambda x, y: x < y, 'lte': lambda x, y: x <= y, 'not': lambda x: not x, 'noteq': lambda x, y: x != y, 'notin': lambda x, y: x not in y, } allowed_values = { 'sys_platform': sys.platform, 'python_version': '%s.%s' % sys.version_info[:2], # parsing sys.platform is not reliable, but there is no other # way to get e.g. 2.7.2+, and the PEP is defined with sys.version 'python_full_version': sys.version.split(' ', 1)[0], 'os_name': os.name, 'platform_in_venv': str(in_venv()), 'platform_release': platform.release(), 'platform_version': platform.version(), 'platform_machine': platform.machine(), 'platform_python_implementation': python_implementation(), } def __init__(self, context=None): """ Initialise an instance. :param context: If specified, names are looked up in this mapping. """ self.context = context or {} self.source = None def get_fragment(self, offset): """ Get the part of the source which is causing a problem. """ fragment_len = 10 s = '%r' % (self.source[offset:offset + fragment_len]) if offset + fragment_len < len(self.source): s += '...' return s def get_handler(self, node_type): """ Get a handler for the specified AST node type. """ return getattr(self, 'do_%s' % node_type, None) def evaluate(self, node, filename=None): """ Evaluate a source string or node, using ``filename`` when displaying errors. """ if isinstance(node, string_types): self.source = node kwargs = {'mode': 'eval'} if filename: kwargs['filename'] = filename try: node = ast.parse(node, **kwargs) except SyntaxError as e: s = self.get_fragment(e.offset) raise SyntaxError('syntax error %s' % s) node_type = node.__class__.__name__.lower() handler = self.get_handler(node_type) if handler is None: if self.source is None: s = '(source not available)' else: s = self.get_fragment(node.col_offset) raise SyntaxError("don't know how to evaluate %r %s" % ( node_type, s)) return handler(node) def get_attr_key(self, node): assert isinstance(node, ast.Attribute), 'attribute node expected' return '%s.%s' % (node.value.id, node.attr) def do_attribute(self, node): if not isinstance(node.value, ast.Name): valid = False else: key = self.get_attr_key(node) valid = key in self.context or key in self.allowed_values if not valid: raise SyntaxError('invalid expression: %s' % key) if key in self.context: result = self.context[key] else: result = self.allowed_values[key] return result def do_boolop(self, node): result = self.evaluate(node.values[0]) is_or = node.op.__class__ is ast.Or is_and = node.op.__class__ is ast.And assert is_or or is_and if (is_and and result) or (is_or and not result): for n in node.values[1:]: result = self.evaluate(n) if (is_or and result) or (is_and and not result): break return result def do_compare(self, node): def sanity_check(lhsnode, rhsnode): valid = True if isinstance(lhsnode, ast.Str) and isinstance(rhsnode, ast.Str): valid = False #elif (isinstance(lhsnode, ast.Attribute) # and isinstance(rhsnode, ast.Attribute)): # klhs = self.get_attr_key(lhsnode) # krhs = self.get_attr_key(rhsnode) # valid = klhs != krhs if not valid: s = self.get_fragment(node.col_offset) raise SyntaxError('Invalid comparison: %s' % s) lhsnode = node.left lhs = self.evaluate(lhsnode) result = True for op, rhsnode in zip(node.ops, node.comparators): sanity_check(lhsnode, rhsnode) op = op.__class__.__name__.lower() if op not in self.operators: raise SyntaxError('unsupported operation: %r' % op) rhs = self.evaluate(rhsnode) result = self.operators[op](lhs, rhs) if not result: break lhs = rhs lhsnode = rhsnode return result def do_expression(self, node): return self.evaluate(node.body) def do_name(self, node): valid = False if node.id in self.context: valid = True result = self.context[node.id] elif node.id in self.allowed_values: valid = True result = self.allowed_values[node.id] if not valid: raise SyntaxError('invalid expression: %s' % node.id) return result def do_str(self, node): return node.s def interpret(marker, execution_context=None): """ Interpret a marker and return a result depending on environment. :param marker: The marker to interpret. :type marker: str :param execution_context: The context used for name lookup. :type execution_context: mapping """ return Evaluator(execution_context).evaluate(marker.strip())
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 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, 624, 2842, 367, 314, 3734, 14327, 9967, 13, 3671, 3247, 315, 13663, 30044, 1041, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 984, 199, 646, 4298, 199, 199, 504, 1275, 5819, 492, 2366, 63, 12236, 12, 1059, 63, 1313, 199, 504, 1275, 1974, 492, 315, 63, 23195, 199, 199, 363, 452, 363, 275, 788, 21533, 418, 421, 199, 533, 16494, 16530, 8, 785, 304, 272, 408, 272, 437, 13988, 29207, 367, 2018, 8455, 14, 272, 408, 339, 10211, 275, 469, 267, 283, 4077, 356, 2400, 671, 12, 612, 26, 671, 508, 612, 12, 267, 283, 3308, 356, 2400, 671, 12, 612, 26, 671, 690, 612, 12, 267, 283, 19586, 356, 2400, 671, 12, 612, 26, 671, 2356, 612, 12, 267, 283, 262, 356, 2400, 671, 12, 612, 26, 671, 315, 612, 12, 267, 283, 4116, 356, 2400, 671, 12, 612, 26, 671, 665, 612, 12, 267, 283, 20740, 356, 2400, 671, 12, 612, 26, 671, 2695, 612, 12, 267, 283, 1397, 356, 2400, 671, 26, 440, 671, 12, 267, 283, 4610, 81, 356, 2400, 671, 12, 612, 26, 671, 1137, 612, 12, 267, 283, 1397, 262, 356, 2400, 671, 12, 612, 26, 671, 440, 315, 612, 12, 272, 789, 339, 4370, 63, 1459, 275, 469, 267, 283, 1274, 63, 3246, 356, 984, 14, 3246, 12, 267, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 267, 327, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 267, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 267, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 267, 283, 736, 63, 354, 356, 747, 14, 354, 12, 267, 283, 3246, 63, 262, 63, 23195, 356, 620, 8, 262, 63, 23195, 4000, 267, 283, 3246, 63, 3221, 356, 4298, 14, 3221, 1062, 267, 283, 3246, 63, 1023, 356, 4298, 14, 1023, 1062, 267, 283, 3246, 63, 6744, 356, 4298, 14, 6744, 1062, 267, 283, 3246, 63, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1067, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1067, 26, 982, 2013, 12, 1561, 787, 21182, 1536, 315, 642, 4412, 14, 267, 408, 267, 291, 14, 1100, 275, 1067, 503, 1052, 267, 291, 14, 1365, 275, 488, 339, 347, 664, 63, 7677, 8, 277, 12, 3268, 304, 267, 408, 267, 2372, 314, 1777, 402, 314, 1350, 1314, 365, 25498, 282, 5160, 14, 267, 408, 267, 7956, 63, 552, 275, 1616, 267, 308, 275, 1543, 82, 7, 450, 334, 277, 14, 1365, 59, 2743, 26, 2743, 435, 7956, 63, 552, 566, 267, 340, 3268, 435, 7956, 63, 552, 665, 822, 8, 277, 14, 1365, 304, 288, 308, 847, 28044, 267, 372, 308, 339, 347, 664, 63, 2232, 8, 277, 12, 1031, 63, 466, 304, 267, 408, 267, 2372, 282, 3016, 367, 314, 2013, 20788, 1031, 730, 14, 267, 408, 267, 372, 2519, 8, 277, 12, 283, 1117, 4970, 83, 7, 450, 1031, 63, 466, 12, 488, 9, 339, 347, 9352, 8, 277, 12, 1031, 12, 1788, 29, 403, 304, 267, 408, 267, 27450, 282, 1350, 1059, 503, 1031, 12, 1808, 1124, 1501, 1040, 1380, 267, 20589, 2552, 14, 267, 408, 267, 340, 1228, 8, 932, 12, 1059, 63, 1313, 304, 288, 291, 14, 1365, 275, 1031, 288, 2074, 275, 791, 632, 356, 283, 2579, 936, 288, 340, 1788, 26, 355, 2074, 459, 1501, 418, 275, 1788, 288, 862, 26, 355, 1031, 275, 6073, 14, 1122, 8, 932, 12, 1011, 958, 9, 288, 871, 12053, 465, 325, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 69, 14, 2743, 9, 355, 746, 12053, 360, 7093, 1125, 450, 83, 7, 450, 308, 9, 267, 1031, 63, 466, 275, 1031, 855, 533, 4914, 354, 4343, 2325, 342, 267, 3016, 275, 291, 14, 362, 63, 2232, 8, 932, 63, 466, 9, 267, 340, 3016, 365, 488, 26, 288, 340, 291, 14, 1365, 365, 488, 26, 355, 308, 275, 8189, 1365, 440, 2808, 3171, 288, 587, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 932, 14, 761, 63, 2743, 9, 288, 746, 12053, 480, 13196, 1133, 5715, 4212, 370, 9352, 450, 82, 450, 83, 2, 450, 334, 355, 1031, 63, 466, 12, 308, 430, 267, 372, 3016, 8, 932, 9, 339, 347, 664, 63, 962, 63, 498, 8, 277, 12, 1031, 304, 267, 702, 1228, 8, 932, 12, 6073, 14, 1646, 395, 283, 3215, 1031, 1420, 7, 267, 372, 1543, 83, 4111, 83, 7, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 9, 339, 347, 886, 63, 3215, 8, 277, 12, 1031, 304, 267, 340, 440, 1228, 8, 932, 14, 585, 12, 6073, 14, 985, 304, 288, 1686, 275, 756, 267, 587, 26, 288, 790, 275, 291, 14, 362, 63, 962, 63, 498, 8, 932, 9, 288, 1686, 275, 790, 315, 291, 14, 1100, 503, 790, 315, 291, 14, 6541, 63, 1459, 267, 340, 440, 1686, 26, 288, 746, 12053, 360, 3197, 3965, 26, 450, 83, 7, 450, 790, 9, 267, 340, 790, 315, 291, 14, 1100, 26, 288, 754, 275, 291, 14, 1100, 59, 498, 61, 267, 587, 26, 288, 754, 275, 291, 14, 6541, 63, 1459, 59, 498, 61, 267, 372, 754, 339, 347, 886, 63, 15056, 18630, 8, 277, 12, 1031, 304, 267, 754, 275, 291, 14, 7383, 8, 932, 14, 1459, 59, 16, 566, 267, 365, 63, 269, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 2844, 267, 365, 63, 460, 275, 1031, 14, 411, 855, 533, 363, 365, 6073, 14, 3325, 267, 702, 365, 63, 269, 503, 365, 63, 460, 267, 340, 334, 374, 63, 460, 436, 754, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 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, 624, 2842, 367, 314, 3734, 14327, 9967, 13, 3671, 3247, 315, 13663, 30044, 1041, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 984, 199, 646, 4298, 199, 199, 504, 1275, 5819, 492, 2366, 63, 12236, 12, 1059, 63, 1313, 199, 504, 1275, 1974, 492, 315, 63, 23195, 199, 199, 363, 452, 363, 275, 788, 21533, 418, 421, 199, 533, 16494, 16530, 8, 785, 304, 272, 408, 272, 437, 13988, 29207, 367, 2018, 8455, 14, 272, 408, 339, 10211, 275, 469, 267, 283, 4077, 356, 2400, 671, 12, 612, 26, 671, 508, 612, 12, 267, 283, 3308, 356, 2400, 671, 12, 612, 26, 671, 690, 612, 12, 267, 283, 19586, 356, 2400, 671, 12, 612, 26, 671, 2356, 612, 12, 267, 283, 262, 356, 2400, 671, 12, 612, 26, 671, 315, 612, 12, 267, 283, 4116, 356, 2400, 671, 12, 612, 26, 671, 665, 612, 12, 267, 283, 20740, 356, 2400, 671, 12, 612, 26, 671, 2695, 612, 12, 267, 283, 1397, 356, 2400, 671, 26, 440, 671, 12, 267, 283, 4610, 81, 356, 2400, 671, 12, 612, 26, 671, 1137, 612, 12, 267, 283, 1397, 262, 356, 2400, 671, 12, 612, 26, 671, 440, 315, 612, 12, 272, 789, 339, 4370, 63, 1459, 275, 469, 267, 283, 1274, 63, 3246, 356, 984, 14, 3246, 12, 267, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 267, 327, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 267, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 267, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 267, 283, 736, 63, 354, 356, 747, 14, 354, 12, 267, 283, 3246, 63, 262, 63, 23195, 356, 620, 8, 262, 63, 23195, 4000, 267, 283, 3246, 63, 3221, 356, 4298, 14, 3221, 1062, 267, 283, 3246, 63, 1023, 356, 4298, 14, 1023, 1062, 267, 283, 3246, 63, 6744, 356, 4298, 14, 6744, 1062, 267, 283, 3246, 63, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1067, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1067, 26, 982, 2013, 12, 1561, 787, 21182, 1536, 315, 642, 4412, 14, 267, 408, 267, 291, 14, 1100, 275, 1067, 503, 1052, 267, 291, 14, 1365, 275, 488, 339, 347, 664, 63, 7677, 8, 277, 12, 3268, 304, 267, 408, 267, 2372, 314, 1777, 402, 314, 1350, 1314, 365, 25498, 282, 5160, 14, 267, 408, 267, 7956, 63, 552, 275, 1616, 267, 308, 275, 1543, 82, 7, 450, 334, 277, 14, 1365, 59, 2743, 26, 2743, 435, 7956, 63, 552, 566, 267, 340, 3268, 435, 7956, 63, 552, 665, 822, 8, 277, 14, 1365, 304, 288, 308, 847, 28044, 267, 372, 308, 339, 347, 664, 63, 2232, 8, 277, 12, 1031, 63, 466, 304, 267, 408, 267, 2372, 282, 3016, 367, 314, 2013, 20788, 1031, 730, 14, 267, 408, 267, 372, 2519, 8, 277, 12, 283, 1117, 4970, 83, 7, 450, 1031, 63, 466, 12, 488, 9, 339, 347, 9352, 8, 277, 12, 1031, 12, 1788, 29, 403, 304, 267, 408, 267, 27450, 282, 1350, 1059, 503, 1031, 12, 1808, 1124, 1501, 1040, 1380, 267, 20589, 2552, 14, 267, 408, 267, 340, 1228, 8, 932, 12, 1059, 63, 1313, 304, 288, 291, 14, 1365, 275, 1031, 288, 2074, 275, 791, 632, 356, 283, 2579, 936, 288, 340, 1788, 26, 355, 2074, 459, 1501, 418, 275, 1788, 288, 862, 26, 355, 1031, 275, 6073, 14, 1122, 8, 932, 12, 1011, 958, 9, 288, 871, 12053, 465, 325, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 69, 14, 2743, 9, 355, 746, 12053, 360, 7093, 1125, 450, 83, 7, 450, 308, 9, 267, 1031, 63, 466, 275, 1031, 855, 533, 4914, 354, 4343, 2325, 342, 267, 3016, 275, 291, 14, 362, 63, 2232, 8, 932, 63, 466, 9, 267, 340, 3016, 365, 488, 26, 288, 340, 291, 14, 1365, 365, 488, 26, 355, 308, 275, 8189, 1365, 440, 2808, 3171, 288, 587, 26, 355, 308, 275, 291, 14, 362, 63, 7677, 8, 932, 14, 761, 63, 2743, 9, 288, 746, 12053, 480, 13196, 1133, 5715, 4212, 370, 9352, 450, 82, 450, 83, 2, 450, 334, 355, 1031, 63, 466, 12, 308, 430, 267, 372, 3016, 8, 932, 9, 339, 347, 664, 63, 962, 63, 498, 8, 277, 12, 1031, 304, 267, 702, 1228, 8, 932, 12, 6073, 14, 1646, 395, 283, 3215, 1031, 1420, 7, 267, 372, 1543, 83, 4111, 83, 7, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 9, 339, 347, 886, 63, 3215, 8, 277, 12, 1031, 304, 267, 340, 440, 1228, 8, 932, 14, 585, 12, 6073, 14, 985, 304, 288, 1686, 275, 756, 267, 587, 26, 288, 790, 275, 291, 14, 362, 63, 962, 63, 498, 8, 932, 9, 288, 1686, 275, 790, 315, 291, 14, 1100, 503, 790, 315, 291, 14, 6541, 63, 1459, 267, 340, 440, 1686, 26, 288, 746, 12053, 360, 3197, 3965, 26, 450, 83, 7, 450, 790, 9, 267, 340, 790, 315, 291, 14, 1100, 26, 288, 754, 275, 291, 14, 1100, 59, 498, 61, 267, 587, 26, 288, 754, 275, 291, 14, 6541, 63, 1459, 59, 498, 61, 267, 372, 754, 339, 347, 886, 63, 15056, 18630, 8, 277, 12, 1031, 304, 267, 754, 275, 291, 14, 7383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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MDAnalysis/mdanalysis
package/MDAnalysis/analysis/encore/dimensionality_reduction/reduce_dimensionality.py
1
9928
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # # MDAnalysis --- https://www.mdanalysis.org # Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors # (see the file AUTHORS for the full list of names) # # Released under the GNU Public Licence, v2 or any higher version # # Please cite your use of MDAnalysis in published work: # # R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, # D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. # MDAnalysis: A Python package for the rapid analysis of molecular dynamics # simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th # Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. # doi: 10.25080/majora-629e541a-00e # # N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. # MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # """ dimensionality reduction frontend --- :mod:`MDAnalysis.analysis.encore.dimensionality_reduction.reduce_dimensionality` ====================================================================================================================== The module defines a function serving as front-end for various dimensionality reduction algorithms, wrapping them to allow them to be used interchangably. :Author: Matteo Tiberti, Wouter Boomsma, Tone Bengtsen .. versionadded:: 0.16.0 """ import numpy as np from ..confdistmatrix import get_distance_matrix from ..utils import ParallelCalculation, merge_universes from ..dimensionality_reduction.DimensionalityReductionMethod import ( StochasticProximityEmbeddingNative) def reduce_dimensionality(ensembles, method=StochasticProximityEmbeddingNative(), select="name CA", distance_matrix=None, allow_collapsed_result=True, ncores=1, **kwargs): """ Reduce dimensions in frames from one or more ensembles, using one or more dimensionality reduction methods. The function optionally takes pre-calculated distances matrices as an argument. Note that not all dimensionality reduction procedure can work directly on distance matrices, so the distance matrices might be ignored for particular choices of method. Parameters ---------- ensembles : MDAnalysis.Universe, or list or list of list thereof The function takes either a single Universe object, a list of Universe objects or a list of lists of Universe objects. If given a single universe, it simply works on the conformations in the trajectory. If given a list of ensembles, it will merge them and analyse them together, keeping track of the ensemble to which each of the conformations belong. Finally, if passed a list of list of ensembles, the function will just repeat the functionality just described - merging ensembles for each ensemble in the outer loop. method : MDAnalysis.analysis.encore.dimensionality_reduction.DimensionalityReductionMethod or list A single or a list of instances of the DimensionalityReductionMethod classes from the dimensionality_reduction module. A separate analysis will be run for each method. Note that different parameters for the same method can be explored by adding different instances of the same dimensionality reduction class. Options are Stochastic Proximity Embedding or Principal Component Analysis. select : str, optional Atom selection string in the MDAnalysis format (default is "name CA") distance_matrix : encore.utils.TriangularMatrix, optional Distance matrix for stochastic proximity embedding. If this parameter is not supplied an RMSD distance matrix will be calculated on the fly (default). If several distance matrices are supplied, an analysis will be done for each of them. The number of provided distance matrices should match the number of provided ensembles. allow_collapsed_result: bool, optional Whether a return value of a list of one value should be collapsed into just the value (default = True). ncores : int, optional Maximum number of cores to be used (default is 1). Returns ------- list of coordinate arrays in the reduced dimensions (or potentially a single coordinate array object if allow_collapsed_result is set to True) Example ------- Two ensembles are created as Universe object using a topology file and two trajectories. The topology- and trajectory files used are obtained from the MDAnalysis test suite for two different simulations of the protein AdK. Here, we reduce two ensembles to two dimensions, and plot the result using matplotlib: :: >>> from MDAnalysis import Universe >>> import MDAnalysis.analysis.encore as encore >>> from MDAnalysis.tests.datafiles import PSF, DCD, DCD2 >>> ens1 = Universe(PSF, DCD) >>> ens2 = Universe(PSF, DCD2) >>> coordinates, details = encore.reduce_dimensionality([ens1,ens2]) >>> plt.scatter(coordinates[0], coordinates[1], color=[["red", "blue"][m-1] for m in details["ensemble_membership"]]) Note how we extracted information about which conformation belonged to which ensemble from the details variable. You can change the parameters of the dimensionality reduction method by explicitly specifying the method :: >>> coordinates, details = encore.reduce_dimensionality([ens1,ens2], method=encore.StochasticProximityEmbeddingNative(dimension=3)) Here is an illustration using Principal Component Analysis, instead of the default dimensionality reduction method :: >>> coordinates, details = encore.reduce_dimensionality( [ens1,ens2], method=encore.PrincipalComponentAnalysis(dimension=2)) You can also combine multiple methods in one call :: >>> coordinates, details = encore.reduce_dimensionality( [ens1,ens2], method=[encore.PrincipalComponentAnalysis(dimension=2), encore.StochasticProximityEmbeddingNative(dimension=2)]) """ if ensembles is not None: if not hasattr(ensembles, '__iter__'): ensembles = [ensembles] ensembles_list = ensembles if not hasattr(ensembles[0], '__iter__'): ensembles_list = [ensembles] # Calculate merged ensembles and transfer to memory merged_ensembles = [] for ensembles in ensembles_list: # Transfer ensembles to memory for ensemble in ensembles: ensemble.transfer_to_memory() merged_ensembles.append(merge_universes(ensembles)) methods = method if not hasattr(method, '__iter__'): methods = [method] # Check whether any of the methods can make use of a distance matrix any_method_accept_distance_matrix = \ np.any([_method.accepts_distance_matrix for _method in methods]) # If distance matrices are provided, check that it matches the number # of ensembles if distance_matrix: if not hasattr(distance_matrix, '__iter__'): distance_matrix = [distance_matrix] if ensembles is not None and \ len(distance_matrix) != len(merged_ensembles): raise ValueError("Dimensions of provided list of distance matrices " "does not match that of provided list of " "ensembles: {0} vs {1}" .format(len(distance_matrix), len(merged_ensembles))) else: # Calculate distance matrices for all merged ensembles - if not provided if any_method_accept_distance_matrix: distance_matrix = [] for merged_ensemble in merged_ensembles: distance_matrix.append(get_distance_matrix(merged_ensemble, select=select, **kwargs)) args = [] for method in methods: if method.accepts_distance_matrix: args += [(d,) for d in distance_matrix] else: for merged_ensemble in merged_ensembles: coordinates = merged_ensemble.trajectory.timeseries(order="fac") # Flatten coordinate matrix into n_frame x n_coordinates coordinates = np.reshape(coordinates, (coordinates.shape[0], -1)) args.append((coordinates,)) # Execute dimensionality reduction procedure pc = ParallelCalculation(ncores, methods, args) # Run parallel calculation results = pc.run() # Keep track of which sample belongs to which ensembles details = {} if ensembles is not None: ensemble_assignment = [] for i, ensemble in enumerate(ensembles): ensemble_assignment += [i+1]*len(ensemble.trajectory) ensemble_assignment = np.array(ensemble_assignment) details['ensemble_membership'] = ensemble_assignment coordinates = [] for result in results: coordinates.append(result[1][0]) # details.append(result[1][1]) if allow_collapsed_result and len(coordinates)==1: coordinates = coordinates[0] # details = details[0] return coordinates, details
gpl-2.0
[ 3, 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 2803, 26, 1624, 13, 24, 1882, 199, 3, 6695, 26, 20849, 29, 20, 26414, 20105, 29, 20, 25966, 29, 20, 199, 3, 199, 3, 15830, 13182, 10894, 4178, 921, 1544, 14, 1064, 10466, 14, 1308, 199, 3, 1898, 334, 67, 9, 8315, 13, 10680, 710, 15830, 13182, 15290, 11682, 436, 8417, 199, 3, 334, 3239, 314, 570, 10610, 367, 314, 2615, 769, 402, 1561, 9, 199, 3, 199, 3, 17646, 68, 1334, 314, 1664, 1684, 491, 530, 4894, 12, 373, 18, 503, 1263, 10948, 1015, 199, 3, 199, 3, 7754, 286, 1175, 2195, 675, 402, 15830, 13182, 315, 3267, 1736, 26, 199, 3, 199, 3, 820, 14, 1603, 14, 598, 583, 1192, 12, 603, 14, 29730, 415, 12, 1603, 14, 699, 1060, 810, 68, 12, 377, 14, 1603, 14, 662, 14, 9572, 8161, 12, 603, 14, 653, 14, 3194, 320, 12, 428, 14, 491, 14, 3240, 89, 1435, 12, 199, 3, 577, 14, 491, 14, 24716, 834, 12, 1603, 14, 577, 676, 796, 8810, 12, 428, 14, 699, 2133, 810, 88, 12, 473, 14, 603, 14, 1804, 287, 23263, 12, 436, 593, 14, 6423, 346, 1597, 262, 14, 199, 3, 15830, 13182, 26, 437, 2018, 2559, 367, 314, 660, 3150, 11284, 402, 1303, 10251, 2238, 31388, 2932, 199, 3, 4389, 21429, 14, 1010, 428, 14, 26844, 273, 452, 436, 428, 14, 6848, 495, 384, 5283, 1384, 12, 2165, 15648, 780, 402, 314, 4114, 273, 199, 3, 2018, 315, 27491, 1448, 1769, 12, 6497, 12996, 13, 6996, 12, 437, 833, 262, 12, 377, 56, 12, 7800, 14, 16578, 2713, 14, 199, 3, 886, 73, 26, 1616, 14, 7991, 1257, 15, 8452, 65, 13, 29151, 69, 21278, 65, 13, 383, 69, 199, 3, 199, 3, 653, 14, 603, 1158, 32024, 13, 33, 926, 20877, 12, 662, 14, 1603, 14, 25187, 1835, 12, 377, 14, 699, 14, 644, 1534, 276, 12, 436, 593, 14, 6423, 346, 1597, 262, 14, 199, 3, 15830, 13182, 26, 437, 15650, 6065, 367, 314, 21916, 402, 3930, 10251, 2238, 577, 4019, 2932, 10751, 21429, 14, 199, 3, 1603, 14, 3599, 337, 14, 445, 27037, 14, 4337, 334, 8128, 395, 6546, 1167, 306, 8001, 23, 12, 886, 73, 26, 709, 14, 32562, 15, 74, 2055, 14, 9335, 1555, 199, 3, 199, 624, 199, 7430, 6712, 16773, 22523, 10894, 520, 1494, 1705, 5127, 13182, 14, 10466, 14, 287, 1018, 14, 7430, 6712, 63, 22508, 14, 5270, 63, 7430, 6712, 64, 199, 5695, 12813, 23476, 199, 199, 1918, 859, 7890, 282, 805, 22701, 465, 13738, 13, 500, 367, 7750, 6240, 6712, 199, 22508, 18036, 12, 19696, 3062, 370, 2040, 3062, 370, 506, 1202, 1640, 335, 621, 6665, 14, 199, 199, 26, 5949, 26, 18619, 266, 79, 377, 73, 605, 280, 12, 644, 7837, 5088, 22491, 391, 12, 377, 368, 26844, 3308, 2464, 199, 199, 703, 7445, 447, 378, 14, 975, 14, 16, 199, 199, 624, 199, 646, 2680, 465, 980, 199, 504, 2508, 2190, 2686, 3642, 492, 664, 63, 5590, 63, 3642, 199, 504, 2508, 1208, 492, 27311, 13862, 425, 12, 5389, 63, 324, 4380, 874, 199, 504, 2508, 7430, 6712, 63, 22508, 14, 17905, 6712, 29705, 3767, 492, 334, 272, 9785, 21913, 26689, 1017, 1209, 27907, 19675, 9, 421, 199, 318, 7114, 63, 7430, 6712, 8, 15628, 83, 12, 2079, 1083, 29, 4759, 21913, 26689, 1017, 1209, 27907, 19675, 1062, 2079, 3504, 628, 354, 7240, 401, 2079, 6033, 63, 3642, 29, 403, 12, 2079, 2040, 63, 761, 9982, 63, 1099, 29, 549, 12, 2079, 302, 4630, 29, 17, 12, 2079, 1011, 958, 304, 272, 408, 272, 30778, 7365, 315, 11223, 687, 1373, 503, 1655, 19965, 83, 12, 1808, 1373, 503, 1655, 272, 6240, 6712, 16773, 3102, 14, 710, 805, 14190, 6181, 272, 876, 13, 13494, 972, 15108, 12627, 465, 376, 1423, 14, 3390, 626, 440, 1006, 272, 6240, 6712, 16773, 17782, 883, 1736, 5370, 641, 6033, 12627, 12, 272, 880, 314, 6033, 12627, 5594, 506, 5525, 367, 6770, 3415, 402, 272, 1083, 14, 2378, 3897, 272, 4143, 339, 19965, 83, 520, 15830, 13182, 14, 27921, 2077, 12, 503, 769, 503, 769, 402, 769, 2337, 1618, 267, 710, 805, 6181, 1902, 282, 2849, 1910, 73, 2077, 909, 12, 282, 769, 402, 1910, 73, 2077, 267, 2251, 503, 282, 769, 402, 5548, 402, 1910, 73, 2077, 2251, 14, 982, 1627, 282, 2849, 267, 15439, 2077, 12, 652, 9329, 5419, 641, 314, 406, 17308, 315, 314, 30595, 14, 982, 267, 1627, 282, 769, 402, 19965, 83, 12, 652, 911, 5389, 3062, 436, 21297, 3062, 10451, 12, 267, 22181, 4426, 402, 314, 19965, 370, 1314, 1924, 402, 314, 406, 17308, 13511, 14, 267, 19177, 12, 340, 3032, 282, 769, 402, 769, 402, 19965, 83, 12, 314, 805, 911, 2951, 267, 11982, 314, 9330, 2951, 11736, 446, 22537, 19965, 83, 367, 1924, 267, 19965, 315, 314, 6890, 4438, 14, 339, 1083, 520, 15830, 13182, 14, 10466, 14, 287, 1018, 14, 7430, 6712, 63, 22508, 14, 17905, 6712, 29705, 3767, 503, 769, 267, 437, 2849, 503, 282, 769, 402, 4454, 402, 314, 25291, 6712, 29705, 3767, 267, 3992, 687, 314, 6240, 6712, 63, 22508, 859, 14, 437, 7396, 11284, 267, 911, 506, 1255, 367, 1924, 1083, 14, 3390, 626, 3365, 2633, 367, 314, 267, 2011, 1083, 883, 506, 15868, 581, 701, 7791, 3365, 4454, 402, 267, 314, 2011, 6240, 6712, 16773, 1021, 14, 8394, 787, 9785, 21913, 267, 2165, 88, 1017, 1209, 24297, 1098, 503, 25716, 11590, 12727, 21916, 14, 339, 3504, 520, 620, 12, 2716, 267, 18840, 7267, 1059, 315, 314, 15830, 13182, 1475, 334, 885, 365, 298, 354, 7240, 531, 339, 6033, 63, 3642, 520, 655, 1018, 14, 1208, 14, 23341, 6443, 12, 2716, 267, 21892, 3634, 367, 26123, 21913, 10645, 1017, 1209, 12452, 14, 982, 642, 2725, 267, 365, 440, 6841, 376, 820, 3053, 36, 6033, 3634, 911, 506, 12950, 641, 314, 23158, 334, 885, 680, 267, 982, 9978, 6033, 12627, 787, 6841, 12, 376, 11284, 911, 506, 4224, 267, 367, 1924, 402, 3062, 14, 710, 1329, 402, 2741, 6033, 12627, 1077, 267, 1336, 314, 1329, 402, 2741, 19965, 83, 14, 339, 2040, 63, 761, 9982, 63 ]
[ 1882, 4900, 26, 2366, 27, 5174, 13, 2063, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 2803, 26, 1624, 13, 24, 1882, 199, 3, 6695, 26, 20849, 29, 20, 26414, 20105, 29, 20, 25966, 29, 20, 199, 3, 199, 3, 15830, 13182, 10894, 4178, 921, 1544, 14, 1064, 10466, 14, 1308, 199, 3, 1898, 334, 67, 9, 8315, 13, 10680, 710, 15830, 13182, 15290, 11682, 436, 8417, 199, 3, 334, 3239, 314, 570, 10610, 367, 314, 2615, 769, 402, 1561, 9, 199, 3, 199, 3, 17646, 68, 1334, 314, 1664, 1684, 491, 530, 4894, 12, 373, 18, 503, 1263, 10948, 1015, 199, 3, 199, 3, 7754, 286, 1175, 2195, 675, 402, 15830, 13182, 315, 3267, 1736, 26, 199, 3, 199, 3, 820, 14, 1603, 14, 598, 583, 1192, 12, 603, 14, 29730, 415, 12, 1603, 14, 699, 1060, 810, 68, 12, 377, 14, 1603, 14, 662, 14, 9572, 8161, 12, 603, 14, 653, 14, 3194, 320, 12, 428, 14, 491, 14, 3240, 89, 1435, 12, 199, 3, 577, 14, 491, 14, 24716, 834, 12, 1603, 14, 577, 676, 796, 8810, 12, 428, 14, 699, 2133, 810, 88, 12, 473, 14, 603, 14, 1804, 287, 23263, 12, 436, 593, 14, 6423, 346, 1597, 262, 14, 199, 3, 15830, 13182, 26, 437, 2018, 2559, 367, 314, 660, 3150, 11284, 402, 1303, 10251, 2238, 31388, 2932, 199, 3, 4389, 21429, 14, 1010, 428, 14, 26844, 273, 452, 436, 428, 14, 6848, 495, 384, 5283, 1384, 12, 2165, 15648, 780, 402, 314, 4114, 273, 199, 3, 2018, 315, 27491, 1448, 1769, 12, 6497, 12996, 13, 6996, 12, 437, 833, 262, 12, 377, 56, 12, 7800, 14, 16578, 2713, 14, 199, 3, 886, 73, 26, 1616, 14, 7991, 1257, 15, 8452, 65, 13, 29151, 69, 21278, 65, 13, 383, 69, 199, 3, 199, 3, 653, 14, 603, 1158, 32024, 13, 33, 926, 20877, 12, 662, 14, 1603, 14, 25187, 1835, 12, 377, 14, 699, 14, 644, 1534, 276, 12, 436, 593, 14, 6423, 346, 1597, 262, 14, 199, 3, 15830, 13182, 26, 437, 15650, 6065, 367, 314, 21916, 402, 3930, 10251, 2238, 577, 4019, 2932, 10751, 21429, 14, 199, 3, 1603, 14, 3599, 337, 14, 445, 27037, 14, 4337, 334, 8128, 395, 6546, 1167, 306, 8001, 23, 12, 886, 73, 26, 709, 14, 32562, 15, 74, 2055, 14, 9335, 1555, 199, 3, 199, 624, 199, 7430, 6712, 16773, 22523, 10894, 520, 1494, 1705, 5127, 13182, 14, 10466, 14, 287, 1018, 14, 7430, 6712, 63, 22508, 14, 5270, 63, 7430, 6712, 64, 199, 5695, 12813, 23476, 199, 199, 1918, 859, 7890, 282, 805, 22701, 465, 13738, 13, 500, 367, 7750, 6240, 6712, 199, 22508, 18036, 12, 19696, 3062, 370, 2040, 3062, 370, 506, 1202, 1640, 335, 621, 6665, 14, 199, 199, 26, 5949, 26, 18619, 266, 79, 377, 73, 605, 280, 12, 644, 7837, 5088, 22491, 391, 12, 377, 368, 26844, 3308, 2464, 199, 199, 703, 7445, 447, 378, 14, 975, 14, 16, 199, 199, 624, 199, 646, 2680, 465, 980, 199, 504, 2508, 2190, 2686, 3642, 492, 664, 63, 5590, 63, 3642, 199, 504, 2508, 1208, 492, 27311, 13862, 425, 12, 5389, 63, 324, 4380, 874, 199, 504, 2508, 7430, 6712, 63, 22508, 14, 17905, 6712, 29705, 3767, 492, 334, 272, 9785, 21913, 26689, 1017, 1209, 27907, 19675, 9, 421, 199, 318, 7114, 63, 7430, 6712, 8, 15628, 83, 12, 2079, 1083, 29, 4759, 21913, 26689, 1017, 1209, 27907, 19675, 1062, 2079, 3504, 628, 354, 7240, 401, 2079, 6033, 63, 3642, 29, 403, 12, 2079, 2040, 63, 761, 9982, 63, 1099, 29, 549, 12, 2079, 302, 4630, 29, 17, 12, 2079, 1011, 958, 304, 272, 408, 272, 30778, 7365, 315, 11223, 687, 1373, 503, 1655, 19965, 83, 12, 1808, 1373, 503, 1655, 272, 6240, 6712, 16773, 3102, 14, 710, 805, 14190, 6181, 272, 876, 13, 13494, 972, 15108, 12627, 465, 376, 1423, 14, 3390, 626, 440, 1006, 272, 6240, 6712, 16773, 17782, 883, 1736, 5370, 641, 6033, 12627, 12, 272, 880, 314, 6033, 12627, 5594, 506, 5525, 367, 6770, 3415, 402, 272, 1083, 14, 2378, 3897, 272, 4143, 339, 19965, 83, 520, 15830, 13182, 14, 27921, 2077, 12, 503, 769, 503, 769, 402, 769, 2337, 1618, 267, 710, 805, 6181, 1902, 282, 2849, 1910, 73, 2077, 909, 12, 282, 769, 402, 1910, 73, 2077, 267, 2251, 503, 282, 769, 402, 5548, 402, 1910, 73, 2077, 2251, 14, 982, 1627, 282, 2849, 267, 15439, 2077, 12, 652, 9329, 5419, 641, 314, 406, 17308, 315, 314, 30595, 14, 982, 267, 1627, 282, 769, 402, 19965, 83, 12, 652, 911, 5389, 3062, 436, 21297, 3062, 10451, 12, 267, 22181, 4426, 402, 314, 19965, 370, 1314, 1924, 402, 314, 406, 17308, 13511, 14, 267, 19177, 12, 340, 3032, 282, 769, 402, 769, 402, 19965, 83, 12, 314, 805, 911, 2951, 267, 11982, 314, 9330, 2951, 11736, 446, 22537, 19965, 83, 367, 1924, 267, 19965, 315, 314, 6890, 4438, 14, 339, 1083, 520, 15830, 13182, 14, 10466, 14, 287, 1018, 14, 7430, 6712, 63, 22508, 14, 17905, 6712, 29705, 3767, 503, 769, 267, 437, 2849, 503, 282, 769, 402, 4454, 402, 314, 25291, 6712, 29705, 3767, 267, 3992, 687, 314, 6240, 6712, 63, 22508, 859, 14, 437, 7396, 11284, 267, 911, 506, 1255, 367, 1924, 1083, 14, 3390, 626, 3365, 2633, 367, 314, 267, 2011, 1083, 883, 506, 15868, 581, 701, 7791, 3365, 4454, 402, 267, 314, 2011, 6240, 6712, 16773, 1021, 14, 8394, 787, 9785, 21913, 267, 2165, 88, 1017, 1209, 24297, 1098, 503, 25716, 11590, 12727, 21916, 14, 339, 3504, 520, 620, 12, 2716, 267, 18840, 7267, 1059, 315, 314, 15830, 13182, 1475, 334, 885, 365, 298, 354, 7240, 531, 339, 6033, 63, 3642, 520, 655, 1018, 14, 1208, 14, 23341, 6443, 12, 2716, 267, 21892, 3634, 367, 26123, 21913, 10645, 1017, 1209, 12452, 14, 982, 642, 2725, 267, 365, 440, 6841, 376, 820, 3053, 36, 6033, 3634, 911, 506, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
CiscoSystems/neutron
neutron/tests/unit/test_hacking.py
5
5110
# 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 neutron.hacking import checks from neutron.tests import base class HackingTestCase(base.BaseTestCase): def test_log_translations(self): expected_marks = { 'audit': '_', 'error': '_LE', 'info': '_LI', 'warn': '_LW', 'warning': '_LW', 'critical': '_LC', 'exception': '_LE', } logs = expected_marks.keys() debug = "LOG.debug('OK')" self.assertEqual( 0, len(list(checks.validate_log_translations(debug, debug, 'f')))) for log in logs: bad = 'LOG.%s("Bad")' % log self.assertEqual( 1, len(list(checks.validate_log_translations(bad, bad, 'f')))) ok = "LOG.%s('OK') # noqa" % log self.assertEqual( 0, len(list(checks.validate_log_translations(ok, ok, 'f')))) ok = "LOG.%s(variable)" % log self.assertEqual( 0, len(list(checks.validate_log_translations(ok, ok, 'f')))) for mark in checks._all_hints: stmt = "LOG.%s(%s('test'))" % (log, mark) self.assertEqual( 0 if expected_marks[log] == mark else 1, len(list(checks.validate_log_translations(stmt, stmt, 'f')))) def test_no_translate_debug_logs(self): for hint in checks._all_hints: bad = "LOG.debug(%s('bad'))" % hint self.assertEqual( 1, len(list(checks.no_translate_debug_logs(bad, 'f')))) def test_use_jsonutils(self): def __get_msg(fun): msg = ("N321: jsonutils.%(fun)s must be used instead of " "json.%(fun)s" % {'fun': fun}) return [(0, msg)] for method in ('dump', 'dumps', 'load', 'loads'): self.assertEqual( __get_msg(method), list(checks.use_jsonutils("json.%s(" % method, "./neutron/common/rpc.py"))) self.assertEqual(0, len(list(checks.use_jsonutils("jsonx.%s(" % method, "./neutron/common/rpc.py")))) self.assertEqual(0, len(list(checks.use_jsonutils("json.%sx(" % method, "./neutron/common/rpc.py")))) self.assertEqual(0, len(list(checks.use_jsonutils( "json.%s" % method, "./neutron/plugins/openvswitch/agent/xenapi/etc/xapi.d/" "plugins/netwrap")))) def test_no_author_tags(self): self.assertIsInstance(checks.no_author_tags("# author: pele"), tuple) self.assertIsInstance(checks.no_author_tags("# @author: pele"), tuple) self.assertIsInstance(checks.no_author_tags("# @Author: pele"), tuple) self.assertIsInstance(checks.no_author_tags("# Author: pele"), tuple) self.assertIsInstance(checks.no_author_tags("# Author pele"), tuple) self.assertIsInstance(checks.no_author_tags(".. moduleauthor:: pele"), tuple) self.assertEqual(2, checks.no_author_tags("# author: pele")[0]) self.assertEqual(2, checks.no_author_tags("# Author: pele")[0]) self.assertEqual(3, checks.no_author_tags(".. moduleauthor:: pele")[0]) def test_assert_called_once_with(self): fail_code1 = """ mock = Mock() mock.method(1, 2, 3, test='wow') mock.method.assert_called_once() """ fail_code2 = """ mock = Mock() mock.method(1, 2, 3, test='wow') mock.method.assertCalledOnceWith() """ pass_code = """ mock = Mock() mock.method(1, 2, 3, test='wow') mock.method.assert_called_once_with() """ self.assertEqual( 1, len(list(checks.check_assert_called_once_with(fail_code1, "neutron/tests/test_assert.py")))) self.assertEqual( 1, len(list(checks.check_assert_called_once_with(fail_code2, "neutron/tests/test_assert.py")))) self.assertEqual( 0, len(list(checks.check_assert_called_once_with(pass_code, "neutron/tests/test_assert.py"))))
apache-2.0
[ 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 8224, 14, 20875, 316, 492, 5920, 199, 504, 8224, 14, 2219, 492, 1300, 421, 199, 533, 30802, 316, 1746, 8, 1095, 14, 20760, 304, 339, 347, 511, 63, 793, 63, 13982, 8, 277, 304, 267, 1420, 63, 10375, 275, 469, 288, 283, 14274, 356, 25469, 288, 283, 705, 356, 2513, 906, 297, 288, 283, 815, 356, 2513, 2673, 297, 288, 283, 4050, 356, 2513, 20145, 297, 288, 283, 3764, 356, 2513, 20145, 297, 288, 283, 13138, 356, 2513, 7027, 297, 288, 283, 1971, 356, 2513, 906, 297, 267, 789, 267, 9610, 275, 1420, 63, 10375, 14, 1612, 342, 267, 3105, 275, 298, 4947, 14, 1757, 360, 3593, 19124, 267, 291, 14, 629, 8, 288, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 1757, 12, 3105, 12, 283, 70, 31789, 267, 367, 943, 315, 9610, 26, 288, 4875, 275, 283, 4947, 4111, 83, 480, 5725, 32292, 450, 943, 288, 291, 14, 629, 8, 355, 413, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 4087, 12, 4875, 12, 283, 70, 31789, 288, 4112, 275, 298, 4947, 4111, 83, 360, 3593, 358, 259, 327, 8151, 2, 450, 943, 288, 291, 14, 629, 8, 355, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 745, 12, 4112, 12, 283, 70, 31789, 288, 4112, 275, 298, 4947, 4111, 83, 8, 1975, 2924, 450, 943, 288, 291, 14, 629, 8, 355, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 745, 12, 4112, 12, 283, 70, 31789, 953, 367, 2216, 315, 5920, 423, 452, 63, 12354, 26, 355, 12284, 275, 298, 4947, 4111, 83, 4042, 83, 360, 396, 1333, 2, 450, 334, 793, 12, 2216, 9, 355, 291, 14, 629, 8, 490, 378, 340, 1420, 63, 10375, 59, 793, 61, 508, 2216, 587, 413, 12, 490, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 9649, 12, 12284, 12, 16854, 283, 70, 31789, 339, 347, 511, 63, 889, 63, 5275, 63, 1757, 63, 7270, 8, 277, 304, 267, 367, 8328, 315, 5920, 423, 452, 63, 12354, 26, 288, 4875, 275, 298, 4947, 14, 1757, 4042, 83, 360, 4087, 1333, 2, 450, 8328, 288, 291, 14, 629, 8, 355, 413, 12, 822, 8, 513, 8, 8625, 14, 889, 63, 5275, 63, 1757, 63, 7270, 8, 4087, 12, 283, 70, 31789, 339, 347, 511, 63, 1180, 63, 1001, 1208, 8, 277, 304, 267, 347, 636, 362, 63, 1328, 8, 7036, 304, 288, 1499, 275, 1689, 46, 12638, 26, 18705, 31706, 7036, 9, 83, 1471, 506, 1202, 3140, 402, 298, 673, 298, 1001, 31706, 7036, 9, 83, 2, 450, 791, 7036, 356, 9627, 1552, 288, 372, 3842, 16, 12, 1499, 1874, 398, 367, 1083, 315, 661, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 735, 288, 291, 14, 629, 8, 355, 636, 362, 63, 1328, 8, 765, 395, 355, 769, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 4111, 83, 480, 450, 1083, 12, 5101, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 13324, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 88, 4111, 83, 480, 450, 1083, 12, 6343, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 2237, 430, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 4111, 12915, 480, 450, 1083, 12, 6343, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 2237, 430, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 8, 490, 298, 1001, 4111, 83, 2, 450, 1083, 12, 490, 26069, 10271, 15, 5265, 15, 1490, 23201, 15, 4054, 15, 20392, 15, 6839, 15, 32751, 14, 68, 6687, 490, 298, 5265, 15, 846, 3823, 2237, 430, 339, 347, 511, 63, 889, 63, 2502, 63, 2969, 8, 277, 304, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 4132, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 768, 2502, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 768, 5949, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 480, 703, 28966, 447, 4837, 274, 1288, 2892, 2008, 9, 267, 291, 14, 629, 8, 18, 12, 5920, 14, 889, 63, 2502, 63, 2969, 10064, 4132, 26, 4837, 274, 9981, 16, 566, 267, 291, 14, 629, 8, 18, 12, 5920, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 26, 4837, 274, 9981, 16, 566, 267, 291, 14, 629, 8, 19, 12, 5920, 14, 889, 63, 2502, 63, 2969, 480, 703, 28966, 447, 4837, 274, 9981, 16, 566, 339, 347, 511, 63, 479, 63, 3527, 63, 5089, 63, 1045, 8, 277, 304, 267, 2449, 63, 600, 17, 275, 408, 2049, 1683, 275, 4420, 342, 2049, 1683, 14, 765, 8, 17, 12, 499, 12, 650, 12, 511, 534, 87, 583 ]
[ 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 8224, 14, 20875, 316, 492, 5920, 199, 504, 8224, 14, 2219, 492, 1300, 421, 199, 533, 30802, 316, 1746, 8, 1095, 14, 20760, 304, 339, 347, 511, 63, 793, 63, 13982, 8, 277, 304, 267, 1420, 63, 10375, 275, 469, 288, 283, 14274, 356, 25469, 288, 283, 705, 356, 2513, 906, 297, 288, 283, 815, 356, 2513, 2673, 297, 288, 283, 4050, 356, 2513, 20145, 297, 288, 283, 3764, 356, 2513, 20145, 297, 288, 283, 13138, 356, 2513, 7027, 297, 288, 283, 1971, 356, 2513, 906, 297, 267, 789, 267, 9610, 275, 1420, 63, 10375, 14, 1612, 342, 267, 3105, 275, 298, 4947, 14, 1757, 360, 3593, 19124, 267, 291, 14, 629, 8, 288, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 1757, 12, 3105, 12, 283, 70, 31789, 267, 367, 943, 315, 9610, 26, 288, 4875, 275, 283, 4947, 4111, 83, 480, 5725, 32292, 450, 943, 288, 291, 14, 629, 8, 355, 413, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 4087, 12, 4875, 12, 283, 70, 31789, 288, 4112, 275, 298, 4947, 4111, 83, 360, 3593, 358, 259, 327, 8151, 2, 450, 943, 288, 291, 14, 629, 8, 355, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 745, 12, 4112, 12, 283, 70, 31789, 288, 4112, 275, 298, 4947, 4111, 83, 8, 1975, 2924, 450, 943, 288, 291, 14, 629, 8, 355, 378, 12, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 745, 12, 4112, 12, 283, 70, 31789, 953, 367, 2216, 315, 5920, 423, 452, 63, 12354, 26, 355, 12284, 275, 298, 4947, 4111, 83, 4042, 83, 360, 396, 1333, 2, 450, 334, 793, 12, 2216, 9, 355, 291, 14, 629, 8, 490, 378, 340, 1420, 63, 10375, 59, 793, 61, 508, 2216, 587, 413, 12, 490, 822, 8, 513, 8, 8625, 14, 3502, 63, 793, 63, 13982, 8, 9649, 12, 12284, 12, 16854, 283, 70, 31789, 339, 347, 511, 63, 889, 63, 5275, 63, 1757, 63, 7270, 8, 277, 304, 267, 367, 8328, 315, 5920, 423, 452, 63, 12354, 26, 288, 4875, 275, 298, 4947, 14, 1757, 4042, 83, 360, 4087, 1333, 2, 450, 8328, 288, 291, 14, 629, 8, 355, 413, 12, 822, 8, 513, 8, 8625, 14, 889, 63, 5275, 63, 1757, 63, 7270, 8, 4087, 12, 283, 70, 31789, 339, 347, 511, 63, 1180, 63, 1001, 1208, 8, 277, 304, 267, 347, 636, 362, 63, 1328, 8, 7036, 304, 288, 1499, 275, 1689, 46, 12638, 26, 18705, 31706, 7036, 9, 83, 1471, 506, 1202, 3140, 402, 298, 673, 298, 1001, 31706, 7036, 9, 83, 2, 450, 791, 7036, 356, 9627, 1552, 288, 372, 3842, 16, 12, 1499, 1874, 398, 367, 1083, 315, 661, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 735, 288, 291, 14, 629, 8, 355, 636, 362, 63, 1328, 8, 765, 395, 355, 769, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 4111, 83, 480, 450, 1083, 12, 5101, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 13324, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 88, 4111, 83, 480, 450, 1083, 12, 6343, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 2237, 430, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 480, 1001, 4111, 12915, 480, 450, 1083, 12, 6343, 26069, 10271, 15, 2330, 15, 4354, 14, 647, 2237, 430, 953, 291, 14, 629, 8, 16, 12, 355, 822, 8, 513, 8, 8625, 14, 1180, 63, 1001, 1208, 8, 490, 298, 1001, 4111, 83, 2, 450, 1083, 12, 490, 26069, 10271, 15, 5265, 15, 1490, 23201, 15, 4054, 15, 20392, 15, 6839, 15, 32751, 14, 68, 6687, 490, 298, 5265, 15, 846, 3823, 2237, 430, 339, 347, 511, 63, 889, 63, 2502, 63, 2969, 8, 277, 304, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 4132, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 768, 2502, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 768, 5949, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 26, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 4837, 274, 1288, 2008, 9, 267, 291, 14, 6926, 8, 8625, 14, 889, 63, 2502, 63, 2969, 480, 703, 28966, 447, 4837, 274, 1288, 2892, 2008, 9, 267, 291, 14, 629, 8, 18, 12, 5920, 14, 889, 63, 2502, 63, 2969, 10064, 4132, 26, 4837, 274, 9981, 16, 566, 267, 291, 14, 629, 8, 18, 12, 5920, 14, 889, 63, 2502, 63, 2969, 10064, 6529, 26, 4837, 274, 9981, 16, 566, 267, 291, 14, 629, 8, 19, 12, 5920, 14, 889, 63, 2502, 63, 2969, 480, 703, 28966, 447, 4837, 274, 9981, 16, 566, 339, 347, 511, 63, 479, 63, 3527, 63, 5089, 63, 1045, 8, 277, 304, 267, 2449, 63, 600, 17, 275, 408, 2049, 1683, 275, 4420, 342, 2049, 1683, 14, 765, 8, 17, 12, 499, 12, 650, 12, 511, 534, 87, 583, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alianmohammad/pd-gem5
src/mem/slicc/generate/dot.py
92
2077
# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood # Copyright (c) 2009 The Hewlett-Packard Development Company # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution; # neither the name of the copyright holders nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from m5.util.code_formatter import code_formatter def printDotty(sm, code): code('digraph ${{sm.getIdent()}} {') code.indent() for t in sm.transitions: # Don't print ignored transitions if t.getActionShorthands() in ("--", "z"): continue code('${{t.getStateShorthand()}} -> ${{t.getNextStateShorthand()}') code(' [label="${{t.getEventShorthand()}}/${{t.getActionShorthands()}}"') code.dedent() code('}')
bsd-3-clause
[ 3, 1898, 334, 67, 9, 21300, 13, 9300, 7173, 577, 14, 869, 778, 436, 20232, 437, 14, 644, 23521, 199, 3, 1898, 334, 67, 9, 8937, 710, 27849, 13, 29471, 15290, 15878, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 333, 21, 14, 1974, 14, 600, 63, 8911, 492, 1233, 63, 8911, 199, 199, 318, 870, 14004, 369, 8, 3300, 12, 1233, 304, 272, 1233, 360, 328, 2180, 2672, 3638, 3300, 14, 362, 41, 1326, 342, 4863, 469, 358, 272, 1233, 14, 3724, 342, 272, 367, 307, 315, 4383, 14, 23062, 26, 267, 327, 7529, 1133, 870, 5525, 19077, 267, 340, 307, 14, 362, 3310, 2662, 11297, 5915, 342, 315, 1689, 306, 401, 298, 90, 2349, 288, 1980, 398, 1233, 14676, 3638, 84, 14, 362, 2223, 2662, 23999, 342, 4863, 1035, 2672, 3638, 84, 14, 362, 5765, 2223, 2662, 23999, 342, 12216, 267, 1233, 360, 259, 359, 1302, 628, 4, 3638, 84, 14, 362, 2390, 2662, 23999, 342, 4863, 21792, 3638, 84, 14, 362, 3310, 2662, 11297, 5915, 342, 4863, 9008, 272, 1233, 14, 14674, 342, 272, 1233, 31358, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 21300, 13, 9300, 7173, 577, 14, 869, 778, 436, 20232, 437, 14, 644, 23521, 199, 3, 1898, 334, 67, 9, 8937, 710, 27849, 13, 29471, 15290, 15878, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 333, 21, 14, 1974, 14, 600, 63, 8911, 492, 1233, 63, 8911, 199, 199, 318, 870, 14004, 369, 8, 3300, 12, 1233, 304, 272, 1233, 360, 328, 2180, 2672, 3638, 3300, 14, 362, 41, 1326, 342, 4863, 469, 358, 272, 1233, 14, 3724, 342, 272, 367, 307, 315, 4383, 14, 23062, 26, 267, 327, 7529, 1133, 870, 5525, 19077, 267, 340, 307, 14, 362, 3310, 2662, 11297, 5915, 342, 315, 1689, 306, 401, 298, 90, 2349, 288, 1980, 398, 1233, 14676, 3638, 84, 14, 362, 2223, 2662, 23999, 342, 4863, 1035, 2672, 3638, 84, 14, 362, 5765, 2223, 2662, 23999, 342, 12216, 267, 1233, 360, 259, 359, 1302, 628, 4, 3638, 84, 14, 362, 2390, 2662, 23999, 342, 4863, 21792, 3638, 84, 14, 362, 3310, 2662, 11297, 5915, 342, 4863, 9008, 272, 1233, 14, 14674, 342, 272, 1233, 31358, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
GabrielNicolasAvellaneda/dd-agent
tests/checks/mock/test_mesos_slave.py
45
1565
# stdlib import json # 3p from mock import patch from nose.plugins.attrib import attr # project from checks import AgentCheck from tests.checks.common import AgentCheckTest, Fixtures, get_check_class def _mocked_get_state(*args, **kwargs): state = json.loads(Fixtures.read_file('state.json')) return state def _mocked_get_stats(*args, **kwargs): stats = json.loads(Fixtures.read_file('stats.json')) return stats @attr(requires='mesos_slave') class TestMesosSlave(AgentCheckTest): CHECK_NAME = 'mesos_slave' def test_checks(self): config = { 'init_config': {}, 'instances': [ { 'url': 'http://localhost:5050', 'tasks': ['hello'] } ] } klass = get_check_class('mesos_slave') with patch.object(klass, '_get_state', _mocked_get_state): with patch.object(klass, '_get_stats', _mocked_get_stats): check = klass('mesos_slave', {}, {}) self.run_check_twice(config) metrics = {} for d in (check.SLAVE_TASKS_METRICS, check.SYSTEM_METRICS, check.SLAVE_RESOURCE_METRICS, check.SLAVE_EXECUTORS_METRICS, check.STATS_METRICS): metrics.update(d) [self.assertMetric(v[0]) for k, v in check.TASK_METRICS.iteritems()] [self.assertMetric(v[0]) for k, v in metrics.iteritems()] self.assertServiceCheck('hello.ok', count=1, status=AgentCheck.OK)
bsd-3-clause
[ 3, 26678, 199, 646, 2022, 199, 199, 3, 650, 80, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 3, 2199, 199, 504, 5920, 492, 19866, 1799, 199, 504, 2295, 14, 8625, 14, 2330, 492, 19866, 1799, 774, 12, 31574, 6969, 12, 664, 63, 1074, 63, 533, 421, 199, 318, 485, 27740, 63, 362, 63, 929, 2031, 589, 12, 1011, 958, 304, 272, 1174, 275, 2022, 14, 3640, 8, 9047, 6969, 14, 739, 63, 493, 360, 929, 14, 1001, 1333, 272, 372, 1174, 199, 318, 485, 27740, 63, 362, 63, 3200, 2031, 589, 12, 1011, 958, 304, 272, 5020, 275, 2022, 14, 3640, 8, 9047, 6969, 14, 739, 63, 493, 360, 3200, 14, 1001, 1333, 272, 372, 5020, 199, 199, 32, 962, 8, 6537, 534, 6415, 736, 63, 12384, 358, 199, 533, 1379, 45, 397, 736, 28950, 8, 7788, 1799, 774, 304, 272, 17654, 63, 2339, 275, 283, 6415, 736, 63, 12384, 7, 339, 347, 511, 63, 8625, 8, 277, 304, 267, 1101, 275, 469, 288, 283, 826, 63, 888, 356, 5479, 288, 283, 5990, 356, 359, 355, 469, 490, 283, 633, 356, 283, 1014, 921, 5967, 26, 1400, 1400, 297, 490, 283, 5054, 356, 788, 5006, 418, 355, 789, 288, 1622, 267, 789, 398, 8531, 275, 664, 63, 1074, 63, 533, 360, 6415, 736, 63, 12384, 358, 267, 543, 3371, 14, 785, 8, 11645, 12, 2513, 362, 63, 929, 297, 485, 27740, 63, 362, 63, 929, 304, 288, 543, 3371, 14, 785, 8, 11645, 12, 2513, 362, 63, 3200, 297, 485, 27740, 63, 362, 63, 3200, 304, 355, 1104, 275, 8531, 360, 6415, 736, 63, 12384, 297, 5479, 5009, 355, 291, 14, 1065, 63, 1074, 63, 8122, 1885, 8, 888, 9, 355, 7186, 275, 1052, 355, 367, 366, 315, 334, 1074, 14, 4929, 26907, 63, 17179, 51, 63, 30476, 12, 1104, 14, 12711, 63, 30476, 12, 1104, 14, 4929, 26907, 63, 14110, 63, 30476, 12, 2079, 1104, 14, 4929, 26907, 63, 18074, 4149, 63, 30476, 12, 1104, 14, 19202, 63, 30476, 304, 490, 7186, 14, 873, 8, 68, 9, 355, 359, 277, 14, 479, 11119, 8, 86, 59, 16, 566, 367, 1022, 12, 373, 315, 1104, 14, 17179, 63, 30476, 14, 4611, 5106, 355, 359, 277, 14, 479, 11119, 8, 86, 59, 16, 566, 367, 1022, 12, 373, 315, 7186, 14, 4611, 5106, 355, 291, 14, 479, 3167, 1799, 360, 5006, 14, 745, 297, 2338, 29, 17, 12, 2004, 29, 7788, 1799, 14, 3593, 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 ]
[ 26678, 199, 646, 2022, 199, 199, 3, 650, 80, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 3, 2199, 199, 504, 5920, 492, 19866, 1799, 199, 504, 2295, 14, 8625, 14, 2330, 492, 19866, 1799, 774, 12, 31574, 6969, 12, 664, 63, 1074, 63, 533, 421, 199, 318, 485, 27740, 63, 362, 63, 929, 2031, 589, 12, 1011, 958, 304, 272, 1174, 275, 2022, 14, 3640, 8, 9047, 6969, 14, 739, 63, 493, 360, 929, 14, 1001, 1333, 272, 372, 1174, 199, 318, 485, 27740, 63, 362, 63, 3200, 2031, 589, 12, 1011, 958, 304, 272, 5020, 275, 2022, 14, 3640, 8, 9047, 6969, 14, 739, 63, 493, 360, 3200, 14, 1001, 1333, 272, 372, 5020, 199, 199, 32, 962, 8, 6537, 534, 6415, 736, 63, 12384, 358, 199, 533, 1379, 45, 397, 736, 28950, 8, 7788, 1799, 774, 304, 272, 17654, 63, 2339, 275, 283, 6415, 736, 63, 12384, 7, 339, 347, 511, 63, 8625, 8, 277, 304, 267, 1101, 275, 469, 288, 283, 826, 63, 888, 356, 5479, 288, 283, 5990, 356, 359, 355, 469, 490, 283, 633, 356, 283, 1014, 921, 5967, 26, 1400, 1400, 297, 490, 283, 5054, 356, 788, 5006, 418, 355, 789, 288, 1622, 267, 789, 398, 8531, 275, 664, 63, 1074, 63, 533, 360, 6415, 736, 63, 12384, 358, 267, 543, 3371, 14, 785, 8, 11645, 12, 2513, 362, 63, 929, 297, 485, 27740, 63, 362, 63, 929, 304, 288, 543, 3371, 14, 785, 8, 11645, 12, 2513, 362, 63, 3200, 297, 485, 27740, 63, 362, 63, 3200, 304, 355, 1104, 275, 8531, 360, 6415, 736, 63, 12384, 297, 5479, 5009, 355, 291, 14, 1065, 63, 1074, 63, 8122, 1885, 8, 888, 9, 355, 7186, 275, 1052, 355, 367, 366, 315, 334, 1074, 14, 4929, 26907, 63, 17179, 51, 63, 30476, 12, 1104, 14, 12711, 63, 30476, 12, 1104, 14, 4929, 26907, 63, 14110, 63, 30476, 12, 2079, 1104, 14, 4929, 26907, 63, 18074, 4149, 63, 30476, 12, 1104, 14, 19202, 63, 30476, 304, 490, 7186, 14, 873, 8, 68, 9, 355, 359, 277, 14, 479, 11119, 8, 86, 59, 16, 566, 367, 1022, 12, 373, 315, 1104, 14, 17179, 63, 30476, 14, 4611, 5106, 355, 359, 277, 14, 479, 11119, 8, 86, 59, 16, 566, 367, 1022, 12, 373, 315, 7186, 14, 4611, 5106, 355, 291, 14, 479, 3167, 1799, 360, 5006, 14, 745, 297, 2338, 29, 17, 12, 2004, 29, 7788, 1799, 14, 3593, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
piquadrat/django
tests/conditional_processing/tests.py
86
12853
from datetime import datetime from django.test import SimpleTestCase, override_settings FULL_RESPONSE = 'Test conditional get response' LAST_MODIFIED = datetime(2007, 10, 21, 23, 21, 47) LAST_MODIFIED_STR = 'Sun, 21 Oct 2007 23:21:47 GMT' LAST_MODIFIED_NEWER_STR = 'Mon, 18 Oct 2010 16:56:23 GMT' LAST_MODIFIED_INVALID_STR = 'Mon, 32 Oct 2010 16:56:23 GMT' EXPIRED_LAST_MODIFIED_STR = 'Sat, 20 Oct 2007 23:21:47 GMT' ETAG = '"b4246ffc4f62314ca13147c9d4f76974"' WEAK_ETAG = 'W/"b4246ffc4f62314ca13147c9d4f76974"' # weak match to ETAG EXPIRED_ETAG = '"7fae4cd4b0f81e7d2914700043aa8ed6"' @override_settings(ROOT_URLCONF='conditional_processing.urls') class ConditionalGet(SimpleTestCase): def assertFullResponse(self, response, check_last_modified=True, check_etag=True): self.assertEqual(response.status_code, 200) self.assertEqual(response.content, FULL_RESPONSE.encode()) if response.request['REQUEST_METHOD'] in ('GET', 'HEAD'): if check_last_modified: self.assertEqual(response['Last-Modified'], LAST_MODIFIED_STR) if check_etag: self.assertEqual(response['ETag'], ETAG) else: self.assertNotIn('Last-Modified', response) self.assertNotIn('ETag', response) def assertNotModified(self, response): self.assertEqual(response.status_code, 304) self.assertEqual(response.content, b'') def test_without_conditions(self): response = self.client.get('/condition/') self.assertFullResponse(response) def test_if_modified_since(self): self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.get('/condition/') self.assertNotModified(response) response = self.client.put('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_NEWER_STR response = self.client.get('/condition/') self.assertNotModified(response) response = self.client.put('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_INVALID_STR response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR response = self.client.get('/condition/') self.assertFullResponse(response) def test_if_unmodified_since(self): self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_NEWER_STR response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_INVALID_STR response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR response = self.client.get('/condition/') self.assertEqual(response.status_code, 412) def test_if_none_match(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/') self.assertNotModified(response) response = self.client.put('/condition/') self.assertEqual(response.status_code, 412) self.client.defaults['HTTP_IF_NONE_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/') self.assertFullResponse(response) # Several etags in If-None-Match is a bit exotic but why not? self.client.defaults['HTTP_IF_NONE_MATCH'] = '%s, %s' % (ETAG, EXPIRED_ETAG) response = self.client.get('/condition/') self.assertNotModified(response) def test_weak_if_none_match(self): """ If-None-Match comparisons use weak matching, so weak and strong ETags with the same value result in a 304 response. """ self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/weak_etag/') self.assertNotModified(response) response = self.client.put('/condition/weak_etag/') self.assertEqual(response.status_code, 412) self.client.defaults['HTTP_IF_NONE_MATCH'] = WEAK_ETAG response = self.client.get('/condition/weak_etag/') self.assertNotModified(response) response = self.client.put('/condition/weak_etag/') self.assertEqual(response.status_code, 412) response = self.client.get('/condition/') self.assertNotModified(response) response = self.client.put('/condition/') self.assertEqual(response.status_code, 412) def test_all_if_none_match(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = '*' response = self.client.get('/condition/') self.assertNotModified(response) response = self.client.put('/condition/') self.assertEqual(response.status_code, 412) response = self.client.get('/condition/no_etag/') self.assertFullResponse(response, check_last_modified=False, check_etag=False) def test_if_match(self): self.client.defaults['HTTP_IF_MATCH'] = ETAG response = self.client.put('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_MATCH'] = EXPIRED_ETAG response = self.client.put('/condition/') self.assertEqual(response.status_code, 412) def test_weak_if_match(self): """ If-Match comparisons use strong matching, so any comparison involving a weak ETag return a 412 response. """ self.client.defaults['HTTP_IF_MATCH'] = ETAG response = self.client.get('/condition/weak_etag/') self.assertEqual(response.status_code, 412) self.client.defaults['HTTP_IF_MATCH'] = WEAK_ETAG response = self.client.get('/condition/weak_etag/') self.assertEqual(response.status_code, 412) response = self.client.get('/condition/') self.assertEqual(response.status_code, 412) def test_all_if_match(self): self.client.defaults['HTTP_IF_MATCH'] = '*' response = self.client.get('/condition/') self.assertFullResponse(response) response = self.client.get('/condition/no_etag/') self.assertEqual(response.status_code, 412) def test_both_headers(self): # see https://tools.ietf.org/html/rfc7232#section-6 self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/') self.assertNotModified(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/') self.assertNotModified(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR self.client.defaults['HTTP_IF_NONE_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR self.client.defaults['HTTP_IF_NONE_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/') self.assertFullResponse(response) def test_both_headers_2(self): self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_STR self.client.defaults['HTTP_IF_MATCH'] = ETAG response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR self.client.defaults['HTTP_IF_MATCH'] = ETAG response = self.client.get('/condition/') self.assertFullResponse(response) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR self.client.defaults['HTTP_IF_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/') self.assertEqual(response.status_code, 412) self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_STR self.client.defaults['HTTP_IF_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/') self.assertEqual(response.status_code, 412) def test_single_condition_1(self): self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.get('/condition/last_modified/') self.assertNotModified(response) response = self.client.get('/condition/etag/') self.assertFullResponse(response, check_last_modified=False) def test_single_condition_2(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/etag/') self.assertNotModified(response) response = self.client.get('/condition/last_modified/') self.assertFullResponse(response, check_etag=False) def test_single_condition_3(self): self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR response = self.client.get('/condition/last_modified/') self.assertFullResponse(response, check_etag=False) def test_single_condition_4(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/etag/') self.assertFullResponse(response, check_last_modified=False) def test_single_condition_5(self): self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.get('/condition/last_modified2/') self.assertNotModified(response) response = self.client.get('/condition/etag2/') self.assertFullResponse(response, check_last_modified=False) def test_single_condition_6(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/etag2/') self.assertNotModified(response) response = self.client.get('/condition/last_modified2/') self.assertFullResponse(response, check_etag=False) def test_single_condition_7(self): self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR response = self.client.get('/condition/last_modified/') self.assertEqual(response.status_code, 412) response = self.client.get('/condition/etag/') self.assertEqual(response.status_code, 412) def test_single_condition_8(self): self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.get('/condition/last_modified/') self.assertFullResponse(response, check_etag=False) def test_single_condition_9(self): self.client.defaults['HTTP_IF_UNMODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR response = self.client.get('/condition/last_modified2/') self.assertEqual(response.status_code, 412) response = self.client.get('/condition/etag2/') self.assertEqual(response.status_code, 412) def test_single_condition_head(self): self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR response = self.client.head('/condition/') self.assertNotModified(response) def test_unquoted(self): """ The same quoted ETag should be set on the header regardless of whether etag_func() in condition() returns a quoted or an unquoted ETag. """ response_quoted = self.client.get('/condition/etag/') response_unquoted = self.client.get('/condition/unquoted_etag/') self.assertEqual(response_quoted['ETag'], response_unquoted['ETag']) # It's possible that the matching algorithm could use the wrong value even # if the ETag header is set correctly correctly (as tested by # test_unquoted()), so check that the unquoted value is matched. def test_unquoted_if_none_match(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = ETAG response = self.client.get('/condition/unquoted_etag/') self.assertNotModified(response) response = self.client.put('/condition/unquoted_etag/') self.assertEqual(response.status_code, 412) self.client.defaults['HTTP_IF_NONE_MATCH'] = EXPIRED_ETAG response = self.client.get('/condition/unquoted_etag/') self.assertFullResponse(response, check_last_modified=False) def test_invalid_etag(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = '"""' response = self.client.get('/condition/etag/') self.assertFullResponse(response, check_last_modified=False)
bsd-3-clause
[ 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 199, 14742, 63, 12801, 275, 283, 774, 12303, 664, 1177, 7, 199, 16901, 63, 30389, 275, 2197, 8, 9488, 12, 1616, 12, 7829, 12, 6546, 12, 7829, 12, 10954, 9, 199, 16901, 63, 30389, 63, 3027, 275, 283, 22546, 12, 7829, 18365, 10219, 6546, 26, 2025, 26, 2417, 19152, 7, 199, 16901, 63, 30389, 63, 11365, 540, 63, 3027, 275, 283, 6671, 12, 6155, 18365, 7129, 3193, 26, 1367, 26, 1789, 19152, 7, 199, 16901, 63, 30389, 63, 9692, 63, 3027, 275, 283, 6671, 12, 4337, 18365, 7129, 3193, 26, 1367, 26, 1789, 19152, 7, 199, 25632, 7387, 63, 16901, 63, 30389, 63, 3027, 275, 283, 22332, 12, 3388, 18365, 10219, 6546, 26, 2025, 26, 2417, 19152, 7, 199, 775, 1254, 275, 5522, 66, 20, 11440, 26299, 20, 70, 31353, 1079, 696, 969, 11160, 67, 25, 68, 20, 70, 16165, 1342, 4507, 199, 5408, 7872, 63, 775, 1254, 275, 283, 55, 6687, 66, 20, 11440, 26299, 20, 70, 31353, 1079, 696, 969, 11160, 67, 25, 68, 20, 70, 16165, 1342, 4507, 221, 327, 9282, 1336, 370, 662, 6967, 199, 25632, 7387, 63, 775, 1254, 275, 5522, 23, 667, 69, 20, 2866, 20, 66, 16, 70, 2835, 69, 23, 68, 1398, 11160, 383, 5882, 2158, 24, 379, 22, 4507, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 14353, 63, 6338, 14, 3603, 358, 199, 533, 24191, 1002, 8, 17968, 304, 339, 347, 702, 9042, 2364, 8, 277, 12, 1177, 12, 1104, 63, 2019, 63, 5540, 29, 549, 12, 1104, 63, 11304, 29, 549, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 18530, 63, 12801, 14, 2143, 1012, 267, 340, 1177, 14, 1069, 459, 6780, 63, 9977, 418, 315, 661, 2970, 297, 283, 5211, 735, 288, 340, 1104, 63, 2019, 63, 5540, 26, 355, 291, 14, 629, 8, 1310, 459, 6090, 13, 11911, 995, 491, 11307, 63, 30389, 63, 3027, 9, 288, 340, 1104, 63, 11304, 26, 355, 291, 14, 629, 8, 1310, 459, 30206, 995, 662, 6967, 9, 267, 587, 26, 288, 291, 14, 8795, 360, 6090, 13, 11911, 297, 1177, 9, 288, 291, 14, 8795, 360, 30206, 297, 1177, 9, 339, 347, 702, 1763, 11911, 8, 277, 12, 1177, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 20398, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 17483, 339, 347, 511, 63, 7395, 63, 9855, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 339, 347, 511, 63, 692, 63, 5540, 63, 8585, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 11365, 540, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 9692, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 3651, 2252, 7387, 63, 16901, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 339, 347, 511, 63, 692, 63, 324, 5540, 63, 8585, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 11365, 540, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 9692, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 3651, 2252, 7387, 63, 16901, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 841, 713, 9, 339, 347, 511, 63, 692, 63, 3592, 63, 1431, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 9185, 63, 14747, 418, 275, 662, 6967, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 841, 713, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 9185, 63, 14747, 418, 275, 3651, 2252, 7387, 63, 775, 1254, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 398, 327, 3240, 422, 279, 325, 2969, 315, 982, 13, 403, 13, 4486, 365, 282, 4546, 444, 79, 764 ]
[ 2197, 492, 2197, 199, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 199, 14742, 63, 12801, 275, 283, 774, 12303, 664, 1177, 7, 199, 16901, 63, 30389, 275, 2197, 8, 9488, 12, 1616, 12, 7829, 12, 6546, 12, 7829, 12, 10954, 9, 199, 16901, 63, 30389, 63, 3027, 275, 283, 22546, 12, 7829, 18365, 10219, 6546, 26, 2025, 26, 2417, 19152, 7, 199, 16901, 63, 30389, 63, 11365, 540, 63, 3027, 275, 283, 6671, 12, 6155, 18365, 7129, 3193, 26, 1367, 26, 1789, 19152, 7, 199, 16901, 63, 30389, 63, 9692, 63, 3027, 275, 283, 6671, 12, 4337, 18365, 7129, 3193, 26, 1367, 26, 1789, 19152, 7, 199, 25632, 7387, 63, 16901, 63, 30389, 63, 3027, 275, 283, 22332, 12, 3388, 18365, 10219, 6546, 26, 2025, 26, 2417, 19152, 7, 199, 775, 1254, 275, 5522, 66, 20, 11440, 26299, 20, 70, 31353, 1079, 696, 969, 11160, 67, 25, 68, 20, 70, 16165, 1342, 4507, 199, 5408, 7872, 63, 775, 1254, 275, 283, 55, 6687, 66, 20, 11440, 26299, 20, 70, 31353, 1079, 696, 969, 11160, 67, 25, 68, 20, 70, 16165, 1342, 4507, 221, 327, 9282, 1336, 370, 662, 6967, 199, 25632, 7387, 63, 775, 1254, 275, 5522, 23, 667, 69, 20, 2866, 20, 66, 16, 70, 2835, 69, 23, 68, 1398, 11160, 383, 5882, 2158, 24, 379, 22, 4507, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 14353, 63, 6338, 14, 3603, 358, 199, 533, 24191, 1002, 8, 17968, 304, 339, 347, 702, 9042, 2364, 8, 277, 12, 1177, 12, 1104, 63, 2019, 63, 5540, 29, 549, 12, 1104, 63, 11304, 29, 549, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 18530, 63, 12801, 14, 2143, 1012, 267, 340, 1177, 14, 1069, 459, 6780, 63, 9977, 418, 315, 661, 2970, 297, 283, 5211, 735, 288, 340, 1104, 63, 2019, 63, 5540, 26, 355, 291, 14, 629, 8, 1310, 459, 6090, 13, 11911, 995, 491, 11307, 63, 30389, 63, 3027, 9, 288, 340, 1104, 63, 11304, 26, 355, 291, 14, 629, 8, 1310, 459, 30206, 995, 662, 6967, 9, 267, 587, 26, 288, 291, 14, 8795, 360, 6090, 13, 11911, 297, 1177, 9, 288, 291, 14, 8795, 360, 30206, 297, 1177, 9, 339, 347, 702, 1763, 11911, 8, 277, 12, 1177, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 20398, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 17483, 339, 347, 511, 63, 7395, 63, 9855, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 339, 347, 511, 63, 692, 63, 5540, 63, 8585, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 11365, 540, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 9692, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 30389, 63, 51, 568, 2089, 418, 275, 3651, 2252, 7387, 63, 16901, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 339, 347, 511, 63, 692, 63, 324, 5540, 63, 8585, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 11365, 540, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 491, 11307, 63, 30389, 63, 9692, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 1734, 30389, 63, 51, 568, 2089, 418, 275, 3651, 2252, 7387, 63, 16901, 63, 30389, 63, 3027, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 841, 713, 9, 339, 347, 511, 63, 692, 63, 3592, 63, 1431, 8, 277, 304, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 9185, 63, 14747, 418, 275, 662, 6967, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 4809, 11911, 8, 1310, 9, 267, 1177, 275, 291, 14, 1258, 14, 524, 2336, 5394, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 841, 713, 9, 267, 291, 14, 1258, 14, 4322, 459, 2856, 63, 4656, 63, 9185, 63, 14747, 418, 275, 3651, 2252, 7387, 63, 775, 1254, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 5394, 6217, 267, 291, 14, 479, 9042, 2364, 8, 1310, 9, 398, 327, 3240, 422, 279, 325, 2969, 315, 982, 13, 403, 13, 4486, 365, 282, 4546, 444, 79, 764, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
petertodd/replace-by-fee-tools
doublespend.py
1
7977
#!/usr/bin/python3 # Copyright (C) 2014 Peter Todd <pete@petertodd.org> # # This file is subject to the license terms in the LICENSE file found in the # top-level directory of this distribution. import argparse import binascii import bitcoin import bitcoin.rpc import logging import math import time from bitcoin.core import b2x, b2lx, x, lx, str_money_value, COIN, CMutableTransaction, CMutableTxIn, CMutableTxOut from bitcoin.core.script import CScript, OP_RETURN, OP_CHECKMULTISIG from bitcoin.wallet import CBitcoinAddress parser = argparse.ArgumentParser( description="Attempt to double-spend a payment", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-t', action='store_true', dest='testnet', help='Enable testnet') parser.add_argument('-n', action='store_true', dest='dryrun', help="Dry-run; don't actually send the transactions") parser.add_argument('-d', action='store', type=int, default=15, dest='delay', help="Delay in seconds between payment and double-spend") parser.add_argument('--dust', action='store', type=float, default=0.0001, help="Dust amount") parser.add_argument('--fee1', action='store', type=float, metavar='FEEPERKB', default=0.000011, help='Fee-per-KB of payment transaction') parser.add_argument('--fee2', action='store', type=float, metavar='FEEPERKB', default=0.001, help='Fee-per-KB of double-spend transaction') parser.add_argument('--op-return', action='store_true', help="Add OP_RETURN <data> output to payment tx") parser.add_argument('--multisig', action='store_true', help="Add multisig output to payment tx") parser.add_argument('--optinrbf', action='store_true', default=False, help="Signal full-RBF opt-in (BIP125)") parser.add_argument('--bad-addr', action='append', default=[], help="Pay some dust to a 'bad' address to discourage propagation") parser.add_argument('address', action='store', type=str, help='Address to double-spend') parser.add_argument('amount', action='store', type=float, help='Amount to send') args = parser.parse_args() logging.root.setLevel('DEBUG') if args.testnet: bitcoin.SelectParams('testnet') rpc = bitcoin.rpc.Proxy() args.dust = int(args.dust * COIN) feeperbyte1 = args.fee1 / 1000 * COIN feeperbyte2 = args.fee2 / 1000 * COIN # Construct payment tx payment_address = CBitcoinAddress(args.address) payment_txout = CMutableTxOut(int(args.amount * COIN), payment_address.to_scriptPubKey()) change_txout = CMutableTxOut(0, rpc.getnewaddress().to_scriptPubKey()) tx = CMutableTransaction() tx.vout.append(change_txout) tx.vout.append(payment_txout) # Add all undesirable txouts meant to reduce propagation if args.op_return: op_ret_txout = CMutableTxOut(0, CScript([OP_RETURN, b'\x00unsuccessful double-spend attempt\x00'])) tx.vout.append(op_ret_txout) if args.multisig: multisig_txout = CMutableTxOut(args.dust, CScript([1, x('0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71'), b'\x00'*33, 2, OP_CHECKMULTISIG])) tx.vout.append(multisig_txout) tx1_nSequence = 0xFFFFFFFF-2 if args.optinrbf else 0xFFFFFFFF tx2_nSequence = tx1_nSequence # maybe they should be different in the future? for bad_addr in args.bad_addr: bad_addr = CBitcoinAddress(bad_addr) txout = CMutableTxOut(args.dust, bad_addr.to_scriptPubKey()) tx.vout.append(txout) # Add inputs until we meet the fee1 threshold unspent = sorted(rpc.listunspent(1), key=lambda x: x['amount']) value_in = 0 value_out = sum([vout.nValue for vout in tx.vout]) while (value_in - value_out) / len(tx.serialize()) < feeperbyte1: # What's the delta fee that we need to get to our desired fees per byte at # the current tx size? delta_fee = math.ceil((feeperbyte1 * len(tx.serialize())) - (value_in - value_out)) logging.debug('Delta fee: %s' % str_money_value(delta_fee)) # If we simply subtract that from the change outpoint are we still above # the dust threshold? if change_txout.nValue - delta_fee > args.dust: change_txout.nValue -= delta_fee value_out -= delta_fee # Do we need to add another input? if value_in - value_out < 0: new_outpoint = unspent[-1]['outpoint'] new_amount = unspent[-1]['amount'] unspent = unspent[:-1] logging.debug('Adding new input %s:%d with value %s BTC' % \ (b2lx(new_outpoint.hash), new_outpoint.n, str_money_value(new_amount))) new_txin = CMutableTxIn(new_outpoint, nSequence=tx1_nSequence) tx.vin.append(new_txin) value_in += new_amount change_txout.nValue += new_amount value_out += new_amount # Resign the tx so we can figure out how large the new input's scriptSig will be. r = rpc.signrawtransaction(tx) assert(r['complete']) tx.vin[-1].scriptSig = r['tx'].vin[-1].scriptSig r = rpc.signrawtransaction(tx) assert(r['complete']) tx = CMutableTransaction.from_tx(r['tx']) logging.debug('Payment tx %s' % b2x(tx.serialize())) logging.info('Payment tx size: %.3f KB, fees: %s, %s BTC/KB' % \ (len(tx.serialize()) / 1000, str_money_value(value_in-value_out), str_money_value((value_in-value_out) / len(tx.serialize()) * 1000))) if not args.dryrun: txid = rpc.sendrawtransaction(tx) logging.info('Sent payment tx: %s' % b2lx(txid)) if not args.dryrun: logging.info('Sleeping for %d seconds' % args.delay) time.sleep(args.delay) # Double-spend! Remove all but the change output tx.vout = tx.vout[0:1] change_txout = tx.vout[0] value_out = value_in change_txout.nValue = value_out # FIXME: need to modularize this code while (value_in - value_out) / len(tx.serialize()) < feeperbyte2: # What's the delta fee that we need to get to our desired fees per byte at # the current tx size? delta_fee = math.ceil((feeperbyte2 * len(tx.serialize())) - (value_in - value_out)) logging.debug('Delta fee: %s' % str_money_value(delta_fee)) # If we simply subtract that from the change outpoint are we still above # the dust threshold? if change_txout.nValue - delta_fee > args.dust: change_txout.nValue -= delta_fee value_out -= delta_fee # Do we need to add another input? if value_in - value_out < 0: new_outpoint = unspent[-1]['outpoint'] new_amount = unspent[-1]['amount'] unspent = unspent[:-1] logging.debug('Adding new input %s:%d with value %s BTC' % \ (b2lx(new_outpoint.hash), new_outpoint.n, str_money_value(new_amount))) new_txin = CMutableTxIn(new_outpoint, nSequence=tx2_nSequence) tx.vin.append(new_txin) value_in += new_amount change_txout.nValue += new_amount value_out += new_amount # Resign the tx so we can figure out how large the new input's scriptSig will be. r = rpc.signrawtransaction(tx) assert(r['complete']) tx.vin[-1].scriptSig = r['tx'].vin[-1].scriptSig r = rpc.signrawtransaction(tx) assert(r['complete']) tx = r['tx'] logging.debug('Double-spend tx %s' % b2x(tx.serialize())) logging.info('Double-spend tx size: %.3f KB, fees: %s, %s BTC/KB' % \ (len(tx.serialize()) / 1000, str_money_value(value_in-value_out), str_money_value((value_in-value_out) / len(tx.serialize()) * 1000))) if not args.dryrun: txid = rpc.sendrawtransaction(tx) logging.info('Sent double-spend tx: %s' % b2lx(txid))
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 3, 1898, 334, 35, 9, 6927, 22912, 377, 16216, 665, 321, 266, 32, 321, 351, 5766, 68, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 5420, 370, 314, 4190, 2895, 315, 314, 5113, 570, 1911, 315, 314, 199, 3, 2746, 13, 1896, 2082, 402, 642, 4084, 14, 199, 199, 646, 7534, 199, 646, 14755, 199, 646, 27214, 199, 646, 27214, 14, 4354, 199, 646, 2050, 199, 646, 3473, 199, 646, 900, 199, 199, 504, 27214, 14, 1018, 492, 330, 18, 88, 12, 330, 18, 23605, 12, 671, 12, 634, 88, 12, 620, 63, 27468, 63, 585, 12, 5099, 568, 12, 445, 17707, 10161, 12, 445, 17707, 8052, 607, 12, 445, 17707, 8052, 2204, 199, 504, 27214, 14, 1018, 14, 1579, 492, 24682, 12, 9827, 63, 9677, 12, 9827, 63, 8936, 8203, 1311, 1277, 199, 504, 27214, 14, 13892, 492, 445, 4734, 9061, 1476, 199, 199, 2087, 275, 7534, 14, 10730, 8, 267, 1369, 628, 23272, 370, 4270, 13, 31340, 282, 11628, 401, 267, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 199, 2087, 14, 525, 63, 2094, 3654, 84, 297, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 396, 846, 297, 490, 1720, 534, 6476, 511, 846, 358, 199, 2087, 14, 525, 63, 2094, 3654, 78, 297, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 10481, 1065, 297, 490, 1720, 628, 36, 651, 13, 1065, 27, 2793, 1133, 5965, 3222, 314, 15809, 531, 199, 2087, 14, 525, 63, 2094, 3654, 68, 297, 1595, 534, 1617, 297, 730, 29, 442, 12, 490, 849, 29, 1046, 12, 490, 2053, 534, 5814, 297, 490, 1720, 628, 10796, 315, 4696, 3382, 11628, 436, 4270, 13, 31340, 531, 199, 2087, 14, 525, 63, 2094, 4517, 68, 833, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 849, 29, 16, 14, 4183, 12, 490, 1720, 628, 36, 833, 5982, 531, 199, 2087, 14, 525, 63, 2094, 4517, 11195, 17, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 8214, 534, 5100, 37, 4227, 12780, 297, 490, 849, 29, 16, 14, 993, 845, 12, 490, 1720, 534, 28042, 13, 529, 13, 12780, 402, 11628, 6008, 358, 199, 2087, 14, 525, 63, 2094, 4517, 11195, 18, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 8214, 534, 5100, 37, 4227, 12780, 297, 490, 849, 29, 16, 14, 4587, 12, 490, 1720, 534, 28042, 13, 529, 13, 12780, 402, 4270, 13, 31340, 6008, 358, 199, 199, 2087, 14, 525, 63, 2094, 4517, 411, 13, 1107, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 1123, 9827, 63, 9677, 665, 576, 30, 1072, 370, 11628, 4773, 531, 199, 2087, 14, 525, 63, 2094, 4517, 3029, 4093, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 1123, 3510, 4093, 1072, 370, 11628, 4773, 531, 199, 2087, 14, 525, 63, 2094, 4517, 411, 1346, 25853, 297, 1595, 534, 1617, 63, 2052, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 11274, 2615, 13, 50, 12659, 2450, 13, 262, 334, 34, 1772, 6889, 6320, 199, 2087, 14, 525, 63, 2094, 4517, 4087, 13, 2697, 297, 1595, 534, 740, 297, 490, 849, 6034, 490, 1720, 628, 10517, 2005, 366, 833, 370, 282, 283, 4087, 7, 2287, 370, 2153, 25715, 474, 17012, 531, 199, 199, 2087, 14, 525, 63, 2094, 360, 1562, 297, 1595, 534, 1617, 297, 730, 29, 495, 12, 490, 1720, 534, 1476, 370, 4270, 13, 31340, 358, 199, 2087, 14, 525, 63, 2094, 360, 4606, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 1720, 534, 18785, 370, 3222, 358, 199, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 4806, 14, 1231, 14, 13548, 360, 5287, 358, 199, 199, 692, 1249, 14, 396, 846, 26, 272, 27214, 14, 5446, 6007, 360, 396, 846, 358, 199, 199, 4354, 275, 27214, 14, 4354, 14, 4936, 342, 199, 199, 589, 14, 68, 833, 275, 1109, 8, 589, 14, 68, 833, 627, 5099, 568, 9, 199, 199, 11195, 529, 4414, 17, 275, 1249, 14, 11195, 17, 1182, 5198, 627, 5099, 568, 199, 11195, 529, 4414, 18, 275, 1249, 14, 11195, 18, 1182, 5198, 627, 5099, 568, 199, 199, 3, 9215, 11628, 4773, 199, 7948, 63, 1562, 275, 445, 4734, 9061, 1476, 8, 589, 14, 1562, 9, 199, 199, 7948, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 442, 8, 589, 14, 4606, 627, 5099, 568, 395, 11628, 63, 1562, 14, 475, 63, 1579, 29632, 1012, 199, 1461, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 16, 12, 8985, 14, 21102, 1252, 475, 63, 1579, 29632, 1012, 199, 199, 2347, 275, 445, 17707, 10161, 342, 199, 2347, 14, 17853, 14, 740, 8, 1461, 63, 2347, 548, 9, 199, 2347, 14, 17853, 14, 740, 8, 7948, 63, 2347, 548, 9, 199, 199, 3, 2654, 1006, 625, 271, 338, 6842, 4773, 16816, 18329, 370, 7114, 17012, 199, 692, 1249, 14, 411, 63, 1107, 26, 272, 1687, 63, 3292, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 16, 12, 24682, 779, 1938, 63, 9677, 12, 330, 1154, 88, 383, 324, 18157, 4270, 13, 31340, 7427, 60, 88, 383, 5156, 272, 4773, 14, 17853, 14, 740, 8, 411, 63, 3292, 63, 2347, 548, 9, 199, 199, 692, 1249, 14, 3029, 4093, 26, 272, 3510, 4093, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 589, 14, 68, 833, 12, 288, 24682, 779, 17, 12, 671, 360, 16, 12046, 68, 2824, 996, 1342, 70, 24, 67, 21, 825, 6557, 969, 1703, 12768, 69, 25, 70, 1465, 70, 20, 67, 19087, 65, 8662, 66, 1587, 1184, 1703, 68, 1780, 67, 16, 66, 22, 1235, 25, 371, 1276, 67, 3172, 659, 717, 330, 1154, 88, 383, 16804, 1153, 12, 2151, 499, 12, 9827, 63, 8936, 8203, 1311, 1277, 2459, 272, 4773, 14, 17853, 14, 740, 8, 3029, 4093, 63, 2347, 548, 9, 199, 199, 2347, 17, 63, 78, 5826, 275, 378, 32158, 13, 18, 340, 1249, 14, 411, 1346, 25853, 587, 378, 32158, 199, 2347, 18, 63, 78, 5826, 275, 4773, 17, 63, 78, 5826, 327, 11703, 2985, 1077, 506, 3365, 315, 314, 6466, 31, 199, 199, 509, 4875, 63, 2697 ]
[ 2647, 15, 1393, 15, 1548, 19, 199, 3, 1898, 334, 35, 9, 6927, 22912, 377, 16216, 665, 321, 266, 32, 321, 351, 5766, 68, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 5420, 370, 314, 4190, 2895, 315, 314, 5113, 570, 1911, 315, 314, 199, 3, 2746, 13, 1896, 2082, 402, 642, 4084, 14, 199, 199, 646, 7534, 199, 646, 14755, 199, 646, 27214, 199, 646, 27214, 14, 4354, 199, 646, 2050, 199, 646, 3473, 199, 646, 900, 199, 199, 504, 27214, 14, 1018, 492, 330, 18, 88, 12, 330, 18, 23605, 12, 671, 12, 634, 88, 12, 620, 63, 27468, 63, 585, 12, 5099, 568, 12, 445, 17707, 10161, 12, 445, 17707, 8052, 607, 12, 445, 17707, 8052, 2204, 199, 504, 27214, 14, 1018, 14, 1579, 492, 24682, 12, 9827, 63, 9677, 12, 9827, 63, 8936, 8203, 1311, 1277, 199, 504, 27214, 14, 13892, 492, 445, 4734, 9061, 1476, 199, 199, 2087, 275, 7534, 14, 10730, 8, 267, 1369, 628, 23272, 370, 4270, 13, 31340, 282, 11628, 401, 267, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 199, 2087, 14, 525, 63, 2094, 3654, 84, 297, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 396, 846, 297, 490, 1720, 534, 6476, 511, 846, 358, 199, 2087, 14, 525, 63, 2094, 3654, 78, 297, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 10481, 1065, 297, 490, 1720, 628, 36, 651, 13, 1065, 27, 2793, 1133, 5965, 3222, 314, 15809, 531, 199, 2087, 14, 525, 63, 2094, 3654, 68, 297, 1595, 534, 1617, 297, 730, 29, 442, 12, 490, 849, 29, 1046, 12, 490, 2053, 534, 5814, 297, 490, 1720, 628, 10796, 315, 4696, 3382, 11628, 436, 4270, 13, 31340, 531, 199, 2087, 14, 525, 63, 2094, 4517, 68, 833, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 849, 29, 16, 14, 4183, 12, 490, 1720, 628, 36, 833, 5982, 531, 199, 2087, 14, 525, 63, 2094, 4517, 11195, 17, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 8214, 534, 5100, 37, 4227, 12780, 297, 490, 849, 29, 16, 14, 993, 845, 12, 490, 1720, 534, 28042, 13, 529, 13, 12780, 402, 11628, 6008, 358, 199, 2087, 14, 525, 63, 2094, 4517, 11195, 18, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 8214, 534, 5100, 37, 4227, 12780, 297, 490, 849, 29, 16, 14, 4587, 12, 490, 1720, 534, 28042, 13, 529, 13, 12780, 402, 4270, 13, 31340, 6008, 358, 199, 199, 2087, 14, 525, 63, 2094, 4517, 411, 13, 1107, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 1123, 9827, 63, 9677, 665, 576, 30, 1072, 370, 11628, 4773, 531, 199, 2087, 14, 525, 63, 2094, 4517, 3029, 4093, 297, 1595, 534, 1617, 63, 2052, 297, 490, 1720, 628, 1123, 3510, 4093, 1072, 370, 11628, 4773, 531, 199, 2087, 14, 525, 63, 2094, 4517, 411, 1346, 25853, 297, 1595, 534, 1617, 63, 2052, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 11274, 2615, 13, 50, 12659, 2450, 13, 262, 334, 34, 1772, 6889, 6320, 199, 2087, 14, 525, 63, 2094, 4517, 4087, 13, 2697, 297, 1595, 534, 740, 297, 490, 849, 6034, 490, 1720, 628, 10517, 2005, 366, 833, 370, 282, 283, 4087, 7, 2287, 370, 2153, 25715, 474, 17012, 531, 199, 199, 2087, 14, 525, 63, 2094, 360, 1562, 297, 1595, 534, 1617, 297, 730, 29, 495, 12, 490, 1720, 534, 1476, 370, 4270, 13, 31340, 358, 199, 2087, 14, 525, 63, 2094, 360, 4606, 297, 1595, 534, 1617, 297, 730, 29, 1609, 12, 490, 1720, 534, 18785, 370, 3222, 358, 199, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 4806, 14, 1231, 14, 13548, 360, 5287, 358, 199, 199, 692, 1249, 14, 396, 846, 26, 272, 27214, 14, 5446, 6007, 360, 396, 846, 358, 199, 199, 4354, 275, 27214, 14, 4354, 14, 4936, 342, 199, 199, 589, 14, 68, 833, 275, 1109, 8, 589, 14, 68, 833, 627, 5099, 568, 9, 199, 199, 11195, 529, 4414, 17, 275, 1249, 14, 11195, 17, 1182, 5198, 627, 5099, 568, 199, 11195, 529, 4414, 18, 275, 1249, 14, 11195, 18, 1182, 5198, 627, 5099, 568, 199, 199, 3, 9215, 11628, 4773, 199, 7948, 63, 1562, 275, 445, 4734, 9061, 1476, 8, 589, 14, 1562, 9, 199, 199, 7948, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 442, 8, 589, 14, 4606, 627, 5099, 568, 395, 11628, 63, 1562, 14, 475, 63, 1579, 29632, 1012, 199, 1461, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 16, 12, 8985, 14, 21102, 1252, 475, 63, 1579, 29632, 1012, 199, 199, 2347, 275, 445, 17707, 10161, 342, 199, 2347, 14, 17853, 14, 740, 8, 1461, 63, 2347, 548, 9, 199, 2347, 14, 17853, 14, 740, 8, 7948, 63, 2347, 548, 9, 199, 199, 3, 2654, 1006, 625, 271, 338, 6842, 4773, 16816, 18329, 370, 7114, 17012, 199, 692, 1249, 14, 411, 63, 1107, 26, 272, 1687, 63, 3292, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 16, 12, 24682, 779, 1938, 63, 9677, 12, 330, 1154, 88, 383, 324, 18157, 4270, 13, 31340, 7427, 60, 88, 383, 5156, 272, 4773, 14, 17853, 14, 740, 8, 411, 63, 3292, 63, 2347, 548, 9, 199, 199, 692, 1249, 14, 3029, 4093, 26, 272, 3510, 4093, 63, 2347, 548, 275, 445, 17707, 8052, 2204, 8, 589, 14, 68, 833, 12, 288, 24682, 779, 17, 12, 671, 360, 16, 12046, 68, 2824, 996, 1342, 70, 24, 67, 21, 825, 6557, 969, 1703, 12768, 69, 25, 70, 1465, 70, 20, 67, 19087, 65, 8662, 66, 1587, 1184, 1703, 68, 1780, 67, 16, 66, 22, 1235, 25, 371, 1276, 67, 3172, 659, 717, 330, 1154, 88, 383, 16804, 1153, 12, 2151, 499, 12, 9827, 63, 8936, 8203, 1311, 1277, 2459, 272, 4773, 14, 17853, 14, 740, 8, 3029, 4093, 63, 2347, 548, 9, 199, 199, 2347, 17, 63, 78, 5826, 275, 378, 32158, 13, 18, 340, 1249, 14, 411, 1346, 25853, 587, 378, 32158, 199, 2347, 18, 63, 78, 5826, 275, 4773, 17, 63, 78, 5826, 327, 11703, 2985, 1077, 506, 3365, 315, 314, 6466, 31, 199, 199, 509, 4875, 63, 2697, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shiquanwang/pylearn2
pylearn2/cross_validation/tests/test_train_cv_extensions.py
49
1681
""" Tests for TrainCV extensions. """ import os import tempfile from pylearn2.config import yaml_parse from pylearn2.testing.skip import skip_if_no_sklearn def test_monitor_based_save_best_cv(): """Test MonitorBasedSaveBestCV.""" handle, filename = tempfile.mkstemp() skip_if_no_sklearn() trainer = yaml_parse.load(test_yaml_monitor_based_save_best_cv % {'save_path': filename}) trainer.main_loop() # clean up os.remove(filename) test_yaml_monitor_based_save_best_cv = """ !obj:pylearn2.cross_validation.TrainCV { dataset_iterator: !obj:pylearn2.cross_validation.dataset_iterators.DatasetKFold { dataset: !obj:pylearn2.testing.datasets.random_one_hot_dense_design_matrix { rng: !obj:numpy.random.RandomState { seed: 1 }, num_examples: 100, dim: 10, num_classes: 2, }, }, model: !obj:pylearn2.models.autoencoder.Autoencoder { nvis: 10, nhid: 8, act_enc: sigmoid, act_dec: linear }, algorithm: !obj:pylearn2.training_algorithms.bgd.BGD { batch_size: 50, line_search_mode: exhaustive, conjugate: 1, termination_criterion: !obj:pylearn2.termination_criteria.EpochCounter { max_epochs: 1, }, cost: !obj:pylearn2.costs.autoencoder.MeanSquaredReconstructionError { }, }, cv_extensions: [ !obj:pylearn2.cross_validation.train_cv_extensions.MonitorBasedSaveBestCV { channel_name: train_objective, save_path: %(save_path)s, }, ], } """
bsd-3-clause
[ 624, 199, 2925, 367, 16732, 12847, 5478, 14, 199, 624, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 27959, 18, 14, 888, 492, 8864, 63, 1122, 199, 504, 27959, 18, 14, 4776, 14, 2759, 492, 3372, 63, 692, 63, 889, 63, 27993, 421, 199, 318, 511, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 837, 272, 408, 774, 26504, 20409, 8229, 19478, 12847, 1041, 272, 2429, 12, 1788, 275, 5549, 14, 17721, 342, 272, 3372, 63, 692, 63, 889, 63, 27993, 342, 272, 3560, 281, 275, 8864, 63, 1122, 14, 912, 8, 396, 63, 5963, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 450, 2892, 791, 2117, 63, 515, 356, 1788, 1552, 272, 3560, 281, 14, 973, 63, 3813, 342, 339, 327, 3633, 1536, 272, 747, 14, 2168, 8, 1501, 9, 199, 199, 396, 63, 5963, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 275, 408, 199, 1, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 18591, 12847, 469, 272, 4789, 63, 5778, 26, 267, 8546, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 5214, 63, 1661, 2750, 14, 9271, 17706, 1753, 469, 267, 4789, 26, 288, 8546, 1113, 26, 647, 4643, 18, 14, 4776, 14, 12281, 14, 2355, 63, 368, 63, 8885, 63, 7253, 63, 14748, 63, 3642, 288, 469, 355, 9038, 26, 8546, 1113, 26, 4714, 14, 2355, 14, 15726, 469, 6347, 26, 413, 1660, 355, 1967, 63, 8589, 26, 2948, 12, 355, 8134, 26, 1616, 12, 355, 1967, 63, 2888, 26, 499, 12, 288, 1660, 272, 1660, 272, 1402, 26, 8546, 1113, 26, 647, 4643, 18, 14, 992, 14, 2495, 9347, 14, 3358, 9347, 469, 267, 302, 5068, 26, 1616, 12, 267, 302, 18209, 26, 1695, 12, 267, 2454, 63, 10945, 26, 28886, 12, 267, 2454, 63, 7778, 26, 7798, 272, 1660, 272, 5563, 26, 8546, 1113, 26, 647, 4643, 18, 14, 7588, 63, 24365, 14, 6856, 68, 14, 18998, 36, 469, 267, 3522, 63, 890, 26, 5238, 12, 267, 1004, 63, 1733, 63, 632, 26, 21354, 833, 1912, 12, 267, 27246, 26, 413, 12, 267, 23868, 63, 21418, 26, 288, 8546, 1113, 26, 647, 4643, 18, 14, 20667, 63, 20525, 14, 29322, 11348, 469, 490, 1390, 63, 13161, 26, 413, 12, 267, 1660, 267, 7918, 26, 8546, 1113, 26, 647, 4643, 18, 14, 25432, 14, 2495, 9347, 14, 14825, 51, 30458, 497, 12708, 547, 469, 267, 1660, 272, 1660, 272, 6277, 63, 5359, 26, 359, 523, 8546, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 2834, 63, 5107, 63, 5359, 14, 13189, 20409, 8229, 19478, 12847, 469, 267, 3623, 63, 354, 26, 3560, 63, 24091, 12, 267, 3354, 63, 515, 26, 2818, 2117, 63, 515, 9, 83, 12, 489, 1660, 272, 2156, 199, 93, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2925, 367, 16732, 12847, 5478, 14, 199, 624, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 27959, 18, 14, 888, 492, 8864, 63, 1122, 199, 504, 27959, 18, 14, 4776, 14, 2759, 492, 3372, 63, 692, 63, 889, 63, 27993, 421, 199, 318, 511, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 837, 272, 408, 774, 26504, 20409, 8229, 19478, 12847, 1041, 272, 2429, 12, 1788, 275, 5549, 14, 17721, 342, 272, 3372, 63, 692, 63, 889, 63, 27993, 342, 272, 3560, 281, 275, 8864, 63, 1122, 14, 912, 8, 396, 63, 5963, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 450, 2892, 791, 2117, 63, 515, 356, 1788, 1552, 272, 3560, 281, 14, 973, 63, 3813, 342, 339, 327, 3633, 1536, 272, 747, 14, 2168, 8, 1501, 9, 199, 199, 396, 63, 5963, 63, 7157, 63, 6788, 63, 2117, 63, 7010, 63, 5107, 275, 408, 199, 1, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 18591, 12847, 469, 272, 4789, 63, 5778, 26, 267, 8546, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 5214, 63, 1661, 2750, 14, 9271, 17706, 1753, 469, 267, 4789, 26, 288, 8546, 1113, 26, 647, 4643, 18, 14, 4776, 14, 12281, 14, 2355, 63, 368, 63, 8885, 63, 7253, 63, 14748, 63, 3642, 288, 469, 355, 9038, 26, 8546, 1113, 26, 4714, 14, 2355, 14, 15726, 469, 6347, 26, 413, 1660, 355, 1967, 63, 8589, 26, 2948, 12, 355, 8134, 26, 1616, 12, 355, 1967, 63, 2888, 26, 499, 12, 288, 1660, 272, 1660, 272, 1402, 26, 8546, 1113, 26, 647, 4643, 18, 14, 992, 14, 2495, 9347, 14, 3358, 9347, 469, 267, 302, 5068, 26, 1616, 12, 267, 302, 18209, 26, 1695, 12, 267, 2454, 63, 10945, 26, 28886, 12, 267, 2454, 63, 7778, 26, 7798, 272, 1660, 272, 5563, 26, 8546, 1113, 26, 647, 4643, 18, 14, 7588, 63, 24365, 14, 6856, 68, 14, 18998, 36, 469, 267, 3522, 63, 890, 26, 5238, 12, 267, 1004, 63, 1733, 63, 632, 26, 21354, 833, 1912, 12, 267, 27246, 26, 413, 12, 267, 23868, 63, 21418, 26, 288, 8546, 1113, 26, 647, 4643, 18, 14, 20667, 63, 20525, 14, 29322, 11348, 469, 490, 1390, 63, 13161, 26, 413, 12, 267, 1660, 267, 7918, 26, 8546, 1113, 26, 647, 4643, 18, 14, 25432, 14, 2495, 9347, 14, 14825, 51, 30458, 497, 12708, 547, 469, 267, 1660, 272, 1660, 272, 6277, 63, 5359, 26, 359, 523, 8546, 1113, 26, 647, 4643, 18, 14, 7925, 63, 6136, 14, 2834, 63, 5107, 63, 5359, 14, 13189, 20409, 8229, 19478, 12847, 469, 267, 3623, 63, 354, 26, 3560, 63, 24091, 12, 267, 3354, 63, 515, 26, 2818, 2117, 63, 515, 9, 83, 12, 489, 1660, 272, 2156, 199, 93, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
edx-solutions/edx-platform
openedx/core/djangoapps/catalog/management/commands/cache_programs.py
4
11186
""""Management command to add program information to the cache.""" import logging import sys from collections import defaultdict from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.cache import cache from django.core.management import BaseCommand from six import text_type from openedx.core.djangoapps.catalog.cache import ( COURSE_PROGRAMS_CACHE_KEY_TPL, CATALOG_COURSE_PROGRAMS_CACHE_KEY_TPL, PATHWAY_CACHE_KEY_TPL, PROGRAM_CACHE_KEY_TPL, PROGRAMS_BY_ORGANIZATION_CACHE_KEY_TPL, PROGRAMS_BY_TYPE_CACHE_KEY_TPL, SITE_PATHWAY_IDS_CACHE_KEY_TPL, SITE_PROGRAM_UUIDS_CACHE_KEY_TPL ) from openedx.core.djangoapps.catalog.models import CatalogIntegration from openedx.core.djangoapps.catalog.utils import ( course_run_keys_for_program, course_uuids_for_program, create_catalog_api_client, normalize_program_type ) logger = logging.getLogger(__name__) User = get_user_model() # pylint: disable=invalid-name class Command(BaseCommand): """Management command used to cache program data. This command requests every available program from the discovery service, writing each to its own cache entry with an indefinite expiration. It is meant to be run on a scheduled basis and should be the only code updating these cache entries. """ help = "Rebuild the LMS' cache of program data." # pylint: disable=unicode-format-string def handle(self, *args, **options): failure = False logger.info('populate-multitenant-programs switch is ON') catalog_integration = CatalogIntegration.current() username = catalog_integration.service_username try: user = User.objects.get(username=username) except User.DoesNotExist: logger.exception( u'Failed to create API client. Service user {username} does not exist.'.format(username=username) ) raise programs = {} pathways = {} courses = {} catalog_courses = {} programs_by_type = {} organizations = {} for site in Site.objects.all(): site_config = getattr(site, 'configuration', None) if site_config is None or not site_config.get_value('COURSE_CATALOG_API_URL'): logger.info(u'Skipping site {domain}. No configuration.'.format(domain=site.domain)) cache.set(SITE_PROGRAM_UUIDS_CACHE_KEY_TPL.format(domain=site.domain), [], None) cache.set(SITE_PATHWAY_IDS_CACHE_KEY_TPL.format(domain=site.domain), [], None) continue client = create_catalog_api_client(user, site=site) uuids, program_uuids_failed = self.get_site_program_uuids(client, site) new_programs, program_details_failed = self.fetch_program_details(client, uuids) new_pathways, pathways_failed = self.get_pathways(client, site) new_pathways, new_programs, pathway_processing_failed = self.process_pathways( site, new_pathways, new_programs ) failure = any([ program_uuids_failed, program_details_failed, pathways_failed, pathway_processing_failed, ]) programs.update(new_programs) pathways.update(new_pathways) courses.update(self.get_courses(new_programs)) catalog_courses.update(self.get_catalog_courses(new_programs)) programs_by_type.update(self.get_programs_by_type(site, new_programs)) organizations.update(self.get_programs_by_organization(new_programs)) logger.info(u'Caching UUIDs for {total} programs for site {site_name}.'.format( total=len(uuids), site_name=site.domain, )) cache.set(SITE_PROGRAM_UUIDS_CACHE_KEY_TPL.format(domain=site.domain), uuids, None) pathway_ids = list(new_pathways.keys()) logger.info(u'Caching ids for {total} pathways for site {site_name}.'.format( total=len(pathway_ids), site_name=site.domain, )) cache.set(SITE_PATHWAY_IDS_CACHE_KEY_TPL.format(domain=site.domain), pathway_ids, None) logger.info(u'Caching details for {} programs.'.format(len(programs))) cache.set_many(programs, None) logger.info(u'Caching details for {} pathways.'.format(len(pathways))) cache.set_many(pathways, None) logger.info(u'Caching programs uuids for {} courses.'.format(len(courses))) cache.set_many(courses, None) logger.info(u'Caching programs uuids for {} catalog courses.'.format(len(catalog_courses))) cache.set_many(catalog_courses, None) logger.info(text_type('Caching program UUIDs by {} program types.'.format(len(programs_by_type)))) cache.set_many(programs_by_type, None) logger.info(u'Caching programs uuids for {} organizations'.format(len(organizations))) cache.set_many(organizations, None) if failure: sys.exit(1) def get_site_program_uuids(self, client, site): failure = False uuids = [] try: querystring = { 'exclude_utm': 1, 'status': ('active', 'retired'), 'uuids_only': 1, } logger.info(u'Requesting program UUIDs for {domain}.'.format(domain=site.domain)) uuids = client.programs.get(**querystring) except: # pylint: disable=bare-except logger.exception(u'Failed to retrieve program UUIDs for site: {domain}.'.format(domain=site.domain)) failure = True logger.info(u'Received {total} UUIDs for site {domain}'.format( total=len(uuids), domain=site.domain )) return uuids, failure def fetch_program_details(self, client, uuids): programs = {} failure = False for uuid in uuids: try: cache_key = PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) logger.info(u'Requesting details for program {uuid}.'.format(uuid=uuid)) program = client.programs(uuid).get(exclude_utm=1) # pathways get added in process_pathways program['pathway_ids'] = [] programs[cache_key] = program except: # pylint: disable=bare-except logger.exception(u'Failed to retrieve details for program {uuid}.'.format(uuid=uuid)) failure = True continue return programs, failure def get_pathways(self, client, site): """ Get all pathways for the current client """ pathways = [] failure = False logger.info(u'Requesting pathways for {domain}.'.format(domain=site.domain)) try: next_page = 1 while next_page: new_pathways = client.pathways.get(exclude_utm=1, page=next_page) pathways.extend(new_pathways['results']) next_page = next_page + 1 if new_pathways['next'] else None except: # pylint: disable=bare-except logger.exception( msg=u'Failed to retrieve pathways for site: {domain}.'.format(domain=site.domain), ) failure = True logger.info(u'Received {total} pathways for site {domain}'.format( total=len(pathways), domain=site.domain )) return pathways, failure def process_pathways(self, site, pathways, programs): """ For each program, add references to each pathway it is a part of. For each pathway, replace the "programs" dict with "program_uuids", which only contains uuids (since program data is already cached) """ processed_pathways = {} failure = False for pathway in pathways: try: pathway_id = pathway['id'] pathway_cache_key = PATHWAY_CACHE_KEY_TPL.format(id=pathway_id) processed_pathways[pathway_cache_key] = pathway uuids = [] for program in pathway['programs']: program_uuid = program['uuid'] program_cache_key = PROGRAM_CACHE_KEY_TPL.format(uuid=program_uuid) programs[program_cache_key]['pathway_ids'].append(pathway_id) uuids.append(program_uuid) del pathway['programs'] pathway['program_uuids'] = uuids except: # pylint: disable=bare-except logger.exception(u'Failed to process pathways for {domain}'.format(domain=site.domain)) failure = True return processed_pathways, programs, failure def get_courses(self, programs): """ Get all course runs for programs. TODO: when course discovery can handle it, use that instead. That will allow us to put all course runs in the cache not just the course runs in a program. Therefore, a cache miss would be different from a course not in a program. """ course_runs = defaultdict(list) for program in programs.values(): for course_run_key in course_run_keys_for_program(program): course_run_cache_key = COURSE_PROGRAMS_CACHE_KEY_TPL.format(course_run_id=course_run_key) course_runs[course_run_cache_key].append(program['uuid']) return course_runs def get_catalog_courses(self, programs): """ Get all catalog courses for the programs. """ courses = defaultdict(list) for program in programs.values(): for course_uuid in course_uuids_for_program(program): course_cache_key = CATALOG_COURSE_PROGRAMS_CACHE_KEY_TPL.format(course_uuid=course_uuid) courses[course_cache_key].append(program['uuid']) return courses def get_programs_by_type(self, site, programs): """ Returns a dictionary mapping site-aware cache keys corresponding to program types to lists of program uuids with that type. """ programs_by_type = defaultdict(list) for program in programs.values(): program_type = normalize_program_type(program.get('type')) cache_key = PROGRAMS_BY_TYPE_CACHE_KEY_TPL.format(site_id=site.id, program_type=program_type) programs_by_type[cache_key].append(program['uuid']) return programs_by_type def get_programs_by_organization(self, programs): """ Returns a dictionary mapping organization keys to lists of program uuids authored by that org """ organizations = defaultdict(list) for program in programs.values(): for org in program['authoring_organizations']: org_cache_key = PROGRAMS_BY_ORGANIZATION_CACHE_KEY_TPL.format(org_key=org['key']) organizations[org_cache_key].append(program['uuid']) return organizations
agpl-3.0
[ 341, 341, 14552, 1414, 370, 1050, 2240, 2556, 370, 314, 2581, 1041, 421, 199, 646, 2050, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 8110, 492, 22239, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 1637, 492, 334, 272, 5099, 14302, 63, 15605, 51, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 445, 619, 23622, 63, 15552, 63, 15605, 51, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 15097, 17488, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 51, 63, 8285, 63, 25797, 879, 22800, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 51, 63, 8285, 63, 2711, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 428, 4427, 63, 3243, 17488, 63, 20857, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 428, 4427, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 199, 9, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 992, 492, 22881, 20405, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 1208, 492, 334, 272, 2518, 63, 1065, 63, 1612, 63, 509, 63, 6815, 12, 272, 2518, 63, 18401, 63, 509, 63, 6815, 12, 272, 1218, 63, 7959, 63, 1246, 63, 1258, 12, 272, 7666, 63, 6815, 63, 466, 199, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 14552, 1414, 1202, 370, 2581, 2240, 666, 14, 339, 961, 1414, 4145, 4036, 2808, 2240, 687, 314, 13172, 272, 2435, 12, 3575, 1924, 370, 2399, 5705, 2581, 2397, 543, 376, 315, 23442, 15399, 14, 272, 2779, 365, 18329, 370, 506, 1255, 641, 282, 18416, 5597, 436, 1077, 506, 314, 1454, 1233, 272, 12928, 3520, 2581, 4811, 14, 272, 408, 272, 1720, 275, 298, 497, 1506, 314, 27540, 7, 2581, 402, 2240, 666, 2122, 339, 327, 4287, 26, 3507, 29, 2975, 13, 908, 13, 875, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 5988, 275, 756, 267, 2512, 14, 815, 360, 13817, 13, 3029, 4647, 13, 28464, 6258, 365, 5258, 358, 398, 10594, 63, 15092, 275, 22881, 20405, 14, 1818, 342, 267, 3434, 275, 10594, 63, 15092, 14, 1364, 63, 2473, 398, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 2473, 9, 267, 871, 2876, 14, 7400, 26, 288, 2512, 14, 1971, 8, 355, 399, 7, 4276, 370, 1218, 3261, 1890, 14, 7591, 922, 469, 2473, 93, 1630, 440, 2187, 17374, 908, 8, 2473, 29, 2473, 9, 288, 776, 288, 746, 398, 18572, 275, 1052, 267, 931, 2885, 275, 1052, 267, 13588, 275, 1052, 267, 10594, 63, 11653, 275, 1052, 267, 18572, 63, 991, 63, 466, 275, 1052, 267, 20765, 12270, 275, 1052, 267, 367, 4770, 315, 11666, 14, 1462, 14, 452, 837, 288, 4770, 63, 888, 275, 2519, 8, 2124, 12, 283, 4758, 297, 488, 9, 288, 340, 4770, 63, 888, 365, 488, 503, 440, 4770, 63, 888, 14, 362, 63, 585, 360, 15552, 63, 11206, 23622, 63, 3735, 63, 2632, 735, 355, 2512, 14, 815, 8, 85, 7, 18297, 4770, 469, 2261, 5565, 3091, 2897, 17374, 908, 8, 2261, 29, 2124, 14, 2261, 430, 355, 2581, 14, 409, 8, 7917, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 990, 488, 9, 355, 2581, 14, 409, 8, 7917, 63, 3243, 17488, 63, 20857, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 990, 488, 9, 355, 1980, 953, 1890, 275, 1218, 63, 7959, 63, 1246, 63, 1258, 8, 751, 12, 4770, 29, 2124, 9, 288, 26650, 12, 2240, 63, 18401, 63, 4892, 275, 291, 14, 362, 63, 2124, 63, 6815, 63, 18401, 8, 1258, 12, 4770, 9, 288, 892, 63, 28464, 12, 2240, 63, 5087, 63, 4892, 275, 291, 14, 3535, 63, 6815, 63, 5087, 8, 1258, 12, 26650, 9, 288, 892, 63, 515, 2885, 12, 931, 2885, 63, 4892, 275, 291, 14, 362, 63, 515, 2885, 8, 1258, 12, 4770, 9, 288, 892, 63, 515, 2885, 12, 892, 63, 28464, 12, 931, 3316, 63, 6338, 63, 4892, 275, 291, 14, 1412, 63, 515, 2885, 8, 355, 4770, 12, 892, 63, 515, 2885, 12, 892, 63, 28464, 288, 776, 953, 5988, 275, 1263, 779, 355, 2240, 63, 18401, 63, 4892, 12, 355, 2240, 63, 5087, 63, 4892, 12, 355, 931, 2885, 63, 4892, 12, 355, 931, 3316, 63, 6338, 63, 4892, 12, 288, 4794, 953, 18572, 14, 873, 8, 1222, 63, 28464, 9, 288, 931, 2885, 14, 873, 8, 1222, 63, 515, 2885, 9, 288, 13588, 14, 873, 8, 277, 14, 362, 63, 11653, 8, 1222, 63, 28464, 430, 288, 10594, 63, 11653, 14, 873, 8, 277, 14, 362, 63, 7959, 63, 11653, 8, 1222, 63, 28464, 430, 288, 18572, 63, 991, 63, 466, 14, 873, 8, 277, 14, 362, 63, 28464, 63, 991, 63, 466, 8, 2124, 12, 892, 63, 28464, 430, 288, 20765, 12270, 14, 873, 8, 277, 14, 362, 63, 28464, 63, 991, 63, 9071, 8, 1222, 63, 28464, 430, 953, 2512, 14, 815, 8, 85, 7, 35, 23302, 11134, 83, 367, 469, 2923, 93, 18572, 367, 4770, 469, 2124, 63, 354, 5565, 1370, 908, 8, 355, 3141, 29, 552, 8, 18401, 395, 355, 4770, 63, 354, 29, 2124, 14, 2261, 12, 288, 5082, 288, 2581, 14, 409, 8, 7917, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 26650, 12, 488, 9, 953, 931, 3316, 63, 1580, 275, 769, 8, 1222, 63, 515, 2885, 14, 1612, 1012, 288, 2512, 14, 815, 8, 85, 7, 35, 23302, 2762, 367, 469 ]
[ 341, 14552, 1414, 370, 1050, 2240, 2556, 370, 314, 2581, 1041, 421, 199, 646, 2050, 199, 646, 984, 199, 504, 5055, 492, 10018, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 8110, 492, 22239, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 1637, 492, 334, 272, 5099, 14302, 63, 15605, 51, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 445, 619, 23622, 63, 15552, 63, 15605, 51, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 15097, 17488, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 51, 63, 8285, 63, 25797, 879, 22800, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 3611, 10896, 51, 63, 8285, 63, 2711, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 428, 4427, 63, 3243, 17488, 63, 20857, 63, 8677, 63, 3078, 63, 52, 2749, 12, 272, 428, 4427, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 199, 9, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 992, 492, 22881, 20405, 199, 504, 22709, 14, 1018, 14, 16432, 14, 7959, 14, 1208, 492, 334, 272, 2518, 63, 1065, 63, 1612, 63, 509, 63, 6815, 12, 272, 2518, 63, 18401, 63, 509, 63, 6815, 12, 272, 1218, 63, 7959, 63, 1246, 63, 1258, 12, 272, 7666, 63, 6815, 63, 466, 199, 9, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 14552, 1414, 1202, 370, 2581, 2240, 666, 14, 339, 961, 1414, 4145, 4036, 2808, 2240, 687, 314, 13172, 272, 2435, 12, 3575, 1924, 370, 2399, 5705, 2581, 2397, 543, 376, 315, 23442, 15399, 14, 272, 2779, 365, 18329, 370, 506, 1255, 641, 282, 18416, 5597, 436, 1077, 506, 314, 1454, 1233, 272, 12928, 3520, 2581, 4811, 14, 272, 408, 272, 1720, 275, 298, 497, 1506, 314, 27540, 7, 2581, 402, 2240, 666, 2122, 339, 327, 4287, 26, 3507, 29, 2975, 13, 908, 13, 875, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 5988, 275, 756, 267, 2512, 14, 815, 360, 13817, 13, 3029, 4647, 13, 28464, 6258, 365, 5258, 358, 398, 10594, 63, 15092, 275, 22881, 20405, 14, 1818, 342, 267, 3434, 275, 10594, 63, 15092, 14, 1364, 63, 2473, 398, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 2473, 9, 267, 871, 2876, 14, 7400, 26, 288, 2512, 14, 1971, 8, 355, 399, 7, 4276, 370, 1218, 3261, 1890, 14, 7591, 922, 469, 2473, 93, 1630, 440, 2187, 17374, 908, 8, 2473, 29, 2473, 9, 288, 776, 288, 746, 398, 18572, 275, 1052, 267, 931, 2885, 275, 1052, 267, 13588, 275, 1052, 267, 10594, 63, 11653, 275, 1052, 267, 18572, 63, 991, 63, 466, 275, 1052, 267, 20765, 12270, 275, 1052, 267, 367, 4770, 315, 11666, 14, 1462, 14, 452, 837, 288, 4770, 63, 888, 275, 2519, 8, 2124, 12, 283, 4758, 297, 488, 9, 288, 340, 4770, 63, 888, 365, 488, 503, 440, 4770, 63, 888, 14, 362, 63, 585, 360, 15552, 63, 11206, 23622, 63, 3735, 63, 2632, 735, 355, 2512, 14, 815, 8, 85, 7, 18297, 4770, 469, 2261, 5565, 3091, 2897, 17374, 908, 8, 2261, 29, 2124, 14, 2261, 430, 355, 2581, 14, 409, 8, 7917, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 990, 488, 9, 355, 2581, 14, 409, 8, 7917, 63, 3243, 17488, 63, 20857, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 990, 488, 9, 355, 1980, 953, 1890, 275, 1218, 63, 7959, 63, 1246, 63, 1258, 8, 751, 12, 4770, 29, 2124, 9, 288, 26650, 12, 2240, 63, 18401, 63, 4892, 275, 291, 14, 362, 63, 2124, 63, 6815, 63, 18401, 8, 1258, 12, 4770, 9, 288, 892, 63, 28464, 12, 2240, 63, 5087, 63, 4892, 275, 291, 14, 3535, 63, 6815, 63, 5087, 8, 1258, 12, 26650, 9, 288, 892, 63, 515, 2885, 12, 931, 2885, 63, 4892, 275, 291, 14, 362, 63, 515, 2885, 8, 1258, 12, 4770, 9, 288, 892, 63, 515, 2885, 12, 892, 63, 28464, 12, 931, 3316, 63, 6338, 63, 4892, 275, 291, 14, 1412, 63, 515, 2885, 8, 355, 4770, 12, 892, 63, 515, 2885, 12, 892, 63, 28464, 288, 776, 953, 5988, 275, 1263, 779, 355, 2240, 63, 18401, 63, 4892, 12, 355, 2240, 63, 5087, 63, 4892, 12, 355, 931, 2885, 63, 4892, 12, 355, 931, 3316, 63, 6338, 63, 4892, 12, 288, 4794, 953, 18572, 14, 873, 8, 1222, 63, 28464, 9, 288, 931, 2885, 14, 873, 8, 1222, 63, 515, 2885, 9, 288, 13588, 14, 873, 8, 277, 14, 362, 63, 11653, 8, 1222, 63, 28464, 430, 288, 10594, 63, 11653, 14, 873, 8, 277, 14, 362, 63, 7959, 63, 11653, 8, 1222, 63, 28464, 430, 288, 18572, 63, 991, 63, 466, 14, 873, 8, 277, 14, 362, 63, 28464, 63, 991, 63, 466, 8, 2124, 12, 892, 63, 28464, 430, 288, 20765, 12270, 14, 873, 8, 277, 14, 362, 63, 28464, 63, 991, 63, 9071, 8, 1222, 63, 28464, 430, 953, 2512, 14, 815, 8, 85, 7, 35, 23302, 11134, 83, 367, 469, 2923, 93, 18572, 367, 4770, 469, 2124, 63, 354, 5565, 1370, 908, 8, 355, 3141, 29, 552, 8, 18401, 395, 355, 4770, 63, 354, 29, 2124, 14, 2261, 12, 288, 5082, 288, 2581, 14, 409, 8, 7917, 63, 15605, 63, 8757, 51, 63, 8677, 63, 3078, 63, 52, 2749, 14, 908, 8, 2261, 29, 2124, 14, 2261, 395, 26650, 12, 488, 9, 953, 931, 3316, 63, 1580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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Echelon9/vulk
vulk/tests/math/bak_vector.py
2
1975
from vulk.math.vector import Vector2 from vulk.math.vector import Vector3 def test_init(): assert len(Vector2(0, 0)) == 2 assert len(Vector3(0, 0, 0)) == 3 def test_equals(): assert Vector3(1, 2, 3) == Vector3(1, 2, 3) assert Vector2(4, 5) == Vector2(4, 5) def test_iter(): vector = Vector3(1, 2, 3) for t in zip(vector, [1, 2, 3]): assert t[0] == t[1] vector = Vector2(1, 2) for t in zip(vector, [1, 2]): assert t[0] == t[1] def test_operations_vector3(): # Add assert Vector3(1, 2, 3) + 2 == Vector3(3, 4, 5) assert Vector3(1, 2, 3) + (3, 2, 1) == Vector3(4, 4, 4) assert Vector3(1, 2, 3) + Vector3(3, 2, 1) == Vector3(4, 4, 4) # Sub assert Vector3(1, 2, 3) - 2 == Vector3(-1, 0, 1) assert Vector3(1, 2, 3) - (3, 2, 1) == Vector3(-2, 0, 2) assert Vector3(1, 2, 3) - Vector3(3, 2, 1) == Vector3(-2, 0, 2) # Mul assert Vector3(1, 2, 3) * 2 == Vector3(2, 4, 6) assert Vector3(1, 2, 3) * (3, 2, 1) == Vector3(3, 4, 3) assert Vector3(1, 2, 3) * Vector3(3, 2, 1) == Vector3(3, 4, 3) # Div assert Vector3(0, 2, 4) / 2 == Vector3(0, 1, 2) assert Vector3(0, 2, 4) / (3, 2, 1) == Vector3(0, 1, 4) assert Vector3(0, 2, 4) / Vector3(3, 2, 1) == Vector3(0, 1, 4) def test_operations_vector2(): # Add assert Vector2(1, 2) + 2 == Vector2(3, 4) assert Vector2(1, 2) + (3, 2) == Vector2(4, 4) assert Vector2(1, 2) + Vector2(3, 2) == Vector2(4, 4) # Sub assert Vector2(1, 2) - 2 == Vector2(-1, 0) assert Vector2(1, 2) - (3, 2) == Vector2(-2, 0) assert Vector2(1, 2) - Vector2(3, 2) == Vector2(-2, 0) # Mul assert Vector2(1, 2) * 2 == Vector2(2, 4) assert Vector2(1, 2) * (3, 2) == Vector2(3, 4) assert Vector2(1, 2) * Vector2(3, 2) == Vector2(3, 4) # Div assert Vector2(0, 2) / 2 == Vector2(0, 1) assert Vector2(0, 2) / (3, 2) == Vector2(0, 1) assert Vector2(0, 2) / Vector2(3, 2) == Vector2(0, 1)
apache-2.0
[ 504, 373, 6368, 14, 3442, 14, 4106, 492, 11388, 18, 199, 504, 373, 6368, 14, 3442, 14, 4106, 492, 11388, 19, 421, 199, 318, 511, 63, 826, 837, 272, 702, 822, 8, 3646, 18, 8, 16, 12, 378, 430, 508, 499, 272, 702, 822, 8, 3646, 19, 8, 16, 12, 378, 12, 378, 430, 508, 650, 421, 199, 318, 511, 63, 11332, 837, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 508, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 272, 702, 11388, 18, 8, 20, 12, 959, 9, 508, 11388, 18, 8, 20, 12, 959, 9, 421, 199, 318, 511, 63, 1661, 837, 272, 5477, 275, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 272, 367, 307, 315, 3482, 8, 4106, 12, 359, 17, 12, 499, 12, 650, 4682, 267, 702, 307, 59, 16, 61, 508, 307, 59, 17, 61, 339, 5477, 275, 11388, 18, 8, 17, 12, 499, 9, 272, 367, 307, 315, 3482, 8, 4106, 12, 359, 17, 12, 499, 4682, 267, 702, 307, 59, 16, 61, 508, 307, 59, 17, 61, 421, 199, 318, 511, 63, 8170, 63, 4106, 19, 837, 272, 327, 2654, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 499, 508, 11388, 19, 8, 19, 12, 841, 12, 959, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 20, 12, 841, 12, 841, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 20, 12, 841, 12, 841, 9, 339, 327, 4804, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 499, 508, 11388, 19, 2801, 17, 12, 378, 12, 413, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 2801, 18, 12, 378, 12, 499, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 2801, 18, 12, 378, 12, 499, 9, 339, 327, 22578, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 499, 508, 11388, 19, 8, 18, 12, 841, 12, 1227, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 19, 12, 841, 12, 650, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 19, 12, 841, 12, 650, 9, 339, 327, 32077, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 499, 508, 11388, 19, 8, 16, 12, 413, 12, 499, 9, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 16, 12, 413, 12, 841, 9, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 16, 12, 413, 12, 841, 9, 421, 199, 318, 511, 63, 8170, 63, 4106, 18, 837, 272, 327, 2654, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 499, 508, 11388, 18, 8, 19, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 20, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 20, 12, 841, 9, 339, 327, 4804, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 499, 508, 11388, 18, 2801, 17, 12, 378, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 334, 19, 12, 499, 9, 508, 11388, 18, 2801, 18, 12, 378, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 2801, 18, 12, 378, 9, 339, 327, 22578, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 499, 508, 11388, 18, 8, 18, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 19, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 19, 12, 841, 9, 339, 327, 32077, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 499, 508, 11388, 18, 8, 16, 12, 413, 9, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 16, 12, 413, 9, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 16, 12, 413, 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 ]
[ 373, 6368, 14, 3442, 14, 4106, 492, 11388, 18, 199, 504, 373, 6368, 14, 3442, 14, 4106, 492, 11388, 19, 421, 199, 318, 511, 63, 826, 837, 272, 702, 822, 8, 3646, 18, 8, 16, 12, 378, 430, 508, 499, 272, 702, 822, 8, 3646, 19, 8, 16, 12, 378, 12, 378, 430, 508, 650, 421, 199, 318, 511, 63, 11332, 837, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 508, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 272, 702, 11388, 18, 8, 20, 12, 959, 9, 508, 11388, 18, 8, 20, 12, 959, 9, 421, 199, 318, 511, 63, 1661, 837, 272, 5477, 275, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 272, 367, 307, 315, 3482, 8, 4106, 12, 359, 17, 12, 499, 12, 650, 4682, 267, 702, 307, 59, 16, 61, 508, 307, 59, 17, 61, 339, 5477, 275, 11388, 18, 8, 17, 12, 499, 9, 272, 367, 307, 315, 3482, 8, 4106, 12, 359, 17, 12, 499, 4682, 267, 702, 307, 59, 16, 61, 508, 307, 59, 17, 61, 421, 199, 318, 511, 63, 8170, 63, 4106, 19, 837, 272, 327, 2654, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 499, 508, 11388, 19, 8, 19, 12, 841, 12, 959, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 20, 12, 841, 12, 841, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 435, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 20, 12, 841, 12, 841, 9, 339, 327, 4804, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 499, 508, 11388, 19, 2801, 17, 12, 378, 12, 413, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 2801, 18, 12, 378, 12, 499, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 446, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 2801, 18, 12, 378, 12, 499, 9, 339, 327, 22578, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 499, 508, 11388, 19, 8, 18, 12, 841, 12, 1227, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 19, 12, 841, 12, 650, 9, 272, 702, 11388, 19, 8, 17, 12, 499, 12, 650, 9, 627, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 19, 12, 841, 12, 650, 9, 339, 327, 32077, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 499, 508, 11388, 19, 8, 16, 12, 413, 12, 499, 9, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 334, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 16, 12, 413, 12, 841, 9, 272, 702, 11388, 19, 8, 16, 12, 499, 12, 841, 9, 1182, 11388, 19, 8, 19, 12, 499, 12, 413, 9, 508, 11388, 19, 8, 16, 12, 413, 12, 841, 9, 421, 199, 318, 511, 63, 8170, 63, 4106, 18, 837, 272, 327, 2654, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 499, 508, 11388, 18, 8, 19, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 20, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 435, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 20, 12, 841, 9, 339, 327, 4804, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 499, 508, 11388, 18, 2801, 17, 12, 378, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 334, 19, 12, 499, 9, 508, 11388, 18, 2801, 18, 12, 378, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 446, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 2801, 18, 12, 378, 9, 339, 327, 22578, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 499, 508, 11388, 18, 8, 18, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 19, 12, 841, 9, 272, 702, 11388, 18, 8, 17, 12, 499, 9, 627, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 19, 12, 841, 9, 339, 327, 32077, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 499, 508, 11388, 18, 8, 16, 12, 413, 9, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 334, 19, 12, 499, 9, 508, 11388, 18, 8, 16, 12, 413, 9, 272, 702, 11388, 18, 8, 16, 12, 499, 9, 1182, 11388, 18, 8, 19, 12, 499, 9, 508, 11388, 18, 8, 16, 12, 413, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
adrienbrault/home-assistant
tests/components/group/common.py
15
1784
"""Collection of helper methods. All containing methods are legacy helpers that should not be used by new components. Instead call the service directly. """ from homeassistant.components.group import ( ATTR_ADD_ENTITIES, ATTR_ENTITIES, ATTR_OBJECT_ID, DOMAIN, SERVICE_REMOVE, SERVICE_SET, ) from homeassistant.const import ATTR_ICON, ATTR_NAME, SERVICE_RELOAD from homeassistant.core import callback from homeassistant.loader import bind_hass @bind_hass def reload(hass): """Reload the automation from config.""" hass.add_job(async_reload, hass) @callback @bind_hass def async_reload(hass): """Reload the automation from config.""" hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_RELOAD)) @bind_hass def set_group( hass, object_id, name=None, entity_ids=None, icon=None, add=None, ): """Create/Update a group.""" hass.add_job( async_set_group, hass, object_id, name, entity_ids, icon, add, ) @callback @bind_hass def async_set_group( hass, object_id, name=None, entity_ids=None, icon=None, add=None, ): """Create/Update a group.""" data = { key: value for key, value in [ (ATTR_OBJECT_ID, object_id), (ATTR_NAME, name), (ATTR_ENTITIES, entity_ids), (ATTR_ICON, icon), (ATTR_ADD_ENTITIES, add), ] if value is not None } hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_SET, data)) @callback @bind_hass def async_remove(hass, object_id): """Remove a user group.""" data = {ATTR_OBJECT_ID: object_id} hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_REMOVE, data))
mit
[ 624, 7768, 402, 5922, 3102, 14, 199, 199, 2422, 3035, 3102, 787, 12139, 10897, 626, 1077, 440, 506, 1202, 701, 892, 199, 4608, 14, 15345, 1240, 314, 2435, 5370, 14, 199, 624, 199, 504, 8846, 14, 4608, 14, 923, 492, 334, 272, 10762, 63, 9732, 63, 1309, 19144, 12, 272, 10762, 63, 1309, 19144, 12, 272, 10762, 63, 9868, 63, 998, 12, 272, 15265, 12, 272, 16655, 63, 25856, 12, 272, 16655, 63, 3597, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 10762, 63, 15903, 12, 10762, 63, 2339, 12, 16655, 63, 907, 7405, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 3422, 492, 5398, 63, 5387, 421, 199, 32, 3409, 63, 5387, 199, 318, 13101, 8, 5387, 304, 272, 408, 30590, 314, 25461, 687, 1101, 1041, 272, 6298, 14, 525, 63, 2423, 8, 4146, 63, 9233, 12, 6298, 9, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 9233, 8, 5387, 304, 272, 408, 30590, 314, 25461, 687, 1101, 1041, 272, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 907, 7405, 430, 421, 199, 32, 3409, 63, 5387, 199, 318, 663, 63, 923, 8, 272, 6298, 12, 272, 909, 63, 344, 12, 272, 536, 29, 403, 12, 272, 4642, 63, 1580, 29, 403, 12, 272, 7016, 29, 403, 12, 272, 1050, 29, 403, 12, 199, 304, 272, 408, 2499, 15, 4152, 282, 1572, 1041, 272, 6298, 14, 525, 63, 2423, 8, 267, 5316, 63, 409, 63, 923, 12, 267, 6298, 12, 267, 909, 63, 344, 12, 267, 536, 12, 267, 4642, 63, 1580, 12, 267, 7016, 12, 267, 1050, 12, 272, 776, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 409, 63, 923, 8, 272, 6298, 12, 272, 909, 63, 344, 12, 272, 536, 29, 403, 12, 272, 4642, 63, 1580, 29, 403, 12, 272, 7016, 29, 403, 12, 272, 1050, 29, 403, 12, 199, 304, 272, 408, 2499, 15, 4152, 282, 1572, 1041, 272, 666, 275, 469, 267, 790, 26, 574, 267, 367, 790, 12, 574, 315, 359, 288, 334, 5280, 63, 9868, 63, 998, 12, 909, 63, 344, 395, 288, 334, 5280, 63, 2339, 12, 536, 395, 288, 334, 5280, 63, 1309, 19144, 12, 4642, 63, 1580, 395, 288, 334, 5280, 63, 15903, 12, 7016, 395, 288, 334, 5280, 63, 9732, 63, 1309, 19144, 12, 1050, 395, 267, 1622, 267, 340, 574, 365, 440, 488, 272, 789, 339, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 3597, 12, 666, 430, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 2168, 8, 5387, 12, 909, 63, 344, 304, 272, 408, 5587, 282, 922, 1572, 1041, 272, 666, 275, 469, 5280, 63, 9868, 63, 998, 26, 909, 63, 344, 93, 272, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 25856, 12, 666, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7768, 402, 5922, 3102, 14, 199, 199, 2422, 3035, 3102, 787, 12139, 10897, 626, 1077, 440, 506, 1202, 701, 892, 199, 4608, 14, 15345, 1240, 314, 2435, 5370, 14, 199, 624, 199, 504, 8846, 14, 4608, 14, 923, 492, 334, 272, 10762, 63, 9732, 63, 1309, 19144, 12, 272, 10762, 63, 1309, 19144, 12, 272, 10762, 63, 9868, 63, 998, 12, 272, 15265, 12, 272, 16655, 63, 25856, 12, 272, 16655, 63, 3597, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 10762, 63, 15903, 12, 10762, 63, 2339, 12, 16655, 63, 907, 7405, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 3422, 492, 5398, 63, 5387, 421, 199, 32, 3409, 63, 5387, 199, 318, 13101, 8, 5387, 304, 272, 408, 30590, 314, 25461, 687, 1101, 1041, 272, 6298, 14, 525, 63, 2423, 8, 4146, 63, 9233, 12, 6298, 9, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 9233, 8, 5387, 304, 272, 408, 30590, 314, 25461, 687, 1101, 1041, 272, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 907, 7405, 430, 421, 199, 32, 3409, 63, 5387, 199, 318, 663, 63, 923, 8, 272, 6298, 12, 272, 909, 63, 344, 12, 272, 536, 29, 403, 12, 272, 4642, 63, 1580, 29, 403, 12, 272, 7016, 29, 403, 12, 272, 1050, 29, 403, 12, 199, 304, 272, 408, 2499, 15, 4152, 282, 1572, 1041, 272, 6298, 14, 525, 63, 2423, 8, 267, 5316, 63, 409, 63, 923, 12, 267, 6298, 12, 267, 909, 63, 344, 12, 267, 536, 12, 267, 4642, 63, 1580, 12, 267, 7016, 12, 267, 1050, 12, 272, 776, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 409, 63, 923, 8, 272, 6298, 12, 272, 909, 63, 344, 12, 272, 536, 29, 403, 12, 272, 4642, 63, 1580, 29, 403, 12, 272, 7016, 29, 403, 12, 272, 1050, 29, 403, 12, 199, 304, 272, 408, 2499, 15, 4152, 282, 1572, 1041, 272, 666, 275, 469, 267, 790, 26, 574, 267, 367, 790, 12, 574, 315, 359, 288, 334, 5280, 63, 9868, 63, 998, 12, 909, 63, 344, 395, 288, 334, 5280, 63, 2339, 12, 536, 395, 288, 334, 5280, 63, 1309, 19144, 12, 4642, 63, 1580, 395, 288, 334, 5280, 63, 15903, 12, 7016, 395, 288, 334, 5280, 63, 9732, 63, 1309, 19144, 12, 1050, 395, 267, 1622, 267, 340, 574, 365, 440, 488, 272, 789, 339, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 3597, 12, 666, 430, 421, 199, 32, 3058, 199, 32, 3409, 63, 5387, 199, 318, 5316, 63, 2168, 8, 5387, 12, 909, 63, 344, 304, 272, 408, 5587, 282, 922, 1572, 1041, 272, 666, 275, 469, 5280, 63, 9868, 63, 998, 26, 909, 63, 344, 93, 272, 6298, 14, 4146, 63, 525, 63, 2423, 8, 5387, 14, 5950, 14, 4146, 63, 1250, 8, 7378, 12, 16655, 63, 25856, 12, 666, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NICTA/dora
dora/active_sampling/delaunay_sampler.py
1
4870
""" Delaunay Sampler Module. Provides the Delaunay Sampler Class which contains the strategies for active sampling a spatial field """ from dora.active_sampling.base_sampler import Sampler, grid_sample import numpy as np from scipy.spatial import Delaunay as ScipyDelaunay class Delaunay(Sampler): """ Delaunay Class. Inherits from the Sampler class and augments pick and update with the mechanics of the Delanauy triangulation method Attributes ---------- triangulation : scipy.spatial.qhull.Delaunay The Delaunay triangulation model object simplex_cache : dict Cached values of simplices for Delaunay triangulation explore_priority : float The priority of exploration against exploitation See Also -------- Sampler : Base Class """ name = 'Delaunay' def __init__(self, lower, upper, explore_priority=0.0001): """ Initialise the Delaunay class. .. note :: Currently only supports rectangular type restrictions on the parameter space Parameters ---------- lower : array_like Lower or minimum bounds for the parameter space upper : array_like Upper or maximum bounds for the parameter space explore_priority : float, optional The priority of exploration against exploitation """ Sampler.__init__(self, lower, upper) self.triangulation = None # Delaunay model self.simplex_cache = {} # Pre-computed values of simplices self.explore_priority = explore_priority def update(self, uid, y_true): """ Update a job with its observed value. Parameters ---------- uid : str A hexadecimal ID that identifies the job to be updated y_true : float The observed value corresponding to the job identified by 'uid' Returns ------- int Index location in the data lists 'Delaunay.X' and 'Delaunay.y' corresponding to the job being updated """ return self._update(uid, y_true) def pick(self): """ Pick the next feature location for the next observation to be taken. This uses the recursive Delaunay subdivision algorithm. Returns ------- numpy.ndarray Location in the parameter space for the next observation to be taken str A random hexadecimal ID to identify the corresponding job """ n = len(self.X) # -- note that we are assuming the points in X are not reordered by # the scipy Delaunay implementation n_corners = 2 ** self.dims if n < n_corners + 1: # Bootstrap with a regular sampling strategy to get it started xq = grid_sample(self.lower, self.upper, n) yq_exp = [0.] else: X = self.X() # calling returns the value as an array y = self.y() virtual = self.virtual_flag() # Otherwise, recursive subdivide the edges with the Delaunay model if not self.triangulation: self.triangulation = ScipyDelaunay(X, incremental=True) # Weight by hyper-volume simplices = [tuple(s) for s in self.triangulation.vertices] cache = self.simplex_cache def get_value(s): # Computes the sample value as: # hyper-volume of simplex * variance of values in simplex ind = list(s) value = (np.var(y[ind]) + self.explore_priority) * \ np.linalg.det((X[ind] - X[ind[0]])[1:]) if not np.max(virtual[ind]): cache[s] = value return value # Mostly the simplices won't change from call to call - cache! sample_value = [cache[s] if s in cache else get_value(s) for s in simplices] # alternatively, a nicely vectorised computation might work here # profile and check what the bottleneck is # Extract the points in the highest value simplex simplex_indices = list(simplices[np.argmax(sample_value)]) simplex = X[simplex_indices] simplex_v = y[simplex_indices] # Weight the position in this simplex based on value deviation eps = 1e-3 weight = eps + np.abs(simplex_v - np.mean(simplex_v)) weight /= np.sum(weight) xq = np.sum(weight * simplex, axis=0) # dot yq_exp = np.sum(weight * simplex_v, axis=0) self.triangulation.add_points(xq[np.newaxis, :]) # incremental uid = Sampler._assign(self, xq, yq_exp) return xq, uid
apache-2.0
[ 624, 199, 6994, 65, 324, 1187, 15227, 82, 5673, 14, 199, 199, 17473, 314, 18464, 65, 324, 1187, 15227, 82, 8089, 1314, 3509, 314, 32647, 367, 199, 2682, 15877, 282, 11469, 901, 199, 624, 199, 504, 366, 11131, 14, 2682, 63, 17376, 14, 1095, 63, 22934, 492, 15227, 82, 12, 6068, 63, 3271, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 7026, 14, 11679, 492, 18464, 65, 324, 1187, 465, 16578, 647, 6994, 65, 324, 1187, 421, 199, 533, 18464, 65, 324, 1187, 8, 27434, 304, 272, 408, 272, 18464, 65, 324, 1187, 8089, 14, 339, 1010, 13923, 687, 314, 15227, 82, 1021, 436, 18336, 1470, 3732, 436, 1678, 543, 314, 272, 562, 11984, 2932, 402, 314, 18464, 290, 3844, 89, 3229, 621, 5332, 1083, 339, 9382, 272, 4143, 272, 3229, 621, 5332, 520, 7026, 14, 11679, 14, 81, 72, 979, 14, 6994, 65, 324, 1187, 267, 710, 18464, 65, 324, 1187, 3229, 621, 5332, 1402, 909, 272, 3486, 88, 63, 1637, 520, 1211, 267, 445, 4583, 1338, 402, 6414, 7598, 367, 18464, 65, 324, 1187, 3229, 621, 5332, 272, 15868, 264, 63, 6693, 520, 2069, 267, 710, 7464, 402, 31337, 6169, 15868, 5314, 339, 1666, 6121, 272, 3001, 272, 15227, 82, 520, 3523, 8089, 272, 408, 339, 536, 275, 283, 6994, 65, 324, 1187, 7, 339, 347, 636, 826, 721, 277, 12, 5117, 12, 7008, 12, 15868, 264, 63, 6693, 29, 16, 14, 4183, 304, 267, 408, 267, 6026, 572, 314, 18464, 65, 324, 1187, 1021, 14, 398, 2508, 5317, 3800, 953, 13550, 1454, 5171, 8626, 11572, 730, 24488, 641, 314, 288, 2725, 4601, 398, 3897, 267, 4143, 267, 5117, 520, 1625, 63, 2930, 288, 29893, 503, 7481, 10461, 367, 314, 2725, 4601, 267, 7008, 520, 1625, 63, 2930, 288, 4949, 529, 503, 5696, 10461, 367, 314, 2725, 4601, 267, 15868, 264, 63, 6693, 520, 2069, 12, 2716, 288, 710, 7464, 402, 31337, 6169, 15868, 5314, 267, 408, 267, 15227, 82, 855, 826, 721, 277, 12, 5117, 12, 7008, 9, 267, 291, 14, 599, 621, 5332, 275, 488, 221, 327, 18464, 65, 324, 1187, 1402, 267, 291, 14, 4129, 88, 63, 1637, 275, 1052, 221, 327, 5543, 13, 14378, 1338, 402, 6414, 7598, 267, 291, 14, 16971, 264, 63, 6693, 275, 15868, 264, 63, 6693, 339, 347, 1678, 8, 277, 12, 1747, 12, 612, 63, 2052, 304, 267, 408, 267, 6162, 282, 3906, 543, 2399, 20802, 574, 14, 398, 3897, 267, 4143, 267, 1747, 520, 620, 288, 437, 20379, 2870, 626, 22975, 314, 3906, 370, 506, 4588, 267, 612, 63, 2052, 520, 2069, 288, 710, 20802, 574, 5226, 370, 314, 3906, 15836, 701, 283, 1535, 7, 398, 1803, 267, 5514, 267, 1109, 288, 5499, 2909, 315, 314, 666, 5548, 283, 6994, 65, 324, 1187, 14, 56, 7, 436, 288, 283, 6994, 65, 324, 1187, 14, 89, 7, 5226, 370, 314, 3906, 3769, 4588, 267, 408, 267, 372, 291, 423, 873, 8, 1535, 12, 612, 63, 2052, 9, 339, 347, 3732, 8, 277, 304, 267, 408, 267, 16568, 314, 2163, 3878, 2909, 367, 314, 2163, 20038, 370, 506, 9394, 14, 398, 961, 4440, 314, 9133, 18464, 65, 324, 1187, 1007, 25035, 5563, 14, 398, 1803, 267, 5514, 267, 2680, 14, 8237, 288, 12625, 315, 314, 2725, 4601, 367, 314, 2163, 20038, 370, 506, 288, 9394, 267, 620, 288, 437, 2196, 20379, 2870, 370, 10405, 314, 5226, 3906, 267, 408, 267, 302, 275, 822, 8, 277, 14, 56, 9, 398, 327, 1553, 5317, 626, 781, 787, 18002, 314, 4501, 315, 1323, 787, 440, 295, 8235, 701, 267, 327, 314, 7026, 18464, 65, 324, 1187, 4514, 398, 302, 63, 30652, 275, 499, 1011, 291, 14, 5380, 267, 340, 302, 665, 302, 63, 30652, 435, 413, 26, 953, 327, 27324, 7868, 543, 282, 5578, 15877, 10054, 370, 664, 652, 8239, 288, 671, 81, 275, 6068, 63, 3271, 8, 277, 14, 2325, 12, 291, 14, 4142, 12, 302, 9, 288, 612, 81, 63, 1474, 275, 359, 16, 19784, 267, 587, 26, 953, 1323, 275, 291, 14, 56, 342, 221, 327, 6358, 2529, 314, 574, 465, 376, 1625, 288, 612, 275, 291, 14, 89, 342, 288, 5791, 275, 291, 14, 2065, 63, 4173, 342, 953, 327, 6630, 12, 9133, 1007, 16081, 314, 8207, 543, 314, 18464, 65, 324, 1187, 1402, 288, 340, 440, 291, 14, 599, 621, 5332, 26, 355, 291, 14, 599, 621, 5332, 275, 16578, 647, 6994, 65, 324, 1187, 8, 56, 12, 16316, 29, 549, 9, 953, 327, 2136, 1070, 701, 10342, 13, 2405, 288, 6414, 7598, 275, 359, 2960, 8, 83, 9, 367, 308, 315, 291, 14, 599, 621, 5332, 14, 12637, 61, 288, 2581, 275, 291, 14, 4129, 88, 63, 1637, 953, 347, 664, 63, 585, 8, 83, 304, 2234, 327, 28040, 314, 2690, 574, 465, 26, 355, 327, 257, 10342, 13, 2405, 402, 3486, 88, 627, 11773, 402, 1338, 315, 3486, 88, 355, 7654, 275, 769, 8, 83, 9, 355, 574, 275, 334, 1590, 14, 1391, 8, 89, 59, 688, 566, 435, 291, 14, 16971, 264, 63, 6693, 9, 627, 971, 490, 980, 14, 10096, 14, 9886, 1332, 56, 59, 688, 61, 446, 1323, 59, 688, 59, 16, 3934, 59, 17, 5728, 355, 340, 440, 980, 14, 988, 8, 2065, 59, 688, 4682, 490, 2581, 59, 83, 61, 275, 574, 355, 372, 574, 953, 327, 17536, 590, 314, 6414, 7598, 7859, 1133, 1570, 687, 1240, 370, 1240, 446, 2581, 1, 288, 2690, 63, 585, 275, 359, 1637, 59, 83, 61, 340, 308, 315, 2581, 587, 664, 63, 585, 8, 83, 9, 1169, 367, 308, 315, 6414, 7598, 61, 953, 327, 8679, 17330, 12, 282, 14213, 590, 5477, 9096, 14009, 5594, 1736, 2348, 288, 327, 4690, 436, 1104, 4052, 314, 5888, 27412, 365, 953, 327, 12892, 314, 4501, 315, 314, 15356, 574, 3486, 88, 288, 3486, 88, 63, 4108, 275, 769, 8, 11184, 7598, 59, 1590, 14, 16383, 8, 3271, 63, 585, 3948, 288, 3486, 88, 275, 1323, 59, 4129, 88, 63, 4108, 61, 288, 3486, 88, 63, 86, 275, 612, 59, 4129, 88, 63, 4108, 61, 953, 327, 2136, 1070, 314, 3421, 315, 642, 3486, 88, 4079, 641, 574, 18458, 288, 10245, 275, 413, 69, 13, 19, 288, 5401, 275, 10245, 435 ]
[ 199, 6994, 65, 324, 1187, 15227, 82, 5673, 14, 199, 199, 17473, 314, 18464, 65, 324, 1187, 15227, 82, 8089, 1314, 3509, 314, 32647, 367, 199, 2682, 15877, 282, 11469, 901, 199, 624, 199, 504, 366, 11131, 14, 2682, 63, 17376, 14, 1095, 63, 22934, 492, 15227, 82, 12, 6068, 63, 3271, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 7026, 14, 11679, 492, 18464, 65, 324, 1187, 465, 16578, 647, 6994, 65, 324, 1187, 421, 199, 533, 18464, 65, 324, 1187, 8, 27434, 304, 272, 408, 272, 18464, 65, 324, 1187, 8089, 14, 339, 1010, 13923, 687, 314, 15227, 82, 1021, 436, 18336, 1470, 3732, 436, 1678, 543, 314, 272, 562, 11984, 2932, 402, 314, 18464, 290, 3844, 89, 3229, 621, 5332, 1083, 339, 9382, 272, 4143, 272, 3229, 621, 5332, 520, 7026, 14, 11679, 14, 81, 72, 979, 14, 6994, 65, 324, 1187, 267, 710, 18464, 65, 324, 1187, 3229, 621, 5332, 1402, 909, 272, 3486, 88, 63, 1637, 520, 1211, 267, 445, 4583, 1338, 402, 6414, 7598, 367, 18464, 65, 324, 1187, 3229, 621, 5332, 272, 15868, 264, 63, 6693, 520, 2069, 267, 710, 7464, 402, 31337, 6169, 15868, 5314, 339, 1666, 6121, 272, 3001, 272, 15227, 82, 520, 3523, 8089, 272, 408, 339, 536, 275, 283, 6994, 65, 324, 1187, 7, 339, 347, 636, 826, 721, 277, 12, 5117, 12, 7008, 12, 15868, 264, 63, 6693, 29, 16, 14, 4183, 304, 267, 408, 267, 6026, 572, 314, 18464, 65, 324, 1187, 1021, 14, 398, 2508, 5317, 3800, 953, 13550, 1454, 5171, 8626, 11572, 730, 24488, 641, 314, 288, 2725, 4601, 398, 3897, 267, 4143, 267, 5117, 520, 1625, 63, 2930, 288, 29893, 503, 7481, 10461, 367, 314, 2725, 4601, 267, 7008, 520, 1625, 63, 2930, 288, 4949, 529, 503, 5696, 10461, 367, 314, 2725, 4601, 267, 15868, 264, 63, 6693, 520, 2069, 12, 2716, 288, 710, 7464, 402, 31337, 6169, 15868, 5314, 267, 408, 267, 15227, 82, 855, 826, 721, 277, 12, 5117, 12, 7008, 9, 267, 291, 14, 599, 621, 5332, 275, 488, 221, 327, 18464, 65, 324, 1187, 1402, 267, 291, 14, 4129, 88, 63, 1637, 275, 1052, 221, 327, 5543, 13, 14378, 1338, 402, 6414, 7598, 267, 291, 14, 16971, 264, 63, 6693, 275, 15868, 264, 63, 6693, 339, 347, 1678, 8, 277, 12, 1747, 12, 612, 63, 2052, 304, 267, 408, 267, 6162, 282, 3906, 543, 2399, 20802, 574, 14, 398, 3897, 267, 4143, 267, 1747, 520, 620, 288, 437, 20379, 2870, 626, 22975, 314, 3906, 370, 506, 4588, 267, 612, 63, 2052, 520, 2069, 288, 710, 20802, 574, 5226, 370, 314, 3906, 15836, 701, 283, 1535, 7, 398, 1803, 267, 5514, 267, 1109, 288, 5499, 2909, 315, 314, 666, 5548, 283, 6994, 65, 324, 1187, 14, 56, 7, 436, 288, 283, 6994, 65, 324, 1187, 14, 89, 7, 5226, 370, 314, 3906, 3769, 4588, 267, 408, 267, 372, 291, 423, 873, 8, 1535, 12, 612, 63, 2052, 9, 339, 347, 3732, 8, 277, 304, 267, 408, 267, 16568, 314, 2163, 3878, 2909, 367, 314, 2163, 20038, 370, 506, 9394, 14, 398, 961, 4440, 314, 9133, 18464, 65, 324, 1187, 1007, 25035, 5563, 14, 398, 1803, 267, 5514, 267, 2680, 14, 8237, 288, 12625, 315, 314, 2725, 4601, 367, 314, 2163, 20038, 370, 506, 288, 9394, 267, 620, 288, 437, 2196, 20379, 2870, 370, 10405, 314, 5226, 3906, 267, 408, 267, 302, 275, 822, 8, 277, 14, 56, 9, 398, 327, 1553, 5317, 626, 781, 787, 18002, 314, 4501, 315, 1323, 787, 440, 295, 8235, 701, 267, 327, 314, 7026, 18464, 65, 324, 1187, 4514, 398, 302, 63, 30652, 275, 499, 1011, 291, 14, 5380, 267, 340, 302, 665, 302, 63, 30652, 435, 413, 26, 953, 327, 27324, 7868, 543, 282, 5578, 15877, 10054, 370, 664, 652, 8239, 288, 671, 81, 275, 6068, 63, 3271, 8, 277, 14, 2325, 12, 291, 14, 4142, 12, 302, 9, 288, 612, 81, 63, 1474, 275, 359, 16, 19784, 267, 587, 26, 953, 1323, 275, 291, 14, 56, 342, 221, 327, 6358, 2529, 314, 574, 465, 376, 1625, 288, 612, 275, 291, 14, 89, 342, 288, 5791, 275, 291, 14, 2065, 63, 4173, 342, 953, 327, 6630, 12, 9133, 1007, 16081, 314, 8207, 543, 314, 18464, 65, 324, 1187, 1402, 288, 340, 440, 291, 14, 599, 621, 5332, 26, 355, 291, 14, 599, 621, 5332, 275, 16578, 647, 6994, 65, 324, 1187, 8, 56, 12, 16316, 29, 549, 9, 953, 327, 2136, 1070, 701, 10342, 13, 2405, 288, 6414, 7598, 275, 359, 2960, 8, 83, 9, 367, 308, 315, 291, 14, 599, 621, 5332, 14, 12637, 61, 288, 2581, 275, 291, 14, 4129, 88, 63, 1637, 953, 347, 664, 63, 585, 8, 83, 304, 2234, 327, 28040, 314, 2690, 574, 465, 26, 355, 327, 257, 10342, 13, 2405, 402, 3486, 88, 627, 11773, 402, 1338, 315, 3486, 88, 355, 7654, 275, 769, 8, 83, 9, 355, 574, 275, 334, 1590, 14, 1391, 8, 89, 59, 688, 566, 435, 291, 14, 16971, 264, 63, 6693, 9, 627, 971, 490, 980, 14, 10096, 14, 9886, 1332, 56, 59, 688, 61, 446, 1323, 59, 688, 59, 16, 3934, 59, 17, 5728, 355, 340, 440, 980, 14, 988, 8, 2065, 59, 688, 4682, 490, 2581, 59, 83, 61, 275, 574, 355, 372, 574, 953, 327, 17536, 590, 314, 6414, 7598, 7859, 1133, 1570, 687, 1240, 370, 1240, 446, 2581, 1, 288, 2690, 63, 585, 275, 359, 1637, 59, 83, 61, 340, 308, 315, 2581, 587, 664, 63, 585, 8, 83, 9, 1169, 367, 308, 315, 6414, 7598, 61, 953, 327, 8679, 17330, 12, 282, 14213, 590, 5477, 9096, 14009, 5594, 1736, 2348, 288, 327, 4690, 436, 1104, 4052, 314, 5888, 27412, 365, 953, 327, 12892, 314, 4501, 315, 314, 15356, 574, 3486, 88, 288, 3486, 88, 63, 4108, 275, 769, 8, 11184, 7598, 59, 1590, 14, 16383, 8, 3271, 63, 585, 3948, 288, 3486, 88, 275, 1323, 59, 4129, 88, 63, 4108, 61, 288, 3486, 88, 63, 86, 275, 612, 59, 4129, 88, 63, 4108, 61, 953, 327, 2136, 1070, 314, 3421, 315, 642, 3486, 88, 4079, 641, 574, 18458, 288, 10245, 275, 413, 69, 13, 19, 288, 5401, 275, 10245, 435, 0 ]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 1 ]
miptliot/edx-platform
openedx/core/djangoapps/safe_sessions/tests/test_middleware.py
15
12716
# pylint: disable=no-member # pylint: disable=protected-access """ Unit tests for SafeSessionMiddleware """ import ddt from django.conf import settings from django.contrib.auth import SESSION_KEY from django.contrib.auth.models import AnonymousUser from django.http import HttpResponse, HttpResponseRedirect, SimpleCookie from django.test import TestCase from django.test.client import RequestFactory from django.test.utils import override_settings from mock import patch from nose.plugins.attrib import attr from openedx.core.djangolib.testing.utils import get_mock_request from student.tests.factories import UserFactory from ..middleware import SafeSessionMiddleware, SafeCookieData from .test_utils import TestSafeSessionsLogMixin @attr(shard=2) class TestSafeSessionProcessRequest(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware.process_request """ def setUp(self): super(TestSafeSessionProcessRequest, self).setUp() self.user = UserFactory.create() self.request = get_mock_request() def assert_response(self, safe_cookie_data=None, success=True): """ Calls SafeSessionMiddleware.process_request and verifies the response. Arguments: safe_cookie_data - If provided, it is serialized and stored in the request's cookies. success - If True, verifies a successful response. Else, verifies a failed response with an HTTP redirect. """ if safe_cookie_data: self.request.COOKIES[settings.SESSION_COOKIE_NAME] = unicode(safe_cookie_data) response = SafeSessionMiddleware().process_request(self.request) if success: self.assertIsNone(response) self.assertIsNone(getattr(self.request, 'need_to_delete_cookie', None)) else: self.assertEquals(response.status_code, HttpResponseRedirect.status_code) self.assertTrue(self.request.need_to_delete_cookie) def assert_no_session(self): """ Asserts that a session object is *not* set on the request. """ self.assertIsNone(getattr(self.request, 'session', None)) def assert_no_user_in_session(self): """ Asserts that a user object is *not* set on the request's session. """ self.assertIsNone(self.request.session.get(SESSION_KEY)) def assert_user_in_session(self): """ Asserts that a user object *is* set on the request's session. """ self.assertEquals( SafeSessionMiddleware.get_user_id_from_session(self.request), self.user.id ) def test_success(self): self.client.login(username=self.user.username, password='test') session_id = self.client.session.session_key safe_cookie_data = SafeCookieData.create(session_id, self.user.id) # pre-verify steps 3, 4, 5 self.assertIsNone(getattr(self.request, 'session', None)) self.assertIsNone(getattr(self.request, 'safe_cookie_verified_user_id', None)) # verify step 1: safe cookie data is parsed self.assert_response(safe_cookie_data) self.assert_user_in_session() # verify step 2: cookie value is replaced with parsed session_id self.assertEquals(self.request.COOKIES[settings.SESSION_COOKIE_NAME], session_id) # verify step 3: session set in request self.assertIsNotNone(self.request.session) # verify steps 4, 5: user_id stored for later verification self.assertEquals(self.request.safe_cookie_verified_user_id, self.user.id) def test_success_no_cookies(self): self.assert_response() self.assert_no_user_in_session() def test_success_no_session(self): safe_cookie_data = SafeCookieData.create('no_such_session_id', self.user.id) self.assert_response(safe_cookie_data) self.assert_no_user_in_session() def test_success_no_session_and_user(self): safe_cookie_data = SafeCookieData.create('no_such_session_id', 'no_such_user') self.assert_response(safe_cookie_data) self.assert_no_user_in_session() def test_parse_error_at_step_1(self): with self.assert_parse_error(): self.assert_response('not-a-safe-cookie', success=False) self.assert_no_session() def test_invalid_user_at_step_4(self): self.client.login(username=self.user.username, password='test') safe_cookie_data = SafeCookieData.create(self.client.session.session_key, 'no_such_user') with self.assert_incorrect_user_logged(): self.assert_response(safe_cookie_data, success=False) self.assert_user_in_session() @attr(shard=2) @ddt.ddt class TestSafeSessionProcessResponse(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware.process_response """ def setUp(self): super(TestSafeSessionProcessResponse, self).setUp() self.user = UserFactory.create() self.request = get_mock_request() self.request.session = {} self.client.response = HttpResponse() self.client.response.cookies = SimpleCookie() def assert_response(self, set_request_user=False, set_session_cookie=False): """ Calls SafeSessionMiddleware.process_response and verifies the response. Arguments: set_request_user - If True, the user is set on the request object. set_session_cookie - If True, a session_id is set in the session cookie in the response. """ if set_request_user: self.request.user = self.user SafeSessionMiddleware.set_user_id_in_session(self.request, self.user) if set_session_cookie: self.client.response.cookies[settings.SESSION_COOKIE_NAME] = "some_session_id" response = SafeSessionMiddleware().process_response(self.request, self.client.response) self.assertEquals(response.status_code, 200) def assert_response_with_delete_cookie( self, expect_delete_called=True, set_request_user=False, set_session_cookie=False, ): """ Calls SafeSessionMiddleware.process_response and verifies the response, while expecting the cookie to be deleted if expect_delete_called is True. See assert_response for information on the other parameters. """ with patch('django.http.HttpResponse.set_cookie') as mock_delete_cookie: self.assert_response(set_request_user=set_request_user, set_session_cookie=set_session_cookie) self.assertEquals(mock_delete_cookie.called, expect_delete_called) def test_success(self): with self.assert_not_logged(): self.assert_response(set_request_user=True, set_session_cookie=True) def test_confirm_user_at_step_2(self): self.request.safe_cookie_verified_user_id = self.user.id with self.assert_not_logged(): self.assert_response(set_request_user=True, set_session_cookie=True) def test_different_user_at_step_2_error(self): self.request.safe_cookie_verified_user_id = "different_user" with self.assert_logged_for_request_user_mismatch("different_user", self.user.id, 'warning'): self.assert_response(set_request_user=True, set_session_cookie=True) with self.assert_logged_for_session_user_mismatch("different_user", self.user.id): self.assert_response(set_request_user=True, set_session_cookie=True) def test_anonymous_user(self): self.request.safe_cookie_verified_user_id = self.user.id self.request.user = AnonymousUser() self.request.session[SESSION_KEY] = self.user.id with self.assert_no_error_logged(): with self.assert_logged_for_request_user_mismatch(self.user.id, None, 'debug'): self.assert_response(set_request_user=False, set_session_cookie=True) def test_update_cookie_data_at_step_3(self): self.assert_response(set_request_user=True, set_session_cookie=True) serialized_cookie_data = self.client.response.cookies[settings.SESSION_COOKIE_NAME].value safe_cookie_data = SafeCookieData.parse(serialized_cookie_data) self.assertEquals(safe_cookie_data.version, SafeCookieData.CURRENT_VERSION) self.assertEquals(safe_cookie_data.session_id, "some_session_id") self.assertTrue(safe_cookie_data.verify(self.user.id)) def test_cant_update_cookie_at_step_3_error(self): self.client.response.cookies[settings.SESSION_COOKIE_NAME] = None with self.assert_invalid_session_id(): self.assert_response_with_delete_cookie(set_request_user=True) @ddt.data(True, False) def test_deletion_of_cookies_at_step_4(self, set_request_user): self.request.need_to_delete_cookie = True self.assert_response_with_delete_cookie(set_session_cookie=True, set_request_user=set_request_user) def test_deletion_of_no_cookies_at_step_4(self): self.request.need_to_delete_cookie = True # delete_cookies is called even if there are no cookies set self.assert_response_with_delete_cookie() @attr(shard=2) @ddt.ddt class TestSafeSessionMiddleware(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware, testing both process_request and process_response. """ def setUp(self): super(TestSafeSessionMiddleware, self).setUp() self.user = UserFactory.create() self.request = get_mock_request() self.client.response = HttpResponse() self.client.response.cookies = SimpleCookie() def cookies_from_request_to_response(self): """ Transfers the cookies from the request object to the response object. """ if self.request.COOKIES.get(settings.SESSION_COOKIE_NAME): self.client.response.cookies[settings.SESSION_COOKIE_NAME] = self.request.COOKIES[ settings.SESSION_COOKIE_NAME ] def verify_success(self): """ Verifies success path. """ self.client.login(username=self.user.username, password='test') self.request.user = self.user session_id = self.client.session.session_key safe_cookie_data = SafeCookieData.create(session_id, self.user.id) self.request.COOKIES[settings.SESSION_COOKIE_NAME] = unicode(safe_cookie_data) with self.assert_not_logged(): response = SafeSessionMiddleware().process_request(self.request) self.assertIsNone(response) self.assertEquals(self.request.safe_cookie_verified_user_id, self.user.id) self.cookies_from_request_to_response() with self.assert_not_logged(): response = SafeSessionMiddleware().process_response(self.request, self.client.response) self.assertEquals(response.status_code, 200) def test_success(self): self.verify_success() def test_success_from_mobile_web_view(self): self.request.path = '/xblock/block-v1:org+course+run+type@html+block@block_id' self.verify_success() @override_settings(MOBILE_APP_USER_AGENT_REGEXES=[r'open edX Mobile App']) def test_success_from_mobile_app(self): self.request.META = {'HTTP_USER_AGENT': 'open edX Mobile App Version 2.1'} self.verify_success() def verify_error(self, expected_response_status): """ Verifies error path. """ self.request.COOKIES[settings.SESSION_COOKIE_NAME] = 'not-a-safe-cookie' with self.assert_parse_error(): request_response = SafeSessionMiddleware().process_request(self.request) self.assertEquals(request_response.status_code, expected_response_status) self.assertTrue(self.request.need_to_delete_cookie) self.cookies_from_request_to_response() with patch('django.http.HttpResponse.set_cookie') as mock_delete_cookie: SafeSessionMiddleware().process_response(self.request, self.client.response) self.assertTrue(mock_delete_cookie.called) def test_error(self): self.verify_error(302) def test_error_from_mobile_web_view(self): self.request.path = '/xblock/block-v1:org+course+run+type@html+block@block_id' self.verify_error(401) @override_settings(MOBILE_APP_USER_AGENT_REGEXES=[r'open edX Mobile App']) def test_error_from_mobile_app(self): self.request.META = {'HTTP_USER_AGENT': 'open edX Mobile App Version 2.1'} self.verify_error(401)
agpl-3.0
[ 3, 4287, 26, 3507, 29, 889, 13, 1114, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 624, 199, 5072, 2295, 367, 14969, 4434, 6608, 199, 624, 199, 646, 366, 3583, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 492, 428, 9577, 63, 3078, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 12, 5870, 7810, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 22709, 14, 1018, 14, 1176, 773, 14, 4776, 14, 1208, 492, 664, 63, 1805, 63, 1069, 199, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 199, 504, 2508, 5754, 492, 14969, 4434, 6608, 12, 14969, 7810, 1451, 199, 504, 1275, 396, 63, 1208, 492, 1379, 11090, 51, 30414, 2445, 4256, 421, 199, 32, 962, 8, 10810, 29, 18, 9, 199, 533, 1379, 11090, 4434, 3498, 2017, 8, 774, 11090, 51, 30414, 2445, 4256, 12, 7640, 304, 272, 408, 272, 1379, 1021, 367, 14969, 4434, 6608, 14, 1412, 63, 1069, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11090, 4434, 3498, 2017, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 342, 267, 291, 14, 1069, 275, 664, 63, 1805, 63, 1069, 342, 339, 347, 702, 63, 1310, 8, 277, 12, 5048, 63, 5306, 63, 576, 29, 403, 12, 3182, 29, 549, 304, 267, 408, 267, 28055, 14969, 4434, 6608, 14, 1412, 63, 1069, 436, 22694, 267, 314, 1177, 14, 398, 7628, 26, 288, 5048, 63, 5306, 63, 576, 446, 982, 2741, 12, 652, 365, 6380, 436, 1598, 5489, 315, 314, 1056, 1159, 10049, 14, 288, 3182, 446, 982, 715, 12, 22694, 282, 9512, 1177, 14, 1598, 19524, 12, 22694, 282, 3405, 1177, 543, 376, 3101, 4660, 14, 267, 408, 267, 340, 5048, 63, 5306, 63, 576, 26, 288, 291, 14, 1069, 14, 12189, 2563, 59, 1751, 14, 12763, 63, 13665, 63, 2339, 61, 275, 2649, 8, 3489, 63, 5306, 63, 576, 9, 267, 1177, 275, 14969, 4434, 6608, 1252, 1412, 63, 1069, 8, 277, 14, 1069, 9, 267, 340, 3182, 26, 288, 291, 14, 7702, 8, 1310, 9, 288, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 9321, 63, 475, 63, 1807, 63, 5306, 297, 488, 430, 267, 587, 26, 288, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 14935, 14, 1205, 63, 600, 9, 288, 291, 14, 1815, 8, 277, 14, 1069, 14, 9321, 63, 475, 63, 1807, 63, 5306, 9, 339, 347, 702, 63, 889, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 2351, 909, 365, 627, 1397, 10, 663, 641, 314, 1056, 14, 267, 408, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 1730, 297, 488, 430, 339, 347, 702, 63, 889, 63, 751, 63, 262, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 922, 909, 365, 627, 1397, 10, 663, 641, 314, 1056, 1159, 2351, 14, 267, 408, 267, 291, 14, 7702, 8, 277, 14, 1069, 14, 1730, 14, 362, 8, 12763, 63, 3078, 430, 339, 347, 702, 63, 751, 63, 262, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 922, 909, 627, 374, 10, 663, 641, 314, 1056, 1159, 2351, 14, 267, 408, 267, 291, 14, 2947, 8, 288, 14969, 4434, 6608, 14, 362, 63, 751, 63, 344, 63, 504, 63, 1730, 8, 277, 14, 1069, 395, 288, 291, 14, 751, 14, 344, 267, 776, 339, 347, 511, 63, 3742, 8, 277, 304, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 751, 14, 2473, 12, 2505, 534, 396, 358, 267, 2351, 63, 344, 275, 291, 14, 1258, 14, 1730, 14, 1730, 63, 498, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 8, 1730, 63, 344, 12, 291, 14, 751, 14, 344, 9, 398, 327, 876, 13, 4712, 7124, 650, 12, 841, 12, 959, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 1730, 297, 488, 430, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 3489, 63, 5306, 63, 12949, 63, 751, 63, 344, 297, 488, 430, 398, 327, 4911, 3650, 413, 26, 5048, 5494, 666, 365, 4565, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 9, 267, 291, 14, 479, 63, 751, 63, 262, 63, 1730, 342, 398, 327, 4911, 3650, 499, 26, 5494, 574, 365, 8717, 543, 4565, 2351, 63, 344, 267, 291, 14, 2947, 8, 277, 14, 1069, 14, 12189, 2563, 59, 1751, 14, 12763, 63, 13665, 63, 2339, 467, 2351, 63, 344, 9, 398, 327, 4911, 3650, 650, 26, 2351, 663, 315, 1056, 267, 291, 14, 10389, 8, 277, 14, 1069, 14, 1730, 9, 398, 327, 4911, 7124, 841, 12, 959, 26, 922, 63, 344, 5489, 367, 2945, 14786, 267, 291, 14, 2947, 8, 277, 14, 1069, 14, 3489, 63, 5306, 63, 12949, 63, 751, 63, 344, 12, 291, 14, 751, 14, 344, 9, 339, 347, 511, 63, 3742, 63, 889, 63, 7792, 8, 277, 304, 267, 291, 14, 479, 63, 1310, 342, 267, 291, 14, 479, 63, 889, 63, 751, 63, 262, 63, 1730, 342, 339, 347, 511, 63, 3742, 63, 889, 63, 1730, 8, 277, 304, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 360, 889, 63, 10180, 63, 1730, 63, 344, 297, 291, 14, 751, 14, 344, 9, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 9, 267, 291, 14, 479, 63, 889, 63, 751, 63, 262, 63, 1730, 342, 339, 347, 511, 63, 3742, 63, 889, 63, 1730, 63, 460, 63, 751, 8, 277, 304, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 360, 889, 63, 10180, 63, 1730, 63, 344, 297, 283, 889, 63, 10180, 63, 751, 358, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 9, 267 ]
[ 4287, 26, 3507, 29, 889, 13, 1114, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 624, 199, 5072, 2295, 367, 14969, 4434, 6608, 199, 624, 199, 646, 366, 3583, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 492, 428, 9577, 63, 3078, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 12, 5870, 7810, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 22709, 14, 1018, 14, 1176, 773, 14, 4776, 14, 1208, 492, 664, 63, 1805, 63, 1069, 199, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 199, 504, 2508, 5754, 492, 14969, 4434, 6608, 12, 14969, 7810, 1451, 199, 504, 1275, 396, 63, 1208, 492, 1379, 11090, 51, 30414, 2445, 4256, 421, 199, 32, 962, 8, 10810, 29, 18, 9, 199, 533, 1379, 11090, 4434, 3498, 2017, 8, 774, 11090, 51, 30414, 2445, 4256, 12, 7640, 304, 272, 408, 272, 1379, 1021, 367, 14969, 4434, 6608, 14, 1412, 63, 1069, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11090, 4434, 3498, 2017, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 342, 267, 291, 14, 1069, 275, 664, 63, 1805, 63, 1069, 342, 339, 347, 702, 63, 1310, 8, 277, 12, 5048, 63, 5306, 63, 576, 29, 403, 12, 3182, 29, 549, 304, 267, 408, 267, 28055, 14969, 4434, 6608, 14, 1412, 63, 1069, 436, 22694, 267, 314, 1177, 14, 398, 7628, 26, 288, 5048, 63, 5306, 63, 576, 446, 982, 2741, 12, 652, 365, 6380, 436, 1598, 5489, 315, 314, 1056, 1159, 10049, 14, 288, 3182, 446, 982, 715, 12, 22694, 282, 9512, 1177, 14, 1598, 19524, 12, 22694, 282, 3405, 1177, 543, 376, 3101, 4660, 14, 267, 408, 267, 340, 5048, 63, 5306, 63, 576, 26, 288, 291, 14, 1069, 14, 12189, 2563, 59, 1751, 14, 12763, 63, 13665, 63, 2339, 61, 275, 2649, 8, 3489, 63, 5306, 63, 576, 9, 267, 1177, 275, 14969, 4434, 6608, 1252, 1412, 63, 1069, 8, 277, 14, 1069, 9, 267, 340, 3182, 26, 288, 291, 14, 7702, 8, 1310, 9, 288, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 9321, 63, 475, 63, 1807, 63, 5306, 297, 488, 430, 267, 587, 26, 288, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 14935, 14, 1205, 63, 600, 9, 288, 291, 14, 1815, 8, 277, 14, 1069, 14, 9321, 63, 475, 63, 1807, 63, 5306, 9, 339, 347, 702, 63, 889, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 2351, 909, 365, 627, 1397, 10, 663, 641, 314, 1056, 14, 267, 408, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 1730, 297, 488, 430, 339, 347, 702, 63, 889, 63, 751, 63, 262, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 922, 909, 365, 627, 1397, 10, 663, 641, 314, 1056, 1159, 2351, 14, 267, 408, 267, 291, 14, 7702, 8, 277, 14, 1069, 14, 1730, 14, 362, 8, 12763, 63, 3078, 430, 339, 347, 702, 63, 751, 63, 262, 63, 1730, 8, 277, 304, 267, 408, 267, 10716, 83, 626, 282, 922, 909, 627, 374, 10, 663, 641, 314, 1056, 1159, 2351, 14, 267, 408, 267, 291, 14, 2947, 8, 288, 14969, 4434, 6608, 14, 362, 63, 751, 63, 344, 63, 504, 63, 1730, 8, 277, 14, 1069, 395, 288, 291, 14, 751, 14, 344, 267, 776, 339, 347, 511, 63, 3742, 8, 277, 304, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 751, 14, 2473, 12, 2505, 534, 396, 358, 267, 2351, 63, 344, 275, 291, 14, 1258, 14, 1730, 14, 1730, 63, 498, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 8, 1730, 63, 344, 12, 291, 14, 751, 14, 344, 9, 398, 327, 876, 13, 4712, 7124, 650, 12, 841, 12, 959, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 1730, 297, 488, 430, 267, 291, 14, 7702, 8, 5675, 8, 277, 14, 1069, 12, 283, 3489, 63, 5306, 63, 12949, 63, 751, 63, 344, 297, 488, 430, 398, 327, 4911, 3650, 413, 26, 5048, 5494, 666, 365, 4565, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 9, 267, 291, 14, 479, 63, 751, 63, 262, 63, 1730, 342, 398, 327, 4911, 3650, 499, 26, 5494, 574, 365, 8717, 543, 4565, 2351, 63, 344, 267, 291, 14, 2947, 8, 277, 14, 1069, 14, 12189, 2563, 59, 1751, 14, 12763, 63, 13665, 63, 2339, 467, 2351, 63, 344, 9, 398, 327, 4911, 3650, 650, 26, 2351, 663, 315, 1056, 267, 291, 14, 10389, 8, 277, 14, 1069, 14, 1730, 9, 398, 327, 4911, 7124, 841, 12, 959, 26, 922, 63, 344, 5489, 367, 2945, 14786, 267, 291, 14, 2947, 8, 277, 14, 1069, 14, 3489, 63, 5306, 63, 12949, 63, 751, 63, 344, 12, 291, 14, 751, 14, 344, 9, 339, 347, 511, 63, 3742, 63, 889, 63, 7792, 8, 277, 304, 267, 291, 14, 479, 63, 1310, 342, 267, 291, 14, 479, 63, 889, 63, 751, 63, 262, 63, 1730, 342, 339, 347, 511, 63, 3742, 63, 889, 63, 1730, 8, 277, 304, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 360, 889, 63, 10180, 63, 1730, 63, 344, 297, 291, 14, 751, 14, 344, 9, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 9, 267, 291, 14, 479, 63, 889, 63, 751, 63, 262, 63, 1730, 342, 339, 347, 511, 63, 3742, 63, 889, 63, 1730, 63, 460, 63, 751, 8, 277, 304, 267, 5048, 63, 5306, 63, 576, 275, 14969, 7810, 1451, 14, 981, 360, 889, 63, 10180, 63, 1730, 63, 344, 297, 283, 889, 63, 10180, 63, 751, 358, 267, 291, 14, 479, 63, 1310, 8, 3489, 63, 5306, 63, 576, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jzitelli/three.js
utils/exporters/blender/addons/io_three/logger.py
121
1589
import os import logging import tempfile from . import constants LOG_FILE = None LOGGER = None LEVELS = { constants.DEBUG: logging.DEBUG, constants.INFO: logging.INFO, constants.WARNING: logging.WARNING, constants.ERROR: logging.ERROR, constants.CRITICAL: logging.CRITICAL } def init(filename, level=constants.DEBUG): """Initialize the logger. :param filename: base name of the log file :param level: logging level (Default value = DEBUG) """ global LOG_FILE LOG_FILE = os.path.join(tempfile.gettempdir(), filename) with open(LOG_FILE, 'w'): pass global LOGGER LOGGER = logging.getLogger('Three.Export') LOGGER.setLevel(LEVELS[level]) if not LOGGER.handlers: stream = logging.StreamHandler() stream.setLevel(LEVELS[level]) format_ = '%(asctime)s - %(name)s - %(levelname)s: %(message)s' formatter = logging.Formatter(format_) stream.setFormatter(formatter) file_handler = logging.FileHandler(LOG_FILE) file_handler.setLevel(LEVELS[level]) file_handler.setFormatter(formatter) LOGGER.addHandler(stream) LOGGER.addHandler(file_handler) def _logger(func): def inner(*args): if LOGGER is not None: func(*args) return inner @_logger def info(*args): LOGGER.info(*args) @_logger def debug(*args): LOGGER.debug(*args) @_logger def warning(*args): LOGGER.warning(*args) @_logger def error(*args): LOGGER.error(*args) @_logger def critical(*args): LOGGER.critical(*args)
mit
[ 646, 747, 199, 646, 2050, 199, 646, 5549, 199, 199, 504, 1275, 492, 5262, 199, 199, 4947, 63, 3817, 275, 488, 199, 10186, 275, 488, 199, 199, 906, 2524, 5296, 275, 469, 272, 5262, 14, 5287, 26, 2050, 14, 5287, 12, 272, 5262, 14, 4531, 26, 2050, 14, 4531, 12, 272, 5262, 14, 9171, 26, 2050, 14, 9171, 12, 272, 5262, 14, 3170, 26, 2050, 14, 3170, 12, 272, 5262, 14, 21539, 26, 2050, 14, 21539, 199, 93, 421, 199, 318, 4205, 8, 1501, 12, 2166, 29, 5559, 14, 5287, 304, 272, 408, 9345, 314, 2512, 14, 339, 520, 635, 1788, 26, 1300, 536, 402, 314, 943, 570, 272, 520, 635, 2166, 26, 2050, 2166, 334, 2698, 574, 275, 10990, 9, 339, 408, 272, 2288, 5051, 63, 3817, 272, 5051, 63, 3817, 275, 747, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 1788, 9, 272, 543, 1551, 8, 4947, 63, 3817, 12, 283, 87, 735, 267, 986, 339, 2288, 20184, 272, 20184, 275, 2050, 14, 5572, 360, 21485, 14, 11399, 358, 272, 20184, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 339, 340, 440, 20184, 14, 5586, 26, 267, 2547, 275, 2050, 14, 22482, 342, 267, 2547, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 398, 1475, 63, 275, 9487, 18331, 9, 83, 446, 2818, 354, 9, 83, 446, 2818, 20056, 9, 83, 26, 2818, 1188, 9, 83, 7, 267, 9698, 275, 2050, 14, 7772, 8, 908, 4602, 398, 2547, 14, 26076, 8, 8911, 9, 398, 570, 63, 2232, 275, 2050, 14, 21982, 8, 4947, 63, 3817, 9, 267, 570, 63, 2232, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 267, 570, 63, 2232, 14, 26076, 8, 8911, 9, 398, 20184, 14, 18826, 8, 1745, 9, 267, 20184, 14, 18826, 8, 493, 63, 2232, 9, 421, 199, 318, 485, 2921, 8, 1532, 304, 339, 347, 6506, 2031, 589, 304, 267, 340, 20184, 365, 440, 488, 26, 288, 2562, 2031, 589, 9, 339, 372, 6506, 421, 199, 17608, 2921, 199, 318, 2256, 2031, 589, 304, 272, 20184, 14, 815, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 3105, 2031, 589, 304, 272, 20184, 14, 1757, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 5721, 2031, 589, 304, 272, 20184, 14, 3764, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 1125, 2031, 589, 304, 272, 20184, 14, 705, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 19698, 2031, 589, 304, 272, 20184, 14, 13138, 2031, 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 ]
[ 747, 199, 646, 2050, 199, 646, 5549, 199, 199, 504, 1275, 492, 5262, 199, 199, 4947, 63, 3817, 275, 488, 199, 10186, 275, 488, 199, 199, 906, 2524, 5296, 275, 469, 272, 5262, 14, 5287, 26, 2050, 14, 5287, 12, 272, 5262, 14, 4531, 26, 2050, 14, 4531, 12, 272, 5262, 14, 9171, 26, 2050, 14, 9171, 12, 272, 5262, 14, 3170, 26, 2050, 14, 3170, 12, 272, 5262, 14, 21539, 26, 2050, 14, 21539, 199, 93, 421, 199, 318, 4205, 8, 1501, 12, 2166, 29, 5559, 14, 5287, 304, 272, 408, 9345, 314, 2512, 14, 339, 520, 635, 1788, 26, 1300, 536, 402, 314, 943, 570, 272, 520, 635, 2166, 26, 2050, 2166, 334, 2698, 574, 275, 10990, 9, 339, 408, 272, 2288, 5051, 63, 3817, 272, 5051, 63, 3817, 275, 747, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 1788, 9, 272, 543, 1551, 8, 4947, 63, 3817, 12, 283, 87, 735, 267, 986, 339, 2288, 20184, 272, 20184, 275, 2050, 14, 5572, 360, 21485, 14, 11399, 358, 272, 20184, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 339, 340, 440, 20184, 14, 5586, 26, 267, 2547, 275, 2050, 14, 22482, 342, 267, 2547, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 398, 1475, 63, 275, 9487, 18331, 9, 83, 446, 2818, 354, 9, 83, 446, 2818, 20056, 9, 83, 26, 2818, 1188, 9, 83, 7, 267, 9698, 275, 2050, 14, 7772, 8, 908, 4602, 398, 2547, 14, 26076, 8, 8911, 9, 398, 570, 63, 2232, 275, 2050, 14, 21982, 8, 4947, 63, 3817, 9, 267, 570, 63, 2232, 14, 13548, 8, 906, 2524, 5296, 59, 1896, 566, 267, 570, 63, 2232, 14, 26076, 8, 8911, 9, 398, 20184, 14, 18826, 8, 1745, 9, 267, 20184, 14, 18826, 8, 493, 63, 2232, 9, 421, 199, 318, 485, 2921, 8, 1532, 304, 339, 347, 6506, 2031, 589, 304, 267, 340, 20184, 365, 440, 488, 26, 288, 2562, 2031, 589, 9, 339, 372, 6506, 421, 199, 17608, 2921, 199, 318, 2256, 2031, 589, 304, 272, 20184, 14, 815, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 3105, 2031, 589, 304, 272, 20184, 14, 1757, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 5721, 2031, 589, 304, 272, 20184, 14, 3764, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 1125, 2031, 589, 304, 272, 20184, 14, 705, 2031, 589, 9, 421, 199, 17608, 2921, 199, 318, 19698, 2031, 589, 304, 272, 20184, 14, 13138, 2031, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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. <http://rockstor.com> This file is part of RockStor. RockStor 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. RockStor 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 pool import Pool from disk import Disk from snapshot import Snapshot from share import Share from nfs_export_group import NFSExportGroup from nfs_export import NFSExport from iscsi_target import IscsiTarget from api_keys import APIKeys from network_interface import NetworkInterface from appliance import Appliance from support_case import SupportCase from dashboard_config import DashboardConfig from group import Group from user import User from samba_share import SambaShare from samba_custom import SambaCustomConfig from posix_acls import PosixACLs from scrub import PoolScrub from setup import Setup from sftp import SFTP from plugin import Plugin from installed_plugin import InstalledPlugin from adv_nfs_exports import AdvancedNFSExport from oauth_app import OauthApp from netatalk_share import NetatalkShare from pool_balance import PoolBalance from tls_certificate import TLSCertificate from rockon import (RockOn, DImage, DContainer, DPort, DVolume, ContainerOption, DCustomConfig, DContainerLink) from smart import (SMARTAttribute, SMARTCapability, SMARTErrorLog, SMARTErrorLogSummary, SMARTTestLog, SMARTTestLogDetail, SMARTIdentity, SMARTInfo) from config_backup import ConfigBackup from email import EmailClient from update_subscription import UpdateSubscription
gpl-3.0
[ 624, 199, 7384, 334, 67, 9, 6029, 13, 6965, 820, 766, 933, 269, 12, 3277, 14, 665, 1014, 921, 24892, 8041, 14, 957, 30, 199, 2765, 570, 365, 1777, 402, 820, 766, 933, 269, 14, 199, 199, 50, 766, 933, 269, 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, 199, 991, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 199, 269, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 50, 766, 933, 269, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 29946, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 14109, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 504, 4203, 492, 15553, 199, 504, 4543, 492, 26287, 199, 504, 5740, 492, 23896, 199, 504, 8663, 492, 5244, 1530, 199, 504, 31307, 63, 3790, 63, 923, 492, 653, 38, 899, 88, 719, 2448, 199, 504, 31307, 63, 3790, 492, 653, 38, 899, 88, 719, 199, 504, 22144, 63, 1375, 492, 473, 15873, 4277, 199, 504, 2986, 63, 1612, 492, 3261, 6340, 199, 504, 2784, 63, 3266, 492, 7220, 4267, 199, 504, 20986, 492, 4693, 3636, 199, 504, 2291, 63, 2546, 492, 12502, 1538, 199, 504, 17216, 63, 888, 492, 577, 1119, 3576, 2028, 199, 504, 1572, 492, 5611, 199, 504, 922, 492, 2876, 199, 504, 31710, 63, 6251, 492, 428, 14310, 18713, 199, 504, 31710, 63, 4229, 492, 428, 14310, 7223, 2028, 199, 504, 10694, 63, 28647, 492, 4376, 4174, 18765, 83, 199, 504, 19270, 456, 492, 15553, 51, 1556, 456, 199, 504, 3272, 492, 12439, 199, 504, 308, 8915, 492, 428, 15123, 199, 504, 3589, 492, 11349, 199, 504, 4903, 63, 2718, 492, 14089, 1843, 5061, 199, 504, 19396, 63, 19591, 63, 20775, 492, 32445, 19749, 899, 88, 719, 199, 504, 9725, 63, 571, 492, 593, 1178, 2640, 199, 504, 1851, 292, 4878, 63, 6251, 492, 5365, 292, 4878, 18713, 199, 504, 4203, 63, 7358, 492, 15553, 27106, 199, 504, 15142, 63, 6999, 492, 377, 44, 5153, 281, 3454, 199, 504, 882, 346, 265, 492, 334, 50, 766, 3314, 12, 577, 3491, 12, 577, 4076, 12, 577, 4313, 12, 577, 6464, 12, 490, 15395, 2602, 12, 577, 7223, 2028, 12, 577, 4076, 3834, 9, 199, 504, 11179, 492, 334, 4029, 2294, 1646, 12, 2389, 2294, 24512, 12, 2389, 2294, 547, 2445, 12, 673, 2389, 2294, 547, 2445, 10407, 12, 2389, 2294, 774, 2445, 12, 2389, 2294, 774, 2445, 8064, 12, 673, 2389, 2294, 10193, 12, 2389, 2294, 2354, 9, 199, 504, 1101, 63, 5751, 492, 4094, 16559, 199, 504, 3031, 492, 11426, 3041, 199, 504, 1678, 63, 6645, 492, 6162, 19120, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7384, 334, 67, 9, 6029, 13, 6965, 820, 766, 933, 269, 12, 3277, 14, 665, 1014, 921, 24892, 8041, 14, 957, 30, 199, 2765, 570, 365, 1777, 402, 820, 766, 933, 269, 14, 199, 199, 50, 766, 933, 269, 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, 199, 991, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 199, 269, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 50, 766, 933, 269, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 29946, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 14109, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 504, 4203, 492, 15553, 199, 504, 4543, 492, 26287, 199, 504, 5740, 492, 23896, 199, 504, 8663, 492, 5244, 1530, 199, 504, 31307, 63, 3790, 63, 923, 492, 653, 38, 899, 88, 719, 2448, 199, 504, 31307, 63, 3790, 492, 653, 38, 899, 88, 719, 199, 504, 22144, 63, 1375, 492, 473, 15873, 4277, 199, 504, 2986, 63, 1612, 492, 3261, 6340, 199, 504, 2784, 63, 3266, 492, 7220, 4267, 199, 504, 20986, 492, 4693, 3636, 199, 504, 2291, 63, 2546, 492, 12502, 1538, 199, 504, 17216, 63, 888, 492, 577, 1119, 3576, 2028, 199, 504, 1572, 492, 5611, 199, 504, 922, 492, 2876, 199, 504, 31710, 63, 6251, 492, 428, 14310, 18713, 199, 504, 31710, 63, 4229, 492, 428, 14310, 7223, 2028, 199, 504, 10694, 63, 28647, 492, 4376, 4174, 18765, 83, 199, 504, 19270, 456, 492, 15553, 51, 1556, 456, 199, 504, 3272, 492, 12439, 199, 504, 308, 8915, 492, 428, 15123, 199, 504, 3589, 492, 11349, 199, 504, 4903, 63, 2718, 492, 14089, 1843, 5061, 199, 504, 19396, 63, 19591, 63, 20775, 492, 32445, 19749, 899, 88, 719, 199, 504, 9725, 63, 571, 492, 593, 1178, 2640, 199, 504, 1851, 292, 4878, 63, 6251, 492, 5365, 292, 4878, 18713, 199, 504, 4203, 63, 7358, 492, 15553, 27106, 199, 504, 15142, 63, 6999, 492, 377, 44, 5153, 281, 3454, 199, 504, 882, 346, 265, 492, 334, 50, 766, 3314, 12, 577, 3491, 12, 577, 4076, 12, 577, 4313, 12, 577, 6464, 12, 490, 15395, 2602, 12, 577, 7223, 2028, 12, 577, 4076, 3834, 9, 199, 504, 11179, 492, 334, 4029, 2294, 1646, 12, 2389, 2294, 24512, 12, 2389, 2294, 547, 2445, 12, 673, 2389, 2294, 547, 2445, 10407, 12, 2389, 2294, 774, 2445, 12, 2389, 2294, 774, 2445, 8064, 12, 673, 2389, 2294, 10193, 12, 2389, 2294, 2354, 9, 199, 504, 1101, 63, 5751, 492, 4094, 16559, 199, 504, 3031, 492, 11426, 3041, 199, 504, 1678, 63, 6645, 492, 6162, 19120, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pipehappy1/super-engine
mlbase/binary.py
1
6426
import numpy as np import theano import theano.tensor as T import mlbase.networkhelper as N import h5py from theano.scalar.basic import UnaryScalarOp, same_out_nocomplex from theano.tensor.elemwise import Elemwise class BinaryOp(UnaryScalarOp): def c_code(self, node, name, x1, z1, sub): x = x1[0] z = z1[0] return "%(z)s = round(%(x)s);" % locals() def grad(self, inputs, gout): (gz,) = gout return gz, binaryScalar = BinaryOp(same_out_nocomplex, name='binaryScalar') binaryOp = Elemwise(binaryScalar) class BinaryConv2d(N.Conv2d): """ A binary convolution layer where both output and weights are binary. The input may be binary or not. """ debugname = 'bindaryconv2d' LayerTypeName = 'BinaryConv2d' yaml_tag = u'!BinaryConv2d' def __init__(self, filter_size=(3,3), input_feature=None, output_feature=None, feature_map_multiplier=None, subsample=(1,1), border='half'): super(BinaryConv2d, self).__init__(filter_size, input_feature, output_feature, feature_map_multiplier, subsample, border) def getpara(self): return super(BinaryConv2d, self).getpara() def forward(self, inputtensor): x = inputtensor[0] wb = T.clip(self.w, -1, 1) l3conv = T.nnet.conv2d(x, wb, border_mode=self.border, subsample=self.subsample) return (l3conv,) def forwardSize(self, inputsize): ret = super(BinaryConv2d, self).forwardSize(inputsize) return ret def fillToObjMap(self): objDict = super(BinaryConv2d, self).fillToObjMap() return objDict def loadFromObjMap(self, tmap): super(BinaryConv2d, self).loadFromObjMap(tmap) @classmethod def to_yaml(cls, dumper, data): objDict = data.fillToObjMap() node = dumper.represent_mapping(BinaryConv2d.yaml_tag, objDict) return node @classmethod def from_yaml(cls, loader, node): objDict = loader.construct_mapping(node) ret = BinaryConv2d() ret.loadFromObjMap(objDict) return ret class Binarize(N.Layer): """ Binary layer to binarilize input and bypass gradient (i.e. use straight through estimator) """ debugname = 'binary' LayerTypeName = 'Binarize' yaml_tag = u'!Binarize' def __init__(self): super(Binarize, self).__init__() def getpara(self): return [] def forward(self, inputtensor): x = inputtensor[0] x = T.clip(x, -1, 1) return (binaryOp(x),) def forwardSize(self, inputsize): return inputsize def fillToObjMap(self): objDict = super(Binarize, self).fillToObjMap() return objDict def loadFromObjMap(self, tmap): super(Binarize, self).loadFromObjMap(tmap) @classmethod def to_yaml(cls, dumper, data): objDict = data.fillToObjMap() node = dumper.represent_mapping(Binarize.yaml_tag, objDict) return node @classmethod def from_yaml(cls, loader, node): objDict = loader.construct_mapping(node) ret = Binarize() ret.loadFromObjMap(objDict) return ret def test_input(): network = N.Network() network.debug = True network.setInput(N.RawInput((1, 28,28))) network.append(N.Conv2d(filter_size=(3,3), input_feature=1, output_feature=32)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(Binarize()) network.append(N.Conv2d(filter_size=(3,3), input_feature=32, output_feature=64)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(Binarize()) network.append(N.Conv2d(filter_size=(3,3), input_feature=64, output_feature=128)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(N.Flatten()) network.append(N.FullConn(input_feature=1152, output_feature=1152*2)) network.append(N.Relu()) network.append(N.FullConn(input_feature=1152*2, output_feature=10)) network.append(N.SoftMax()) network.build() f = h5py.File('/hdd/home/yueguan/workspace/data/mnist/mnist.hdf5', 'r') trX = f['x_train'][:,:].reshape(-1, 1, 28, 28) teX = f['x_test'][:,:].reshape(-1, 1, 28, 28) trY = np.zeros((f['t_train'].shape[0], 10)) trY[np.arange(len(f['t_train'])), f['t_train']] = 1 teY = np.zeros((f['t_test'].shape[0], 10)) teY[np.arange(len(f['t_test'])), f['t_test']] = 1 for i in range(5000): print(i) network.train(trX, trY) print(1 - np.mean(np.argmax(teY, axis=1) == np.argmax(network.predict(teX), axis=1))) def test_binaryweight(): network = N.Network() network.debug = True network.setInput(N.RawInput((1, 28,28))) network.append(N.Conv2d(feature_map_multiplier=32)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(Binarize()) network.append(N.Conv2d(feature_map_multiplier=2)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(Binarize()) network.append(BinaryConv2d(feature_map_multiplier=2)) network.append(N.Relu()) network.append(N.Pooling((2,2))) network.append(N.Flatten()) network.append(N.FullConn(input_feature=1152, output_feature=1152*2)) network.append(N.Relu()) network.append(N.FullConn(input_feature=1152*2, output_feature=10)) network.append(N.SoftMax()) network.build() f = h5py.File('/hdd/home/yueguan/workspace/data/mnist/mnist.hdf5', 'r') trX = f['x_train'][:,:].reshape(-1, 1, 28, 28) teX = f['x_test'][:,:].reshape(-1, 1, 28, 28) trY = np.zeros((f['t_train'].shape[0], 10)) trY[np.arange(len(f['t_train'])), f['t_train']] = 1 teY = np.zeros((f['t_test'].shape[0], 10)) teY[np.arange(len(f['t_test'])), f['t_test']] = 1 for i in range(5000): print(i) network.train(trX, trY) print(1 - np.mean(np.argmax(teY, axis=1) == np.argmax(network.predict(teX), axis=1))) if __name__ == '__main__': test_binaryweight()
bsd-3-clause
[ 646, 2680, 465, 980, 199, 646, 14377, 199, 646, 14377, 14, 3128, 465, 377, 199, 646, 19184, 1095, 14, 1200, 3676, 465, 653, 199, 646, 394, 21, 647, 199, 199, 504, 14377, 14, 7033, 14, 4316, 492, 1910, 695, 13090, 4619, 12, 2011, 63, 548, 63, 889, 5254, 199, 504, 14377, 14, 3128, 14, 6086, 2605, 492, 662, 3701, 2605, 199, 199, 533, 14161, 4619, 8, 22401, 13090, 4619, 304, 272, 347, 286, 63, 600, 8, 277, 12, 1031, 12, 536, 12, 671, 17, 12, 1315, 17, 12, 1007, 304, 267, 671, 275, 671, 17, 59, 16, 61, 267, 1315, 275, 1315, 17, 59, 16, 61, 267, 372, 11792, 90, 9, 83, 275, 6168, 12473, 88, 9, 83, 27556, 450, 9480, 342, 339, 347, 7659, 8, 277, 12, 4153, 12, 486, 548, 304, 267, 334, 6838, 4258, 275, 486, 548, 267, 372, 486, 90, 12, 199, 199, 3008, 13090, 275, 14161, 4619, 8, 7191, 63, 548, 63, 889, 5254, 12, 536, 534, 3008, 13090, 358, 199, 3008, 4619, 275, 662, 3701, 2605, 8, 3008, 13090, 9, 199, 199, 533, 14161, 11596, 18, 68, 8, 46, 14, 11596, 18, 68, 304, 272, 408, 272, 437, 3366, 17461, 4045, 2382, 272, 3865, 1072, 436, 4931, 787, 3366, 14, 272, 710, 1324, 1443, 506, 3366, 503, 440, 14, 272, 408, 272, 3105, 354, 275, 283, 3409, 695, 5598, 18, 68, 7, 272, 11915, 23059, 275, 283, 6636, 11596, 18, 68, 7, 272, 8864, 63, 1450, 275, 399, 7, 1, 6636, 11596, 18, 68, 7, 339, 347, 636, 826, 721, 277, 12, 326, 2457, 63, 890, 2687, 19, 12, 19, 395, 326, 1324, 63, 4445, 29, 403, 12, 1072, 63, 4445, 29, 403, 12, 326, 3878, 63, 1130, 63, 15812, 29, 403, 12, 326, 1007, 3271, 2687, 17, 12, 17, 395, 20169, 9162, 534, 10220, 735, 267, 1613, 8, 6636, 11596, 18, 68, 12, 291, 2843, 826, 721, 1541, 63, 890, 12, 5644, 1324, 63, 4445, 12, 221, 5644, 1072, 63, 4445, 12, 221, 5644, 3878, 63, 1130, 63, 15812, 12, 221, 5644, 1007, 3271, 12, 221, 5644, 9162, 9, 339, 347, 664, 12227, 8, 277, 304, 267, 372, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 362, 12227, 342, 339, 347, 7568, 8, 277, 12, 1324, 3128, 304, 267, 671, 275, 1324, 3128, 59, 16, 61, 267, 336, 66, 275, 377, 14, 7548, 8, 277, 14, 87, 12, 446, 17, 12, 413, 9, 267, 634, 19, 5598, 275, 377, 14, 78, 846, 14, 5598, 18, 68, 8, 88, 12, 3044, 336, 66, 12, 3044, 9162, 63, 632, 29, 277, 14, 8665, 12, 3044, 1007, 3271, 29, 277, 14, 954, 3271, 9, 267, 372, 334, 76, 19, 5598, 4258, 339, 347, 7568, 2320, 8, 277, 12, 1324, 890, 304, 267, 2203, 275, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 6688, 2320, 8, 1210, 890, 9, 267, 372, 2203, 339, 347, 5554, 1378, 5665, 2956, 8, 277, 304, 267, 1559, 2141, 275, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 4498, 1378, 5665, 2956, 342, 267, 372, 1559, 2141, 339, 347, 2248, 2532, 5665, 2956, 8, 277, 12, 307, 1130, 304, 267, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 912, 2532, 5665, 2956, 8, 84, 1130, 9, 339, 768, 3744, 272, 347, 370, 63, 5963, 8, 1886, 12, 5461, 281, 12, 666, 304, 267, 1559, 2141, 275, 666, 14, 4498, 1378, 5665, 2956, 342, 267, 1031, 275, 5461, 281, 14, 13063, 63, 4745, 8, 6636, 11596, 18, 68, 14, 5963, 63, 1450, 12, 1559, 2141, 9, 267, 372, 1031, 339, 768, 3744, 272, 347, 687, 63, 5963, 8, 1886, 12, 5077, 12, 1031, 304, 267, 1559, 2141, 275, 5077, 14, 8514, 63, 4745, 8, 932, 9, 267, 2203, 275, 14161, 11596, 18, 68, 342, 267, 2203, 14, 912, 2532, 5665, 2956, 8, 1113, 2141, 9, 267, 372, 2203, 421, 199, 533, 32613, 285, 794, 8, 46, 14, 5003, 304, 272, 408, 272, 14161, 4045, 370, 2517, 759, 13559, 1324, 272, 436, 21115, 6709, 334, 73, 14, 69, 14, 675, 23669, 4012, 8943, 9, 272, 408, 272, 3105, 354, 275, 283, 3008, 7, 272, 11915, 23059, 275, 283, 13394, 285, 794, 7, 272, 8864, 63, 1450, 275, 399, 7, 1, 13394, 285, 794, 7, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 13394, 285, 794, 12, 291, 2843, 826, 4533, 339, 347, 664, 12227, 8, 277, 304, 267, 372, 942, 2286, 347, 7568, 8, 277, 12, 1324, 3128, 304, 267, 671, 275, 1324, 3128, 59, 16, 61, 267, 671, 275, 377, 14, 7548, 8, 88, 12, 446, 17, 12, 413, 9, 267, 372, 334, 3008, 4619, 8, 88, 16945, 339, 347, 7568, 2320, 8, 277, 12, 1324, 890, 304, 267, 372, 1324, 890, 339, 347, 5554, 1378, 5665, 2956, 8, 277, 304, 267, 1559, 2141, 275, 1613, 8, 13394, 285, 794, 12, 291, 680, 4498, 1378, 5665, 2956, 342, 267, 372, 1559, 2141, 339, 347, 2248, 2532, 5665, 2956, 8, 277, 12, 307, 1130, 304, 267, 1613, 8, 13394, 285, 794, 12, 291, 680, 912, 2532, 5665, 2956, 8, 84, 1130, 9, 339, 768, 3744, 272, 347, 370, 63, 5963, 8, 1886, 12, 5461, 281, 12, 666, 304, 267, 1559, 2141, 275, 666, 14, 4498, 1378, 5665, 2956, 342, 267, 1031, 275, 5461, 281, 14, 13063, 63, 4745, 8, 13394, 285, 794, 14, 5963, 63, 1450, 12, 1559, 2141, 9, 267, 372, 1031, 339, 768, 3744, 272, 347, 687, 63, 5963, 8, 1886, 12, 5077, 12, 1031, 304, 267, 1559, 2141, 275, 5077, 14, 8514, 63, 4745, 8, 932, 9, 267, 2203, 275, 32613, 285, 794, 342, 267, 2203, 14, 912, 2532, 5665, 2956, 8, 1113, 2141, 9, 267, 372, 2203, 199, 199, 318, 511, 63, 1210, 837, 272, 2784, 275, 653, 14, 4491, 342, 272, 2784, 14, 1757, 275, 715, 339, 2784, 14, 409, 3205, 8, 46, 14, 7963, 3205, 1332, 17, 12, 7294, 12, 1651, 1724, 272, 2784, 14, 740, 8, 46, 14, 11596, 18, 68, 8, 1541, 63, 890, 2687, 19, 12, 19, 395, 1324, 63, 4445, 29, 17, 12, 1072, 63, 4445, 29, 708, 430, 272, 2784, 14, 740, 8, 46, 14, 5640, 85, 1012, 272, 2784, 14 ]
[ 2680, 465, 980, 199, 646, 14377, 199, 646, 14377, 14, 3128, 465, 377, 199, 646, 19184, 1095, 14, 1200, 3676, 465, 653, 199, 646, 394, 21, 647, 199, 199, 504, 14377, 14, 7033, 14, 4316, 492, 1910, 695, 13090, 4619, 12, 2011, 63, 548, 63, 889, 5254, 199, 504, 14377, 14, 3128, 14, 6086, 2605, 492, 662, 3701, 2605, 199, 199, 533, 14161, 4619, 8, 22401, 13090, 4619, 304, 272, 347, 286, 63, 600, 8, 277, 12, 1031, 12, 536, 12, 671, 17, 12, 1315, 17, 12, 1007, 304, 267, 671, 275, 671, 17, 59, 16, 61, 267, 1315, 275, 1315, 17, 59, 16, 61, 267, 372, 11792, 90, 9, 83, 275, 6168, 12473, 88, 9, 83, 27556, 450, 9480, 342, 339, 347, 7659, 8, 277, 12, 4153, 12, 486, 548, 304, 267, 334, 6838, 4258, 275, 486, 548, 267, 372, 486, 90, 12, 199, 199, 3008, 13090, 275, 14161, 4619, 8, 7191, 63, 548, 63, 889, 5254, 12, 536, 534, 3008, 13090, 358, 199, 3008, 4619, 275, 662, 3701, 2605, 8, 3008, 13090, 9, 199, 199, 533, 14161, 11596, 18, 68, 8, 46, 14, 11596, 18, 68, 304, 272, 408, 272, 437, 3366, 17461, 4045, 2382, 272, 3865, 1072, 436, 4931, 787, 3366, 14, 272, 710, 1324, 1443, 506, 3366, 503, 440, 14, 272, 408, 272, 3105, 354, 275, 283, 3409, 695, 5598, 18, 68, 7, 272, 11915, 23059, 275, 283, 6636, 11596, 18, 68, 7, 272, 8864, 63, 1450, 275, 399, 7, 1, 6636, 11596, 18, 68, 7, 339, 347, 636, 826, 721, 277, 12, 326, 2457, 63, 890, 2687, 19, 12, 19, 395, 326, 1324, 63, 4445, 29, 403, 12, 1072, 63, 4445, 29, 403, 12, 326, 3878, 63, 1130, 63, 15812, 29, 403, 12, 326, 1007, 3271, 2687, 17, 12, 17, 395, 20169, 9162, 534, 10220, 735, 267, 1613, 8, 6636, 11596, 18, 68, 12, 291, 2843, 826, 721, 1541, 63, 890, 12, 5644, 1324, 63, 4445, 12, 221, 5644, 1072, 63, 4445, 12, 221, 5644, 3878, 63, 1130, 63, 15812, 12, 221, 5644, 1007, 3271, 12, 221, 5644, 9162, 9, 339, 347, 664, 12227, 8, 277, 304, 267, 372, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 362, 12227, 342, 339, 347, 7568, 8, 277, 12, 1324, 3128, 304, 267, 671, 275, 1324, 3128, 59, 16, 61, 267, 336, 66, 275, 377, 14, 7548, 8, 277, 14, 87, 12, 446, 17, 12, 413, 9, 267, 634, 19, 5598, 275, 377, 14, 78, 846, 14, 5598, 18, 68, 8, 88, 12, 3044, 336, 66, 12, 3044, 9162, 63, 632, 29, 277, 14, 8665, 12, 3044, 1007, 3271, 29, 277, 14, 954, 3271, 9, 267, 372, 334, 76, 19, 5598, 4258, 339, 347, 7568, 2320, 8, 277, 12, 1324, 890, 304, 267, 2203, 275, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 6688, 2320, 8, 1210, 890, 9, 267, 372, 2203, 339, 347, 5554, 1378, 5665, 2956, 8, 277, 304, 267, 1559, 2141, 275, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 4498, 1378, 5665, 2956, 342, 267, 372, 1559, 2141, 339, 347, 2248, 2532, 5665, 2956, 8, 277, 12, 307, 1130, 304, 267, 1613, 8, 6636, 11596, 18, 68, 12, 291, 680, 912, 2532, 5665, 2956, 8, 84, 1130, 9, 339, 768, 3744, 272, 347, 370, 63, 5963, 8, 1886, 12, 5461, 281, 12, 666, 304, 267, 1559, 2141, 275, 666, 14, 4498, 1378, 5665, 2956, 342, 267, 1031, 275, 5461, 281, 14, 13063, 63, 4745, 8, 6636, 11596, 18, 68, 14, 5963, 63, 1450, 12, 1559, 2141, 9, 267, 372, 1031, 339, 768, 3744, 272, 347, 687, 63, 5963, 8, 1886, 12, 5077, 12, 1031, 304, 267, 1559, 2141, 275, 5077, 14, 8514, 63, 4745, 8, 932, 9, 267, 2203, 275, 14161, 11596, 18, 68, 342, 267, 2203, 14, 912, 2532, 5665, 2956, 8, 1113, 2141, 9, 267, 372, 2203, 421, 199, 533, 32613, 285, 794, 8, 46, 14, 5003, 304, 272, 408, 272, 14161, 4045, 370, 2517, 759, 13559, 1324, 272, 436, 21115, 6709, 334, 73, 14, 69, 14, 675, 23669, 4012, 8943, 9, 272, 408, 272, 3105, 354, 275, 283, 3008, 7, 272, 11915, 23059, 275, 283, 13394, 285, 794, 7, 272, 8864, 63, 1450, 275, 399, 7, 1, 13394, 285, 794, 7, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 13394, 285, 794, 12, 291, 2843, 826, 4533, 339, 347, 664, 12227, 8, 277, 304, 267, 372, 942, 2286, 347, 7568, 8, 277, 12, 1324, 3128, 304, 267, 671, 275, 1324, 3128, 59, 16, 61, 267, 671, 275, 377, 14, 7548, 8, 88, 12, 446, 17, 12, 413, 9, 267, 372, 334, 3008, 4619, 8, 88, 16945, 339, 347, 7568, 2320, 8, 277, 12, 1324, 890, 304, 267, 372, 1324, 890, 339, 347, 5554, 1378, 5665, 2956, 8, 277, 304, 267, 1559, 2141, 275, 1613, 8, 13394, 285, 794, 12, 291, 680, 4498, 1378, 5665, 2956, 342, 267, 372, 1559, 2141, 339, 347, 2248, 2532, 5665, 2956, 8, 277, 12, 307, 1130, 304, 267, 1613, 8, 13394, 285, 794, 12, 291, 680, 912, 2532, 5665, 2956, 8, 84, 1130, 9, 339, 768, 3744, 272, 347, 370, 63, 5963, 8, 1886, 12, 5461, 281, 12, 666, 304, 267, 1559, 2141, 275, 666, 14, 4498, 1378, 5665, 2956, 342, 267, 1031, 275, 5461, 281, 14, 13063, 63, 4745, 8, 13394, 285, 794, 14, 5963, 63, 1450, 12, 1559, 2141, 9, 267, 372, 1031, 339, 768, 3744, 272, 347, 687, 63, 5963, 8, 1886, 12, 5077, 12, 1031, 304, 267, 1559, 2141, 275, 5077, 14, 8514, 63, 4745, 8, 932, 9, 267, 2203, 275, 32613, 285, 794, 342, 267, 2203, 14, 912, 2532, 5665, 2956, 8, 1113, 2141, 9, 267, 372, 2203, 199, 199, 318, 511, 63, 1210, 837, 272, 2784, 275, 653, 14, 4491, 342, 272, 2784, 14, 1757, 275, 715, 339, 2784, 14, 409, 3205, 8, 46, 14, 7963, 3205, 1332, 17, 12, 7294, 12, 1651, 1724, 272, 2784, 14, 740, 8, 46, 14, 11596, 18, 68, 8, 1541, 63, 890, 2687, 19, 12, 19, 395, 1324, 63, 4445, 29, 17, 12, 1072, 63, 4445, 29, 708, 430, 272, 2784, 14, 740, 8, 46, 14, 5640, 85, 1012, 272, 2784, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mmalorni/server-tools
__unported__/base_external_dbsource/base_external_dbsource.py
6
6672
# -*- coding: utf-8 -*- ############################################################################## # # Daniel Reis # 2011 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import os import logging from openerp.osv import orm, fields from openerp.tools.translate import _ import openerp.tools as tools _logger = logging.getLogger(__name__) CONNECTORS = [] try: import sqlalchemy CONNECTORS.append(('sqlite', 'SQLite')) try: import pymssql CONNECTORS.append(('mssql', 'Microsoft SQL Server')) except: _logger.info('MS SQL Server not available. Please install "pymssql"\ python package.') try: import MySQLdb CONNECTORS.append(('mysql', 'MySQL')) except: _logger.info('MySQL not available. Please install "mysqldb"\ python package.') except: _logger.info('SQL Alchemy not available. Please install "slqalchemy"\ python package.') try: import pyodbc CONNECTORS.append(('pyodbc', 'ODBC')) except: _logger.info('ODBC libraries not available. Please install "unixodbc"\ and "python-pyodbc" packages.') try: import cx_Oracle CONNECTORS.append(('cx_Oracle', 'Oracle')) except: _logger.info('Oracle libraries not available. Please install "cx_Oracle"\ python package.') import psycopg2 CONNECTORS.append(('postgresql', 'PostgreSQL')) class base_external_dbsource(orm.Model): _name = "base.external.dbsource" _description = 'External Database Sources' _columns = { 'name': fields.char('Datasource name', required=True, size=64), 'conn_string': fields.text('Connection string', help=""" Sample connection strings: - Microsoft SQL Server: mssql+pymssql://username:%s@server:port/dbname?charset=utf8 - MySQL: mysql://user:%s@server:port/dbname - ODBC: DRIVER={FreeTDS};SERVER=server.address;Database=mydb;UID=sa - ORACLE: username/%s@//server.address:port/instance - PostgreSQL: dbname='template1' user='dbuser' host='localhost' port='5432' password=%s - SQLite: sqlite:///test.db """), 'password': fields.char('Password', size=40), 'connector': fields.selection(CONNECTORS, 'Connector', required=True, help="If a connector is missing from the\ list, check the server log to confirm\ that the required components were\ detected."), } def conn_open(self, cr, uid, id1): #Get dbsource record data = self.browse(cr, uid, id1) #Build the full connection string connStr = data.conn_string if data.password: if '%s' not in data.conn_string: connStr += ';PWD=%s' connStr = connStr % data.password #Try to connect if data.connector == 'cx_Oracle': os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8' conn = cx_Oracle.connect(connStr) elif data.connector == 'pyodbc': conn = pyodbc.connect(connStr) elif data.connector in ('sqlite', 'mysql', 'mssql'): conn = sqlalchemy.create_engine(connStr).connect() elif data.connector == 'postgresql': conn = psycopg2.connect(connStr) return conn def execute(self, cr, uid, ids, sqlquery, sqlparams=None, metadata=False, context=None): """Executes SQL and returns a list of rows. "sqlparams" can be a dict of values, that can be referenced in the SQL statement using "%(key)s" or, in the case of Oracle, ":key". Example: sqlquery = "select * from mytable where city = %(city)s and date > %(dt)s" params = {'city': 'Lisbon', 'dt': datetime.datetime(2000, 12, 31)} If metadata=True, it will instead return a dict containing the rows list and the columns list, in the format: { 'cols': [ 'col_a', 'col_b', ...] , 'rows': [ (a0, b0, ...), (a1, b1, ...), ...] } """ data = self.browse(cr, uid, ids) rows, cols = list(), list() for obj in data: conn = self.conn_open(cr, uid, obj.id) if obj.connector in ["sqlite", "mysql", "mssql"]: #using sqlalchemy cur = conn.execute(sqlquery, sqlparams) if metadata: cols = cur.keys() rows = [r for r in cur] else: #using other db connectors cur = conn.cursor() cur.execute(sqlquery, sqlparams) if metadata: cols = [d[0] for d in cur.description] rows = cur.fetchall() conn.close() if metadata: return{'cols': cols, 'rows': rows} else: return rows def connection_test(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context): conn = False try: conn = self.conn_open(cr, uid, obj.id) except Exception, e: raise orm.except_orm(_("Connection test failed!"), _("Here is what we got instead:\n %s") % tools.ustr(e)) finally: try: if conn: conn.close() except Exception: # ignored, just a consequence of the previous exception pass #TODO: if OK a (wizard) message box should be displayed raise orm.except_orm(_("Connection test succeeded!"), _("Everything seems properly set up!")) #EOF
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 24747, 14769, 799, 374, 199, 3, 259, 7760, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 747, 199, 646, 2050, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 14, 2537, 465, 7249, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 14657, 4149, 275, 942, 199, 199, 893, 26, 272, 492, 8335, 272, 1868, 6930, 4149, 14, 740, 4725, 10659, 297, 283, 4657, 1175, 1333, 272, 862, 26, 267, 492, 1134, 30230, 267, 1868, 6930, 4149, 14, 740, 4725, 30230, 297, 283, 12940, 5385, 7146, 1333, 272, 871, 26, 267, 485, 2921, 14, 815, 360, 3053, 5385, 7146, 440, 2808, 14, 7754, 3907, 298, 647, 30230, 3212, 1993, 2366, 2559, 2659, 272, 862, 26, 267, 492, 25709, 267, 1868, 6930, 4149, 14, 740, 4725, 8644, 297, 283, 20784, 1333, 272, 871, 26, 267, 485, 2921, 14, 815, 360, 20784, 440, 2808, 14, 7754, 3907, 298, 8644, 697, 3212, 2151, 2366, 2559, 2659, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 4657, 4580, 5623, 440, 2808, 14, 7754, 3907, 298, 2482, 81, 6732, 3212, 326, 2366, 2559, 2659, 199, 893, 26, 272, 492, 1134, 19887, 272, 1868, 6930, 4149, 14, 740, 4725, 647, 19887, 297, 283, 47, 23317, 1333, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 47, 23317, 8363, 440, 2808, 14, 7754, 3907, 298, 11864, 19887, 3212, 326, 436, 298, 1548, 13, 647, 19887, 2, 6117, 2659, 199, 199, 893, 26, 272, 492, 17280, 63, 21202, 272, 1868, 6930, 4149, 14, 740, 4725, 11859, 63, 21202, 297, 283, 21202, 1333, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 21202, 8363, 440, 2808, 14, 7754, 3907, 298, 11859, 63, 21202, 3212, 326, 2366, 2559, 2659, 199, 199, 646, 15492, 18, 199, 14657, 4149, 14, 740, 4725, 15437, 297, 283, 31433, 1333, 421, 199, 533, 1300, 63, 5159, 63, 697, 1365, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 298, 1095, 14, 5159, 14, 697, 1365, 2, 272, 485, 1802, 275, 283, 11389, 8692, 5800, 83, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 28369, 305, 616, 536, 297, 1415, 29, 549, 12, 1568, 29, 772, 395, 267, 283, 1631, 63, 875, 356, 1504, 14, 505, 360, 3225, 1059, 297, 1720, 11916, 199, 8176, 1950, 3326, 26, 199, 13, 15332, 5385, 7146, 26, 523, 333, 385, 1710, 11, 647, 30230, 921, 2473, 2689, 83, 32, 1000, 26, 719, 15, 13238, 31, 6043, 29, 1624, 24, 199, 13, 11200, 26, 12896, 921, 751, 2689, 83, 32, 1000, 26, 719, 15, 13238, 199, 13, 593, 23317, 26, 577, 6129, 2111, 3126, 10146, 52, 3177, 12084, 6613, 29, 1000, 14, 1562, 27, 7243, 29, 1662, 697, 27, 6685, 29, 2231, 199, 13, 1549, 1348, 906, 26, 3434, 3149, 83, 32, 501, 1000, 14, 1562, 26, 719, 15, 842, 199, 13, 20175, 26, 523, 21842, 534, 1160, 17, 7, 922, 534, 68, 464, 332, 7, 1591, 534, 5967, 7, 1844, 534, 1477, 708, 7, 2505, 2458, 83, 199, 13, 19245, 26, 11723, 24436, 396, 14, 697, 199, 624, 395, 267, 283, 2060, 356, 1504, 14, 1560, 360, 6139, 297, 1568, 29, 2167, 395, 267, 283, 11815, 356, 1504, 14, 5592, 8, 14657, 4149, 12, 283, 20476, 297, 4228, 1415, 29, 549, 12, 4228, 1720, 628, 3917, 282, 13252, 365, 4124, 687, 314, 60, 4228, 769, 12, 1104, 314, 1654, 943, 370, 12679, 60, 4228, 626, 314, 1415, 7323, 4898, 60, 4228, 10501, 7651, 272, 789, 339, 347, 2557, 63, 1490, 8, 277, 12, 2467, 12, 1747, 12, 1305, 17, 304, 267, 327, 1002, 1592, 1365, 2777, 267, 666, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1305, 17, 9, 267, 327, 3425, 314, 2615, 1950, 1059, 267, 2557, 2848, 275, 666, 14, 1631, 63, 875, 267, 340, 666, 14, 2060, 26, 288, 340, 1543, 83, 7, 440, 315, 666, 14, 1631, 63, 875, 26, 355, 2557, 2848, 847, 14289, 10780, 36, 2458, 83, 7, 288, 2557, 2848, 275, 2557, 2848, 450, 666, 14, 2060, 267, 327, 12357, 370, 4907, 267, 340, 666, 14, 11815, 508, 283, 11859, 63, 21202, 356, 288, 747, 14, 2314, 459, 46, 5296, 63, 7442, 418, 275, 283, 1156, 18082, 879, 63, 1156, 18082, 33, 14, 6610, 24, 7, 288, 2557, 275, 17280, 63, 21202, 14, 2242, 8, 1631, 2848, 9, 267, 916, 666, 14, 11815, 508, 283, 647, 19887, 356, 288, 2557, 275, 1134, 19887, 14, 2242, 8, 1631, 2848, 9, 267, 916, 666, 14, 11815, 315, 661, 10659, 297, 283, 8644, 297, 283, 30230, 735, 288, 2557, 275, 8335, 14, 981, 63, 3908, 8, 1631, 2848, 680, 2242, 342, 267, 916, 666, 14, 11815, 508, 283, 15437, 356, 288, 2557, 275, 15492, 18, 14, 2242, 8, 1631, 2848, 9, 398, 372, 2557, 339, 347, 5341, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 3875, 1131, 12, 3875, 1162, 29, 403, 12, 3341, 29, 797, 12, 355, 1067, 29, 403, 304, 267, 408, 4858, 3862, 5385, 436, 2529, 282, 769, 402, 4730, 14, 953, 298, 3009, 1162, 2 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 24747, 14769, 799, 374, 199, 3, 259, 7760, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 747, 199, 646, 2050, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 14, 2537, 465, 7249, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 14657, 4149, 275, 942, 199, 199, 893, 26, 272, 492, 8335, 272, 1868, 6930, 4149, 14, 740, 4725, 10659, 297, 283, 4657, 1175, 1333, 272, 862, 26, 267, 492, 1134, 30230, 267, 1868, 6930, 4149, 14, 740, 4725, 30230, 297, 283, 12940, 5385, 7146, 1333, 272, 871, 26, 267, 485, 2921, 14, 815, 360, 3053, 5385, 7146, 440, 2808, 14, 7754, 3907, 298, 647, 30230, 3212, 1993, 2366, 2559, 2659, 272, 862, 26, 267, 492, 25709, 267, 1868, 6930, 4149, 14, 740, 4725, 8644, 297, 283, 20784, 1333, 272, 871, 26, 267, 485, 2921, 14, 815, 360, 20784, 440, 2808, 14, 7754, 3907, 298, 8644, 697, 3212, 2151, 2366, 2559, 2659, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 4657, 4580, 5623, 440, 2808, 14, 7754, 3907, 298, 2482, 81, 6732, 3212, 326, 2366, 2559, 2659, 199, 893, 26, 272, 492, 1134, 19887, 272, 1868, 6930, 4149, 14, 740, 4725, 647, 19887, 297, 283, 47, 23317, 1333, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 47, 23317, 8363, 440, 2808, 14, 7754, 3907, 298, 11864, 19887, 3212, 326, 436, 298, 1548, 13, 647, 19887, 2, 6117, 2659, 199, 199, 893, 26, 272, 492, 17280, 63, 21202, 272, 1868, 6930, 4149, 14, 740, 4725, 11859, 63, 21202, 297, 283, 21202, 1333, 199, 2590, 26, 272, 485, 2921, 14, 815, 360, 21202, 8363, 440, 2808, 14, 7754, 3907, 298, 11859, 63, 21202, 3212, 326, 2366, 2559, 2659, 199, 199, 646, 15492, 18, 199, 14657, 4149, 14, 740, 4725, 15437, 297, 283, 31433, 1333, 421, 199, 533, 1300, 63, 5159, 63, 697, 1365, 8, 1025, 14, 1685, 304, 272, 485, 354, 275, 298, 1095, 14, 5159, 14, 697, 1365, 2, 272, 485, 1802, 275, 283, 11389, 8692, 5800, 83, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 28369, 305, 616, 536, 297, 1415, 29, 549, 12, 1568, 29, 772, 395, 267, 283, 1631, 63, 875, 356, 1504, 14, 505, 360, 3225, 1059, 297, 1720, 11916, 199, 8176, 1950, 3326, 26, 199, 13, 15332, 5385, 7146, 26, 523, 333, 385, 1710, 11, 647, 30230, 921, 2473, 2689, 83, 32, 1000, 26, 719, 15, 13238, 31, 6043, 29, 1624, 24, 199, 13, 11200, 26, 12896, 921, 751, 2689, 83, 32, 1000, 26, 719, 15, 13238, 199, 13, 593, 23317, 26, 577, 6129, 2111, 3126, 10146, 52, 3177, 12084, 6613, 29, 1000, 14, 1562, 27, 7243, 29, 1662, 697, 27, 6685, 29, 2231, 199, 13, 1549, 1348, 906, 26, 3434, 3149, 83, 32, 501, 1000, 14, 1562, 26, 719, 15, 842, 199, 13, 20175, 26, 523, 21842, 534, 1160, 17, 7, 922, 534, 68, 464, 332, 7, 1591, 534, 5967, 7, 1844, 534, 1477, 708, 7, 2505, 2458, 83, 199, 13, 19245, 26, 11723, 24436, 396, 14, 697, 199, 624, 395, 267, 283, 2060, 356, 1504, 14, 1560, 360, 6139, 297, 1568, 29, 2167, 395, 267, 283, 11815, 356, 1504, 14, 5592, 8, 14657, 4149, 12, 283, 20476, 297, 4228, 1415, 29, 549, 12, 4228, 1720, 628, 3917, 282, 13252, 365, 4124, 687, 314, 60, 4228, 769, 12, 1104, 314, 1654, 943, 370, 12679, 60, 4228, 626, 314, 1415, 7323, 4898, 60, 4228, 10501, 7651, 272, 789, 339, 347, 2557, 63, 1490, 8, 277, 12, 2467, 12, 1747, 12, 1305, 17, 304, 267, 327, 1002, 1592, 1365, 2777, 267, 666, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1305, 17, 9, 267, 327, 3425, 314, 2615, 1950, 1059, 267, 2557, 2848, 275, 666, 14, 1631, 63, 875, 267, 340, 666, 14, 2060, 26, 288, 340, 1543, 83, 7, 440, 315, 666, 14, 1631, 63, 875, 26, 355, 2557, 2848, 847, 14289, 10780, 36, 2458, 83, 7, 288, 2557, 2848, 275, 2557, 2848, 450, 666, 14, 2060, 267, 327, 12357, 370, 4907, 267, 340, 666, 14, 11815, 508, 283, 11859, 63, 21202, 356, 288, 747, 14, 2314, 459, 46, 5296, 63, 7442, 418, 275, 283, 1156, 18082, 879, 63, 1156, 18082, 33, 14, 6610, 24, 7, 288, 2557, 275, 17280, 63, 21202, 14, 2242, 8, 1631, 2848, 9, 267, 916, 666, 14, 11815, 508, 283, 647, 19887, 356, 288, 2557, 275, 1134, 19887, 14, 2242, 8, 1631, 2848, 9, 267, 916, 666, 14, 11815, 315, 661, 10659, 297, 283, 8644, 297, 283, 30230, 735, 288, 2557, 275, 8335, 14, 981, 63, 3908, 8, 1631, 2848, 680, 2242, 342, 267, 916, 666, 14, 11815, 508, 283, 15437, 356, 288, 2557, 275, 15492, 18, 14, 2242, 8, 1631, 2848, 9, 398, 372, 2557, 339, 347, 5341, 8, 277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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gogobook/Spirit
example/project/settings/prod.py
5
1898
# -*- coding: utf-8 -*- # MINIMAL CONFIGURATION FOR PRODUCTION ENV # Create your own prod_local.py # import * this module there and use it like this: # python manage.py runserver --settings=project.settings.prod_local from __future__ import unicode_literals from .base import * DEBUG = False # https://docs.djangoproject.com/en/dev/ref/settings/#admins ADMINS = (('John', 'john@example.com'), ) # Secret key generator: https://djskgen.herokuapp.com/ # You should set your key as an environ variable SECRET_KEY = os.environ.get("SECRET_KEY", "") # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = ['.example.com', ] # Extend the Spirit installed apps # Check out the .base.py file for more examples INSTALLED_APPS.extend([ # 'my_app1', ]) # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'mydatabase', 'USER': 'mydatabaseuser', 'PASSWORD': 'mypassword', 'HOST': '127.0.0.1', 'PORT': '5432', } } # These are all the languages Spirit provides. # https://www.transifex.com/projects/p/spirit/ gettext_noop = lambda s: s LANGUAGES = [ ('de', gettext_noop('German')), ('en', gettext_noop('English')), ('es', gettext_noop('Spanish')), ('fr', gettext_noop('French')), ('pl', gettext_noop('Polish')), ('pl-pl', gettext_noop('Poland Polish')), ('ru', gettext_noop('Russian')), ('sv', gettext_noop('Swedish')), ('zh-hans', gettext_noop('Simplified Chinese')), ] # Default language LANGUAGE_CODE = 'en' # Keep templates in memory del TEMPLATES[0]['APP_DIRS'] TEMPLATES[0]['OPTIONS']['loaders'] = [ ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ]
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 15861, 16980, 15869, 15301, 2381, 3611, 4980, 5430, 5070, 54, 199, 199, 3, 2790, 2195, 5705, 12441, 63, 1832, 14, 647, 199, 3, 492, 627, 642, 859, 2337, 436, 675, 652, 2839, 642, 26, 199, 3, 2366, 9635, 14, 647, 1255, 1000, 1553, 1751, 29, 1715, 14, 1751, 14, 8788, 63, 1832, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1095, 492, 627, 421, 199, 5287, 275, 756, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 23121, 199, 14288, 51, 275, 13636, 12923, 297, 283, 20216, 32, 2694, 14, 957, 659, 776, 199, 199, 3, 23580, 790, 4306, 26, 4178, 921, 18256, 1339, 2268, 14, 2523, 745, 85, 571, 14, 957, 15, 199, 3, 2047, 1077, 663, 2195, 790, 465, 376, 6160, 1750, 199, 12961, 63, 3078, 275, 747, 14, 2314, 14, 362, 480, 12961, 63, 3078, 401, 6899, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 6541, 13, 5146, 199, 17350, 63, 23775, 275, 18953, 2694, 14, 957, 297, 1622, 199, 199, 3, 1316, 7169, 314, 428, 1038, 11133, 4903, 8686, 199, 3, 2670, 734, 314, 1275, 1095, 14, 647, 570, 367, 1655, 7251, 199, 15942, 63, 14219, 14, 2880, 779, 272, 327, 283, 1662, 63, 571, 17, 297, 199, 566, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 17439, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 15437, 63, 20270, 18, 297, 267, 283, 2339, 356, 283, 1662, 4659, 297, 267, 283, 3791, 356, 283, 1662, 4659, 751, 297, 267, 283, 9032, 356, 283, 1662, 2060, 297, 267, 283, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 267, 283, 3657, 356, 283, 1477, 708, 297, 272, 789, 199, 93, 199, 199, 3, 5723, 787, 1006, 314, 10815, 428, 1038, 11133, 6571, 14, 199, 3, 4178, 921, 1544, 14, 3936, 338, 70, 476, 14, 957, 15, 6776, 15, 80, 15, 8721, 11133, 15, 199, 5152, 63, 12921, 275, 2400, 308, 26, 308, 199, 26886, 275, 359, 272, 661, 271, 297, 9796, 63, 12921, 360, 27866, 1237, 3855, 272, 661, 287, 297, 9796, 63, 12921, 360, 19410, 3855, 272, 661, 397, 297, 9796, 63, 12921, 360, 23717, 2453, 3855, 272, 661, 4391, 297, 9796, 63, 12921, 360, 38, 15148, 3855, 272, 661, 1168, 297, 9796, 63, 12921, 360, 1575, 1891, 3855, 272, 661, 1168, 13, 1168, 297, 9796, 63, 12921, 360, 5858, 460, 4376, 1891, 3855, 272, 661, 6558, 297, 9796, 63, 12921, 360, 50, 8630, 3855, 272, 661, 2772, 297, 9796, 63, 12921, 360, 51, 1129, 29159, 3855, 272, 661, 3951, 13, 72, 796, 297, 9796, 63, 12921, 360, 51, 3236, 30200, 2799, 26883, 3855, 199, 61, 199, 199, 3, 3758, 2637, 199, 13947, 63, 6012, 275, 283, 287, 7, 199, 199, 3, 14797, 7009, 315, 4402, 199, 2264, 377, 9358, 16601, 59, 16, 2733, 7121, 63, 14455, 418, 199, 25437, 59, 16, 2733, 8808, 2545, 16370, 418, 275, 359, 272, 661, 1176, 14, 1160, 14, 16370, 14, 5245, 14, 5455, 297, 334, 267, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 267, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 272, 22583, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 15861, 16980, 15869, 15301, 2381, 3611, 4980, 5430, 5070, 54, 199, 199, 3, 2790, 2195, 5705, 12441, 63, 1832, 14, 647, 199, 3, 492, 627, 642, 859, 2337, 436, 675, 652, 2839, 642, 26, 199, 3, 2366, 9635, 14, 647, 1255, 1000, 1553, 1751, 29, 1715, 14, 1751, 14, 8788, 63, 1832, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1095, 492, 627, 421, 199, 5287, 275, 756, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 23121, 199, 14288, 51, 275, 13636, 12923, 297, 283, 20216, 32, 2694, 14, 957, 659, 776, 199, 199, 3, 23580, 790, 4306, 26, 4178, 921, 18256, 1339, 2268, 14, 2523, 745, 85, 571, 14, 957, 15, 199, 3, 2047, 1077, 663, 2195, 790, 465, 376, 6160, 1750, 199, 12961, 63, 3078, 275, 747, 14, 2314, 14, 362, 480, 12961, 63, 3078, 401, 6899, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 6541, 13, 5146, 199, 17350, 63, 23775, 275, 18953, 2694, 14, 957, 297, 1622, 199, 199, 3, 1316, 7169, 314, 428, 1038, 11133, 4903, 8686, 199, 3, 2670, 734, 314, 1275, 1095, 14, 647, 570, 367, 1655, 7251, 199, 15942, 63, 14219, 14, 2880, 779, 272, 327, 283, 1662, 63, 571, 17, 297, 199, 566, 199, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 17439, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 15437, 63, 20270, 18, 297, 267, 283, 2339, 356, 283, 1662, 4659, 297, 267, 283, 3791, 356, 283, 1662, 4659, 751, 297, 267, 283, 9032, 356, 283, 1662, 2060, 297, 267, 283, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 267, 283, 3657, 356, 283, 1477, 708, 297, 272, 789, 199, 93, 199, 199, 3, 5723, 787, 1006, 314, 10815, 428, 1038, 11133, 6571, 14, 199, 3, 4178, 921, 1544, 14, 3936, 338, 70, 476, 14, 957, 15, 6776, 15, 80, 15, 8721, 11133, 15, 199, 5152, 63, 12921, 275, 2400, 308, 26, 308, 199, 26886, 275, 359, 272, 661, 271, 297, 9796, 63, 12921, 360, 27866, 1237, 3855, 272, 661, 287, 297, 9796, 63, 12921, 360, 19410, 3855, 272, 661, 397, 297, 9796, 63, 12921, 360, 23717, 2453, 3855, 272, 661, 4391, 297, 9796, 63, 12921, 360, 38, 15148, 3855, 272, 661, 1168, 297, 9796, 63, 12921, 360, 1575, 1891, 3855, 272, 661, 1168, 13, 1168, 297, 9796, 63, 12921, 360, 5858, 460, 4376, 1891, 3855, 272, 661, 6558, 297, 9796, 63, 12921, 360, 50, 8630, 3855, 272, 661, 2772, 297, 9796, 63, 12921, 360, 51, 1129, 29159, 3855, 272, 661, 3951, 13, 72, 796, 297, 9796, 63, 12921, 360, 51, 3236, 30200, 2799, 26883, 3855, 199, 61, 199, 199, 3, 3758, 2637, 199, 13947, 63, 6012, 275, 283, 287, 7, 199, 199, 3, 14797, 7009, 315, 4402, 199, 2264, 377, 9358, 16601, 59, 16, 2733, 7121, 63, 14455, 418, 199, 25437, 59, 16, 2733, 8808, 2545, 16370, 418, 275, 359, 272, 661, 1176, 14, 1160, 14, 16370, 14, 5245, 14, 5455, 297, 334, 267, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 267, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 272, 22583, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
redhat-openstack/trove
trove/tests/api/user_access.py
7
21716
# Copyright 2013 OpenStack Foundation # # 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 random import choice from proboscis import after_class from proboscis import asserts from proboscis import before_class from proboscis import test from troveclient.compat import exceptions from trove import tests from trove.tests.api.instances import instance_info from trove.tests.api.users import TestUsers from trove.tests import util from trove.tests.util import test_config GROUP = "dbaas.api.useraccess" GROUP_POSITIVE = GROUP + ".positive" GROUP_NEGATIVE = GROUP + ".negative" FAKE = test_config.values['fake_mode'] class UserAccessBase(object): """ Base class for Positive and Negative TestUserAccess classes """ users = [] databases = [] def set_up(self): self.dbaas = util.create_dbaas_client(instance_info.user) self.users = ["test_access_user"] self.databases = [("test_access_db%02i" % i) for i in range(4)] def _user_list_from_names(self, usernames): return [{"name": name, "password": "password", "databases": []} for name in usernames] def _grant_access_singular(self, user, databases, expected_response=202): """Grant a single user access to the databases listed. Potentially, expect an exception in the process. """ try: self.dbaas.users.grant(instance_info.id, user, databases) except exceptions.BadRequest: asserts.assert_equal(400, expected_response) except exceptions.NotFound: asserts.assert_equal(404, expected_response) except exceptions.ClientException: asserts.assert_equal(500, expected_response) finally: asserts.assert_equal(expected_response, self.dbaas.last_http_code) def _grant_access_plural(self, users, databases, expected_response=202): """Grant each user in the list access to all the databases listed. Potentially, expect an exception in the process. """ for user in users: self._grant_access_singular(user, databases, expected_response) def _revoke_access_singular(self, user, database, expected_response=202): """Revoke from a user access to the given database . Potentially, expect an exception in the process. """ try: self.dbaas.users.revoke(instance_info.id, user, database) asserts.assert_true(expected_response, self.dbaas.last_http_code) except exceptions.BadRequest: asserts.assert_equal(400, self.dbaas.last_http_code) except exceptions.NotFound: asserts.assert_equal(404, self.dbaas.last_http_code) def _revoke_access_plural(self, users, databases, expected_response=202): """Revoke from each user access to each database. Potentially, expect an exception in the process. """ for user in users: for database in databases: self._revoke_access_singular(user, database, expected_response) def _test_access(self, users, databases, expected_response=200): """Verify that each user in the list has access to each database in the list. """ for user in users: access = self.dbaas.users.list_access(instance_info.id, user) asserts.assert_equal(expected_response, self.dbaas.last_http_code) access = [db.name for db in access] asserts.assert_equal(set(access), set(databases)) def _test_ignore_access(self, users, databases, expected_response=200): databases = [d for d in databases if d not in ['lost+found', 'mysql', 'information_schema']] self._test_access(users, databases, expected_response) def _reset_access(self): for user in self.users: for database in self.databases + self.ghostdbs: try: self.dbaas.users.revoke(instance_info.id, user, database) asserts.assert_true(self.dbaas.last_http_code in [202, 404] ) except exceptions.NotFound: # This is all right here, since we're resetting. pass self._test_access(self.users, []) @test(depends_on_classes=[TestUsers], groups=[tests.DBAAS_API, GROUP, tests.INSTANCES], runs_after=[TestUsers]) class TestUserAccessPasswordChange(UserAccessBase): """ Test that change_password works. """ @before_class def setUp(self): super(TestUserAccessPasswordChange, self).set_up() def _check_mysql_connection(self, username, password, success=True): # This can only test connections for users with the host %. # Much more difficult to simulate connection attempts from other hosts. if FAKE: # "Fake mode; cannot test mysql connection." return conn = util.mysql_connection() if success: conn.create(instance_info.get_address(), username, password) else: conn.assert_fails(instance_info.get_address(), username, password) def _pick_a_user(self): users = self._user_list_from_names(self.users) return choice(users) # Pick one, it doesn't matter. @test() def test_change_password_bogus_user(self): user = self._pick_a_user() user["name"] = "thisuserhasanamethatstoolong" asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.change_passwords, instance_info.id, [user]) asserts.assert_equal(400, self.dbaas.last_http_code) @test() def test_change_password_nonexistent_user(self): user = self._pick_a_user() user["name"] = "thisuserDNE" asserts.assert_raises(exceptions.NotFound, self.dbaas.users.change_passwords, instance_info.id, [user]) asserts.assert_equal(404, self.dbaas.last_http_code) @test() def test_create_user_and_dbs(self): users = self._user_list_from_names(self.users) # Default password for everyone is 'password'. self.dbaas.users.create(instance_info.id, users) asserts.assert_equal(202, self.dbaas.last_http_code) databases = [{"name": db} for db in self.databases] self.dbaas.databases.create(instance_info.id, databases) asserts.assert_equal(202, self.dbaas.last_http_code) @test(depends_on=[test_create_user_and_dbs]) def test_initial_connection(self): user = self._pick_a_user() self._check_mysql_connection(user["name"], "password") @test(depends_on=[test_initial_connection]) def test_change_password(self): # Doesn't actually change anything, just tests that the call doesn't # have any problems. As an aside, also checks that a user can # change its password to the same thing again. user = self._pick_a_user() password = user["password"] self.dbaas.users.change_passwords(instance_info.id, [user]) self._check_mysql_connection(user["name"], password) @test(depends_on=[test_change_password]) def test_change_password_back(self): user = self._pick_a_user() old_password = user["password"] new_password = "NEWPASSWORD" user["password"] = new_password self.dbaas.users.change_passwords(instance_info.id, [user]) self._check_mysql_connection(user["name"], new_password) user["password"] = old_password self.dbaas.users.change_passwords(instance_info.id, [user]) self._check_mysql_connection(user["name"], old_password) @test(depends_on=[test_change_password_back]) def test_change_password_twice(self): # Changing the password twice isn't a problem. user = self._pick_a_user() password = "NEWPASSWORD" user["password"] = password self.dbaas.users.change_passwords(instance_info.id, [user]) self.dbaas.users.change_passwords(instance_info.id, [user]) self._check_mysql_connection(user["name"], password) @after_class(always_run=True) def tearDown(self): for database in self.databases: self.dbaas.databases.delete(instance_info.id, database) asserts.assert_equal(202, self.dbaas.last_http_code) for username in self.users: self.dbaas.users.delete(instance_info.id, username) @test(depends_on_classes=[TestUsers], groups=[tests.DBAAS_API, GROUP, GROUP_POSITIVE, tests.INSTANCES], runs_after=[TestUsers]) class TestUserAccessPositive(UserAccessBase): """ Test the creation and deletion of user grants. """ @before_class def setUp(self): super(TestUserAccessPositive, self).set_up() # None of the ghosts are real databases or users. self.ghostdbs = ["test_user_access_ghost_db"] self.ghostusers = ["test_ghostuser"] self.revokedbs = self.databases[:1] self.remainingdbs = self.databases[1:] def _ensure_nothing_else_created(self): # Make sure grants and revokes do not create users or databases. databases = self.dbaas.databases.list(instance_info.id) database_names = [db.name for db in databases] for ghost in self.ghostdbs: asserts.assert_true(ghost not in database_names) users = self.dbaas.users.list(instance_info.id) user_names = [user.name for user in users] for ghost in self.ghostusers: asserts.assert_true(ghost not in user_names) @test() def test_create_user_and_dbs(self): users = self._user_list_from_names(self.users) self.dbaas.users.create(instance_info.id, users) asserts.assert_equal(202, self.dbaas.last_http_code) databases = [{"name": db} for db in self.databases] self.dbaas.databases.create(instance_info.id, databases) asserts.assert_equal(202, self.dbaas.last_http_code) @test(depends_on=[test_create_user_and_dbs]) def test_no_access(self): # No users have any access to any database. self._reset_access() self._test_access(self.users, []) @test(depends_on=[test_no_access]) def test_grant_full_access(self): # The users are granted access to all test databases. self._reset_access() self._grant_access_plural(self.users, self.databases) self._test_access(self.users, self.databases) @test(depends_on=[test_no_access]) def test_grant_full_access_ignore_databases(self): # The users are granted access to all test databases. all_dbs = [] all_dbs.extend(self.databases) all_dbs.extend(['lost+found', 'mysql', 'information_schema']) self._reset_access() self._grant_access_plural(self.users, self.databases) self._test_ignore_access(self.users, self.databases) @test(depends_on=[test_grant_full_access]) def test_grant_idempotence(self): # Grant operations can be repeated with no ill effects. self._reset_access() for repeat in range(3): self._grant_access_plural(self.users, self.databases) self._test_access(self.users, self.databases) @test(depends_on=[test_grant_full_access]) def test_revoke_one_database(self): # Revoking permission removes that database from a user's list. self._reset_access() self._grant_access_plural(self.users, self.databases) self._test_access(self.users, self.databases) self._revoke_access_plural(self.users, self.revokedbs) self._test_access(self.users, self.remainingdbs) @test(depends_on=[test_grant_full_access]) def test_revoke_non_idempotence(self): # Revoking access cannot be repeated. self._reset_access() self._grant_access_plural(self.users, self.databases) self._revoke_access_plural(self.users, self.revokedbs) self._revoke_access_plural(self.users, self.revokedbs, 404) self._test_access(self.users, self.remainingdbs) @test(depends_on=[test_grant_full_access]) def test_revoke_all_access(self): # Revoking access to all databases will leave their access empty. self._reset_access() self._grant_access_plural(self.users, self.databases) self._revoke_access_plural(self.users, self.revokedbs) self._test_access(self.users, self.remainingdbs) @test(depends_on=[test_grant_full_access]) def test_grant_ghostdbs(self): # Grants to imaginary databases are acceptable, and are honored. self._reset_access() self._ensure_nothing_else_created() self._grant_access_plural(self.users, self.ghostdbs) self._ensure_nothing_else_created() @test(depends_on=[test_grant_full_access]) def test_revoke_ghostdbs(self): # Revokes to imaginary databases are acceptable, and are honored. self._reset_access() self._ensure_nothing_else_created() self._grant_access_plural(self.users, self.ghostdbs) self._revoke_access_plural(self.users, self.ghostdbs) self._ensure_nothing_else_created() @test(depends_on=[test_grant_full_access]) def test_grant_ghostusers(self): # You cannot grant permissions to imaginary users, as imaginary users # don't have passwords we can pull from mysql.users self._reset_access() self._grant_access_plural(self.ghostusers, self.databases, 404) @test(depends_on=[test_grant_full_access]) def test_revoke_ghostusers(self): # You cannot revoke permissions from imaginary users, as imaginary # users don't have passwords we can pull from mysql.users self._reset_access() self._revoke_access_plural(self.ghostusers, self.databases, 404) @after_class(always_run=True) def tearDown(self): self._reset_access() for database in self.databases: self.dbaas.databases.delete(instance_info.id, database) asserts.assert_equal(202, self.dbaas.last_http_code) for username in self.users: self.dbaas.users.delete(instance_info.id, username) @test(depends_on_classes=[TestUserAccessPositive], groups=[tests.DBAAS_API, GROUP, GROUP_NEGATIVE, tests.INSTANCES], depends_on=[TestUserAccessPositive]) class TestUserAccessNegative(UserAccessBase): """ Negative tests for the creation and deletion of user grants. """ @before_class def setUp(self): super(TestUserAccessNegative, self).set_up() self.users = ["qe_user?neg3F", "qe_user#neg23"] self.databases = [("qe_user_neg_db%02i" % i) for i in range(2)] self.ghostdbs = [] def _add_users(self, users, expected_response=202): user_list = self._user_list_from_names(users) try: self.dbaas.users.create(instance_info.id, user_list) asserts.assert_equal(self.dbaas.last_http_code, 202) except exceptions.BadRequest: asserts.assert_equal(self.dbaas.last_http_code, 400) asserts.assert_equal(expected_response, self.dbaas.last_http_code) @test() def test_create_duplicate_user_and_dbs(self): """ Create the same user to the first DB - allowed, not part of change """ users = self._user_list_from_names(self.users) self.dbaas.users.create(instance_info.id, users) asserts.assert_equal(202, self.dbaas.last_http_code) databases = [{"name": db} for db in self.databases] self.dbaas.databases.create(instance_info.id, databases) asserts.assert_equal(202, self.dbaas.last_http_code) @test(depends_on=[test_create_duplicate_user_and_dbs]) def test_neg_duplicate_useraccess(self): """ Grant duplicate users access to all database. """ username = "qe_user.neg2E" self._add_users([username]) self._add_users([username], 400) for repeat in range(3): self._grant_access_plural(self.users, self.databases) self._test_access(self.users, self.databases) @test() def test_re_create_user(self): user_list = ["re_create_user"] # create, grant, then check a new user self._add_users(user_list) self._test_access(user_list, []) self._grant_access_singular(user_list[0], self.databases) self._test_access(user_list, self.databases) # drop the user temporarily self.dbaas.users.delete(instance_info.id, user_list[0]) # check his access - user should not be found asserts.assert_raises(exceptions.NotFound, self.dbaas.users.list_access, instance_info.id, user_list[0]) # re-create the user self._add_users(user_list) # check his access - should not exist self._test_access(user_list, []) # grant user access to all database. self._grant_access_singular(user_list[0], self.databases) # check his access - user should exist self._test_access(user_list, self.databases) # revoke users access self._revoke_access_plural(user_list, self.databases) def _negative_user_test(self, username, databases, create_response=202, grant_response=202, access_response=200, revoke_response=202): # Try and fail to create the user. self._add_users([username], create_response) self._grant_access_singular(username, databases, grant_response) access = None try: access = self.dbaas.users.list_access(instance_info.id, username) asserts.assert_equal(200, self.dbaas.last_http_code) except exceptions.BadRequest: asserts.assert_equal(400, self.dbaas.last_http_code) except exceptions.NotFound: asserts.assert_equal(404, self.dbaas.last_http_code) finally: asserts.assert_equal(access_response, self.dbaas.last_http_code) if access is not None: access = [db.name for db in access] asserts.assert_equal(set(access), set(self.databases)) self._revoke_access_plural([username], databases, revoke_response) @test def test_user_withperiod(self): # This is actually fine; we escape dots in the user-host pairing. self._negative_user_test("test.user", self.databases) @test def test_user_empty_no_host(self): # This creates a request to .../<instance-id>/users//databases, # which is parsed to mean "show me user 'databases', which in this # case is a valid username, but not one of an extant user. self._negative_user_test("", self.databases, 400, 500, 404, 404) @test def test_user_empty_with_host(self): # self._negative_user_test("", self.databases, 400, 400, 400, 400) # Try and fail to create the user. empty_user = {"name": "", "host": "%", "password": "password", "databases": []} asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.create, instance_info.id, [empty_user]) asserts.assert_equal(400, self.dbaas.last_http_code) asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.grant, instance_info.id, "", [], "%") asserts.assert_equal(400, self.dbaas.last_http_code) asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.list_access, instance_info.id, "", "%") asserts.assert_equal(400, self.dbaas.last_http_code) asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.revoke, instance_info.id, "", "db", "%") asserts.assert_equal(400, self.dbaas.last_http_code) @test def test_user_nametoolong(self): # You cannot create a user with this name. # Grant revoke, and access filter this username as invalid. self._negative_user_test("exceed_limit_user", self.databases, 400, 400, 400, 400) @test def test_user_allspaces(self): self._negative_user_test(" ", self.databases, 400, 400, 400, 400) @after_class(always_run=True) def tearDown(self): self._reset_access() for database in self.databases: self.dbaas.databases.delete(instance_info.id, database) asserts.assert_equal(202, self.dbaas.last_http_code) for username in self.users: self.dbaas.users.delete(instance_info.id, username)
apache-2.0
[ 3, 259, 1898, 6171, 14260, 2752, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2196, 492, 7141, 199, 199, 504, 557, 656, 551, 374, 492, 2410, 63, 533, 199, 504, 557, 656, 551, 374, 492, 702, 83, 199, 504, 557, 656, 551, 374, 492, 2544, 63, 533, 199, 504, 557, 656, 551, 374, 492, 511, 199, 504, 307, 11750, 1258, 14, 5819, 492, 4967, 199, 199, 504, 307, 11750, 492, 2295, 199, 504, 307, 11750, 14, 2219, 14, 1246, 14, 5990, 492, 1256, 63, 815, 199, 504, 307, 11750, 14, 2219, 14, 1246, 14, 3707, 492, 1379, 12117, 199, 504, 307, 11750, 14, 2219, 492, 4884, 199, 504, 307, 11750, 14, 2219, 14, 1974, 492, 511, 63, 888, 199, 199, 7823, 275, 298, 27634, 305, 14, 1246, 14, 751, 2732, 2, 199, 7823, 63, 27998, 5399, 275, 15443, 435, 3680, 8965, 2, 199, 7823, 63, 46, 23651, 275, 15443, 435, 3680, 7371, 2, 199, 199, 14623, 275, 511, 63, 888, 14, 1459, 459, 3183, 63, 632, 418, 421, 199, 533, 2876, 3946, 1563, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 30245, 436, 32548, 1379, 1899, 3946, 3992, 272, 408, 272, 4390, 275, 942, 272, 16219, 275, 942, 339, 347, 663, 63, 384, 8, 277, 304, 267, 291, 14, 27634, 305, 275, 4884, 14, 981, 63, 27634, 305, 63, 1258, 8, 842, 63, 815, 14, 751, 9, 267, 291, 14, 3707, 275, 2097, 396, 63, 2732, 63, 751, 937, 267, 291, 14, 17439, 275, 10003, 396, 63, 2732, 63, 697, 5, 996, 73, 2, 450, 284, 9, 367, 284, 315, 1425, 8, 20, 1874, 339, 347, 485, 751, 63, 513, 63, 504, 63, 1247, 8, 277, 12, 922, 1247, 304, 267, 372, 16870, 354, 582, 536, 12, 326, 298, 2060, 582, 298, 2060, 401, 326, 298, 17439, 582, 23455, 367, 536, 315, 922, 1247, 61, 339, 347, 485, 17362, 63, 2732, 63, 17045, 8, 277, 12, 922, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 39, 17633, 282, 2849, 922, 2879, 370, 314, 16219, 10532, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 862, 26, 288, 291, 14, 27634, 305, 14, 3707, 14, 17362, 8, 842, 63, 815, 14, 344, 12, 922, 12, 16219, 9, 267, 871, 4967, 14, 12380, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5303, 12, 1420, 63, 1310, 9, 267, 871, 4967, 14, 4667, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5188, 12, 1420, 63, 1310, 9, 267, 871, 4967, 14, 3041, 1726, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5783, 12, 1420, 63, 1310, 9, 267, 3753, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 339, 347, 485, 17362, 63, 2732, 63, 10019, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 39, 17633, 1924, 922, 315, 314, 769, 2879, 370, 1006, 314, 16219, 10532, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 291, 423, 17362, 63, 2732, 63, 17045, 8, 751, 12, 16219, 12, 1420, 63, 1310, 9, 339, 347, 485, 24445, 63, 2732, 63, 17045, 8, 277, 12, 922, 12, 3050, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 497, 6720, 687, 282, 922, 2879, 370, 314, 1627, 3050, 1275, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 862, 26, 288, 291, 14, 27634, 305, 14, 3707, 14, 24445, 8, 842, 63, 815, 14, 344, 12, 922, 12, 3050, 9, 288, 702, 83, 14, 479, 63, 2052, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 267, 871, 4967, 14, 12380, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5303, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 267, 871, 4967, 14, 4667, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5188, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 339, 347, 485, 24445, 63, 2732, 63, 10019, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 497, 6720, 687, 1924, 922, 2879, 370, 1924, 3050, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 367, 3050, 315, 16219, 26, 355, 291, 423, 24445, 63, 2732, 63, 17045, 8, 751, 12, 6163, 3050, 12, 6163, 1420, 63, 1310, 9, 339, 347, 485, 396, 63, 2732, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 1840, 304, 267, 408, 7496, 626, 1924, 922, 315, 314, 769, 965, 2879, 370, 1924, 3050, 315, 288, 314, 769, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 2879, 275, 291, 14, 27634, 305, 14, 3707, 14, 513, 63, 2732, 8, 842, 63, 815, 14, 344, 12, 922, 9, 288, 702, 83, 14, 479, 63, 1452, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 288, 2879, 275, 359, 697, 14, 354, 367, 1592, 315, 2879, 61, 288, 702, 83, 14, 479, 63, 1452, 8, 409, 8, 2732, 395, 663, 8, 17439, 430, 339, 347, 485, 396, 63, 4247, 63, 2732, 8, 277, 12 ]
[ 259, 1898, 6171, 14260, 2752, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2196, 492, 7141, 199, 199, 504, 557, 656, 551, 374, 492, 2410, 63, 533, 199, 504, 557, 656, 551, 374, 492, 702, 83, 199, 504, 557, 656, 551, 374, 492, 2544, 63, 533, 199, 504, 557, 656, 551, 374, 492, 511, 199, 504, 307, 11750, 1258, 14, 5819, 492, 4967, 199, 199, 504, 307, 11750, 492, 2295, 199, 504, 307, 11750, 14, 2219, 14, 1246, 14, 5990, 492, 1256, 63, 815, 199, 504, 307, 11750, 14, 2219, 14, 1246, 14, 3707, 492, 1379, 12117, 199, 504, 307, 11750, 14, 2219, 492, 4884, 199, 504, 307, 11750, 14, 2219, 14, 1974, 492, 511, 63, 888, 199, 199, 7823, 275, 298, 27634, 305, 14, 1246, 14, 751, 2732, 2, 199, 7823, 63, 27998, 5399, 275, 15443, 435, 3680, 8965, 2, 199, 7823, 63, 46, 23651, 275, 15443, 435, 3680, 7371, 2, 199, 199, 14623, 275, 511, 63, 888, 14, 1459, 459, 3183, 63, 632, 418, 421, 199, 533, 2876, 3946, 1563, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 30245, 436, 32548, 1379, 1899, 3946, 3992, 272, 408, 272, 4390, 275, 942, 272, 16219, 275, 942, 339, 347, 663, 63, 384, 8, 277, 304, 267, 291, 14, 27634, 305, 275, 4884, 14, 981, 63, 27634, 305, 63, 1258, 8, 842, 63, 815, 14, 751, 9, 267, 291, 14, 3707, 275, 2097, 396, 63, 2732, 63, 751, 937, 267, 291, 14, 17439, 275, 10003, 396, 63, 2732, 63, 697, 5, 996, 73, 2, 450, 284, 9, 367, 284, 315, 1425, 8, 20, 1874, 339, 347, 485, 751, 63, 513, 63, 504, 63, 1247, 8, 277, 12, 922, 1247, 304, 267, 372, 16870, 354, 582, 536, 12, 326, 298, 2060, 582, 298, 2060, 401, 326, 298, 17439, 582, 23455, 367, 536, 315, 922, 1247, 61, 339, 347, 485, 17362, 63, 2732, 63, 17045, 8, 277, 12, 922, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 39, 17633, 282, 2849, 922, 2879, 370, 314, 16219, 10532, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 862, 26, 288, 291, 14, 27634, 305, 14, 3707, 14, 17362, 8, 842, 63, 815, 14, 344, 12, 922, 12, 16219, 9, 267, 871, 4967, 14, 12380, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5303, 12, 1420, 63, 1310, 9, 267, 871, 4967, 14, 4667, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5188, 12, 1420, 63, 1310, 9, 267, 871, 4967, 14, 3041, 1726, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5783, 12, 1420, 63, 1310, 9, 267, 3753, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 339, 347, 485, 17362, 63, 2732, 63, 10019, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 39, 17633, 1924, 922, 315, 314, 769, 2879, 370, 1006, 314, 16219, 10532, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 291, 423, 17362, 63, 2732, 63, 17045, 8, 751, 12, 16219, 12, 1420, 63, 1310, 9, 339, 347, 485, 24445, 63, 2732, 63, 17045, 8, 277, 12, 922, 12, 3050, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 497, 6720, 687, 282, 922, 2879, 370, 314, 1627, 3050, 1275, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 862, 26, 288, 291, 14, 27634, 305, 14, 3707, 14, 24445, 8, 842, 63, 815, 14, 344, 12, 922, 12, 3050, 9, 288, 702, 83, 14, 479, 63, 2052, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 267, 871, 4967, 14, 12380, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5303, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 267, 871, 4967, 14, 4667, 26, 288, 702, 83, 14, 479, 63, 1452, 8, 5188, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 339, 347, 485, 24445, 63, 2732, 63, 10019, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 4999, 304, 267, 408, 497, 6720, 687, 1924, 922, 2879, 370, 1924, 3050, 14, 288, 4376, 17690, 12, 4282, 376, 1919, 315, 314, 2112, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 367, 3050, 315, 16219, 26, 355, 291, 423, 24445, 63, 2732, 63, 17045, 8, 751, 12, 6163, 3050, 12, 6163, 1420, 63, 1310, 9, 339, 347, 485, 396, 63, 2732, 8, 277, 12, 4390, 12, 16219, 12, 1420, 63, 1310, 29, 1840, 304, 267, 408, 7496, 626, 1924, 922, 315, 314, 769, 965, 2879, 370, 1924, 3050, 315, 288, 314, 769, 14, 267, 408, 267, 367, 922, 315, 4390, 26, 288, 2879, 275, 291, 14, 27634, 305, 14, 3707, 14, 513, 63, 2732, 8, 842, 63, 815, 14, 344, 12, 922, 9, 288, 702, 83, 14, 479, 63, 1452, 8, 2062, 63, 1310, 12, 291, 14, 27634, 305, 14, 2019, 63, 1014, 63, 600, 9, 288, 2879, 275, 359, 697, 14, 354, 367, 1592, 315, 2879, 61, 288, 702, 83, 14, 479, 63, 1452, 8, 409, 8, 2732, 395, 663, 8, 17439, 430, 339, 347, 485, 396, 63, 4247, 63, 2732, 8, 277, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
100star/h2o
py/testdir_single_jvm/test_GLM2_covtype_train.py
9
4476
import unittest, random, sys, time sys.path.extend(['.','..','../..','py']) import h2o, h2o_cmd, h2o_import as h2i, h2o_exec, h2o_glm, h2o_gbm, h2o_exec as h2e class Basic(unittest.TestCase): def tearDown(self): h2o.check_sandbox_for_errors() @classmethod def setUpClass(cls): h2o.init(java_heap_GB=10) @classmethod def tearDownClass(cls): h2o.tear_down_cloud() def test_GLM2_covtype_train(self): importFolderPath = "standard" csvFilename = 'covtype.shuffled.data' csvPathname = importFolderPath + "/" + csvFilename hex_key = csvFilename + ".hex" # Parse and Exec************************************************ parseResult = h2i.import_parse(bucket='home-0xdiag-datasets', path=csvPathname, schema='put', hex_key=hex_key, timeoutSecs=180) execExpr="A.hex=%s" % parseResult['destination_key'] h2e.exec_expr(execExpr=execExpr, timeoutSecs=30) # use exec to change the output col to binary, case_mode/case_val doesn't work if we use predict # will have to live with random extract. will create variance # class 4 = 1, everything else 0 y = 54 execExpr="A.hex[,%s]=(A.hex[,%s]==%s)" % (y+1, y+1, 4) h2e.exec_expr(execExpr=execExpr, timeoutSecs=30) inspect = h2o_cmd.runInspect(key="A.hex") print "\n" + csvPathname, \ " numRows:", "{:,}".format(inspect['numRows']), \ " numCols:", "{:,}".format(inspect['numCols']) # Split Test/Train************************************************ # how many rows for each pct? numRows = inspect['numRows'] pct10 = int(numRows * .1) rowsForPct = [i * pct10 for i in range(0,11)] # this can be slightly less than 10% last10 = numRows - rowsForPct[9] rowsForPct[10] = last10 # use mod below for picking "rows-to-do" in case we do more than 9 trials # use 10 if 0 just to see (we copied 10 to 0 above) rowsForPct[0] = rowsForPct[10] print "Creating the key of the last 10% data, for scoring" trainDataKey = "rTrain" testDataKey = "rTest" # start at 90% rows + 1 # GLM, predict, CM*******************************************************8 kwargs = { 'response': 'C' + str(y+1), 'max_iter': 20, 'n_folds': 0, 'alpha': 0.1, 'lambda': 1e-5, 'family': 'binomial', 'higher_accuracy': 1, } timeoutSecs = 180 for trial in range(10): # always slice from the beginning rowsToUse = rowsForPct[trial%10] # test/train split **********************************************8 h2o_cmd.createTestTrain(srcKey='A.hex', trainDstKey=trainDataKey, testDstKey=testDataKey, trainPercent=90) aHack = {'destination_key': trainDataKey} parseKey = trainDataKey # GLM **********************************************8 start = time.time() glm = h2o_cmd.runGLM(parseResult=aHack, timeoutSecs=timeoutSecs, pollTimeoutSecs=180, **kwargs) print "glm end on ", parseResult['destination_key'], 'took', time.time() - start, 'seconds' h2o_glm.simpleCheckGLM(self, glm, None, **kwargs) modelKey = glm['glm_model']['_key'] # Score ********************************************** predictKey = 'Predict.hex' start = time.time() predictResult = h2o_cmd.runPredict( data_key=testDataKey, model_key=modelKey, destination_key=predictKey, timeoutSecs=timeoutSecs) predictCMResult = h2o.nodes[0].predict_confusion_matrix( actual=testDataKey, vactual='C' + str(y+1), predict=predictKey, vpredict='predict', ) cm = predictCMResult['cm'] # These will move into the h2o_gbm.py pctWrong = h2o_gbm.pp_cm_summary(cm); self.assertLess(pctWrong, 8,"Should see less than 7% error (class = 4)") print "\nTest\n==========\n" print h2o_gbm.pp_cm(cm) print "Trial #", trial, "completed", "using %6.2f" % (rowsToUse*100.0/numRows), "pct. of all rows" if __name__ == '__main__': h2o.unit_main()
apache-2.0
[ 646, 2882, 12, 2196, 12, 984, 12, 900, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 5093, 703, 1673, 647, 1105, 199, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 12, 394, 18, 79, 63, 1628, 12, 394, 18, 79, 63, 3528, 77, 12, 394, 18, 79, 63, 4908, 77, 12, 394, 18, 79, 63, 1628, 465, 394, 18, 69, 199, 199, 533, 10082, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 394, 18, 79, 14, 1074, 63, 16647, 63, 509, 63, 2550, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 394, 18, 79, 14, 826, 8, 6138, 63, 12492, 63, 6487, 29, 709, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 394, 18, 79, 14, 266, 285, 63, 2110, 63, 4091, 342, 339, 347, 511, 63, 2226, 45, 18, 63, 8695, 466, 63, 2834, 8, 277, 304, 267, 492, 7850, 2042, 275, 298, 6807, 2, 267, 7392, 8117, 275, 283, 8695, 466, 14, 609, 3043, 1146, 14, 576, 7, 267, 7392, 2042, 354, 275, 492, 7850, 2042, 435, 10609, 435, 7392, 8117, 267, 6318, 63, 498, 275, 7392, 8117, 435, 3680, 4097, 2, 398, 327, 6077, 436, 9434, 5815, 3096, 267, 2198, 2889, 275, 394, 18, 73, 14, 646, 63, 1122, 8, 4623, 534, 4219, 13, 16, 88, 6706, 13, 12281, 297, 931, 29, 4737, 2042, 354, 12, 4177, 534, 524, 297, 6318, 63, 498, 29, 4097, 63, 498, 12, 2653, 29224, 29, 7663, 9, 398, 2146, 8561, 628, 33, 14, 4097, 2458, 83, 2, 450, 2198, 2889, 459, 6881, 63, 498, 418, 267, 394, 18, 69, 14, 1628, 63, 3684, 8, 1628, 8561, 29, 1628, 8561, 12, 2653, 29224, 29, 1216, 9, 398, 327, 675, 2146, 370, 1570, 314, 1072, 1048, 370, 3366, 12, 1930, 63, 632, 15, 2546, 63, 637, 3181, 1133, 1736, 340, 781, 675, 12610, 267, 327, 911, 1172, 370, 12166, 543, 2196, 5536, 14, 911, 1218, 11773, 267, 327, 1021, 841, 275, 413, 12, 8137, 587, 378, 267, 612, 275, 13470, 267, 2146, 8561, 628, 33, 14, 4097, 59, 8719, 83, 61, 2687, 33, 14, 4097, 59, 8719, 83, 19219, 5, 83, 2924, 450, 334, 89, 11, 17, 12, 612, 11, 17, 12, 841, 9, 267, 394, 18, 69, 14, 1628, 63, 3684, 8, 1628, 8561, 29, 1628, 8561, 12, 2653, 29224, 29, 1216, 9, 398, 6485, 275, 394, 18, 79, 63, 1760, 14, 1065, 13962, 1764, 8, 498, 628, 33, 14, 4097, 531, 267, 870, 1867, 78, 2, 435, 7392, 2042, 354, 12, 971, 288, 298, 259, 1967, 13405, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 13405, 3815, 971, 288, 298, 259, 1967, 17203, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 17203, 1105, 398, 327, 11740, 1379, 15, 18591, 5815, 3096, 267, 327, 4212, 5002, 4730, 367, 1924, 299, 319, 31, 267, 1967, 13405, 275, 6485, 459, 1507, 13405, 418, 267, 299, 319, 709, 275, 1109, 8, 1507, 13405, 627, 1275, 17, 9, 267, 4730, 1858, 48, 319, 275, 359, 73, 627, 299, 319, 709, 367, 284, 315, 1425, 8, 16, 12, 845, 1874, 267, 327, 642, 883, 506, 18023, 6656, 2419, 1616, 5, 267, 2061, 709, 275, 1967, 13405, 446, 4730, 1858, 48, 319, 59, 25, 61, 267, 4730, 1858, 48, 319, 59, 709, 61, 275, 2061, 709, 267, 327, 675, 3413, 5084, 367, 12433, 298, 3838, 13, 475, 13, 1117, 2, 315, 1930, 781, 886, 1655, 2419, 1749, 16324, 83, 267, 327, 675, 1616, 340, 378, 2951, 370, 1937, 334, 1129, 8876, 1616, 370, 378, 3432, 9, 267, 4730, 1858, 48, 319, 59, 16, 61, 275, 4730, 1858, 48, 319, 59, 709, 61, 398, 870, 298, 14380, 314, 790, 402, 314, 2061, 1616, 5, 666, 12, 367, 24153, 2, 267, 3560, 1451, 1197, 275, 298, 82, 18591, 2, 267, 511, 1451, 1197, 275, 298, 82, 774, 2, 267, 327, 1343, 737, 9137, 5, 4730, 435, 413, 2728, 327, 3563, 45, 12, 12610, 12, 445, 45, 5815, 3096, 1116, 9153, 24, 267, 2074, 275, 469, 288, 283, 1310, 356, 283, 35, 7, 435, 620, 8, 89, 11, 17, 395, 288, 283, 988, 63, 1661, 356, 3388, 12, 7205, 283, 78, 63, 23437, 356, 378, 12, 7205, 283, 4468, 356, 378, 14, 17, 12, 7205, 283, 2734, 356, 413, 69, 13, 21, 12, 7205, 283, 6606, 356, 283, 27578, 297, 288, 283, 32357, 63, 13374, 356, 413, 12, 267, 789, 267, 2653, 29224, 275, 13576, 398, 367, 16324, 315, 1425, 8, 709, 304, 288, 327, 3544, 6014, 687, 314, 9608, 288, 4730, 1378, 6119, 275, 4730, 1858, 48, 319, 59, 14443, 5, 709, 61, 221, 953, 327, 511, 15, 2834, 3715, 1011, 5815, 1801, 1116, 24, 288, 394, 18, 79, 63, 1760, 14, 981, 774, 18591, 8, 2164, 1197, 534, 33, 14, 4097, 297, 3560, 31413, 1197, 29, 2834, 1451, 1197, 12, 511, 31413, 1197, 29, 396, 1451, 1197, 12, 3560, 17931, 29, 2710, 9, 288, 282, 40, 564, 275, 791, 6881, 63, 498, 356, 3560, 1451, 1197, 93, 288, 2198, 1197, 275, 3560, 1451, 1197, 953, 327, 3563, 45, 1011, 5815, 1801, 1116, 24, 288, 1343, 275, 900, 14, 521, 342, 288, 6482, 77, 275, 394, 18, 79, 63, 1760, 14, 1065, 2226, 45, 8, 1122, 2889, 29, 65, 40, 564, 12, 2653, 29224, 29, 2593, 29224, 12, 11271, 6372, 29224, 29, 7663, 12, 1011, 958, 9, 288, 870, 298, 3528, 77, 1284, 641, 3872, 2198, 2889, 459, 6881, 63, 498, 995, 283, 475, 745, 297, 900, 14, 521, 342, 446, 1343, 12, 283, 4515, 7, 288, 394, 18, 79, 63, 3528, 77, 14, 4129, 1799, 2226, 45, 8, 277, 12, 6482, 77, 12, 488, 12, 1011, 958, 9, 288, 1402, 1197, 275, 6482, 77, 459, 3528, 77, 63, 1238, 2545, 63, 498, 418, 953, 327, 25318, 1011, 5815, 1801, 1116, 288, 12610, 1197, 275, 283, 28240, 14, 4097, 7, 288, 1343, 275, 900, 14, 521, 342, 953, 12610, 2889, 275, 394, 18, 79, 63, 1760, 14, 1065, 28240, 8, 355, 666, 63, 498, 29, 396, 1451, 1197, 12, 355, 1402, 63, 498, 29, 1238, 1197 ]
[ 2882, 12, 2196, 12, 984, 12, 900, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 5093, 703, 1673, 647, 1105, 199, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 12, 394, 18, 79, 63, 1628, 12, 394, 18, 79, 63, 3528, 77, 12, 394, 18, 79, 63, 4908, 77, 12, 394, 18, 79, 63, 1628, 465, 394, 18, 69, 199, 199, 533, 10082, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 394, 18, 79, 14, 1074, 63, 16647, 63, 509, 63, 2550, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 394, 18, 79, 14, 826, 8, 6138, 63, 12492, 63, 6487, 29, 709, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 394, 18, 79, 14, 266, 285, 63, 2110, 63, 4091, 342, 339, 347, 511, 63, 2226, 45, 18, 63, 8695, 466, 63, 2834, 8, 277, 304, 267, 492, 7850, 2042, 275, 298, 6807, 2, 267, 7392, 8117, 275, 283, 8695, 466, 14, 609, 3043, 1146, 14, 576, 7, 267, 7392, 2042, 354, 275, 492, 7850, 2042, 435, 10609, 435, 7392, 8117, 267, 6318, 63, 498, 275, 7392, 8117, 435, 3680, 4097, 2, 398, 327, 6077, 436, 9434, 5815, 3096, 267, 2198, 2889, 275, 394, 18, 73, 14, 646, 63, 1122, 8, 4623, 534, 4219, 13, 16, 88, 6706, 13, 12281, 297, 931, 29, 4737, 2042, 354, 12, 4177, 534, 524, 297, 6318, 63, 498, 29, 4097, 63, 498, 12, 2653, 29224, 29, 7663, 9, 398, 2146, 8561, 628, 33, 14, 4097, 2458, 83, 2, 450, 2198, 2889, 459, 6881, 63, 498, 418, 267, 394, 18, 69, 14, 1628, 63, 3684, 8, 1628, 8561, 29, 1628, 8561, 12, 2653, 29224, 29, 1216, 9, 398, 327, 675, 2146, 370, 1570, 314, 1072, 1048, 370, 3366, 12, 1930, 63, 632, 15, 2546, 63, 637, 3181, 1133, 1736, 340, 781, 675, 12610, 267, 327, 911, 1172, 370, 12166, 543, 2196, 5536, 14, 911, 1218, 11773, 267, 327, 1021, 841, 275, 413, 12, 8137, 587, 378, 267, 612, 275, 13470, 267, 2146, 8561, 628, 33, 14, 4097, 59, 8719, 83, 61, 2687, 33, 14, 4097, 59, 8719, 83, 19219, 5, 83, 2924, 450, 334, 89, 11, 17, 12, 612, 11, 17, 12, 841, 9, 267, 394, 18, 69, 14, 1628, 63, 3684, 8, 1628, 8561, 29, 1628, 8561, 12, 2653, 29224, 29, 1216, 9, 398, 6485, 275, 394, 18, 79, 63, 1760, 14, 1065, 13962, 1764, 8, 498, 628, 33, 14, 4097, 531, 267, 870, 1867, 78, 2, 435, 7392, 2042, 354, 12, 971, 288, 298, 259, 1967, 13405, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 13405, 3815, 971, 288, 298, 259, 1967, 17203, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 17203, 1105, 398, 327, 11740, 1379, 15, 18591, 5815, 3096, 267, 327, 4212, 5002, 4730, 367, 1924, 299, 319, 31, 267, 1967, 13405, 275, 6485, 459, 1507, 13405, 418, 267, 299, 319, 709, 275, 1109, 8, 1507, 13405, 627, 1275, 17, 9, 267, 4730, 1858, 48, 319, 275, 359, 73, 627, 299, 319, 709, 367, 284, 315, 1425, 8, 16, 12, 845, 1874, 267, 327, 642, 883, 506, 18023, 6656, 2419, 1616, 5, 267, 2061, 709, 275, 1967, 13405, 446, 4730, 1858, 48, 319, 59, 25, 61, 267, 4730, 1858, 48, 319, 59, 709, 61, 275, 2061, 709, 267, 327, 675, 3413, 5084, 367, 12433, 298, 3838, 13, 475, 13, 1117, 2, 315, 1930, 781, 886, 1655, 2419, 1749, 16324, 83, 267, 327, 675, 1616, 340, 378, 2951, 370, 1937, 334, 1129, 8876, 1616, 370, 378, 3432, 9, 267, 4730, 1858, 48, 319, 59, 16, 61, 275, 4730, 1858, 48, 319, 59, 709, 61, 398, 870, 298, 14380, 314, 790, 402, 314, 2061, 1616, 5, 666, 12, 367, 24153, 2, 267, 3560, 1451, 1197, 275, 298, 82, 18591, 2, 267, 511, 1451, 1197, 275, 298, 82, 774, 2, 267, 327, 1343, 737, 9137, 5, 4730, 435, 413, 2728, 327, 3563, 45, 12, 12610, 12, 445, 45, 5815, 3096, 1116, 9153, 24, 267, 2074, 275, 469, 288, 283, 1310, 356, 283, 35, 7, 435, 620, 8, 89, 11, 17, 395, 288, 283, 988, 63, 1661, 356, 3388, 12, 7205, 283, 78, 63, 23437, 356, 378, 12, 7205, 283, 4468, 356, 378, 14, 17, 12, 7205, 283, 2734, 356, 413, 69, 13, 21, 12, 7205, 283, 6606, 356, 283, 27578, 297, 288, 283, 32357, 63, 13374, 356, 413, 12, 267, 789, 267, 2653, 29224, 275, 13576, 398, 367, 16324, 315, 1425, 8, 709, 304, 288, 327, 3544, 6014, 687, 314, 9608, 288, 4730, 1378, 6119, 275, 4730, 1858, 48, 319, 59, 14443, 5, 709, 61, 221, 953, 327, 511, 15, 2834, 3715, 1011, 5815, 1801, 1116, 24, 288, 394, 18, 79, 63, 1760, 14, 981, 774, 18591, 8, 2164, 1197, 534, 33, 14, 4097, 297, 3560, 31413, 1197, 29, 2834, 1451, 1197, 12, 511, 31413, 1197, 29, 396, 1451, 1197, 12, 3560, 17931, 29, 2710, 9, 288, 282, 40, 564, 275, 791, 6881, 63, 498, 356, 3560, 1451, 1197, 93, 288, 2198, 1197, 275, 3560, 1451, 1197, 953, 327, 3563, 45, 1011, 5815, 1801, 1116, 24, 288, 1343, 275, 900, 14, 521, 342, 288, 6482, 77, 275, 394, 18, 79, 63, 1760, 14, 1065, 2226, 45, 8, 1122, 2889, 29, 65, 40, 564, 12, 2653, 29224, 29, 2593, 29224, 12, 11271, 6372, 29224, 29, 7663, 12, 1011, 958, 9, 288, 870, 298, 3528, 77, 1284, 641, 3872, 2198, 2889, 459, 6881, 63, 498, 995, 283, 475, 745, 297, 900, 14, 521, 342, 446, 1343, 12, 283, 4515, 7, 288, 394, 18, 79, 63, 3528, 77, 14, 4129, 1799, 2226, 45, 8, 277, 12, 6482, 77, 12, 488, 12, 1011, 958, 9, 288, 1402, 1197, 275, 6482, 77, 459, 3528, 77, 63, 1238, 2545, 63, 498, 418, 953, 327, 25318, 1011, 5815, 1801, 1116, 288, 12610, 1197, 275, 283, 28240, 14, 4097, 7, 288, 1343, 275, 900, 14, 521, 342, 953, 12610, 2889, 275, 394, 18, 79, 63, 1760, 14, 1065, 28240, 8, 355, 666, 63, 498, 29, 396, 1451, 1197, 12, 355, 1402, 63, 498, 29, 1238, 1197, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zieckey/sdhash
sdhash-ui/cherrypy/tutorial/tut03_get_and_post.py
36
1733
""" Tutorial - Passing variables This tutorial shows you how to pass GET/POST variables to methods. """ import cherrypy class WelcomePage: def index(self): # Ask for the user's name. return ''' <form action="greetUser" method="GET"> What is your name? <input type="text" name="name" /> <input type="submit" /> </form>''' index.exposed = True def greetUser(self, name = None): # CherryPy passes all GET and POST variables as method parameters. # It doesn't make a difference where the variables come from, how # large their contents are, and so on. # # You can define default parameter values as usual. In this # example, the "name" parameter defaults to None so we can check # if a name was actually specified. if name: # Greet the user! return "Hey %s, what's up?" % name else: if name is None: # No name was specified return 'Please enter your name <a href="./">here</a>.' else: return 'No, really, enter your name <a href="./">here</a>.' greetUser.exposed = True import os.path tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': # CherryPy always starts with app.root when trying to map request URIs # to objects, so we need to mount a request handler root. A request # to '/' will be mapped to HelloWorld().index(). cherrypy.quickstart(WelcomePage(), config=tutconf) else: # This branch is for the test suite; you can ignore it. cherrypy.tree.mount(WelcomePage(), config=tutconf)
apache-2.0
[ 624, 199, 52, 15888, 446, 31755, 2860, 199, 199, 2765, 307, 15888, 13703, 1265, 4212, 370, 986, 9576, 15, 4030, 2860, 370, 3102, 14, 199, 624, 199, 199, 646, 13397, 421, 199, 533, 644, 14628, 3276, 26, 339, 347, 1478, 8, 277, 304, 267, 327, 30481, 367, 314, 922, 1159, 536, 14, 267, 372, 1449, 288, 665, 964, 1595, 628, 71, 7936, 1899, 2, 1083, 628, 2970, 1743, 288, 14791, 365, 2195, 536, 31, 288, 665, 1210, 730, 628, 505, 2, 536, 628, 354, 2, 7082, 288, 665, 1210, 730, 628, 7275, 2, 7082, 288, 3068, 964, 26934, 272, 1478, 14, 26717, 275, 715, 2286, 347, 486, 7936, 1899, 8, 277, 12, 536, 275, 488, 304, 267, 327, 30992, 27794, 14933, 1006, 9576, 436, 8761, 2860, 465, 1083, 2633, 14, 267, 327, 2779, 3181, 1133, 1852, 282, 8865, 2382, 314, 2860, 11492, 687, 12, 4212, 267, 327, 7031, 3932, 4072, 787, 12, 436, 880, 641, 14, 267, 327, 267, 327, 2047, 883, 5627, 849, 2725, 1338, 465, 20195, 14, 1010, 642, 267, 327, 2893, 12, 314, 298, 354, 2, 2725, 4243, 370, 488, 880, 781, 883, 1104, 267, 327, 340, 282, 536, 1990, 5965, 2013, 14, 2728, 340, 536, 26, 288, 327, 598, 7936, 314, 922, 1, 288, 372, 298, 1966, 89, 450, 83, 12, 4052, 1159, 1536, 13472, 450, 536, 267, 587, 26, 288, 340, 536, 365, 488, 26, 355, 327, 3091, 536, 1990, 2013, 355, 372, 283, 8254, 9509, 2195, 536, 665, 65, 4369, 628, 13186, 1743, 1681, 1108, 65, 30, 3530, 288, 587, 26, 355, 372, 283, 1944, 12, 7710, 12, 9509, 2195, 536, 665, 65, 4369, 628, 13186, 1743, 1681, 1108, 65, 30, 3530, 272, 486, 7936, 1899, 14, 26717, 275, 715, 421, 199, 646, 747, 14, 515, 199, 84, 337, 2190, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 23561, 14, 2190, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 30992, 27794, 3544, 9174, 543, 1145, 14, 1231, 1380, 9936, 370, 2341, 1056, 30143, 272, 327, 370, 2251, 12, 880, 781, 1929, 370, 10760, 282, 1056, 3016, 1738, 14, 437, 1056, 272, 327, 370, 7324, 911, 506, 9994, 370, 23833, 15943, 1252, 1080, 1252, 272, 13397, 14, 28957, 8, 24679, 3276, 1062, 1101, 29, 84, 337, 2190, 9, 199, 2836, 26, 272, 327, 961, 5246, 365, 367, 314, 511, 5241, 27, 1265, 883, 3686, 652, 14, 272, 13397, 14, 2350, 14, 3956, 8, 24679, 3276, 1062, 1101, 29, 84, 337, 2190, 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 ]
[ 199, 52, 15888, 446, 31755, 2860, 199, 199, 2765, 307, 15888, 13703, 1265, 4212, 370, 986, 9576, 15, 4030, 2860, 370, 3102, 14, 199, 624, 199, 199, 646, 13397, 421, 199, 533, 644, 14628, 3276, 26, 339, 347, 1478, 8, 277, 304, 267, 327, 30481, 367, 314, 922, 1159, 536, 14, 267, 372, 1449, 288, 665, 964, 1595, 628, 71, 7936, 1899, 2, 1083, 628, 2970, 1743, 288, 14791, 365, 2195, 536, 31, 288, 665, 1210, 730, 628, 505, 2, 536, 628, 354, 2, 7082, 288, 665, 1210, 730, 628, 7275, 2, 7082, 288, 3068, 964, 26934, 272, 1478, 14, 26717, 275, 715, 2286, 347, 486, 7936, 1899, 8, 277, 12, 536, 275, 488, 304, 267, 327, 30992, 27794, 14933, 1006, 9576, 436, 8761, 2860, 465, 1083, 2633, 14, 267, 327, 2779, 3181, 1133, 1852, 282, 8865, 2382, 314, 2860, 11492, 687, 12, 4212, 267, 327, 7031, 3932, 4072, 787, 12, 436, 880, 641, 14, 267, 327, 267, 327, 2047, 883, 5627, 849, 2725, 1338, 465, 20195, 14, 1010, 642, 267, 327, 2893, 12, 314, 298, 354, 2, 2725, 4243, 370, 488, 880, 781, 883, 1104, 267, 327, 340, 282, 536, 1990, 5965, 2013, 14, 2728, 340, 536, 26, 288, 327, 598, 7936, 314, 922, 1, 288, 372, 298, 1966, 89, 450, 83, 12, 4052, 1159, 1536, 13472, 450, 536, 267, 587, 26, 288, 340, 536, 365, 488, 26, 355, 327, 3091, 536, 1990, 2013, 355, 372, 283, 8254, 9509, 2195, 536, 665, 65, 4369, 628, 13186, 1743, 1681, 1108, 65, 30, 3530, 288, 587, 26, 355, 372, 283, 1944, 12, 7710, 12, 9509, 2195, 536, 665, 65, 4369, 628, 13186, 1743, 1681, 1108, 65, 30, 3530, 272, 486, 7936, 1899, 14, 26717, 275, 715, 421, 199, 646, 747, 14, 515, 199, 84, 337, 2190, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 23561, 14, 2190, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 30992, 27794, 3544, 9174, 543, 1145, 14, 1231, 1380, 9936, 370, 2341, 1056, 30143, 272, 327, 370, 2251, 12, 880, 781, 1929, 370, 10760, 282, 1056, 3016, 1738, 14, 437, 1056, 272, 327, 370, 7324, 911, 506, 9994, 370, 23833, 15943, 1252, 1080, 1252, 272, 13397, 14, 28957, 8, 24679, 3276, 1062, 1101, 29, 84, 337, 2190, 9, 199, 2836, 26, 272, 327, 961, 5246, 365, 367, 314, 511, 5241, 27, 1265, 883, 3686, 652, 14, 272, 13397, 14, 2350, 14, 3956, 8, 24679, 3276, 1062, 1101, 29, 84, 337, 2190, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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nondot.org/sabre/os/files/FileSystems/iso9660.pdf Author: Victor Stinner Creation: 11 july 2006 """ from hachoir_parser import Parser from hachoir_core.field import (FieldSet, ParserError, UInt8, UInt32, UInt64, Enum, NullBytes, RawBytes, String) from hachoir_core.endian import LITTLE_ENDIAN, BIG_ENDIAN class PrimaryVolumeDescriptor(FieldSet): static_size = 2041*8 def createFields(self): yield NullBytes(self, "unused[]", 1) yield String(self, "system_id", 32, "System identifier", strip=" ") yield String(self, "volume_id", 32, "Volume identifier", strip=" ") yield NullBytes(self, "unused[]", 8) yield UInt64(self, "space_size", "Volume space size") yield NullBytes(self, "unused[]", 32) yield UInt32(self, "set_size", "Volume set size") yield UInt32(self, "seq_num", "Sequence number") yield UInt32(self, "block_size", "Block size") yield UInt64(self, "path_table_size", "Path table size") yield UInt32(self, "occu_lpath", "Location of Occurrence of Type L Path Table") yield UInt32(self, "opt_lpath", "Location of Optional of Type L Path Table") yield UInt32(self, "occu_mpath", "Location of Occurrence of Type M Path Table") yield UInt32(self, "opt_mpath", "Location of Optional of Type M Path Table") yield RawBytes(self, "root", 34, "Directory Record for Root Directory") yield String(self, "vol_set_id", 128, "Volume set identifier", strip=" ") yield String(self, "publisher", 128, "Publisher identifier", strip=" ") yield String(self, "data_preparer", 128, "Data preparer identifier", strip=" ") yield String(self, "application", 128, "Application identifier", strip=" ") yield String(self, "copyright", 37, "Copyright file identifier", strip=" ") yield String(self, "abstract", 37, "Abstract file identifier", strip=" ") yield String(self, "biographic", 37, "Biographic file identifier", strip=" ") yield String(self, "creation_ts", 17, "Creation date and time", strip=" ") yield String(self, "modification_ts", 17, "Modification date and time", strip=" ") yield String(self, "expiration_ts", 17, "Expiration date and time", strip=" ") yield String(self, "effective_ts", 17, "Effective date and time", strip=" ") yield UInt8(self, "struct_ver", "Structure version") yield NullBytes(self, "unused[]", 1) yield String(self, "app_use", 512, "Application use", strip=" \0") yield NullBytes(self, "unused[]", 653) class BootRecord(FieldSet): static_size = 2041*8 def createFields(self): yield String(self, "sys_id", 31, "Boot system identifier", strip="\0") yield String(self, "boot_id", 31, "Boot identifier", strip="\0") yield RawBytes(self, "system_use", 1979, "Boot system use") class Terminator(FieldSet): static_size = 2041*8 def createFields(self): yield NullBytes(self, "null", 2041) class Volume(FieldSet): endian = BIG_ENDIAN TERMINATOR = 255 type_name = { 0: "Boot Record", 1: "Primary Volume Descriptor", 2: "Supplementary Volume Descriptor", 3: "Volume Partition Descriptor", TERMINATOR: "Volume Descriptor Set Terminator", } static_size = 2048 * 8 content_handler = { 0: BootRecord, 1: PrimaryVolumeDescriptor, TERMINATOR: Terminator, } def createFields(self): yield Enum(UInt8(self, "type", "Volume descriptor type"), self.type_name) yield RawBytes(self, "signature", 5, "ISO 9960 signature (CD001)") if self["signature"].value != "CD001": raise ParserError("Invalid ISO 9960 volume signature") yield UInt8(self, "version", "Volume descriptor version") cls = self.content_handler.get(self["type"].value, None) if cls: yield cls(self, "content") else: yield RawBytes(self, "raw_content", 2048-7) class ISO9660(Parser): endian = LITTLE_ENDIAN MAGIC = "\x01CD001" NULL_BYTES = 0x8000 PARSER_TAGS = { "id": "iso9660", "category": "file_system", "description": "ISO 9660 file system", "min_size": (NULL_BYTES + 6)*8, "magic": ((MAGIC, NULL_BYTES*8),), } def validate(self): if self.stream.readBytes(self.NULL_BYTES*8, len(self.MAGIC)) != self.MAGIC: return "Invalid signature" return True def createFields(self): yield self.seekByte(self.NULL_BYTES, null=True) while True: volume = Volume(self, "volume[]") yield volume if volume["type"].value == Volume.TERMINATOR: break if self.current_size < self._size: yield self.seekBit(self._size, "end")
gpl-2.0
[ 624, 199, 7336, 1749, 15268, 334, 2866, 417, 9, 570, 2656, 1798, 14, 199, 199, 26872, 26, 199, 13, 9739, 15352, 2054, 13, 7119, 334, 271, 26381, 5851, 1555, 9, 523, 1455, 921, 1544, 14, 2865, 3287, 14, 1308, 15, 83, 371, 264, 15, 736, 15, 1725, 15, 17521, 83, 15, 4595, 25, 15268, 14, 5607, 199, 199, 5949, 26, 6561, 630, 428, 1346, 1372, 199, 13921, 26, 4119, 1335, 21797, 8315, 199, 624, 199, 199, 504, 394, 21301, 63, 2087, 492, 10191, 199, 504, 394, 21301, 63, 1018, 14, 698, 492, 334, 23532, 12, 10191, 547, 12, 272, 10666, 24, 12, 10666, 708, 12, 10666, 772, 12, 11305, 12, 272, 12119, 5571, 12, 13480, 5571, 12, 2624, 9, 199, 504, 394, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 12, 16524, 63, 21046, 199, 199, 533, 26710, 6464, 4311, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 413, 9, 267, 1995, 2624, 8, 277, 12, 298, 2253, 63, 344, 401, 4337, 12, 298, 3989, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 2405, 63, 344, 401, 4337, 12, 298, 6464, 5148, 401, 6202, 628, 6099, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 1695, 9, 267, 1995, 10666, 772, 8, 277, 12, 298, 2638, 63, 890, 401, 298, 6464, 4601, 1568, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 4337, 9, 267, 1995, 10666, 708, 8, 277, 12, 298, 409, 63, 890, 401, 298, 6464, 663, 1568, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 3610, 63, 1507, 401, 298, 5826, 1329, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 1457, 63, 890, 401, 298, 3142, 1568, 531, 267, 1995, 10666, 772, 8, 277, 12, 298, 515, 63, 1224, 63, 890, 401, 298, 2042, 1817, 1568, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 679, 15140, 63, 76, 515, 401, 298, 6592, 402, 593, 67, 895, 4646, 402, 2434, 491, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 2992, 63, 76, 515, 401, 298, 6592, 402, 4879, 402, 2434, 491, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 679, 15140, 63, 8075, 401, 298, 6592, 402, 593, 67, 895, 4646, 402, 2434, 603, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 2992, 63, 8075, 401, 298, 6592, 402, 4879, 402, 2434, 603, 6912, 6957, 531, 267, 1995, 13480, 5571, 8, 277, 12, 298, 1231, 401, 8177, 12, 298, 6231, 12651, 367, 12826, 15191, 531, 267, 1995, 2624, 8, 277, 12, 298, 5650, 63, 409, 63, 344, 401, 7960, 12, 298, 6464, 663, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 12789, 401, 7960, 12, 298, 27341, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 576, 63, 657, 24939, 401, 7960, 12, 298, 1451, 876, 24939, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 3578, 401, 7960, 12, 298, 5039, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 7307, 401, 6877, 12, 298, 7384, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 6198, 401, 6877, 12, 298, 8458, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 17614, 9770, 401, 6877, 12, 298, 34, 2308, 9770, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 8782, 63, 1086, 401, 5557, 12, 298, 13921, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 20945, 63, 1086, 401, 5557, 12, 298, 29188, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 15469, 63, 1086, 401, 5557, 12, 298, 14000, 1754, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 20427, 63, 1086, 401, 5557, 12, 298, 30754, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 10666, 24, 8, 277, 12, 298, 1820, 63, 422, 401, 298, 10766, 1015, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 413, 9, 267, 1995, 2624, 8, 277, 12, 298, 571, 63, 1180, 401, 10574, 12, 298, 5039, 675, 401, 6202, 628, 971, 16, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 1227, 2481, 9, 199, 199, 533, 27324, 5433, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 2624, 8, 277, 12, 298, 1274, 63, 344, 401, 7105, 12, 298, 17989, 2656, 5148, 401, 6202, 21024, 16, 531, 267, 1995, 2624, 8, 277, 12, 298, 4930, 63, 344, 401, 7105, 12, 298, 17989, 5148, 401, 6202, 21024, 16, 531, 267, 1995, 13480, 5571, 8, 277, 12, 298, 2253, 63, 1180, 401, 5851, 1965, 12, 298, 17989, 2656, 675, 531, 199, 199, 533, 20429, 707, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 12119, 5571, 8, 277, 12, 298, 2307, 401, 499, 10531, 9, 199, 199, 533, 15018, 8, 23532, 304, 272, 17638, 275, 16524, 63, 21046, 272, 31510, 4896, 6467, 275, 5450, 272, 730, 63, 354, 275, 469, 267, 378, 26, 298, 17989, 12651, 401, 267, 413, 26, 298, 14908, 15018, 28131, 401, 267, 499, 26, 298, 17127, 968, 695, 15018, 28131, 401, 267, 650, 26, 298, 6464, 27353, 28131, 401, 267, 31510, 4896, 6467, 26, 298, 6464, 28131, 2494, 20429, 707, 401, 272, 789, 272, 2955, 63, 890, 275, 18427, 627, 1695, 272, 1564, 63, 2232, 275, 469, 267, 378, 26, 27324, 5433, 12, 267, 413, 26, 26710, 6464, 4311, 12, 267, 31510, 4896, 6467, 26, 20429, 707, 12, 272, 789, 339, 347, 24828, 8, 277, 304, 267, 1995, 11305, 8, 13304, 24, 8, 277, 12, 298, 466, 401, 298, 6464, 5872, 730, 1288, 291, 14, 466, 63, 354, 9, 267, 1995, 13480, 5571, 8, 277, 12, 298, 5233, 401, 959, 12, 298, 7336, 8806, 2259, 4955, 334, 7695, 4587, 6320, 267, 340, 291, 905, 5233, 4140, 585, 1137, 298, 7695, 4587 ]
[ 199, 7336, 1749, 15268, 334, 2866, 417, 9, 570, 2656, 1798, 14, 199, 199, 26872, 26, 199, 13, 9739, 15352, 2054, 13, 7119, 334, 271, 26381, 5851, 1555, 9, 523, 1455, 921, 1544, 14, 2865, 3287, 14, 1308, 15, 83, 371, 264, 15, 736, 15, 1725, 15, 17521, 83, 15, 4595, 25, 15268, 14, 5607, 199, 199, 5949, 26, 6561, 630, 428, 1346, 1372, 199, 13921, 26, 4119, 1335, 21797, 8315, 199, 624, 199, 199, 504, 394, 21301, 63, 2087, 492, 10191, 199, 504, 394, 21301, 63, 1018, 14, 698, 492, 334, 23532, 12, 10191, 547, 12, 272, 10666, 24, 12, 10666, 708, 12, 10666, 772, 12, 11305, 12, 272, 12119, 5571, 12, 13480, 5571, 12, 2624, 9, 199, 504, 394, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 12, 16524, 63, 21046, 199, 199, 533, 26710, 6464, 4311, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 413, 9, 267, 1995, 2624, 8, 277, 12, 298, 2253, 63, 344, 401, 4337, 12, 298, 3989, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 2405, 63, 344, 401, 4337, 12, 298, 6464, 5148, 401, 6202, 628, 6099, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 1695, 9, 267, 1995, 10666, 772, 8, 277, 12, 298, 2638, 63, 890, 401, 298, 6464, 4601, 1568, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 4337, 9, 267, 1995, 10666, 708, 8, 277, 12, 298, 409, 63, 890, 401, 298, 6464, 663, 1568, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 3610, 63, 1507, 401, 298, 5826, 1329, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 1457, 63, 890, 401, 298, 3142, 1568, 531, 267, 1995, 10666, 772, 8, 277, 12, 298, 515, 63, 1224, 63, 890, 401, 298, 2042, 1817, 1568, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 679, 15140, 63, 76, 515, 401, 298, 6592, 402, 593, 67, 895, 4646, 402, 2434, 491, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 2992, 63, 76, 515, 401, 298, 6592, 402, 4879, 402, 2434, 491, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 679, 15140, 63, 8075, 401, 298, 6592, 402, 593, 67, 895, 4646, 402, 2434, 603, 6912, 6957, 531, 267, 1995, 10666, 708, 8, 277, 12, 298, 2992, 63, 8075, 401, 298, 6592, 402, 4879, 402, 2434, 603, 6912, 6957, 531, 267, 1995, 13480, 5571, 8, 277, 12, 298, 1231, 401, 8177, 12, 298, 6231, 12651, 367, 12826, 15191, 531, 267, 1995, 2624, 8, 277, 12, 298, 5650, 63, 409, 63, 344, 401, 7960, 12, 298, 6464, 663, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 12789, 401, 7960, 12, 298, 27341, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 576, 63, 657, 24939, 401, 7960, 12, 298, 1451, 876, 24939, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 3578, 401, 7960, 12, 298, 5039, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 7307, 401, 6877, 12, 298, 7384, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 6198, 401, 6877, 12, 298, 8458, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 17614, 9770, 401, 6877, 12, 298, 34, 2308, 9770, 570, 5148, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 8782, 63, 1086, 401, 5557, 12, 298, 13921, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 20945, 63, 1086, 401, 5557, 12, 298, 29188, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 15469, 63, 1086, 401, 5557, 12, 298, 14000, 1754, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 2624, 8, 277, 12, 298, 20427, 63, 1086, 401, 5557, 12, 298, 30754, 1434, 436, 900, 401, 6202, 628, 6099, 267, 1995, 10666, 24, 8, 277, 12, 298, 1820, 63, 422, 401, 298, 10766, 1015, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 413, 9, 267, 1995, 2624, 8, 277, 12, 298, 571, 63, 1180, 401, 10574, 12, 298, 5039, 675, 401, 6202, 628, 971, 16, 531, 267, 1995, 12119, 5571, 8, 277, 12, 298, 8618, 20204, 1227, 2481, 9, 199, 199, 533, 27324, 5433, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 2624, 8, 277, 12, 298, 1274, 63, 344, 401, 7105, 12, 298, 17989, 2656, 5148, 401, 6202, 21024, 16, 531, 267, 1995, 2624, 8, 277, 12, 298, 4930, 63, 344, 401, 7105, 12, 298, 17989, 5148, 401, 6202, 21024, 16, 531, 267, 1995, 13480, 5571, 8, 277, 12, 298, 2253, 63, 1180, 401, 5851, 1965, 12, 298, 17989, 2656, 675, 531, 199, 199, 533, 20429, 707, 8, 23532, 304, 272, 2955, 63, 890, 275, 499, 10531, 10, 24, 272, 347, 24828, 8, 277, 304, 267, 1995, 12119, 5571, 8, 277, 12, 298, 2307, 401, 499, 10531, 9, 199, 199, 533, 15018, 8, 23532, 304, 272, 17638, 275, 16524, 63, 21046, 272, 31510, 4896, 6467, 275, 5450, 272, 730, 63, 354, 275, 469, 267, 378, 26, 298, 17989, 12651, 401, 267, 413, 26, 298, 14908, 15018, 28131, 401, 267, 499, 26, 298, 17127, 968, 695, 15018, 28131, 401, 267, 650, 26, 298, 6464, 27353, 28131, 401, 267, 31510, 4896, 6467, 26, 298, 6464, 28131, 2494, 20429, 707, 401, 272, 789, 272, 2955, 63, 890, 275, 18427, 627, 1695, 272, 1564, 63, 2232, 275, 469, 267, 378, 26, 27324, 5433, 12, 267, 413, 26, 26710, 6464, 4311, 12, 267, 31510, 4896, 6467, 26, 20429, 707, 12, 272, 789, 339, 347, 24828, 8, 277, 304, 267, 1995, 11305, 8, 13304, 24, 8, 277, 12, 298, 466, 401, 298, 6464, 5872, 730, 1288, 291, 14, 466, 63, 354, 9, 267, 1995, 13480, 5571, 8, 277, 12, 298, 5233, 401, 959, 12, 298, 7336, 8806, 2259, 4955, 334, 7695, 4587, 6320, 267, 340, 291, 905, 5233, 4140, 585, 1137, 298, 7695, 4587, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Alexoner/shadowsocks
shadowsocks/eventloop.py
949
7288
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2013-2015 clowwindy # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # from ssloop # https://github.com/clowwindy/ssloop from __future__ import absolute_import, division, print_function, \ with_statement import os import time import socket import select import errno import logging from collections import defaultdict from shadowsocks import shell __all__ = ['EventLoop', 'POLL_NULL', 'POLL_IN', 'POLL_OUT', 'POLL_ERR', 'POLL_HUP', 'POLL_NVAL', 'EVENT_NAMES'] POLL_NULL = 0x00 POLL_IN = 0x01 POLL_OUT = 0x04 POLL_ERR = 0x08 POLL_HUP = 0x10 POLL_NVAL = 0x20 EVENT_NAMES = { POLL_NULL: 'POLL_NULL', POLL_IN: 'POLL_IN', POLL_OUT: 'POLL_OUT', POLL_ERR: 'POLL_ERR', POLL_HUP: 'POLL_HUP', POLL_NVAL: 'POLL_NVAL', } # we check timeouts every TIMEOUT_PRECISION seconds TIMEOUT_PRECISION = 10 class KqueueLoop(object): MAX_EVENTS = 1024 def __init__(self): self._kqueue = select.kqueue() self._fds = {} def _control(self, fd, mode, flags): events = [] if mode & POLL_IN: events.append(select.kevent(fd, select.KQ_FILTER_READ, flags)) if mode & POLL_OUT: events.append(select.kevent(fd, select.KQ_FILTER_WRITE, flags)) for e in events: self._kqueue.control([e], 0) def poll(self, timeout): if timeout < 0: timeout = None # kqueue behaviour events = self._kqueue.control(None, KqueueLoop.MAX_EVENTS, timeout) results = defaultdict(lambda: POLL_NULL) for e in events: fd = e.ident if e.filter == select.KQ_FILTER_READ: results[fd] |= POLL_IN elif e.filter == select.KQ_FILTER_WRITE: results[fd] |= POLL_OUT return results.items() def register(self, fd, mode): self._fds[fd] = mode self._control(fd, mode, select.KQ_EV_ADD) def unregister(self, fd): self._control(fd, self._fds[fd], select.KQ_EV_DELETE) del self._fds[fd] def modify(self, fd, mode): self.unregister(fd) self.register(fd, mode) def close(self): self._kqueue.close() class SelectLoop(object): def __init__(self): self._r_list = set() self._w_list = set() self._x_list = set() def poll(self, timeout): r, w, x = select.select(self._r_list, self._w_list, self._x_list, timeout) results = defaultdict(lambda: POLL_NULL) for p in [(r, POLL_IN), (w, POLL_OUT), (x, POLL_ERR)]: for fd in p[0]: results[fd] |= p[1] return results.items() def register(self, fd, mode): if mode & POLL_IN: self._r_list.add(fd) if mode & POLL_OUT: self._w_list.add(fd) if mode & POLL_ERR: self._x_list.add(fd) def unregister(self, fd): if fd in self._r_list: self._r_list.remove(fd) if fd in self._w_list: self._w_list.remove(fd) if fd in self._x_list: self._x_list.remove(fd) def modify(self, fd, mode): self.unregister(fd) self.register(fd, mode) def close(self): pass class EventLoop(object): def __init__(self): if hasattr(select, 'epoll'): self._impl = select.epoll() model = 'epoll' elif hasattr(select, 'kqueue'): self._impl = KqueueLoop() model = 'kqueue' elif hasattr(select, 'select'): self._impl = SelectLoop() model = 'select' else: raise Exception('can not find any available functions in select ' 'package') self._fdmap = {} # (f, handler) self._last_time = time.time() self._periodic_callbacks = [] self._stopping = False logging.debug('using event model: %s', model) def poll(self, timeout=None): events = self._impl.poll(timeout) return [(self._fdmap[fd][0], fd, event) for fd, event in events] def add(self, f, mode, handler): fd = f.fileno() self._fdmap[fd] = (f, handler) self._impl.register(fd, mode) def remove(self, f): fd = f.fileno() del self._fdmap[fd] self._impl.unregister(fd) def add_periodic(self, callback): self._periodic_callbacks.append(callback) def remove_periodic(self, callback): self._periodic_callbacks.remove(callback) def modify(self, f, mode): fd = f.fileno() self._impl.modify(fd, mode) def stop(self): self._stopping = True def run(self): events = [] while not self._stopping: asap = False try: events = self.poll(TIMEOUT_PRECISION) except (OSError, IOError) as e: if errno_from_exception(e) in (errno.EPIPE, errno.EINTR): # EPIPE: Happens when the client closes the connection # EINTR: Happens when received a signal # handles them as soon as possible asap = True logging.debug('poll:%s', e) else: logging.error('poll:%s', e) import traceback traceback.print_exc() continue for sock, fd, event in events: handler = self._fdmap.get(fd, None) if handler is not None: handler = handler[1] try: handler.handle_event(sock, fd, event) except (OSError, IOError) as e: shell.print_exception(e) now = time.time() if asap or now - self._last_time >= TIMEOUT_PRECISION: for callback in self._periodic_callbacks: callback() self._last_time = now def __del__(self): self._impl.close() # from tornado def errno_from_exception(e): """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instatiates an Exception without any args you will get a tuple error. So this function abstracts all that behavior to give you a safe way to get the errno. """ if hasattr(e, 'errno'): return e.errno elif e.args: return e.args[0] else: return None # from tornado def get_sock_error(sock): error_number = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) return socket.error(error_number, os.strerror(error_number))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6171, 13, 7806, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 687, 10110, 3813, 199, 3, 4178, 921, 5031, 14, 957, 15, 67, 674, 11530, 89, 15, 385, 3813, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 747, 199, 646, 900, 199, 646, 2838, 199, 646, 3504, 199, 646, 7554, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 199, 504, 15084, 21234, 492, 5218, 421, 199, 363, 452, 363, 275, 788, 2390, 7382, 297, 283, 16428, 63, 8084, 297, 283, 16428, 63, 568, 297, 283, 16428, 63, 1877, 297, 283, 16428, 63, 2666, 297, 1779, 283, 16428, 63, 40, 2160, 297, 283, 16428, 63, 46, 3204, 297, 283, 8193, 63, 14546, 418, 199, 199, 16428, 63, 8084, 275, 378, 88, 383, 199, 16428, 63, 568, 275, 378, 88, 614, 199, 16428, 63, 1877, 275, 378, 88, 966, 199, 16428, 63, 2666, 275, 378, 88, 2036, 199, 16428, 63, 40, 2160, 275, 378, 88, 709, 199, 16428, 63, 46, 3204, 275, 378, 88, 1165, 421, 199, 8193, 63, 14546, 275, 469, 272, 25480, 44, 63, 8084, 26, 283, 16428, 63, 8084, 297, 272, 25480, 44, 63, 568, 26, 283, 16428, 63, 568, 297, 272, 25480, 44, 63, 1877, 26, 283, 16428, 63, 1877, 297, 272, 25480, 44, 63, 2666, 26, 283, 16428, 63, 2666, 297, 272, 25480, 44, 63, 40, 2160, 26, 283, 16428, 63, 40, 2160, 297, 272, 25480, 44, 63, 46, 3204, 26, 283, 16428, 63, 46, 3204, 297, 199, 93, 199, 199, 3, 781, 1104, 25870, 4036, 29998, 63, 14246, 30011, 4696, 199, 8899, 63, 14246, 30011, 275, 1616, 421, 199, 533, 1804, 1825, 7382, 8, 785, 304, 339, 9141, 63, 8193, 51, 275, 6619, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 75, 1825, 275, 3504, 14, 75, 1825, 342, 267, 291, 423, 14240, 275, 1052, 339, 347, 485, 2785, 8, 277, 12, 6111, 12, 818, 12, 3285, 304, 267, 4474, 275, 942, 267, 340, 818, 1253, 25480, 44, 63, 568, 26, 288, 4474, 14, 740, 8, 2416, 14, 415, 782, 8, 2592, 12, 3504, 14, 24817, 63, 9905, 63, 5670, 12, 3285, 430, 267, 340, 818, 1253, 25480, 44, 63, 1877, 26, 288, 4474, 14, 740, 8, 2416, 14, 415, 782, 8, 2592, 12, 3504, 14, 24817, 63, 9905, 63, 10387, 12, 3285, 430, 267, 367, 325, 315, 4474, 26, 288, 291, 423, 75, 1825, 14, 2785, 779, 69, 467, 378, 9, 339, 347, 11271, 8, 277, 12, 2653, 304, 267, 340, 2653, 665, 378, 26, 288, 2653, 275, 488, 221, 327, 1022, 1825, 13942, 267, 4474, 275, 291, 423, 75, 1825, 14, 2785, 8, 403, 12, 1804, 1825, 7382, 14, 4283, 63, 8193, 51, 12, 2653, 9, 267, 2058, 275, 10018, 8, 2734, 26, 25480, 44, 63, 8084, 9, 267, 367, 325, 315, 4474, 26, 288, 6111, 275, 325, 14, 5425, 288, 340, 325, 14, 1541, 508, 3504, 14, 24817, 63, 9905, 63, 5670, 26, 355, 2058, 59, 2592, 61, 8901, 25480, 44, 63, 568, 288, 916, 325, 14, 1541, 508, 3504, 14, 24817, 63, 9905, 63, 10387, 26, 355, 2058, 59, 2592, 61, 8901, 25480, 44, 63, 1877, 267, 372, 2058, 14, 1744, 342, 339, 347, 2274, 8, 277, 12, 6111, 12, 818, 304, 267, 291, 423, 14240, 59, 2592, 61, 275, 818, 267, 291, 423, 2785, 8, 2592, 12, 818, 12, 3504, 14, 24817, 63, 18015, 63, 9732, 9, 339, 347, 24369, 8, 277, 12, 6111, 304, 267, 291, 423, 2785, 8, 2592, 12, 291, 423, 14240, 59, 2592, 467, 3504, 14, 24817, 63, 18015, 63, 7014, 9, 267, 2150, 291, 423, 14240, 59, 2592, 61, 339, 347, 2811, 8, 277, 12, 6111, 12, 818, 304, 267, 291, 14, 18408, 8, 2592, 9, 267, 291, 14, 2683, 8, 2592, 12, 818, 9, 339, 347, 4002, 8, 277, 304, 267, 291, 423, 75, 1825, 14, 1600, 342, 421, 199, 533, 9496, 7382, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 82, 63, 513, 275, 663, 342, 267, 291, 423, 87, 63, 513, 275, 663, 342, 267, 291, 423, 88, 63, 513, 275, 663, 342, 339, 347, 11271, 8, 277, 12, 2653, 304, 267, 519, 12, 336, 12, 671, 275, 3504, 14, 2416, 8, 277, 423, 82, 63, 513, 12, 291, 423, 87, 63, 513, 12, 291, 423, 88, 63, 513, 12, 1816, 2653, 9, 267, 2058, 275, 10018, 8, 2734, 26, 25480, 44, 63, 8084, 9, 267, 367, 299, 315, 3842, 82, 12, 25480, 44, 63, 568, 395, 334, 87, 12, 25480, 44, 63, 1877, 395, 334, 88, 12, 25480, 44, 63, 2666, 19532, 288, 367, 6111, 315, 299, 59, 16, 2189, 355, 2058, 59, 2592, 61, 8901, 299, 59, 17, 61, 267, 372, 2058, 14, 1744, 342, 339, 347, 2274, 8, 277, 12, 6111, 12, 818, 304, 267, 340, 818, 1253, 25480, 44, 63, 568, 26, 288, 291, 423, 82, 63, 513, 14, 525, 8, 2592, 9, 267, 340, 818, 1253, 25480, 44, 63, 1877, 26, 288, 291, 423, 87, 63, 513, 14, 525, 8, 2592, 9, 267, 340, 818, 1253, 25480, 44, 63, 2666, 26, 288, 291, 423, 88, 63, 513, 14, 525, 8, 2592, 9, 339, 347, 24369, 8, 277 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6171, 13, 7806, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 687, 10110, 3813, 199, 3, 4178, 921, 5031, 14, 957, 15, 67, 674, 11530, 89, 15, 385, 3813, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 747, 199, 646, 900, 199, 646, 2838, 199, 646, 3504, 199, 646, 7554, 199, 646, 2050, 199, 504, 5055, 492, 10018, 199, 199, 504, 15084, 21234, 492, 5218, 421, 199, 363, 452, 363, 275, 788, 2390, 7382, 297, 283, 16428, 63, 8084, 297, 283, 16428, 63, 568, 297, 283, 16428, 63, 1877, 297, 283, 16428, 63, 2666, 297, 1779, 283, 16428, 63, 40, 2160, 297, 283, 16428, 63, 46, 3204, 297, 283, 8193, 63, 14546, 418, 199, 199, 16428, 63, 8084, 275, 378, 88, 383, 199, 16428, 63, 568, 275, 378, 88, 614, 199, 16428, 63, 1877, 275, 378, 88, 966, 199, 16428, 63, 2666, 275, 378, 88, 2036, 199, 16428, 63, 40, 2160, 275, 378, 88, 709, 199, 16428, 63, 46, 3204, 275, 378, 88, 1165, 421, 199, 8193, 63, 14546, 275, 469, 272, 25480, 44, 63, 8084, 26, 283, 16428, 63, 8084, 297, 272, 25480, 44, 63, 568, 26, 283, 16428, 63, 568, 297, 272, 25480, 44, 63, 1877, 26, 283, 16428, 63, 1877, 297, 272, 25480, 44, 63, 2666, 26, 283, 16428, 63, 2666, 297, 272, 25480, 44, 63, 40, 2160, 26, 283, 16428, 63, 40, 2160, 297, 272, 25480, 44, 63, 46, 3204, 26, 283, 16428, 63, 46, 3204, 297, 199, 93, 199, 199, 3, 781, 1104, 25870, 4036, 29998, 63, 14246, 30011, 4696, 199, 8899, 63, 14246, 30011, 275, 1616, 421, 199, 533, 1804, 1825, 7382, 8, 785, 304, 339, 9141, 63, 8193, 51, 275, 6619, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 75, 1825, 275, 3504, 14, 75, 1825, 342, 267, 291, 423, 14240, 275, 1052, 339, 347, 485, 2785, 8, 277, 12, 6111, 12, 818, 12, 3285, 304, 267, 4474, 275, 942, 267, 340, 818, 1253, 25480, 44, 63, 568, 26, 288, 4474, 14, 740, 8, 2416, 14, 415, 782, 8, 2592, 12, 3504, 14, 24817, 63, 9905, 63, 5670, 12, 3285, 430, 267, 340, 818, 1253, 25480, 44, 63, 1877, 26, 288, 4474, 14, 740, 8, 2416, 14, 415, 782, 8, 2592, 12, 3504, 14, 24817, 63, 9905, 63, 10387, 12, 3285, 430, 267, 367, 325, 315, 4474, 26, 288, 291, 423, 75, 1825, 14, 2785, 779, 69, 467, 378, 9, 339, 347, 11271, 8, 277, 12, 2653, 304, 267, 340, 2653, 665, 378, 26, 288, 2653, 275, 488, 221, 327, 1022, 1825, 13942, 267, 4474, 275, 291, 423, 75, 1825, 14, 2785, 8, 403, 12, 1804, 1825, 7382, 14, 4283, 63, 8193, 51, 12, 2653, 9, 267, 2058, 275, 10018, 8, 2734, 26, 25480, 44, 63, 8084, 9, 267, 367, 325, 315, 4474, 26, 288, 6111, 275, 325, 14, 5425, 288, 340, 325, 14, 1541, 508, 3504, 14, 24817, 63, 9905, 63, 5670, 26, 355, 2058, 59, 2592, 61, 8901, 25480, 44, 63, 568, 288, 916, 325, 14, 1541, 508, 3504, 14, 24817, 63, 9905, 63, 10387, 26, 355, 2058, 59, 2592, 61, 8901, 25480, 44, 63, 1877, 267, 372, 2058, 14, 1744, 342, 339, 347, 2274, 8, 277, 12, 6111, 12, 818, 304, 267, 291, 423, 14240, 59, 2592, 61, 275, 818, 267, 291, 423, 2785, 8, 2592, 12, 818, 12, 3504, 14, 24817, 63, 18015, 63, 9732, 9, 339, 347, 24369, 8, 277, 12, 6111, 304, 267, 291, 423, 2785, 8, 2592, 12, 291, 423, 14240, 59, 2592, 467, 3504, 14, 24817, 63, 18015, 63, 7014, 9, 267, 2150, 291, 423, 14240, 59, 2592, 61, 339, 347, 2811, 8, 277, 12, 6111, 12, 818, 304, 267, 291, 14, 18408, 8, 2592, 9, 267, 291, 14, 2683, 8, 2592, 12, 818, 9, 339, 347, 4002, 8, 277, 304, 267, 291, 423, 75, 1825, 14, 1600, 342, 421, 199, 533, 9496, 7382, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 82, 63, 513, 275, 663, 342, 267, 291, 423, 87, 63, 513, 275, 663, 342, 267, 291, 423, 88, 63, 513, 275, 663, 342, 339, 347, 11271, 8, 277, 12, 2653, 304, 267, 519, 12, 336, 12, 671, 275, 3504, 14, 2416, 8, 277, 423, 82, 63, 513, 12, 291, 423, 87, 63, 513, 12, 291, 423, 88, 63, 513, 12, 1816, 2653, 9, 267, 2058, 275, 10018, 8, 2734, 26, 25480, 44, 63, 8084, 9, 267, 367, 299, 315, 3842, 82, 12, 25480, 44, 63, 568, 395, 334, 87, 12, 25480, 44, 63, 1877, 395, 334, 88, 12, 25480, 44, 63, 2666, 19532, 288, 367, 6111, 315, 299, 59, 16, 2189, 355, 2058, 59, 2592, 61, 8901, 299, 59, 17, 61, 267, 372, 2058, 14, 1744, 342, 339, 347, 2274, 8, 277, 12, 6111, 12, 818, 304, 267, 340, 818, 1253, 25480, 44, 63, 568, 26, 288, 291, 423, 82, 63, 513, 14, 525, 8, 2592, 9, 267, 340, 818, 1253, 25480, 44, 63, 1877, 26, 288, 291, 423, 87, 63, 513, 14, 525, 8, 2592, 9, 267, 340, 818, 1253, 25480, 44, 63, 2666, 26, 288, 291, 423, 88, 63, 513, 14, 525, 8, 2592, 9, 339, 347, 24369, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RackSec/ansible
lib/ansible/modules/net_tools/cloudflare_dns.py
16
25457
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016 Michael Gruener <michael.gruener@chaosmoon.net> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: cloudflare_dns author: "Michael Gruener (@mgruener)" requirements: - "python >= 2.6" version_added: "2.1" short_description: manage Cloudflare DNS records description: - "Manages dns records via the Cloudflare API, see the docs: U(https://api.cloudflare.com/)" options: account_api_token: description: - > Account API token. You can obtain your API key from the bottom of the Cloudflare 'My Account' page, found here: U(https://www.cloudflare.com/a/account) required: true account_email: description: - "Account email." required: true port: description: Service port. Required for C(type=SRV) required: false default: null priority: description: Record priority. Required for C(type=MX) and C(type=SRV) required: false default: "1" proto: description: Service protocol. Required for C(type=SRV) required: false choices: [ 'tcp', 'udp' ] default: null proxied: description: Proxy through cloudflare network or just use DNS required: false default: no version_added: "2.3" record: description: - Record to add. Required if C(state=present). Default is C(@) (e.g. the zone name) required: false default: "@" aliases: [ "name" ] service: description: Record service. Required for C(type=SRV) required: false default: null solo: description: - Whether the record should be the only one for that record type and record name. Only use with C(state=present) - This will delete all other records with the same record name and type. required: false default: null state: description: - Whether the record(s) should exist or not required: false choices: [ 'present', 'absent' ] default: present timeout: description: - Timeout for Cloudflare API calls required: false default: 30 ttl: description: - The TTL to give the new record. Must be between 120 and 2,147,483,647 seconds, or 1 for automatic. required: false default: 1 (automatic) type: description: - The type of DNS record to create. Required if C(state=present) required: false choices: [ 'A', 'AAAA', 'CNAME', 'TXT', 'SRV', 'MX', 'NS', 'SPF' ] default: null value: description: - The record value. Required for C(state=present) required: false default: null aliases: [ "content" ] weight: description: Service weight. Required for C(type=SRV) required: false default: "1" zone: description: - The name of the Zone to work with (e.g. "example.com"). The Zone must already exist. required: true aliases: ["domain"] ''' EXAMPLES = ''' # create a test.my.com A record to point to 127.0.0.1 - cloudflare_dns: zone: my.com record: test type: A value: 127.0.0.1 account_email: test@example.com account_api_token: dummyapitoken register: record # create a my.com CNAME record to example.com - cloudflare_dns: zone: my.com type: CNAME value: example.com state: present account_email: test@example.com account_api_token: dummyapitoken # change it's ttl - cloudflare_dns: zone: my.com type: CNAME value: example.com ttl: 600 state: present account_email: test@example.com account_api_token: dummyapitoken # and delete the record - cloudflare_dns: zone: my.com type: CNAME value: example.com state: absent account_email: test@example.com account_api_token: dummyapitoken # create a my.com CNAME record to example.com and proxy through cloudflare's network - cloudflare_dns: zone: my.com type: CNAME value: example.com state: present proxied: yes account_email: test@example.com account_api_token: dummyapitoken # create TXT record "test.my.com" with value "unique value" # delete all other TXT records named "test.my.com" - cloudflare_dns: domain: my.com record: test type: TXT value: unique value state: present solo: true account_email: test@example.com account_api_token: dummyapitoken # create a SRV record _foo._tcp.my.com - cloudflare_dns: domain: my.com service: foo proto: tcp port: 3500 priority: 10 weight: 20 type: SRV value: fooserver.my.com ''' RETURN = ''' record: description: dictionary containing the record data returned: success, except on record deletion type: complex contains: content: description: the record content (details depend on record type) returned: success type: string sample: 192.0.2.91 created_on: description: the record creation date returned: success type: string sample: 2016-03-25T19:09:42.516553Z data: description: additional record data returned: success, if type is SRV type: dictionary sample: { name: "jabber", port: 8080, priority: 10, proto: "_tcp", service: "_xmpp", target: "jabberhost.sample.com", weight: 5, } id: description: the record id returned: success type: string sample: f9efb0549e96abcb750de63b38c9576e locked: description: No documentation available returned: success type: boolean sample: False meta: description: No documentation available returned: success type: dictionary sample: { auto_added: false } modified_on: description: record modification date returned: success type: string sample: 2016-03-25T19:09:42.516553Z name: description: the record name as FQDN (including _service and _proto for SRV) returned: success type: string sample: www.sample.com priority: description: priority of the MX record returned: success, if type is MX type: int sample: 10 proxiable: description: whether this record can be proxied through cloudflare returned: success type: boolean sample: False proxied: description: whether the record is proxied through cloudflare returned: success type: boolean sample: False ttl: description: the time-to-live for the record returned: success type: int sample: 300 type: description: the record type returned: success type: string sample: A zone_id: description: the id of the zone containing the record returned: success type: string sample: abcede0bf9f0066f94029d2e6b73856a zone_name: description: the name of the zone containing the record returned: success type: string sample: sample.com ''' try: import json except ImportError: try: import simplejson as json except ImportError: # Let snippet from module_utils/basic.py return a proper error in this case pass import urllib from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.urls import fetch_url class CloudflareAPI(object): cf_api_endpoint = 'https://api.cloudflare.com/client/v4' changed = False def __init__(self, module): self.module = module self.account_api_token = module.params['account_api_token'] self.account_email = module.params['account_email'] self.port = module.params['port'] self.priority = module.params['priority'] self.proto = module.params['proto'] self.proxied = module.params['proxied'] self.record = module.params['record'] self.service = module.params['service'] self.is_solo = module.params['solo'] self.state = module.params['state'] self.timeout = module.params['timeout'] self.ttl = module.params['ttl'] self.type = module.params['type'] self.value = module.params['value'] self.weight = module.params['weight'] self.zone = module.params['zone'] if self.record == '@': self.record = self.zone if (self.type in ['CNAME','NS','MX','SRV']) and (self.value is not None): self.value = self.value.rstrip('.') if (self.type == 'SRV'): if (self.proto is not None) and (not self.proto.startswith('_')): self.proto = '_' + self.proto if (self.service is not None) and (not self.service.startswith('_')): self.service = '_' + self.service if not self.record.endswith(self.zone): self.record = self.record + '.' + self.zone def _cf_simple_api_call(self,api_call,method='GET',payload=None): headers = { 'X-Auth-Email': self.account_email, 'X-Auth-Key': self.account_api_token, 'Content-Type': 'application/json' } data = None if payload: try: data = json.dumps(payload) except Exception: e = get_exception() self.module.fail_json(msg="Failed to encode payload as JSON: %s " % str(e)) resp, info = fetch_url(self.module, self.cf_api_endpoint + api_call, headers=headers, data=data, method=method, timeout=self.timeout) if info['status'] not in [200,304,400,401,403,429,405,415]: self.module.fail_json(msg="Failed API call {0}; got unexpected HTTP code {1}".format(api_call,info['status'])) error_msg = '' if info['status'] == 401: # Unauthorized error_msg = "API user does not have permission; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) elif info['status'] == 403: # Forbidden error_msg = "API request not authenticated; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) elif info['status'] == 429: # Too many requests error_msg = "API client is rate limited; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) elif info['status'] == 405: # Method not allowed error_msg = "API incorrect HTTP method provided; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) elif info['status'] == 415: # Unsupported Media Type error_msg = "API request is not valid JSON; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) elif info ['status'] == 400: # Bad Request error_msg = "API bad request; Status: {0}; Method: {1}: Call: {2}".format(info['status'],method,api_call) result = None try: content = resp.read() except AttributeError: if info['body']: content = info['body'] else: error_msg += "; The API response was empty" if content: try: result = json.loads(content) except json.JSONDecodeError: error_msg += "; Failed to parse API response: {0}".format(content) # received an error status but no data with details on what failed if (info['status'] not in [200,304]) and (result is None): self.module.fail_json(msg=error_msg) if not result['success']: error_msg += "; Error details: " for error in result['errors']: error_msg += "code: {0}, error: {1}; ".format(error['code'],error['message']) if 'error_chain' in error: for chain_error in error['error_chain']: error_msg += "code: {0}, error: {1}; ".format(chain_error['code'],chain_error['message']) self.module.fail_json(msg=error_msg) return result, info['status'] def _cf_api_call(self,api_call,method='GET',payload=None): result, status = self._cf_simple_api_call(api_call,method,payload) data = result['result'] if 'result_info' in result: pagination = result['result_info'] if pagination['total_pages'] > 1: next_page = int(pagination['page']) + 1 parameters = ['page={0}'.format(next_page)] # strip "page" parameter from call parameters (if there are any) if '?' in api_call: raw_api_call,query = api_call.split('?',1) parameters += [param for param in query.split('&') if not param.startswith('page')] else: raw_api_call = api_call while next_page <= pagination['total_pages']: raw_api_call += '?' + '&'.join(parameters) result, status = self._cf_simple_api_call(raw_api_call,method,payload) data += result['result'] next_page += 1 return data, status def _get_zone_id(self,zone=None): if not zone: zone = self.zone zones = self.get_zones(zone) if len(zones) > 1: self.module.fail_json(msg="More than one zone matches {0}".format(zone)) if len(zones) < 1: self.module.fail_json(msg="No zone found with name {0}".format(zone)) return zones[0]['id'] def get_zones(self,name=None): if not name: name = self.zone param = '' if name: param = '?' + urllib.urlencode({'name' : name}) zones,status = self._cf_api_call('/zones' + param) return zones def get_dns_records(self,zone_name=None,type=None,record=None,value=''): if not zone_name: zone_name = self.zone if not type: type = self.type if not record: record = self.record # necessary because None as value means to override user # set module value if (not value) and (value is not None): value = self.value zone_id = self._get_zone_id() api_call = '/zones/{0}/dns_records'.format(zone_id) query = {} if type: query['type'] = type if record: query['name'] = record if value: query['content'] = value if query: api_call += '?' + urllib.urlencode(query) records,status = self._cf_api_call(api_call) return records def delete_dns_records(self,**kwargs): params = {} for param in ['port','proto','service','solo','type','record','value','weight','zone']: if param in kwargs: params[param] = kwargs[param] else: params[param] = getattr(self,param) records = [] content = params['value'] search_record = params['record'] if params['type'] == 'SRV': content = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value'] search_record = params['service'] + '.' + params['proto'] + '.' + params['record'] if params['solo']: search_value = None else: search_value = content records = self.get_dns_records(params['zone'],params['type'],search_record,search_value) for rr in records: if params['solo']: if not ((rr['type'] == params['type']) and (rr['name'] == search_record) and (rr['content'] == content)): self.changed = True if not self.module.check_mode: result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(rr['zone_id'],rr['id']),'DELETE') else: self.changed = True if not self.module.check_mode: result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(rr['zone_id'],rr['id']),'DELETE') return self.changed def ensure_dns_record(self,**kwargs): params = {} for param in ['port','priority','proto','proxied','service','ttl','type','record','value','weight','zone']: if param in kwargs: params[param] = kwargs[param] else: params[param] = getattr(self,param) search_value = params['value'] search_record = params['record'] new_record = None if (params['type'] is None) or (params['record'] is None): self.module.fail_json(msg="You must provide a type and a record to create a new record") if (params['type'] in [ 'A','AAAA','CNAME','TXT','MX','NS','SPF']): if not params['value']: self.module.fail_json(msg="You must provide a non-empty value to create this record type") # there can only be one CNAME per record # ignoring the value when searching for existing # CNAME records allows us to update the value if it # changes if params['type'] == 'CNAME': search_value = None new_record = { "type": params['type'], "name": params['record'], "content": params['value'], "ttl": params['ttl'] } if (params['type'] in [ 'A', 'AAAA', 'CNAME' ]): new_record["proxied"] = params["proxied"] if params['type'] == 'MX': for attr in [params['priority'],params['value']]: if (attr is None) or (attr == ''): self.module.fail_json(msg="You must provide priority and a value to create this record type") new_record = { "type": params['type'], "name": params['record'], "content": params['value'], "priority": params['priority'], "ttl": params['ttl'] } if params['type'] == 'SRV': for attr in [params['port'],params['priority'],params['proto'],params['service'],params['weight'],params['value']]: if (attr is None) or (attr == ''): self.module.fail_json(msg="You must provide port, priority, proto, service, weight and a value to create this record type") srv_data = { "target": params['value'], "port": params['port'], "weight": params['weight'], "priority": params['priority'], "name": params['record'][:-len('.' + params['zone'])], "proto": params['proto'], "service": params['service'] } new_record = { "type": params['type'], "ttl": params['ttl'], 'data': srv_data } search_value = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value'] search_record = params['service'] + '.' + params['proto'] + '.' + params['record'] zone_id = self._get_zone_id(params['zone']) records = self.get_dns_records(params['zone'],params['type'],search_record,search_value) # in theory this should be impossible as cloudflare does not allow # the creation of duplicate records but lets cover it anyways if len(records) > 1: self.module.fail_json(msg="More than one record already exists for the given attributes. That should be impossible, please open an issue!") # record already exists, check if it must be updated if len(records) == 1: cur_record = records[0] do_update = False if (params['ttl'] is not None) and (cur_record['ttl'] != params['ttl'] ): do_update = True if (params['priority'] is not None) and ('priority' in cur_record) and (cur_record['priority'] != params['priority']): do_update = True if ('data' in new_record) and ('data' in cur_record): if (cur_record['data'] > new_record['data']) - (cur_record['data'] < new_record['data']): do_update = True if (type == 'CNAME') and (cur_record['content'] != new_record['content']): do_update = True if do_update: if not self.module.check_mode: result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(zone_id,records[0]['id']),'PUT',new_record) self.changed = True return result,self.changed else: return records,self.changed if not self.module.check_mode: result, info = self._cf_api_call('/zones/{0}/dns_records'.format(zone_id),'POST',new_record) self.changed = True return result,self.changed def main(): module = AnsibleModule( argument_spec = dict( account_api_token = dict(required=True, no_log=True, type='str'), account_email = dict(required=True, type='str'), port = dict(required=False, default=None, type='int'), priority = dict(required=False, default=1, type='int'), proto = dict(required=False, default=None, choices=[ 'tcp', 'udp' ], type='str'), proxied = dict(required=False, default=False, type='bool'), record = dict(required=False, default='@', aliases=['name'], type='str'), service = dict(required=False, default=None, type='str'), solo = dict(required=False, default=None, type='bool'), state = dict(required=False, default='present', choices=['present', 'absent'], type='str'), timeout = dict(required=False, default=30, type='int'), ttl = dict(required=False, default=1, type='int'), type = dict(required=False, default=None, choices=[ 'A', 'AAAA', 'CNAME', 'TXT', 'SRV', 'MX', 'NS', 'SPF' ], type='str'), value = dict(required=False, default=None, aliases=['content'], type='str'), weight = dict(required=False, default=1, type='int'), zone = dict(required=True, default=None, aliases=['domain'], type='str'), ), supports_check_mode = True, required_if = ([ ('state','present',['record','type']), ('type','MX',['priority','value']), ('type','SRV',['port','priority','proto','service','value','weight']), ('type','A',['value']), ('type','AAAA',['value']), ('type','CNAME',['value']), ('type','TXT',['value']), ('type','NS',['value']), ('type','SPF',['value']) ] ), required_one_of = ( [['record','value','type']] ) ) changed = False cf_api = CloudflareAPI(module) # sanity checks if cf_api.is_solo and cf_api.state == 'absent': module.fail_json(msg="solo=true can only be used with state=present") # perform add, delete or update (only the TTL can be updated) of one or # more records if cf_api.state == 'present': # delete all records matching record name + type if cf_api.is_solo: changed = cf_api.delete_dns_records(solo=cf_api.is_solo) result,changed = cf_api.ensure_dns_record() if isinstance(result,list): module.exit_json(changed=changed,result={'record': result[0]}) else: module.exit_json(changed=changed,result={'record': result}) else: # force solo to False, just to be sure changed = cf_api.delete_dns_records(solo=False) module.exit_json(changed=changed) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 16922, 598, 6558, 727, 665, 22333, 14, 2587, 85, 727, 32, 9518, 736, 573, 265, 14, 846, 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, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 8002, 14163, 264, 63, 5797, 199, 2502, 26, 298, 45, 11781, 598, 6558, 727, 8593, 7755, 85, 727, 2924, 199, 7538, 26, 2043, 446, 298, 1548, 2356, 499, 14, 22, 2, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 9635, 8142, 14163, 264, 10237, 5767, 199, 1802, 26, 2043, 446, 298, 2395, 7441, 6715, 5767, 4799, 314, 8142, 14163, 264, 3261, 12, 1937, 314, 9149, 26, 738, 8, 2859, 921, 1246, 14, 4091, 14163, 264, 14, 957, 15, 2924, 199, 1419, 26, 523, 2933, 63, 1246, 63, 1418, 26, 272, 1369, 26, 489, 446, 690, 267, 9973, 3261, 1526, 14, 2047, 883, 3332, 2195, 3261, 790, 687, 314, 9048, 402, 314, 8142, 14163, 264, 283, 5713, 9973, 7, 2034, 12, 1911, 2348, 26, 738, 8, 2859, 921, 1544, 14, 4091, 14163, 264, 14, 957, 15, 65, 15, 2048, 9, 272, 1415, 26, 2549, 523, 2933, 63, 2123, 26, 272, 1369, 26, 489, 446, 298, 6009, 3031, 2122, 272, 1415, 26, 2549, 523, 1844, 26, 272, 1369, 26, 7591, 1844, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 7464, 26, 272, 1369, 26, 12651, 7464, 14, 11105, 367, 445, 8, 466, 29, 17401, 9, 436, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 298, 17, 2, 523, 4104, 26, 272, 1369, 26, 7591, 4113, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 8815, 297, 283, 15036, 7, 1622, 272, 849, 26, 2973, 523, 10645, 5299, 26, 272, 1369, 26, 12373, 4012, 8002, 14163, 264, 2784, 503, 2951, 675, 10237, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 1015, 63, 3270, 26, 298, 18, 14, 19, 2, 523, 2777, 26, 272, 1369, 26, 489, 446, 12651, 370, 1050, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 3758, 365, 445, 8, 32, 9, 334, 69, 14, 71, 14, 314, 5718, 536, 9, 272, 1415, 26, 3055, 272, 849, 26, 9244, 2, 272, 5481, 26, 359, 298, 354, 2, 1622, 523, 2435, 26, 272, 1369, 26, 12651, 2435, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 880, 320, 26, 272, 1369, 26, 489, 446, 7480, 314, 2777, 1077, 506, 314, 1454, 1373, 367, 626, 2777, 730, 436, 2777, 536, 14, 5972, 675, 543, 445, 8, 929, 29, 1881, 9, 489, 446, 961, 911, 3145, 1006, 1163, 5767, 543, 314, 2011, 2777, 536, 436, 730, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 2777, 8, 83, 9, 1077, 2187, 503, 440, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 1881, 297, 283, 5575, 7, 1622, 272, 849, 26, 3451, 523, 2653, 26, 272, 1369, 26, 489, 446, 12878, 367, 8142, 14163, 264, 3261, 4882, 272, 1415, 26, 3055, 272, 849, 26, 4233, 523, 14856, 26, 272, 1369, 26, 489, 446, 710, 30822, 370, 8120, 314, 892, 2777, 14, 9498, 506, 3382, 13960, 436, 499, 12, 11160, 12, 23946, 12, 8557, 4696, 12, 503, 413, 367, 4834, 14, 272, 1415, 26, 3055, 272, 849, 26, 413, 334, 23292, 9, 523, 730, 26, 272, 1369, 26, 489, 446, 710, 730, 402, 10237, 2777, 370, 1218, 14, 11105, 340, 445, 8, 929, 29, 1881, 9, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 33, 297, 283, 6151, 297, 283, 35, 2339, 297, 283, 17715, 297, 283, 31546, 297, 283, 17401, 297, 283, 2709, 297, 283, 5763, 38, 7, 1622, 272, 849, 26, 2973, 523, 574, 26, 272, 1369, 26, 489, 446, 710, 2777, 574, 14, 11105, 367, 445, 8, 929, 29, 1881, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 298, 1317, 2, 1622, 523, 5401, 26, 272, 1369, 26, 7591, 5401, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 298, 17, 2, 523, 5718, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 22518, 370, 1736, 543, 334, 69, 14, 71, 14, 298, 2694, 14, 957, 3471, 710, 22518, 1471, 2575, 2187, 14, 272, 1415, 26, 2549, 272, 5481, 26, 2097, 2261, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 511, 14, 1662, 14, 957, 437, 2777, 370, 2376, 370, 12792, 14, 16, 14, 16, 14, 17, 199, 13, 8002, 14163, 264, 63, 5797, 26, 272, 5718, 26, 3002, 14, 957, 272, 2777, 26, 511, 272, 730, 26, 437, 272, 574, 26, 12792, 14, 16, 14, 16, 14, 17, 272, 2933, 63, 2123, 26, 511, 32, 2694, 14, 957, 272, 2933, 63, 1246, 63, 1418, 26 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 16922, 598, 6558, 727, 665, 22333, 14, 2587, 85, 727, 32, 9518, 736, 573, 265, 14, 846, 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, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 8002, 14163, 264, 63, 5797, 199, 2502, 26, 298, 45, 11781, 598, 6558, 727, 8593, 7755, 85, 727, 2924, 199, 7538, 26, 2043, 446, 298, 1548, 2356, 499, 14, 22, 2, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 9635, 8142, 14163, 264, 10237, 5767, 199, 1802, 26, 2043, 446, 298, 2395, 7441, 6715, 5767, 4799, 314, 8142, 14163, 264, 3261, 12, 1937, 314, 9149, 26, 738, 8, 2859, 921, 1246, 14, 4091, 14163, 264, 14, 957, 15, 2924, 199, 1419, 26, 523, 2933, 63, 1246, 63, 1418, 26, 272, 1369, 26, 489, 446, 690, 267, 9973, 3261, 1526, 14, 2047, 883, 3332, 2195, 3261, 790, 687, 314, 9048, 402, 314, 8142, 14163, 264, 283, 5713, 9973, 7, 2034, 12, 1911, 2348, 26, 738, 8, 2859, 921, 1544, 14, 4091, 14163, 264, 14, 957, 15, 65, 15, 2048, 9, 272, 1415, 26, 2549, 523, 2933, 63, 2123, 26, 272, 1369, 26, 489, 446, 298, 6009, 3031, 2122, 272, 1415, 26, 2549, 523, 1844, 26, 272, 1369, 26, 7591, 1844, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 7464, 26, 272, 1369, 26, 12651, 7464, 14, 11105, 367, 445, 8, 466, 29, 17401, 9, 436, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 298, 17, 2, 523, 4104, 26, 272, 1369, 26, 7591, 4113, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 8815, 297, 283, 15036, 7, 1622, 272, 849, 26, 2973, 523, 10645, 5299, 26, 272, 1369, 26, 12373, 4012, 8002, 14163, 264, 2784, 503, 2951, 675, 10237, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 1015, 63, 3270, 26, 298, 18, 14, 19, 2, 523, 2777, 26, 272, 1369, 26, 489, 446, 12651, 370, 1050, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 3758, 365, 445, 8, 32, 9, 334, 69, 14, 71, 14, 314, 5718, 536, 9, 272, 1415, 26, 3055, 272, 849, 26, 9244, 2, 272, 5481, 26, 359, 298, 354, 2, 1622, 523, 2435, 26, 272, 1369, 26, 12651, 2435, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 880, 320, 26, 272, 1369, 26, 489, 446, 7480, 314, 2777, 1077, 506, 314, 1454, 1373, 367, 626, 2777, 730, 436, 2777, 536, 14, 5972, 675, 543, 445, 8, 929, 29, 1881, 9, 489, 446, 961, 911, 3145, 1006, 1163, 5767, 543, 314, 2011, 2777, 536, 436, 730, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 2777, 8, 83, 9, 1077, 2187, 503, 440, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 1881, 297, 283, 5575, 7, 1622, 272, 849, 26, 3451, 523, 2653, 26, 272, 1369, 26, 489, 446, 12878, 367, 8142, 14163, 264, 3261, 4882, 272, 1415, 26, 3055, 272, 849, 26, 4233, 523, 14856, 26, 272, 1369, 26, 489, 446, 710, 30822, 370, 8120, 314, 892, 2777, 14, 9498, 506, 3382, 13960, 436, 499, 12, 11160, 12, 23946, 12, 8557, 4696, 12, 503, 413, 367, 4834, 14, 272, 1415, 26, 3055, 272, 849, 26, 413, 334, 23292, 9, 523, 730, 26, 272, 1369, 26, 489, 446, 710, 730, 402, 10237, 2777, 370, 1218, 14, 11105, 340, 445, 8, 929, 29, 1881, 9, 272, 1415, 26, 3055, 272, 3415, 26, 359, 283, 33, 297, 283, 6151, 297, 283, 35, 2339, 297, 283, 17715, 297, 283, 31546, 297, 283, 17401, 297, 283, 2709, 297, 283, 5763, 38, 7, 1622, 272, 849, 26, 2973, 523, 574, 26, 272, 1369, 26, 489, 446, 710, 2777, 574, 14, 11105, 367, 445, 8, 929, 29, 1881, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 298, 1317, 2, 1622, 523, 5401, 26, 272, 1369, 26, 7591, 5401, 14, 11105, 367, 445, 8, 466, 29, 31546, 9, 272, 1415, 26, 3055, 272, 849, 26, 298, 17, 2, 523, 5718, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 22518, 370, 1736, 543, 334, 69, 14, 71, 14, 298, 2694, 14, 957, 3471, 710, 22518, 1471, 2575, 2187, 14, 272, 1415, 26, 2549, 272, 5481, 26, 2097, 2261, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 511, 14, 1662, 14, 957, 437, 2777, 370, 2376, 370, 12792, 14, 16, 14, 16, 14, 17, 199, 13, 8002, 14163, 264, 63, 5797, 26, 272, 5718, 26, 3002, 14, 957, 272, 2777, 26, 511, 272, 730, 26, 437, 272, 574, 26, 12792, 14, 16, 14, 16, 14, 17, 272, 2933, 63, 2123, 26, 511, 32, 2694, 14, 957, 272, 2933, 63, 1246, 63, 1418, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
DLR-SC/DataFinder
src/datafinder/gui/admin/datastore_configuration_wizard/offline/storage_option_controller.py
1
3268
# $Filename$ # $Authors$ # Last Changed: $Date$ $Committer$ $Revision-Id$ # # Copyright (c) 2003-2011, German Aerospace Center (DLR) # 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 German Aerospace Center 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. """ Implements the functionality of the offline data store storage option page. """ from qt import SIGNAL from datafinder.gui.admin.datastore_configuration_wizard.abstract_option_controller import AbstractOptionController __version__ = "$Revision-Id:$" class StorageOptionController(AbstractOptionController): """ Handles the storage options of the Offline DataStore. """ def __init__(self, wizardView, wizardController, pageType): """ @see L{AbstractOptionController <datafinder.gui. DFDataStoreConfigurationWizard.AbstractOptionController.__init__>} """ AbstractOptionController.__init__(self, wizardView, wizardController, pageType) self.wizardView.connect(self.wizardView.offlineDatastoreDataLocationLineEdit, SIGNAL("textChanged(const QString&)"), self._dataLocationTextChangedSlot) def showModelPart(self): """ @see L{AbstractOptionController <datafinder.gui. DFDataStoreConfigurationWizard.AbstractOptionController.showModelPart>} """ self.wizardView.storageOptionWidgetStack.raiseWidget(1) self.wizardView.offlineDatastoreDataLocationLineEdit.setText(self.wizardController.datastore.dataLocation) def _dataLocationTextChangedSlot(self, dataLocation): """ Set and validate the data location. """ self.setDatastoreProperty("dataLocation", unicode(dataLocation), self.wizardView.dataLocationLineEdit)
bsd-3-clause
[ 3, 2672, 8117, 4, 20712, 199, 3, 2672, 2817, 1384, 4, 202, 199, 3, 15237, 25649, 26, 2672, 2506, 4, 2672, 11421, 351, 4, 2672, 12714, 13, 1304, 4, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 13004, 13, 8128, 12, 22261, 1237, 437, 281, 17601, 24699, 334, 8045, 50, 9, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 202, 199, 3, 202, 199, 3, 20945, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 202, 199, 3, 10207, 26, 202, 199, 3, 202, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 20712, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 20712, 199, 3, 202, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 20712, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 20712, 199, 3, 257, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 20712, 199, 3, 257, 4084, 14, 20712, 199, 3, 202, 199, 3, 627, 11443, 314, 536, 402, 314, 22261, 1237, 437, 281, 17601, 24699, 6590, 314, 1561, 402, 202, 199, 3, 257, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 202, 199, 3, 257, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 202, 199, 3, 202, 199, 3, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 20712, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 20712, 199, 3, 13387, 1149, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 20712, 199, 3, 33, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 20712, 199, 3, 22307, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 20712, 199, 3, 25748, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 20712, 199, 3, 13387, 1149, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 20712, 199, 3, 3998, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 20712, 199, 3, 18061, 5347, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 20712, 199, 3, 8, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 20712, 199, 3, 3359, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 257, 8065, 199, 624, 20712, 199, 29452, 314, 9330, 402, 314, 26302, 666, 3877, 4887, 945, 2034, 14, 20712, 199, 624, 8065, 199, 504, 19227, 492, 24360, 2999, 199, 504, 666, 11681, 14, 5885, 14, 2113, 14, 11450, 63, 4758, 63, 9819, 14, 6198, 63, 1422, 63, 5538, 492, 11836, 2602, 7506, 8065, 199, 363, 1023, 363, 275, 7880, 12714, 13, 1304, 26, 17351, 221, 8065, 199, 533, 10533, 2602, 7506, 8, 8458, 2602, 7506, 304, 1128, 408, 23873, 314, 4887, 1511, 402, 314, 28856, 604, 3918, 5502, 14, 408, 11787, 347, 636, 826, 721, 277, 12, 12262, 2768, 12, 12262, 7506, 12, 2034, 804, 304, 1039, 408, 1039, 768, 3239, 491, 91, 8458, 2602, 7506, 665, 576, 11681, 14, 5885, 14, 1039, 577, 38, 1451, 5502, 5688, 20120, 14, 8458, 2602, 7506, 855, 826, 363, 23307, 1039, 408, 13594, 11836, 2602, 7506, 855, 826, 721, 277, 12, 12262, 2768, 12, 12262, 7506, 12, 2034, 804, 9, 1039, 291, 14, 9819, 2768, 14, 2242, 8, 277, 14, 9819, 2768, 14, 18430, 30444, 1451, 6592, 21708, 12, 24360, 480, 505, 6970, 8, 1297, 1413, 1558, 6, 13185, 20712, 1816, 291, 423, 576, 6592, 1872, 6970, 15183, 9, 26016, 347, 2498, 1685, 8416, 8, 277, 304, 1039, 408, 1039, 768, 3239, 491, 91, 8458, 2602, 7506, 665, 576, 11681, 14, 5885, 14, 1039, 577, 38, 1451, 5502, 5688, 20120, 14, 8458, 2602, 7506, 14, 2384, 1685, 8416, 23307, 1039, 408, 13594, 291, 14, 9819, 2768, 14, 3494, 2602, 3339, 4851, 14, 3730, 3339, 8, 17, 9, 1039, 291, 14, 9819, 2768, 14, 18430, 30444, 1451, 6592, 21708, 14, 8341, 8, 277, 14, 9819, 7506, 14, 11450, 14, 576, 6592, 9, 17554, 1128, 347, 485, 576, 6592, 1872, 6970, 15183, 8, 277, 12, 666, 6592, 304, 1039, 408, 2494, 436, 4107, 314, 666, 2909, 14, 408, 13594, 291, 14, 409, 30444, 3697, 480, 576, 6592, 401, 2649, 8, 576, 6592, 395, 291, 14, 9819, 2768, 14, 576, 6592, 21708, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2672, 8117, 4, 20712, 199, 3, 2672, 2817, 1384, 4, 202, 199, 3, 15237, 25649, 26, 2672, 2506, 4, 2672, 11421, 351, 4, 2672, 12714, 13, 1304, 4, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 13004, 13, 8128, 12, 22261, 1237, 437, 281, 17601, 24699, 334, 8045, 50, 9, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 202, 199, 3, 202, 199, 3, 20945, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 202, 199, 3, 10207, 26, 202, 199, 3, 202, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 20712, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 20712, 199, 3, 202, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 20712, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 20712, 199, 3, 257, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 20712, 199, 3, 257, 4084, 14, 20712, 199, 3, 202, 199, 3, 627, 11443, 314, 536, 402, 314, 22261, 1237, 437, 281, 17601, 24699, 6590, 314, 1561, 402, 202, 199, 3, 257, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 202, 199, 3, 257, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 202, 199, 3, 202, 199, 3, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 20712, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 20712, 199, 3, 13387, 1149, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 20712, 199, 3, 33, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 20712, 199, 3, 22307, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 20712, 199, 3, 25748, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 20712, 199, 3, 13387, 1149, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 20712, 199, 3, 3998, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 20712, 199, 3, 18061, 5347, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 20712, 199, 3, 8, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 20712, 199, 3, 3359, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 257, 8065, 199, 624, 20712, 199, 29452, 314, 9330, 402, 314, 26302, 666, 3877, 4887, 945, 2034, 14, 20712, 199, 624, 8065, 199, 504, 19227, 492, 24360, 2999, 199, 504, 666, 11681, 14, 5885, 14, 2113, 14, 11450, 63, 4758, 63, 9819, 14, 6198, 63, 1422, 63, 5538, 492, 11836, 2602, 7506, 8065, 199, 363, 1023, 363, 275, 7880, 12714, 13, 1304, 26, 17351, 221, 8065, 199, 533, 10533, 2602, 7506, 8, 8458, 2602, 7506, 304, 1128, 408, 23873, 314, 4887, 1511, 402, 314, 28856, 604, 3918, 5502, 14, 408, 11787, 347, 636, 826, 721, 277, 12, 12262, 2768, 12, 12262, 7506, 12, 2034, 804, 304, 1039, 408, 1039, 768, 3239, 491, 91, 8458, 2602, 7506, 665, 576, 11681, 14, 5885, 14, 1039, 577, 38, 1451, 5502, 5688, 20120, 14, 8458, 2602, 7506, 855, 826, 363, 23307, 1039, 408, 13594, 11836, 2602, 7506, 855, 826, 721, 277, 12, 12262, 2768, 12, 12262, 7506, 12, 2034, 804, 9, 1039, 291, 14, 9819, 2768, 14, 2242, 8, 277, 14, 9819, 2768, 14, 18430, 30444, 1451, 6592, 21708, 12, 24360, 480, 505, 6970, 8, 1297, 1413, 1558, 6, 13185, 20712, 1816, 291, 423, 576, 6592, 1872, 6970, 15183, 9, 26016, 347, 2498, 1685, 8416, 8, 277, 304, 1039, 408, 1039, 768, 3239, 491, 91, 8458, 2602, 7506, 665, 576, 11681, 14, 5885, 14, 1039, 577, 38, 1451, 5502, 5688, 20120, 14, 8458, 2602, 7506, 14, 2384, 1685, 8416, 23307, 1039, 408, 13594, 291, 14, 9819, 2768, 14, 3494, 2602, 3339, 4851, 14, 3730, 3339, 8, 17, 9, 1039, 291, 14, 9819, 2768, 14, 18430, 30444, 1451, 6592, 21708, 14, 8341, 8, 277, 14, 9819, 7506, 14, 11450, 14, 576, 6592, 9, 17554, 1128, 347, 485, 576, 6592, 1872, 6970, 15183, 8, 277, 12, 666, 6592, 304, 1039, 408, 2494, 436, 4107, 314, 666, 2909, 14, 408, 13594, 291, 14, 409, 30444, 3697, 480, 576, 6592, 401, 2649, 8, 576, 6592, 395, 291, 14, 9819, 2768, 14, 576, 6592, 21708, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
pixyj/feel
django-server/feel/quiz/models.py
1
5024
import uuid from django.db import models from django.contrib.auth.models import User #from taggit.managers import TaggableManager from core.models import TimestampedModel, UUIDModel QUIZ_TYPES = ( (1, 'SHORT_ANSWER'), (2, 'MCQ'), ) class Quiz(TimestampedModel, UUIDModel): question_input = models.TextField(blank=True) question_display = models.TextField(blank=True) quiz_type = models.IntegerField(choices=QUIZ_TYPES) #tags = TaggableManager(blank=True) @classmethod def get_detailed_quizzes_in(cls, ids): return Quiz.objects.filter(pk__in=ids).prefetch_related('shortanswer_set').prefetch_related('choice_set') def __str__(self): return "{} - Created by {}".format(self.question_input, self.created_by) class ShortAnswer(TimestampedModel, UUIDModel): quiz = models.ForeignKey(Quiz) answer = models.TextField(blank=True) class Meta: unique_together = ('quiz', 'answer') def __str__(self): return "{} is an answer to {} Created by {}".format(self.answer, self.quiz, self.created_by) class ChoiceManager(models.Manager): def get_queryset(self): return super(ChoiceManager, self).get_queryset().order_by('created_at') class Choice(TimestampedModel, UUIDModel): quiz = models.ForeignKey(Quiz) choice_input = models.TextField(blank=True) choice_display = models.TextField(blank=True) is_correct = models.BooleanField() objects = ChoiceManager() class Meta: unique_together = ('quiz', 'choice_input') def __str__(self): status = "correct" if self.is_correct else "wrong" return "{} is a {} choice to {} - Created by {}".format(self.choice_input, status, self.quiz, self.created_by) class QuizUserAttemptManager(models.Manager): def _get_choices(self, choice_string_list): if choice_string_list == "": return {} choice_ids = [int(choice_id) for choice_id in choice_string_list.split(",")] queryset = Choice.objects.filter(pk__in=choice_ids).only("id", "choice_display") choices = [(choice.id, choice.choice_display, ) for choice in queryset] return dict(choices) def get_user_attempts_by_quiz_id(self, user_key, quiz_id): attempts = QuizAttempt.objects.filter(user_key=user_key, quiz_id=quiz_id) choice_string_list = ','.join((attempt.choices for attempt in attempts)) choices_by_id = self._get_choices(choice_string_list) for attempt in attempts: choice_ids = [int(choice_id) for choice_id in attempt.choices.split(",")] attempt.choices = [ { "id": choice_id, "choice_display": choices_by_id[choice_id] } for choice_id in choice_ids] return attempts def get_user_attempts_in_quizzes(self, user_key, quiz_ids): return QuizAttempt.objects.filter(user_key=user_key).filter(quiz__in=quiz_ids) #todo -> ensure multiple correct attempts for same quiz is #either avoided or remove duplicates in this query. def get_answered_quiz_count_in(self, user_key, quiz_ids): return self.get_user_attempts_in_quizzes(user_key, quiz_ids).filter(result=True).count() def get_user_answered_quiz_ids(self, user_key, quiz_ids): return QuizAttempt.objects.filter(user_key=user_key).\ filter(quiz__in=quiz_ids).\ filter(result=True).\ only("quiz_id") def attribute_to_user(self, user, user_key): return self.filter(user_key=user_key).update(user_key=user.id, user=user) #https://github.com/pramodliv1/conceptgrapher/blob/master/server/cg/quiz/models.py #The QuizAttempt model is inspired by the same model from my previous project SESSION_KEY_MAX_LENGTH = 40 #Equal to session_key max length class QuizAttempt(UUIDModel): quiz = models.ForeignKey(Quiz) user = models.ForeignKey(User, null=True) #user_key = user_id if user is logged-in else session_key user_key = models.CharField(max_length=SESSION_KEY_MAX_LENGTH, db_index=True) result = models.BooleanField() answer = models.TextField(blank=True) choices = models.TextField(blank=True) #Denormalized -> Contains choiceIds separated by commas to make writes faster created_at = models.DateTimeField(db_index=True) objects = QuizUserAttemptManager() def __str__(self): if self.user is None: user_print = self.user_key else: user_print = self.user return "{} - {} attempted {} - Result: {}".format(self.created_at, user_print, self.quiz, self.result) ################################################################################ # # signal_receivers, placed at end of file to due to circular imports # ################################################################################ from . import signal_receivers
mit
[ 646, 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 3, 504, 1947, 3187, 14, 16259, 492, 8053, 16725, 2988, 199, 199, 504, 6170, 14, 992, 492, 18267, 379, 1685, 12, 11134, 1685, 421, 199, 2328, 5357, 63, 7893, 275, 334, 272, 334, 17, 12, 283, 13003, 63, 5622, 12018, 659, 272, 334, 18, 12, 283, 7608, 49, 659, 199, 9, 199, 199, 533, 5843, 565, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 339, 7894, 63, 1210, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 7894, 63, 2918, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 2286, 2173, 565, 63, 466, 275, 1709, 14, 3901, 8, 4577, 29, 2328, 5357, 63, 7893, 9, 339, 327, 2969, 275, 8053, 16725, 2988, 8, 2500, 29, 549, 9, 339, 768, 3744, 272, 347, 664, 63, 19170, 63, 392, 28981, 397, 63, 262, 8, 1886, 12, 2762, 304, 267, 372, 5843, 565, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 1580, 680, 15576, 63, 2407, 360, 3612, 5934, 63, 409, 1959, 15576, 63, 2407, 360, 5095, 63, 409, 358, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 11491, 446, 18208, 701, 8352, 908, 8, 277, 14, 4790, 63, 1210, 12, 291, 14, 3966, 63, 991, 9, 6905, 199, 533, 20124, 19104, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 339, 2173, 565, 275, 1709, 14, 3190, 8, 2371, 565, 9, 272, 6385, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 2378, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 392, 565, 297, 283, 5934, 358, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 11491, 365, 376, 6385, 370, 1052, 18208, 701, 8352, 908, 8, 277, 14, 5934, 12, 7205, 291, 14, 392, 565, 12, 291, 14, 3966, 63, 991, 9, 421, 199, 533, 16053, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 9054, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1648, 63, 991, 360, 3966, 63, 292, 358, 199, 199, 533, 16053, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 2286, 2173, 565, 275, 1709, 14, 3190, 8, 2371, 565, 9, 272, 7141, 63, 1210, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 7141, 63, 2918, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 365, 63, 4525, 275, 1709, 14, 5036, 342, 339, 2251, 275, 16053, 2988, 342, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 392, 565, 297, 283, 5095, 63, 1210, 358, 339, 347, 636, 495, 721, 277, 304, 267, 2004, 275, 298, 4525, 2, 340, 291, 14, 374, 63, 4525, 587, 298, 10603, 2, 267, 372, 11491, 365, 282, 1052, 7141, 370, 1052, 446, 18208, 701, 8352, 908, 8, 277, 14, 5095, 63, 1210, 12, 7205, 2004, 12, 291, 14, 392, 565, 12, 291, 14, 3966, 63, 991, 9, 6905, 199, 533, 5843, 565, 1899, 23272, 2988, 8, 992, 14, 2988, 304, 339, 347, 485, 362, 63, 4577, 8, 277, 12, 7141, 63, 875, 63, 513, 304, 267, 340, 7141, 63, 875, 63, 513, 508, 10812, 288, 372, 1052, 398, 7141, 63, 1580, 275, 359, 442, 8, 5095, 63, 344, 9, 367, 7141, 63, 344, 315, 7141, 63, 875, 63, 513, 14, 1294, 11854, 11323, 398, 7594, 275, 16053, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 5095, 63, 1580, 680, 2118, 480, 344, 401, 298, 5095, 63, 2918, 531, 267, 3415, 275, 3842, 5095, 14, 344, 12, 7141, 14, 5095, 63, 2918, 12, 776, 367, 7141, 315, 7594, 61, 267, 372, 1211, 8, 4577, 9, 2378, 347, 664, 63, 751, 63, 13143, 63, 991, 63, 392, 565, 63, 344, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 344, 304, 267, 12454, 275, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 12, 2173, 565, 63, 344, 29, 392, 565, 63, 344, 9, 398, 7141, 63, 875, 63, 513, 275, 12814, 904, 1332, 16880, 14, 4577, 367, 7427, 315, 12454, 430, 267, 3415, 63, 991, 63, 344, 275, 291, 423, 362, 63, 4577, 8, 5095, 63, 875, 63, 513, 9, 2728, 367, 7427, 315, 12454, 26, 288, 7141, 63, 1580, 275, 359, 442, 8, 5095, 63, 344, 9, 367, 7141, 63, 344, 315, 7427, 14, 4577, 14, 1294, 11854, 11323, 288, 7427, 14, 4577, 275, 359, 288, 469, 355, 298, 344, 582, 7141, 63, 344, 12, 8892, 298, 5095, 63, 2918, 582, 3415, 63, 991, 63, 344, 59, 5095, 63, 344, 61, 288, 789, 367, 7141, 63, 344, 315, 7141, 63, 1580, 61, 267, 372, 12454, 2378, 347, 664, 63, 751, 63, 13143, 63, 262, 63, 392, 28981, 397, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 680, 1541, 8, 392, 565, 363, 262, 29, 392, 565, 63, 1580, 9, 339, 327, 11396, 1035, 4868, 3663, 3211, 12454, 367, 2011, 2173, 565, 365, 5591, 327, 22051, 2289, 16142, 770, 503, 2813, 15755, 315, 642, 1827, 14, 5591, 347, 664, 63, 796, 21221, 63, 392, 565, 63, 835, 63, 262, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 291, 14, 362, 63, 751, 63, 13143, 63, 262, 63, 392, 28981, 397, 8, 751, 63, 498, 12, 2173, 565, 63, 1580, 680, 1541, 8, 1099, 29, 549, 680, 835, 342, 339, 347, 664, 63, 751, 63, 796, 21221, 63, 392, 565, 63, 1580, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 12013, 3521, 2457, 8, 392, 565, 363, 262, 29, 392, 565, 63, 1580, 12013, 3521, 2457, 8, 1099, 29, 549, 12013, 3521, 1454, 480, 392, 565, 63, 344, 531, 2378, 347, 2225, 63, 475, 63, 751, 8, 277, 12, 922, 12, 922, 63, 498, 304, 267, 372, 291, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 680, 873, 8, 751, 63, 498, 29, 751, 14, 344, 12, 922 ]
[ 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 3, 504, 1947, 3187, 14, 16259, 492, 8053, 16725, 2988, 199, 199, 504, 6170, 14, 992, 492, 18267, 379, 1685, 12, 11134, 1685, 421, 199, 2328, 5357, 63, 7893, 275, 334, 272, 334, 17, 12, 283, 13003, 63, 5622, 12018, 659, 272, 334, 18, 12, 283, 7608, 49, 659, 199, 9, 199, 199, 533, 5843, 565, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 339, 7894, 63, 1210, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 7894, 63, 2918, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 2286, 2173, 565, 63, 466, 275, 1709, 14, 3901, 8, 4577, 29, 2328, 5357, 63, 7893, 9, 339, 327, 2969, 275, 8053, 16725, 2988, 8, 2500, 29, 549, 9, 339, 768, 3744, 272, 347, 664, 63, 19170, 63, 392, 28981, 397, 63, 262, 8, 1886, 12, 2762, 304, 267, 372, 5843, 565, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 1580, 680, 15576, 63, 2407, 360, 3612, 5934, 63, 409, 1959, 15576, 63, 2407, 360, 5095, 63, 409, 358, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 11491, 446, 18208, 701, 8352, 908, 8, 277, 14, 4790, 63, 1210, 12, 291, 14, 3966, 63, 991, 9, 6905, 199, 533, 20124, 19104, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 339, 2173, 565, 275, 1709, 14, 3190, 8, 2371, 565, 9, 272, 6385, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 2378, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 392, 565, 297, 283, 5934, 358, 2378, 347, 636, 495, 721, 277, 304, 267, 372, 11491, 365, 376, 6385, 370, 1052, 18208, 701, 8352, 908, 8, 277, 14, 5934, 12, 7205, 291, 14, 392, 565, 12, 291, 14, 3966, 63, 991, 9, 421, 199, 533, 16053, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 9054, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1648, 63, 991, 360, 3966, 63, 292, 358, 199, 199, 533, 16053, 8, 10239, 379, 1685, 12, 11134, 1685, 304, 2286, 2173, 565, 275, 1709, 14, 3190, 8, 2371, 565, 9, 272, 7141, 63, 1210, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 7141, 63, 2918, 275, 1709, 14, 6254, 8, 2500, 29, 549, 9, 272, 365, 63, 4525, 275, 1709, 14, 5036, 342, 339, 2251, 275, 16053, 2988, 342, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 392, 565, 297, 283, 5095, 63, 1210, 358, 339, 347, 636, 495, 721, 277, 304, 267, 2004, 275, 298, 4525, 2, 340, 291, 14, 374, 63, 4525, 587, 298, 10603, 2, 267, 372, 11491, 365, 282, 1052, 7141, 370, 1052, 446, 18208, 701, 8352, 908, 8, 277, 14, 5095, 63, 1210, 12, 7205, 2004, 12, 291, 14, 392, 565, 12, 291, 14, 3966, 63, 991, 9, 6905, 199, 533, 5843, 565, 1899, 23272, 2988, 8, 992, 14, 2988, 304, 339, 347, 485, 362, 63, 4577, 8, 277, 12, 7141, 63, 875, 63, 513, 304, 267, 340, 7141, 63, 875, 63, 513, 508, 10812, 288, 372, 1052, 398, 7141, 63, 1580, 275, 359, 442, 8, 5095, 63, 344, 9, 367, 7141, 63, 344, 315, 7141, 63, 875, 63, 513, 14, 1294, 11854, 11323, 398, 7594, 275, 16053, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 5095, 63, 1580, 680, 2118, 480, 344, 401, 298, 5095, 63, 2918, 531, 267, 3415, 275, 3842, 5095, 14, 344, 12, 7141, 14, 5095, 63, 2918, 12, 776, 367, 7141, 315, 7594, 61, 267, 372, 1211, 8, 4577, 9, 2378, 347, 664, 63, 751, 63, 13143, 63, 991, 63, 392, 565, 63, 344, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 344, 304, 267, 12454, 275, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 12, 2173, 565, 63, 344, 29, 392, 565, 63, 344, 9, 398, 7141, 63, 875, 63, 513, 275, 12814, 904, 1332, 16880, 14, 4577, 367, 7427, 315, 12454, 430, 267, 3415, 63, 991, 63, 344, 275, 291, 423, 362, 63, 4577, 8, 5095, 63, 875, 63, 513, 9, 2728, 367, 7427, 315, 12454, 26, 288, 7141, 63, 1580, 275, 359, 442, 8, 5095, 63, 344, 9, 367, 7141, 63, 344, 315, 7427, 14, 4577, 14, 1294, 11854, 11323, 288, 7427, 14, 4577, 275, 359, 288, 469, 355, 298, 344, 582, 7141, 63, 344, 12, 8892, 298, 5095, 63, 2918, 582, 3415, 63, 991, 63, 344, 59, 5095, 63, 344, 61, 288, 789, 367, 7141, 63, 344, 315, 7141, 63, 1580, 61, 267, 372, 12454, 2378, 347, 664, 63, 751, 63, 13143, 63, 262, 63, 392, 28981, 397, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 680, 1541, 8, 392, 565, 363, 262, 29, 392, 565, 63, 1580, 9, 339, 327, 11396, 1035, 4868, 3663, 3211, 12454, 367, 2011, 2173, 565, 365, 5591, 327, 22051, 2289, 16142, 770, 503, 2813, 15755, 315, 642, 1827, 14, 5591, 347, 664, 63, 796, 21221, 63, 392, 565, 63, 835, 63, 262, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 291, 14, 362, 63, 751, 63, 13143, 63, 262, 63, 392, 28981, 397, 8, 751, 63, 498, 12, 2173, 565, 63, 1580, 680, 1541, 8, 1099, 29, 549, 680, 835, 342, 339, 347, 664, 63, 751, 63, 796, 21221, 63, 392, 565, 63, 1580, 8, 277, 12, 922, 63, 498, 12, 2173, 565, 63, 1580, 304, 267, 372, 5843, 565, 23272, 14, 1462, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 12013, 3521, 2457, 8, 392, 565, 363, 262, 29, 392, 565, 63, 1580, 12013, 3521, 2457, 8, 1099, 29, 549, 12013, 3521, 1454, 480, 392, 565, 63, 344, 531, 2378, 347, 2225, 63, 475, 63, 751, 8, 277, 12, 922, 12, 922, 63, 498, 304, 267, 372, 291, 14, 1541, 8, 751, 63, 498, 29, 751, 63, 498, 680, 873, 8, 751, 63, 498, 29, 751, 14, 344, 12, 922, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sonaht/ansible
lib/ansible/module_utils/facts/system/service_mgr.py
59
5946
# Collect facts related to system service manager and init. # # 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 os import platform import re from ansible.module_utils._text import to_native from ansible.module_utils.facts.utils import get_file_content from ansible.module_utils.facts.collector import BaseFactCollector # The distutils module is not shipped with SUNWPython on Solaris. # It's in the SUNWPython-devel package which also contains development files # that don't belong on production boxes. Since our Solaris code doesn't # depend on LooseVersion, do not import it on Solaris. if platform.system() != 'SunOS': from distutils.version import LooseVersion class ServiceMgrFactCollector(BaseFactCollector): name = 'service_mgr' _fact_ids = set() @staticmethod def is_systemd_managed(module): # tools must be installed if module.get_bin_path('systemctl'): # this should show if systemd is the boot init system, if checking init faild to mark as systemd # these mirror systemd's own sd_boot test http://www.freedesktop.org/software/systemd/man/sd_booted.html for canary in ["/run/systemd/system/", "/dev/.run/systemd/", "/dev/.systemd/"]: if os.path.exists(canary): return True return False def collect(self, module=None, collected_facts=None): facts_dict = {} if not module: return facts_dict collected_facts = collected_facts or {} service_mgr_name = None # TODO: detect more custom init setups like bootscripts, dmd, s6, Epoch, etc # also other OSs other than linux might need to check across several possible candidates # Mapping of proc_1 values to more useful names proc_1_map = { 'procd': 'openwrt_init', 'runit-init': 'runit', 'svscan': 'svc', 'openrc-init': 'openrc', } # try various forms of querying pid 1 proc_1 = get_file_content('/proc/1/comm') if proc_1 is None: # FIXME: return code isnt checked # FIXME: if stdout is empty string, odd things # FIXME: other code seems to think we could get proc_1 == None past this point rc, proc_1, err = module.run_command("ps -p 1 -o comm|tail -n 1", use_unsafe_shell=True) # If the output of the command starts with what looks like a PID, then the 'ps' command # probably didn't work the way we wanted, probably because it's busybox if re.match(r' *[0-9]+ ', proc_1): proc_1 = None # The ps command above may return "COMMAND" if the user cannot read /proc, e.g. with grsecurity if proc_1 == "COMMAND\n": proc_1 = None # FIXME: empty string proc_1 staus empty string if proc_1 is not None: proc_1 = os.path.basename(proc_1) proc_1 = to_native(proc_1) proc_1 = proc_1.strip() if proc_1 is not None and (proc_1 == 'init' or proc_1.endswith('sh')): # many systems return init, so this cannot be trusted, if it ends in 'sh' it probalby is a shell in a container proc_1 = None # if not init/None it should be an identifiable or custom init, so we are done! if proc_1 is not None: # Lookup proc_1 value in map and use proc_1 value itself if no match # FIXME: empty string still falls through service_mgr_name = proc_1_map.get(proc_1, proc_1) # FIXME: replace with a system->service_mgr_name map? # start with the easy ones elif collected_facts.get('distribution', None) == 'MacOSX': # FIXME: find way to query executable, version matching is not ideal if LooseVersion(platform.mac_ver()[0]) >= LooseVersion('10.4'): service_mgr_name = 'launchd' else: service_mgr_name = 'systemstarter' elif 'BSD' in collected_facts.get('system', '') or collected_facts.get('system') in ['Bitrig', 'DragonFly']: # FIXME: we might want to break out to individual BSDs or 'rc' service_mgr_name = 'bsdinit' elif collected_facts.get('system') == 'AIX': service_mgr_name = 'src' elif collected_facts.get('system') == 'SunOS': service_mgr_name = 'smf' elif collected_facts.get('distribution') == 'OpenWrt': service_mgr_name = 'openwrt_init' elif collected_facts.get('system') == 'Linux': # FIXME: mv is_systemd_managed if self.is_systemd_managed(module=module): service_mgr_name = 'systemd' elif module.get_bin_path('initctl') and os.path.exists("/etc/init/"): service_mgr_name = 'upstart' elif os.path.exists('/sbin/openrc'): service_mgr_name = 'openrc' elif os.path.exists('/etc/init.d/'): service_mgr_name = 'sysvinit' if not service_mgr_name: # if we cannot detect, fallback to generic 'service' service_mgr_name = 'service' facts_dict['service_mgr'] = service_mgr_name return facts_dict
gpl-3.0
[ 3, 19649, 9036, 4048, 370, 2656, 2435, 5256, 436, 4205, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 4298, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 1208, 492, 664, 63, 493, 63, 1317, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 10946, 492, 3523, 24704, 12852, 199, 199, 3, 710, 7065, 859, 365, 440, 15924, 1915, 543, 428, 1734, 55, 4718, 641, 17991, 4663, 14, 199, 3, 2779, 1159, 315, 314, 428, 1734, 55, 4718, 13, 27870, 2559, 1314, 2597, 3509, 16367, 1584, 199, 3, 626, 2793, 1133, 13511, 641, 9920, 17193, 14, 221, 9336, 4154, 17991, 4663, 1233, 3181, 1133, 199, 3, 11687, 641, 18462, 12, 886, 440, 492, 652, 641, 17991, 4663, 14, 199, 692, 4298, 14, 2253, 342, 1137, 283, 22546, 3100, 356, 272, 687, 7065, 14, 1023, 492, 18462, 421, 199, 533, 7591, 20752, 24704, 12852, 8, 1563, 24704, 12852, 304, 272, 536, 275, 283, 1364, 63, 7755, 7, 272, 485, 7783, 63, 1580, 275, 663, 342, 339, 768, 4639, 272, 347, 365, 63, 30830, 63, 11122, 8, 578, 304, 267, 327, 7249, 1471, 506, 4903, 267, 340, 859, 14, 362, 63, 1393, 63, 515, 360, 2253, 8077, 735, 953, 327, 642, 1077, 2498, 340, 2656, 68, 365, 314, 8498, 4205, 2656, 12, 340, 7907, 4205, 1433, 668, 370, 2216, 465, 2656, 68, 288, 327, 3520, 15216, 2656, 68, 1159, 5705, 14613, 63, 4930, 511, 1455, 921, 1544, 14, 4624, 14487, 14, 1308, 15, 15619, 15, 30830, 15, 1237, 15, 3893, 63, 656, 5731, 14, 1360, 288, 367, 883, 695, 315, 2097, 15, 1065, 15, 30830, 15, 2253, 10665, 3286, 2374, 8083, 1065, 15, 30830, 10665, 3286, 2374, 8083, 30830, 15, 6229, 355, 340, 747, 14, 515, 14, 2444, 8, 2425, 695, 304, 490, 372, 715, 267, 372, 756, 339, 347, 8775, 8, 277, 12, 859, 29, 403, 12, 13736, 63, 5047, 29, 403, 304, 267, 9036, 63, 807, 275, 1052, 398, 340, 440, 859, 26, 288, 372, 9036, 63, 807, 398, 13736, 63, 5047, 275, 13736, 63, 5047, 503, 1052, 267, 2435, 63, 7755, 63, 354, 275, 488, 398, 327, 3254, 26, 9696, 1655, 3537, 4205, 3272, 83, 2839, 8498, 6429, 12, 366, 1064, 12, 308, 22, 12, 662, 5132, 12, 5423, 267, 327, 2597, 1163, 4403, 83, 1163, 2419, 18369, 5594, 1929, 370, 1104, 9371, 9978, 3962, 15101, 398, 327, 12340, 402, 6499, 63, 17, 1338, 370, 1655, 2997, 1561, 267, 6499, 63, 17, 63, 1130, 275, 469, 288, 283, 496, 2866, 356, 283, 1490, 87, 2591, 63, 826, 297, 288, 283, 1065, 390, 13, 826, 356, 283, 1065, 390, 297, 288, 283, 2772, 6282, 356, 283, 10599, 297, 288, 283, 1490, 1195, 13, 826, 356, 283, 1490, 1195, 297, 267, 789, 398, 327, 862, 7750, 4513, 402, 27405, 4422, 413, 267, 6499, 63, 17, 275, 664, 63, 493, 63, 1317, 2336, 4687, 15, 17, 15, 1404, 358, 267, 340, 6499, 63, 17, 365, 488, 26, 288, 327, 7600, 26, 372, 1233, 365, 343, 7923, 288, 327, 7600, 26, 340, 3839, 365, 2701, 1059, 12, 16699, 7645, 288, 327, 7600, 26, 1163, 1233, 12237, 370, 13516, 781, 4293, 664, 6499, 63, 17, 508, 488, 13541, 642, 2376, 288, 4819, 12, 6499, 63, 17, 12, 2329, 275, 859, 14, 1065, 63, 1531, 480, 1190, 446, 80, 413, 446, 79, 1923, 92, 1521, 446, 78, 413, 401, 675, 63, 14242, 63, 5641, 29, 549, 9, 288, 327, 982, 314, 1072, 402, 314, 1414, 9174, 543, 4052, 10734, 2839, 282, 20674, 12, 2066, 314, 283, 1190, 7, 1414, 288, 327, 8646, 9980, 1133, 1736, 314, 4340, 781, 13632, 12, 8646, 2952, 652, 1159, 10414, 89, 1977, 288, 340, 295, 14, 1431, 8, 82, 7, 627, 59, 16, 13, 25, 2807, 1656, 6499, 63, 17, 304, 355, 6499, 63, 17, 275, 488, 398, 327, 710, 7347, 1414, 3432, 1443, 372, 298, 10761, 2, 340, 314, 922, 3913, 1586, 1182, 4687, 12, 325, 14, 71, 14, 543, 7192, 4416, 267, 340, 6499, 63, 17, 508, 298, 10761, 60, 78, 582, 288, 6499, 63, 17, 275, 488, 398, 327, 7600, 26, 2701, 1059, 6499, 63, 17, 2612, 527, 2701, 1059, 267, 340, 6499, 63, 17, 365, 440, 488, 26, 288, 6499, 63, 17, 275, 747, 14, 515, 14, 4846, 8, 4687, 63, 17, 9, 288, 6499, 63, 17, 275, 370, 63, 6106, 8, 4687, 63, 17, 9, 288, 6499, 63, 17, 275, 6499, 63, 17, 14, 1913, 342, 398, 340, 6499, 63, 17, 365, 440, 488, 436, 334, 4687, 63, 17, 508, 283, 826, 7, 503, 6499, 63, 17, 14, 4130, 360, 609, 8109, 288, 327, 5002, 10460, 372, 4205, 12, 880, 642, 3913, 506, 19427, 12, 340, 652, 11187, 315, 283, 609, 7, 652, 557, 4982, 991, 365, 282, 5218, 315, 282, 3970, 288, 6499, 63, 17, 275, 488, 398, 327, 340, 440, 4205, 15, 403, 652, 1077, 506, 376, 16346, 461, 503, 3537, 4205, 12, 880, 781, 787, 4224, 1, 267, 340, 6499, 63, 17, 365, 440, 488 ]
[ 19649, 9036, 4048, 370, 2656, 2435, 5256, 436, 4205, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 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, 4298, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 1208, 492, 664, 63, 493, 63, 1317, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 10946, 492, 3523, 24704, 12852, 199, 199, 3, 710, 7065, 859, 365, 440, 15924, 1915, 543, 428, 1734, 55, 4718, 641, 17991, 4663, 14, 199, 3, 2779, 1159, 315, 314, 428, 1734, 55, 4718, 13, 27870, 2559, 1314, 2597, 3509, 16367, 1584, 199, 3, 626, 2793, 1133, 13511, 641, 9920, 17193, 14, 221, 9336, 4154, 17991, 4663, 1233, 3181, 1133, 199, 3, 11687, 641, 18462, 12, 886, 440, 492, 652, 641, 17991, 4663, 14, 199, 692, 4298, 14, 2253, 342, 1137, 283, 22546, 3100, 356, 272, 687, 7065, 14, 1023, 492, 18462, 421, 199, 533, 7591, 20752, 24704, 12852, 8, 1563, 24704, 12852, 304, 272, 536, 275, 283, 1364, 63, 7755, 7, 272, 485, 7783, 63, 1580, 275, 663, 342, 339, 768, 4639, 272, 347, 365, 63, 30830, 63, 11122, 8, 578, 304, 267, 327, 7249, 1471, 506, 4903, 267, 340, 859, 14, 362, 63, 1393, 63, 515, 360, 2253, 8077, 735, 953, 327, 642, 1077, 2498, 340, 2656, 68, 365, 314, 8498, 4205, 2656, 12, 340, 7907, 4205, 1433, 668, 370, 2216, 465, 2656, 68, 288, 327, 3520, 15216, 2656, 68, 1159, 5705, 14613, 63, 4930, 511, 1455, 921, 1544, 14, 4624, 14487, 14, 1308, 15, 15619, 15, 30830, 15, 1237, 15, 3893, 63, 656, 5731, 14, 1360, 288, 367, 883, 695, 315, 2097, 15, 1065, 15, 30830, 15, 2253, 10665, 3286, 2374, 8083, 1065, 15, 30830, 10665, 3286, 2374, 8083, 30830, 15, 6229, 355, 340, 747, 14, 515, 14, 2444, 8, 2425, 695, 304, 490, 372, 715, 267, 372, 756, 339, 347, 8775, 8, 277, 12, 859, 29, 403, 12, 13736, 63, 5047, 29, 403, 304, 267, 9036, 63, 807, 275, 1052, 398, 340, 440, 859, 26, 288, 372, 9036, 63, 807, 398, 13736, 63, 5047, 275, 13736, 63, 5047, 503, 1052, 267, 2435, 63, 7755, 63, 354, 275, 488, 398, 327, 3254, 26, 9696, 1655, 3537, 4205, 3272, 83, 2839, 8498, 6429, 12, 366, 1064, 12, 308, 22, 12, 662, 5132, 12, 5423, 267, 327, 2597, 1163, 4403, 83, 1163, 2419, 18369, 5594, 1929, 370, 1104, 9371, 9978, 3962, 15101, 398, 327, 12340, 402, 6499, 63, 17, 1338, 370, 1655, 2997, 1561, 267, 6499, 63, 17, 63, 1130, 275, 469, 288, 283, 496, 2866, 356, 283, 1490, 87, 2591, 63, 826, 297, 288, 283, 1065, 390, 13, 826, 356, 283, 1065, 390, 297, 288, 283, 2772, 6282, 356, 283, 10599, 297, 288, 283, 1490, 1195, 13, 826, 356, 283, 1490, 1195, 297, 267, 789, 398, 327, 862, 7750, 4513, 402, 27405, 4422, 413, 267, 6499, 63, 17, 275, 664, 63, 493, 63, 1317, 2336, 4687, 15, 17, 15, 1404, 358, 267, 340, 6499, 63, 17, 365, 488, 26, 288, 327, 7600, 26, 372, 1233, 365, 343, 7923, 288, 327, 7600, 26, 340, 3839, 365, 2701, 1059, 12, 16699, 7645, 288, 327, 7600, 26, 1163, 1233, 12237, 370, 13516, 781, 4293, 664, 6499, 63, 17, 508, 488, 13541, 642, 2376, 288, 4819, 12, 6499, 63, 17, 12, 2329, 275, 859, 14, 1065, 63, 1531, 480, 1190, 446, 80, 413, 446, 79, 1923, 92, 1521, 446, 78, 413, 401, 675, 63, 14242, 63, 5641, 29, 549, 9, 288, 327, 982, 314, 1072, 402, 314, 1414, 9174, 543, 4052, 10734, 2839, 282, 20674, 12, 2066, 314, 283, 1190, 7, 1414, 288, 327, 8646, 9980, 1133, 1736, 314, 4340, 781, 13632, 12, 8646, 2952, 652, 1159, 10414, 89, 1977, 288, 340, 295, 14, 1431, 8, 82, 7, 627, 59, 16, 13, 25, 2807, 1656, 6499, 63, 17, 304, 355, 6499, 63, 17, 275, 488, 398, 327, 710, 7347, 1414, 3432, 1443, 372, 298, 10761, 2, 340, 314, 922, 3913, 1586, 1182, 4687, 12, 325, 14, 71, 14, 543, 7192, 4416, 267, 340, 6499, 63, 17, 508, 298, 10761, 60, 78, 582, 288, 6499, 63, 17, 275, 488, 398, 327, 7600, 26, 2701, 1059, 6499, 63, 17, 2612, 527, 2701, 1059, 267, 340, 6499, 63, 17, 365, 440, 488, 26, 288, 6499, 63, 17, 275, 747, 14, 515, 14, 4846, 8, 4687, 63, 17, 9, 288, 6499, 63, 17, 275, 370, 63, 6106, 8, 4687, 63, 17, 9, 288, 6499, 63, 17, 275, 6499, 63, 17, 14, 1913, 342, 398, 340, 6499, 63, 17, 365, 440, 488, 436, 334, 4687, 63, 17, 508, 283, 826, 7, 503, 6499, 63, 17, 14, 4130, 360, 609, 8109, 288, 327, 5002, 10460, 372, 4205, 12, 880, 642, 3913, 506, 19427, 12, 340, 652, 11187, 315, 283, 609, 7, 652, 557, 4982, 991, 365, 282, 5218, 315, 282, 3970, 288, 6499, 63, 17, 275, 488, 398, 327, 340, 440, 4205, 15, 403, 652, 1077, 506, 376, 16346, 461, 503, 3537, 4205, 12, 880, 781, 787, 4224, 1, 267, 340, 6499, 63, 17, 365, 440, 488, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
devinbalkind/eden
modules/tests/staff/staff_import.py
21
4228
# -*- coding: utf-8 -*- """ Sahana Eden Staff Module Automated Tests @copyright: 2011-2012 (c) Sahana Software Foundation @license: MIT 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 os from gluon import current from tests.web2unittest import SeleniumUnitTest class ImportStaff(SeleniumUnitTest): def test_hrm004_import_staff(self): """ @case: hrm004 @description: Import Staff """ print "\n" import datetime from dateutil.relativedelta import relativedelta base_dir = os.path.join(os.getcwd(), "applications", current.request.application) file_path = os.path.join(base_dir, "modules", "tests", "staff", "staff.csv") #@ToDo: Move these into we2unittest today = datetime.date.today().strftime("%Y-%m-%d") now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") now_1_day = (datetime.datetime.now() + relativedelta( days = +1 )).strftime("%Y-%m-%d %H:%M:%S") now_1_week = (datetime.date.today() + relativedelta( weeks = +1 )).strftime("%Y-%m-%d %H:%M:%S") # HRM004 # Login, if not-already done so self.login(account="admin", nexturl="hrm/person/import?group=staff") self.browser.find_element_by_css_selector('input[type="file"]').send_keys(file_path) # Submit the form self.browser.find_element_by_css_selector('input[type="submit"]').click() # waiting for the page to load self.wait_for_page_to_load() # Importing self.browser.find_element_by_id("submitSelection").click() def test_hrm005_import_staff(self): """ @case: hrm005 @description: Import Staff This test removes any exsisting data before importing """ print "\n" import datetime from dateutil.relativedelta import relativedelta base_dir = os.path.join(os.getcwd(), "applications", current.request.application) file_path = os.path.join(base_dir, "modules", "tests", "staff", "staff.csv") #@ToDo: Move these into we2unittest today = datetime.date.today().strftime("%Y-%m-%d") now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") now_1_day = (datetime.datetime.now() + relativedelta( days = +1 )).strftime("%Y-%m-%d %H:%M:%S") now_1_week = (datetime.date.today() + relativedelta( weeks = +1 )).strftime("%Y-%m-%d %H:%M:%S") # HRM004 # Login, if not-already done so self.login(account="admin", nexturl="hrm/person/import?group=staff") self.browser.find_element_by_css_selector('input[type="file"]').send_keys(file_path) self.browser.find_element_by_id("s3_import_upload_replace_option").click() # Submit the form self.browser.find_element_by_css_selector('input[type="submit"]').click() # waiting for the page to load self.wait_for_page_to_load() # Importing self.browser.find_element_by_id("submitSelection").click()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 2999, 199, 624, 428, 11326, 6738, 662, 848, 25910, 5673, 27722, 23513, 6496, 2958, 768, 7307, 26, 7760, 13, 7409, 334, 67, 9, 428, 11326, 6738, 2290, 2752, 1128, 768, 1682, 26, 10697, 2958, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 1128, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1128, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 1128, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1128, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 1128, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 1128, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 1128, 3704, 26, 2958, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 1128, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 2958, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 1128, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1128, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 1128, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 1128, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 1128, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 1128, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 1128, 5010, 13198, 1621, 2334, 4141, 14, 202, 199, 624, 202, 199, 646, 747, 2999, 199, 504, 26752, 492, 1453, 202, 199, 504, 2295, 14, 2520, 18, 2796, 492, 3240, 9465, 29037, 2999, 199, 533, 3161, 18963, 8, 31315, 29037, 304, 1128, 347, 511, 63, 22276, 7979, 63, 646, 63, 7018, 8, 277, 304, 1039, 408, 1675, 768, 2546, 26, 394, 5682, 7979, 1675, 768, 1802, 26, 3161, 25910, 1039, 408, 1039, 870, 1867, 78, 2, 13594, 492, 2197, 1039, 687, 22208, 14, 32300, 492, 20599, 1039, 1300, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 15853, 401, 1453, 14, 1069, 14, 3578, 9, 1039, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 3112, 401, 298, 2219, 401, 298, 7018, 401, 298, 7018, 14, 4737, 531, 4341, 9213, 1378, 2585, 26, 14171, 3520, 1901, 781, 18, 2796, 1039, 11168, 275, 2197, 14, 602, 14, 8136, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 1039, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 2977, 275, 334, 2083, 14, 2083, 14, 2131, 342, 435, 20599, 8, 7609, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 6419, 275, 334, 2083, 14, 602, 14, 8136, 342, 435, 20599, 8, 29540, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 13594, 327, 869, 11026, 7979, 1039, 327, 16430, 12, 340, 440, 13, 14039, 4224, 880, 1039, 291, 14, 2886, 8, 2048, 628, 2113, 401, 2163, 633, 628, 22276, 15, 5484, 15, 646, 31, 923, 29, 7018, 531, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 493, 937, 1959, 2254, 63, 1612, 8, 493, 63, 515, 9, 1039, 327, 28295, 314, 1824, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 7275, 937, 1959, 4891, 342, 1039, 327, 10923, 367, 314, 2034, 370, 2248, 1039, 291, 14, 2573, 63, 509, 63, 1606, 63, 475, 63, 912, 342, 1039, 327, 3161, 316, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 344, 480, 7275, 7713, 3471, 4891, 342, 2958, 347, 511, 63, 22276, 7972, 63, 646, 63, 7018, 8, 277, 304, 1039, 408, 1675, 768, 2546, 26, 394, 5682, 7972, 1675, 768, 1802, 26, 3161, 25910, 1675, 961, 511, 14185, 1263, 444, 11734, 316, 666, 2544, 16306, 1039, 408, 1039, 870, 1867, 78, 2, 13594, 492, 2197, 1039, 687, 22208, 14, 32300, 492, 20599, 1039, 1300, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 15853, 401, 1453, 14, 1069, 14, 3578, 9, 1039, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 3112, 401, 298, 2219, 401, 298, 7018, 401, 298, 7018, 14, 4737, 531, 4341, 9213, 1378, 2585, 26, 14171, 3520, 1901, 781, 18, 2796, 1039, 11168, 275, 2197, 14, 602, 14, 8136, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 1039, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 2977, 275, 334, 2083, 14, 2083, 14, 2131, 342, 435, 20599, 8, 7609, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 6419, 275, 334, 2083, 14, 602, 14, 8136, 342, 435, 20599, 8, 29540, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 13594, 327, 869, 11026, 7979, 1039, 327, 16430, 12, 340, 440, 13, 14039, 4224, 880, 1039, 291, 14, 2886, 8, 2048, 628, 2113, 401, 2163, 633, 628, 22276, 15, 5484, 15, 646, 31, 923, 29, 7018, 531, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 493, 937, 1959, 2254, 63, 1612, 8, 493, 63, 515, 9, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 344, 480, 83, 19, 63, 646, 63, 5064, 63, 1814, 63, 1422, 3471, 4891, 342, 1039, 327, 28295, 314, 1824, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 7275, 937, 1959, 4891, 342, 1039, 327, 10923, 367, 314, 2034, 370, 2248, 1039, 291, 14, 2573, 63, 509, 63, 1606, 63, 475, 63, 912 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 2999, 199, 624, 428, 11326, 6738, 662, 848, 25910, 5673, 27722, 23513, 6496, 2958, 768, 7307, 26, 7760, 13, 7409, 334, 67, 9, 428, 11326, 6738, 2290, 2752, 1128, 768, 1682, 26, 10697, 2958, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 1128, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1128, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 1128, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 1128, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 1128, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 1128, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 1128, 3704, 26, 2958, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 1128, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 2958, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 1128, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1128, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 1128, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 1128, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 1128, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 1128, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 1128, 5010, 13198, 1621, 2334, 4141, 14, 202, 199, 624, 202, 199, 646, 747, 2999, 199, 504, 26752, 492, 1453, 202, 199, 504, 2295, 14, 2520, 18, 2796, 492, 3240, 9465, 29037, 2999, 199, 533, 3161, 18963, 8, 31315, 29037, 304, 1128, 347, 511, 63, 22276, 7979, 63, 646, 63, 7018, 8, 277, 304, 1039, 408, 1675, 768, 2546, 26, 394, 5682, 7979, 1675, 768, 1802, 26, 3161, 25910, 1039, 408, 1039, 870, 1867, 78, 2, 13594, 492, 2197, 1039, 687, 22208, 14, 32300, 492, 20599, 1039, 1300, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 15853, 401, 1453, 14, 1069, 14, 3578, 9, 1039, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 3112, 401, 298, 2219, 401, 298, 7018, 401, 298, 7018, 14, 4737, 531, 4341, 9213, 1378, 2585, 26, 14171, 3520, 1901, 781, 18, 2796, 1039, 11168, 275, 2197, 14, 602, 14, 8136, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 1039, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 2977, 275, 334, 2083, 14, 2083, 14, 2131, 342, 435, 20599, 8, 7609, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 6419, 275, 334, 2083, 14, 602, 14, 8136, 342, 435, 20599, 8, 29540, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 13594, 327, 869, 11026, 7979, 1039, 327, 16430, 12, 340, 440, 13, 14039, 4224, 880, 1039, 291, 14, 2886, 8, 2048, 628, 2113, 401, 2163, 633, 628, 22276, 15, 5484, 15, 646, 31, 923, 29, 7018, 531, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 493, 937, 1959, 2254, 63, 1612, 8, 493, 63, 515, 9, 1039, 327, 28295, 314, 1824, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 7275, 937, 1959, 4891, 342, 1039, 327, 10923, 367, 314, 2034, 370, 2248, 1039, 291, 14, 2573, 63, 509, 63, 1606, 63, 475, 63, 912, 342, 1039, 327, 3161, 316, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 344, 480, 7275, 7713, 3471, 4891, 342, 2958, 347, 511, 63, 22276, 7972, 63, 646, 63, 7018, 8, 277, 304, 1039, 408, 1675, 768, 2546, 26, 394, 5682, 7972, 1675, 768, 1802, 26, 3161, 25910, 1675, 961, 511, 14185, 1263, 444, 11734, 316, 666, 2544, 16306, 1039, 408, 1039, 870, 1867, 78, 2, 13594, 492, 2197, 1039, 687, 22208, 14, 32300, 492, 20599, 1039, 1300, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 9458, 1062, 298, 15853, 401, 1453, 14, 1069, 14, 3578, 9, 1039, 570, 63, 515, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 3112, 401, 298, 2219, 401, 298, 7018, 401, 298, 7018, 14, 4737, 531, 4341, 9213, 1378, 2585, 26, 14171, 3520, 1901, 781, 18, 2796, 1039, 11168, 275, 2197, 14, 602, 14, 8136, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 1039, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 2977, 275, 334, 2083, 14, 2083, 14, 2131, 342, 435, 20599, 8, 7609, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 1039, 3063, 63, 17, 63, 6419, 275, 334, 2083, 14, 602, 14, 8136, 342, 435, 20599, 8, 29540, 275, 435, 17, 221, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 13594, 327, 869, 11026, 7979, 1039, 327, 16430, 12, 340, 440, 13, 14039, 4224, 880, 1039, 291, 14, 2886, 8, 2048, 628, 2113, 401, 2163, 633, 628, 22276, 15, 5484, 15, 646, 31, 923, 29, 7018, 531, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 493, 937, 1959, 2254, 63, 1612, 8, 493, 63, 515, 9, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 344, 480, 83, 19, 63, 646, 63, 5064, 63, 1814, 63, 1422, 3471, 4891, 342, 1039, 327, 28295, 314, 1824, 1039, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 360, 1210, 59, 466, 628, 7275, 937, 1959, 4891, 342, 1039, 327, 10923, 367, 314, 2034, 370, 2248, 1039, 291, 14, 2573, 63, 509, 63, 1606, 63, 475, 63, 912, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
abrarshivani/kubernetes
cluster/juju/layers/kubeapi-load-balancer/reactive/load_balancer.py
137
5613
#!/usr/bin/env python # Copyright 2015 The Kubernetes Authors. # # 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 socket import subprocess from charms import layer from charms.reactive import when, when_any, when_not from charms.reactive import set_state, remove_state from charmhelpers.core import hookenv from charmhelpers.contrib.charmsupport import nrpe from charms.layer import nginx from subprocess import Popen from subprocess import PIPE from subprocess import STDOUT @when('certificates.available') def request_server_certificates(tls): '''Send the data that is required to create a server certificate for this server.''' # Use the public ip of this unit as the Common Name for the certificate. common_name = hookenv.unit_public_ip() # Create SANs that the tls layer will add to the server cert. sans = [ hookenv.unit_public_ip(), hookenv.unit_private_ip(), socket.gethostname(), ] # Create a path safe name by removing path characters from the unit name. certificate_name = hookenv.local_unit().replace('/', '_') # Request a server cert with this information. tls.request_server_cert(common_name, sans, certificate_name) @when('nginx.available', 'apiserver.available', 'certificates.server.cert.available') def install_load_balancer(apiserver, tls): ''' Create the default vhost template for load balancing ''' # Get the tls paths from the layer data. layer_options = layer.options('tls-client') server_cert_path = layer_options.get('server_certificate_path') cert_exists = server_cert_path and os.path.isfile(server_cert_path) server_key_path = layer_options.get('server_key_path') key_exists = server_key_path and os.path.isfile(server_key_path) # Do both the the key and certificate exist? if cert_exists and key_exists: # At this point the cert and key exist, and they are owned by root. chown = ['chown', 'www-data:www-data', server_cert_path] # Change the owner to www-data so the nginx process can read the cert. subprocess.call(chown) chown = ['chown', 'www-data:www-data', server_key_path] # Change the owner to www-data so the nginx process can read the key. subprocess.call(chown) hookenv.open_port(hookenv.config('port')) services = apiserver.services() nginx.configure_site( 'apilb', 'apilb.conf', server_name='_', services=services, port=hookenv.config('port'), server_certificate=server_cert_path, server_key=server_key_path, ) hookenv.status_set('active', 'Loadbalancer ready.') @when('nginx.available') def set_nginx_version(): ''' Surface the currently deployed version of nginx to Juju ''' cmd = 'nginx -v' p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) raw = p.stdout.read() # The version comes back as: # nginx version: nginx/1.10.0 (Ubuntu) version = raw.split(b'/')[-1].split(b' ')[0] hookenv.application_version_set(version.rstrip()) @when('website.available') def provide_application_details(website): ''' re-use the nginx layer website relation to relay the hostname/port to any consuming kubernetes-workers, or other units that require the kubernetes API ''' website.configure(port=hookenv.config('port')) @when('loadbalancer.available') def provide_loadbalancing(loadbalancer): '''Send the public address and port to the public-address interface, so the subordinates can get the public address of this loadbalancer.''' loadbalancer.set_address_port(hookenv.unit_get('public-address'), hookenv.config('port')) @when('nrpe-external-master.available') @when_not('nrpe-external-master.initial-config') def initial_nrpe_config(nagios=None): set_state('nrpe-external-master.initial-config') update_nrpe_config(nagios) @when('nginx.available') @when('nrpe-external-master.available') @when_any('config.changed.nagios_context', 'config.changed.nagios_servicegroups') def update_nrpe_config(unused=None): services = ('nginx',) hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.add_init_service_checks(nrpe_setup, services, current_unit) nrpe_setup.write() @when_not('nrpe-external-master.available') @when('nrpe-external-master.initial-config') def remove_nrpe_config(nagios=None): remove_state('nrpe-external-master.initial-config') # List of systemd services for which the checks will be removed services = ('nginx',) # The current nrpe-external-master interface doesn't handle a lot of logic, # use the charm-helpers code for now. hostname = nrpe.get_nagios_hostname() nrpe_setup = nrpe.NRPE(hostname=hostname) for service in services: nrpe_setup.remove_check(shortname=service)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 199, 504, 1495, 706, 492, 4045, 199, 504, 1495, 706, 14, 264, 2682, 492, 1380, 12, 1380, 63, 1629, 12, 1380, 63, 1397, 199, 504, 1495, 706, 14, 264, 2682, 492, 663, 63, 929, 12, 2813, 63, 929, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 199, 504, 1495, 77, 7546, 14, 2828, 14, 1560, 706, 384, 719, 492, 14762, 321, 199, 199, 504, 1495, 706, 14, 1897, 492, 302, 19101, 199, 199, 504, 3873, 492, 13995, 199, 504, 3873, 492, 22773, 199, 504, 3873, 492, 4384, 12619, 421, 199, 32, 6526, 360, 16159, 14, 4561, 358, 199, 318, 1056, 63, 1000, 63, 16159, 8, 9945, 304, 272, 1449, 6795, 314, 666, 626, 365, 1415, 370, 1218, 282, 1654, 5897, 367, 272, 642, 1654, 10595, 272, 327, 3645, 314, 4575, 3384, 402, 642, 4137, 465, 314, 13964, 2812, 367, 314, 5897, 14, 272, 2863, 63, 354, 275, 21404, 14, 3248, 63, 3455, 63, 711, 342, 272, 327, 2790, 428, 879, 83, 626, 314, 15142, 4045, 911, 1050, 370, 314, 1654, 6250, 14, 272, 308, 796, 275, 359, 267, 21404, 14, 3248, 63, 3455, 63, 711, 1062, 267, 21404, 14, 3248, 63, 4239, 63, 711, 1062, 267, 2838, 14, 29789, 1062, 272, 1622, 272, 327, 2790, 282, 931, 5048, 536, 701, 12881, 931, 4110, 687, 314, 4137, 536, 14, 272, 5897, 63, 354, 275, 21404, 14, 1832, 63, 3248, 1252, 1814, 10998, 18962, 272, 327, 4784, 282, 1654, 6250, 543, 642, 2556, 14, 272, 15142, 14, 1069, 63, 1000, 63, 4736, 8, 2330, 63, 354, 12, 308, 796, 12, 5897, 63, 354, 9, 421, 199, 32, 6526, 360, 25826, 14, 4561, 297, 283, 1246, 1000, 14, 4561, 297, 489, 283, 16159, 14, 1000, 14, 4736, 14, 4561, 358, 199, 318, 3907, 63, 912, 63, 11841, 8, 1246, 1000, 12, 15142, 304, 272, 1449, 2790, 314, 849, 373, 1102, 1978, 367, 2248, 29300, 1449, 272, 327, 2372, 314, 15142, 3792, 687, 314, 4045, 666, 14, 272, 4045, 63, 1419, 275, 4045, 14, 1419, 360, 9945, 13, 1258, 358, 272, 1654, 63, 4736, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 6999, 63, 515, 358, 272, 6250, 63, 2444, 275, 1654, 63, 4736, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 4736, 63, 515, 9, 272, 1654, 63, 498, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 498, 63, 515, 358, 272, 790, 63, 2444, 275, 1654, 63, 498, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 498, 63, 515, 9, 272, 327, 4226, 3865, 314, 314, 790, 436, 5897, 2187, 31, 272, 340, 6250, 63, 2444, 436, 790, 63, 2444, 26, 267, 327, 2854, 642, 2376, 314, 6250, 436, 790, 2187, 12, 436, 2985, 787, 23191, 701, 1738, 14, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 4736, 63, 515, 61, 267, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314, 302, 19101, 2112, 883, 1586, 314, 6250, 14, 267, 3873, 14, 1250, 8, 20933, 9, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 498, 63, 515, 61, 267, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314, 302, 19101, 2112, 883, 1586, 314, 790, 14, 267, 3873, 14, 1250, 8, 20933, 9, 398, 21404, 14, 1490, 63, 719, 8, 3664, 1813, 14, 888, 360, 719, 1333, 267, 8500, 275, 2986, 1000, 14, 5950, 342, 267, 302, 19101, 14, 6472, 63, 2124, 8, 355, 283, 439, 382, 66, 297, 355, 283, 439, 382, 66, 14, 2190, 297, 355, 1654, 63, 354, 534, 14474, 355, 8500, 29, 5950, 12, 355, 1844, 29, 3664, 1813, 14, 888, 360, 719, 659, 355, 1654, 63, 6999, 29, 1000, 63, 4736, 63, 515, 12, 355, 1654, 63, 498, 29, 1000, 63, 498, 63, 515, 12, 267, 776, 267, 21404, 14, 1205, 63, 409, 360, 2682, 297, 283, 6200, 11841, 10144, 2659, 421, 199, 32, 6526, 360, 25826, 14, 4561, 358, 199, 318, 663, 63, 25826, 63, 1023, 837, 272, 1449, 29564, 314, 5544, 26181, 1015, 402, 302, 19101, 370, 1603, 17189, 85, 1449, 272, 2088, 275, 283, 25826, 446, 86, 7, 272, 299, 275, 13995, 8, 1760, 12, 5218, 29, 549, 12, 1598, 9009, 29, 6089, 12, 1598, 3839, 29, 6089, 12, 1598, 4635, 29, 13850, 12, 1598, 4002, 63, 14240, 29, 549, 9, 272, 3066, 275, 299, 14, 2703, 14, 739, 342, 272, 327, 710, 1015, 12477, 1771, 465, 26, 272, 327, 302, 19101, 1015, 26, 302, 19101, 15, 17, 14, 709, 14, 16, 334, 53, 19313, 9, 272, 1015, 275, 3066, 14, 1294, 8, 66, 7, 6217, 1988, 17, 1055, 1294, 8, 66, 7, 27618, 16, 61, 272, 21404, 14, 3578, 63, 1023, 63, 409, 8, 1023, 14, 6735, 1012, 421, 199, 32, 6526, 360, 7360, 14, 4561, 358, 199, 318, 5647, 63, 3578, 63, 5087, 8, 7360, 304, 272, 1449, 295, 13, 1180, 314, 302, 19101, 4045, 10691, 5850, 370, 25931, 314, 6246, 15, 719, 272, 370, 1263, 406, 26745, 31160, 13, 11009, 12, 503, 1163, 6204, 626, 4409, 314, 272, 31160, 3261, 1449, 272, 10691, 14, 6472, 8, 719, 29, 3664, 1813 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 199, 504, 1495, 706, 492, 4045, 199, 504, 1495, 706, 14, 264, 2682, 492, 1380, 12, 1380, 63, 1629, 12, 1380, 63, 1397, 199, 504, 1495, 706, 14, 264, 2682, 492, 663, 63, 929, 12, 2813, 63, 929, 199, 504, 1495, 77, 7546, 14, 1018, 492, 21404, 199, 504, 1495, 77, 7546, 14, 2828, 14, 1560, 706, 384, 719, 492, 14762, 321, 199, 199, 504, 1495, 706, 14, 1897, 492, 302, 19101, 199, 199, 504, 3873, 492, 13995, 199, 504, 3873, 492, 22773, 199, 504, 3873, 492, 4384, 12619, 421, 199, 32, 6526, 360, 16159, 14, 4561, 358, 199, 318, 1056, 63, 1000, 63, 16159, 8, 9945, 304, 272, 1449, 6795, 314, 666, 626, 365, 1415, 370, 1218, 282, 1654, 5897, 367, 272, 642, 1654, 10595, 272, 327, 3645, 314, 4575, 3384, 402, 642, 4137, 465, 314, 13964, 2812, 367, 314, 5897, 14, 272, 2863, 63, 354, 275, 21404, 14, 3248, 63, 3455, 63, 711, 342, 272, 327, 2790, 428, 879, 83, 626, 314, 15142, 4045, 911, 1050, 370, 314, 1654, 6250, 14, 272, 308, 796, 275, 359, 267, 21404, 14, 3248, 63, 3455, 63, 711, 1062, 267, 21404, 14, 3248, 63, 4239, 63, 711, 1062, 267, 2838, 14, 29789, 1062, 272, 1622, 272, 327, 2790, 282, 931, 5048, 536, 701, 12881, 931, 4110, 687, 314, 4137, 536, 14, 272, 5897, 63, 354, 275, 21404, 14, 1832, 63, 3248, 1252, 1814, 10998, 18962, 272, 327, 4784, 282, 1654, 6250, 543, 642, 2556, 14, 272, 15142, 14, 1069, 63, 1000, 63, 4736, 8, 2330, 63, 354, 12, 308, 796, 12, 5897, 63, 354, 9, 421, 199, 32, 6526, 360, 25826, 14, 4561, 297, 283, 1246, 1000, 14, 4561, 297, 489, 283, 16159, 14, 1000, 14, 4736, 14, 4561, 358, 199, 318, 3907, 63, 912, 63, 11841, 8, 1246, 1000, 12, 15142, 304, 272, 1449, 2790, 314, 849, 373, 1102, 1978, 367, 2248, 29300, 1449, 272, 327, 2372, 314, 15142, 3792, 687, 314, 4045, 666, 14, 272, 4045, 63, 1419, 275, 4045, 14, 1419, 360, 9945, 13, 1258, 358, 272, 1654, 63, 4736, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 6999, 63, 515, 358, 272, 6250, 63, 2444, 275, 1654, 63, 4736, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 4736, 63, 515, 9, 272, 1654, 63, 498, 63, 515, 275, 4045, 63, 1419, 14, 362, 360, 1000, 63, 498, 63, 515, 358, 272, 790, 63, 2444, 275, 1654, 63, 498, 63, 515, 436, 747, 14, 515, 14, 6292, 8, 1000, 63, 498, 63, 515, 9, 272, 327, 4226, 3865, 314, 314, 790, 436, 5897, 2187, 31, 272, 340, 6250, 63, 2444, 436, 790, 63, 2444, 26, 267, 327, 2854, 642, 2376, 314, 6250, 436, 790, 2187, 12, 436, 2985, 787, 23191, 701, 1738, 14, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 4736, 63, 515, 61, 267, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314, 302, 19101, 2112, 883, 1586, 314, 6250, 14, 267, 3873, 14, 1250, 8, 20933, 9, 267, 286, 1917, 78, 275, 788, 20933, 297, 283, 1544, 13, 576, 26, 1544, 13, 576, 297, 1654, 63, 498, 63, 515, 61, 267, 327, 7743, 314, 5771, 370, 20732, 13, 576, 880, 314, 302, 19101, 2112, 883, 1586, 314, 790, 14, 267, 3873, 14, 1250, 8, 20933, 9, 398, 21404, 14, 1490, 63, 719, 8, 3664, 1813, 14, 888, 360, 719, 1333, 267, 8500, 275, 2986, 1000, 14, 5950, 342, 267, 302, 19101, 14, 6472, 63, 2124, 8, 355, 283, 439, 382, 66, 297, 355, 283, 439, 382, 66, 14, 2190, 297, 355, 1654, 63, 354, 534, 14474, 355, 8500, 29, 5950, 12, 355, 1844, 29, 3664, 1813, 14, 888, 360, 719, 659, 355, 1654, 63, 6999, 29, 1000, 63, 4736, 63, 515, 12, 355, 1654, 63, 498, 29, 1000, 63, 498, 63, 515, 12, 267, 776, 267, 21404, 14, 1205, 63, 409, 360, 2682, 297, 283, 6200, 11841, 10144, 2659, 421, 199, 32, 6526, 360, 25826, 14, 4561, 358, 199, 318, 663, 63, 25826, 63, 1023, 837, 272, 1449, 29564, 314, 5544, 26181, 1015, 402, 302, 19101, 370, 1603, 17189, 85, 1449, 272, 2088, 275, 283, 25826, 446, 86, 7, 272, 299, 275, 13995, 8, 1760, 12, 5218, 29, 549, 12, 1598, 9009, 29, 6089, 12, 1598, 3839, 29, 6089, 12, 1598, 4635, 29, 13850, 12, 1598, 4002, 63, 14240, 29, 549, 9, 272, 3066, 275, 299, 14, 2703, 14, 739, 342, 272, 327, 710, 1015, 12477, 1771, 465, 26, 272, 327, 302, 19101, 1015, 26, 302, 19101, 15, 17, 14, 709, 14, 16, 334, 53, 19313, 9, 272, 1015, 275, 3066, 14, 1294, 8, 66, 7, 6217, 1988, 17, 1055, 1294, 8, 66, 7, 27618, 16, 61, 272, 21404, 14, 3578, 63, 1023, 63, 409, 8, 1023, 14, 6735, 1012, 421, 199, 32, 6526, 360, 7360, 14, 4561, 358, 199, 318, 5647, 63, 3578, 63, 5087, 8, 7360, 304, 272, 1449, 295, 13, 1180, 314, 302, 19101, 4045, 10691, 5850, 370, 25931, 314, 6246, 15, 719, 272, 370, 1263, 406, 26745, 31160, 13, 11009, 12, 503, 1163, 6204, 626, 4409, 314, 272, 31160, 3261, 1449, 272, 10691, 14, 6472, 8, 719, 29, 3664, 1813, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
windelbouwman/ppci-mirror
ppci/codegen/peephole.py
1
1950
""" Peephole optimization using the pipe-filter approach. We face a certain stream of instructions. We take a look at a very specific window and check if we can apply the optimization. It's like scrolling over a sequence of instructions and checking for possible optimizations. """ import logging from ..binutils.outstream import OutputStream from ..arch.generic_instructions import Label logger = logging.getLogger("peephole") class PeepHoleStream(OutputStream): """ This is a peephole optimizing output stream. Having the peep hole optimizer as an output stream allows to use the peephole optimizer in several places. """ def __init__(self, downstream): super().__init__() self._downstream = downstream self._window = [] def do_emit(self, item): self._window.append(item) self.clip_window(2) if len(self._window) == 2: a, b = self._window if hasattr(a, "effect") and hasattr(b, "effect"): # print('peephole', self._window) effect_a = a.effect() effect_b = b.effect() # print('a', a.effect()) # print('b', b.effect()) if effect_a == effect_b: if not isinstance(a, Label): logger.debug("Peephole remove %s", a) self._window.pop(0) def clip_window(self, size): """ Flush items, until we have `size` items in scope. """ while len(self._window) > size: item = self._window.pop(0) self._downstream.emit(item) def flush(self): """ Flush remaining items in the peephole window. """ self.clip_window(0) class PeepHoleOptimization: """ Inherit this class to implement a peephole optimization. """ def apply(self): pass def peephole(): for optimization in optimizations: optimization.filter
bsd-2-clause
[ 624, 510, 7840, 16668, 13712, 1808, 314, 5200, 13, 1541, 18140, 14, 199, 199, 6004, 8870, 282, 9842, 2547, 402, 15794, 14, 2136, 5452, 282, 3648, 199, 292, 282, 7437, 2488, 4353, 436, 1104, 340, 781, 883, 4838, 314, 199, 31405, 14, 2779, 1159, 2839, 13704, 316, 1806, 282, 3414, 402, 199, 20718, 436, 7907, 367, 3962, 5323, 12270, 14, 199, 199, 624, 199, 199, 646, 2050, 199, 504, 2508, 1393, 1208, 14, 548, 1745, 492, 7242, 3296, 199, 504, 2508, 1047, 14, 6767, 63, 20718, 492, 10354, 199, 199, 2921, 275, 2050, 14, 5572, 480, 321, 1545, 16668, 531, 421, 199, 533, 510, 7840, 40, 16721, 3296, 8, 10390, 304, 272, 408, 961, 365, 282, 299, 7840, 16668, 5323, 9147, 1072, 2547, 14, 339, 869, 5519, 314, 299, 7840, 2636, 274, 10736, 465, 376, 1072, 2547, 6127, 272, 370, 675, 314, 299, 7840, 16668, 10736, 315, 9978, 9825, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3224, 1745, 304, 267, 1613, 11027, 826, 4533, 267, 291, 423, 2110, 1745, 275, 3224, 1745, 267, 291, 423, 3806, 275, 942, 339, 347, 886, 63, 8159, 8, 277, 12, 1242, 304, 267, 291, 423, 3806, 14, 740, 8, 1053, 9, 267, 291, 14, 7548, 63, 3806, 8, 18, 9, 267, 340, 822, 8, 277, 423, 3806, 9, 508, 499, 26, 288, 282, 12, 330, 275, 291, 423, 3806, 288, 340, 2688, 8, 65, 12, 298, 5881, 531, 436, 2688, 8, 66, 12, 298, 5881, 2349, 355, 327, 870, 360, 321, 1545, 16668, 297, 291, 423, 3806, 9, 355, 7763, 63, 65, 275, 282, 14, 5881, 342, 355, 7763, 63, 66, 275, 330, 14, 5881, 342, 355, 327, 870, 360, 65, 297, 282, 14, 5881, 1012, 355, 327, 870, 360, 66, 297, 330, 14, 5881, 1012, 355, 340, 7763, 63, 65, 508, 7763, 63, 66, 26, 490, 340, 440, 1228, 8, 65, 12, 10354, 304, 717, 2512, 14, 1757, 480, 48, 7840, 16668, 2813, 450, 83, 401, 282, 9, 717, 291, 423, 3806, 14, 1935, 8, 16, 9, 339, 347, 11353, 63, 3806, 8, 277, 12, 1568, 304, 267, 408, 11040, 2084, 2974, 12, 5133, 781, 1172, 658, 890, 64, 2974, 315, 4194, 14, 408, 267, 1830, 822, 8, 277, 423, 3806, 9, 690, 1568, 26, 288, 1242, 275, 291, 423, 3806, 14, 1935, 8, 16, 9, 288, 291, 423, 2110, 1745, 14, 8159, 8, 1053, 9, 339, 347, 8976, 8, 277, 304, 267, 408, 11040, 2084, 7971, 2974, 315, 314, 299, 7840, 16668, 4353, 14, 408, 267, 291, 14, 7548, 63, 3806, 8, 16, 9, 421, 199, 533, 510, 7840, 40, 16721, 30661, 26, 272, 408, 27502, 642, 1021, 370, 5669, 282, 299, 7840, 16668, 13712, 14, 408, 339, 347, 4838, 8, 277, 304, 267, 986, 421, 199, 318, 299, 7840, 16668, 837, 272, 367, 13712, 315, 5323, 12270, 26, 267, 13712, 14, 1541, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 510, 7840, 16668, 13712, 1808, 314, 5200, 13, 1541, 18140, 14, 199, 199, 6004, 8870, 282, 9842, 2547, 402, 15794, 14, 2136, 5452, 282, 3648, 199, 292, 282, 7437, 2488, 4353, 436, 1104, 340, 781, 883, 4838, 314, 199, 31405, 14, 2779, 1159, 2839, 13704, 316, 1806, 282, 3414, 402, 199, 20718, 436, 7907, 367, 3962, 5323, 12270, 14, 199, 199, 624, 199, 199, 646, 2050, 199, 504, 2508, 1393, 1208, 14, 548, 1745, 492, 7242, 3296, 199, 504, 2508, 1047, 14, 6767, 63, 20718, 492, 10354, 199, 199, 2921, 275, 2050, 14, 5572, 480, 321, 1545, 16668, 531, 421, 199, 533, 510, 7840, 40, 16721, 3296, 8, 10390, 304, 272, 408, 961, 365, 282, 299, 7840, 16668, 5323, 9147, 1072, 2547, 14, 339, 869, 5519, 314, 299, 7840, 2636, 274, 10736, 465, 376, 1072, 2547, 6127, 272, 370, 675, 314, 299, 7840, 16668, 10736, 315, 9978, 9825, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3224, 1745, 304, 267, 1613, 11027, 826, 4533, 267, 291, 423, 2110, 1745, 275, 3224, 1745, 267, 291, 423, 3806, 275, 942, 339, 347, 886, 63, 8159, 8, 277, 12, 1242, 304, 267, 291, 423, 3806, 14, 740, 8, 1053, 9, 267, 291, 14, 7548, 63, 3806, 8, 18, 9, 267, 340, 822, 8, 277, 423, 3806, 9, 508, 499, 26, 288, 282, 12, 330, 275, 291, 423, 3806, 288, 340, 2688, 8, 65, 12, 298, 5881, 531, 436, 2688, 8, 66, 12, 298, 5881, 2349, 355, 327, 870, 360, 321, 1545, 16668, 297, 291, 423, 3806, 9, 355, 7763, 63, 65, 275, 282, 14, 5881, 342, 355, 7763, 63, 66, 275, 330, 14, 5881, 342, 355, 327, 870, 360, 65, 297, 282, 14, 5881, 1012, 355, 327, 870, 360, 66, 297, 330, 14, 5881, 1012, 355, 340, 7763, 63, 65, 508, 7763, 63, 66, 26, 490, 340, 440, 1228, 8, 65, 12, 10354, 304, 717, 2512, 14, 1757, 480, 48, 7840, 16668, 2813, 450, 83, 401, 282, 9, 717, 291, 423, 3806, 14, 1935, 8, 16, 9, 339, 347, 11353, 63, 3806, 8, 277, 12, 1568, 304, 267, 408, 11040, 2084, 2974, 12, 5133, 781, 1172, 658, 890, 64, 2974, 315, 4194, 14, 408, 267, 1830, 822, 8, 277, 423, 3806, 9, 690, 1568, 26, 288, 1242, 275, 291, 423, 3806, 14, 1935, 8, 16, 9, 288, 291, 423, 2110, 1745, 14, 8159, 8, 1053, 9, 339, 347, 8976, 8, 277, 304, 267, 408, 11040, 2084, 7971, 2974, 315, 314, 299, 7840, 16668, 4353, 14, 408, 267, 291, 14, 7548, 63, 3806, 8, 16, 9, 421, 199, 533, 510, 7840, 40, 16721, 30661, 26, 272, 408, 27502, 642, 1021, 370, 5669, 282, 299, 7840, 16668, 13712, 14, 408, 339, 347, 4838, 8, 277, 304, 267, 986, 421, 199, 318, 299, 7840, 16668, 837, 272, 367, 13712, 315, 5323, 12270, 26, 267, 13712, 14, 1541, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
renatofb/weblate
weblate/trans/machine/weblatetm.py
11
2721
# -*- coding: utf-8 -*- # # Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com> # # This file is part of Weblate <http://weblate.org/> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from weblate.trans.machine.base import MachineTranslation from weblate.trans.models.unit import Unit def format_unit_match(unit, quality): ''' Formats unit to translation service result. ''' return ( unit.get_target_plurals()[0], quality, 'Weblate (%s)' % unicode(unit.translation.subproject), unit.get_source_plurals()[0], ) class WeblateTranslation(MachineTranslation): ''' Translation service using strings already translated in Weblate. ''' name = 'Weblate' def convert_language(self, language): ''' Converts language to service specific code. ''' return language def is_supported(self, language): ''' Any language is supported. ''' return True def download_translations(self, language, text, unit, user): ''' Downloads list of possible translations from a service. ''' matching_units = Unit.objects.same_source(unit) return [ format_unit_match(munit, 100) for munit in matching_units if munit.has_acl(user) ] class WeblateSimilarTranslation(MachineTranslation): ''' Translation service using strings already translated in Weblate. ''' name = 'Weblate similarity' def convert_language(self, language): ''' Converts language to service specific code. ''' return language def is_supported(self, language): ''' Any language is supported. ''' return True def download_translations(self, language, text, unit, user): ''' Downloads list of possible translations from a service. ''' matching_units = Unit.objects.more_like_this(unit) return [ format_unit_match(munit, 50) for munit in matching_units if munit.has_acl(user) ]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 22405, 103, 6029, 446, 6900, 603, 1158, 279, 221, 129, 235, 73, 2411, 130, 248, 665, 77, 1158, 279, 32, 559, 8210, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6001, 750, 665, 1014, 921, 2520, 750, 14, 1308, 3133, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 504, 3330, 750, 14, 1515, 14, 6744, 14, 1095, 492, 18722, 18483, 199, 504, 3330, 750, 14, 1515, 14, 992, 14, 3248, 492, 12008, 421, 199, 318, 1475, 63, 3248, 63, 1431, 8, 3248, 12, 11030, 304, 272, 1449, 272, 9701, 83, 4137, 370, 7761, 2435, 754, 14, 272, 1449, 272, 372, 334, 267, 4137, 14, 362, 63, 1375, 63, 1168, 300, 2551, 3430, 16, 467, 267, 11030, 12, 267, 283, 5926, 750, 4366, 83, 3171, 450, 2649, 8, 3248, 14, 6893, 14, 954, 1715, 395, 267, 4137, 14, 362, 63, 1365, 63, 1168, 300, 2551, 3430, 16, 467, 272, 776, 421, 199, 533, 6001, 750, 18483, 8, 8412, 18483, 304, 272, 1449, 272, 25224, 2435, 1808, 3326, 2575, 14598, 315, 6001, 750, 14, 272, 1449, 272, 536, 275, 283, 5926, 750, 7, 339, 347, 3957, 63, 3671, 8, 277, 12, 2637, 304, 267, 1449, 267, 19107, 2637, 370, 2435, 2488, 1233, 14, 267, 1449, 267, 372, 2637, 339, 347, 365, 63, 4946, 8, 277, 12, 2637, 304, 267, 1449, 267, 6184, 2637, 365, 3748, 14, 267, 1449, 267, 372, 715, 339, 347, 5235, 63, 13982, 8, 277, 12, 2637, 12, 1318, 12, 4137, 12, 922, 304, 267, 1449, 267, 13392, 3640, 769, 402, 3962, 15547, 687, 282, 2435, 14, 267, 1449, 267, 4877, 63, 5260, 275, 12008, 14, 1462, 14, 7191, 63, 1365, 8, 3248, 9, 398, 372, 359, 288, 1475, 63, 3248, 63, 1431, 8, 77, 3248, 12, 2948, 9, 288, 367, 333, 3248, 315, 4877, 63, 5260, 288, 340, 333, 3248, 14, 1989, 63, 5853, 8, 751, 9, 267, 1622, 421, 199, 533, 6001, 750, 7467, 6734, 18483, 8, 8412, 18483, 304, 272, 1449, 272, 25224, 2435, 1808, 3326, 2575, 14598, 315, 6001, 750, 14, 272, 1449, 272, 536, 275, 283, 5926, 750, 22838, 7, 339, 347, 3957, 63, 3671, 8, 277, 12, 2637, 304, 267, 1449, 267, 19107, 2637, 370, 2435, 2488, 1233, 14, 267, 1449, 267, 372, 2637, 339, 347, 365, 63, 4946, 8, 277, 12, 2637, 304, 267, 1449, 267, 6184, 2637, 365, 3748, 14, 267, 1449, 267, 372, 715, 339, 347, 5235, 63, 13982, 8, 277, 12, 2637, 12, 1318, 12, 4137, 12, 922, 304, 267, 1449, 267, 13392, 3640, 769, 402, 3962, 15547, 687, 282, 2435, 14, 267, 1449, 267, 4877, 63, 5260, 275, 12008, 14, 1462, 14, 6878, 63, 2930, 63, 3749, 8, 3248, 9, 398, 372, 359, 288, 1475, 63, 3248, 63, 1431, 8, 77, 3248, 12, 5238, 9, 288, 367, 333, 3248, 315, 4877, 63, 5260, 288, 340, 333, 3248, 14, 1989, 63, 5853, 8, 751, 9, 267, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 22405, 103, 6029, 446, 6900, 603, 1158, 279, 221, 129, 235, 73, 2411, 130, 248, 665, 77, 1158, 279, 32, 559, 8210, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 6001, 750, 665, 1014, 921, 2520, 750, 14, 1308, 3133, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 504, 3330, 750, 14, 1515, 14, 6744, 14, 1095, 492, 18722, 18483, 199, 504, 3330, 750, 14, 1515, 14, 992, 14, 3248, 492, 12008, 421, 199, 318, 1475, 63, 3248, 63, 1431, 8, 3248, 12, 11030, 304, 272, 1449, 272, 9701, 83, 4137, 370, 7761, 2435, 754, 14, 272, 1449, 272, 372, 334, 267, 4137, 14, 362, 63, 1375, 63, 1168, 300, 2551, 3430, 16, 467, 267, 11030, 12, 267, 283, 5926, 750, 4366, 83, 3171, 450, 2649, 8, 3248, 14, 6893, 14, 954, 1715, 395, 267, 4137, 14, 362, 63, 1365, 63, 1168, 300, 2551, 3430, 16, 467, 272, 776, 421, 199, 533, 6001, 750, 18483, 8, 8412, 18483, 304, 272, 1449, 272, 25224, 2435, 1808, 3326, 2575, 14598, 315, 6001, 750, 14, 272, 1449, 272, 536, 275, 283, 5926, 750, 7, 339, 347, 3957, 63, 3671, 8, 277, 12, 2637, 304, 267, 1449, 267, 19107, 2637, 370, 2435, 2488, 1233, 14, 267, 1449, 267, 372, 2637, 339, 347, 365, 63, 4946, 8, 277, 12, 2637, 304, 267, 1449, 267, 6184, 2637, 365, 3748, 14, 267, 1449, 267, 372, 715, 339, 347, 5235, 63, 13982, 8, 277, 12, 2637, 12, 1318, 12, 4137, 12, 922, 304, 267, 1449, 267, 13392, 3640, 769, 402, 3962, 15547, 687, 282, 2435, 14, 267, 1449, 267, 4877, 63, 5260, 275, 12008, 14, 1462, 14, 7191, 63, 1365, 8, 3248, 9, 398, 372, 359, 288, 1475, 63, 3248, 63, 1431, 8, 77, 3248, 12, 2948, 9, 288, 367, 333, 3248, 315, 4877, 63, 5260, 288, 340, 333, 3248, 14, 1989, 63, 5853, 8, 751, 9, 267, 1622, 421, 199, 533, 6001, 750, 7467, 6734, 18483, 8, 8412, 18483, 304, 272, 1449, 272, 25224, 2435, 1808, 3326, 2575, 14598, 315, 6001, 750, 14, 272, 1449, 272, 536, 275, 283, 5926, 750, 22838, 7, 339, 347, 3957, 63, 3671, 8, 277, 12, 2637, 304, 267, 1449, 267, 19107, 2637, 370, 2435, 2488, 1233, 14, 267, 1449, 267, 372, 2637, 339, 347, 365, 63, 4946, 8, 277, 12, 2637, 304, 267, 1449, 267, 6184, 2637, 365, 3748, 14, 267, 1449, 267, 372, 715, 339, 347, 5235, 63, 13982, 8, 277, 12, 2637, 12, 1318, 12, 4137, 12, 922, 304, 267, 1449, 267, 13392, 3640, 769, 402, 3962, 15547, 687, 282, 2435, 14, 267, 1449, 267, 4877, 63, 5260, 275, 12008, 14, 1462, 14, 6878, 63, 2930, 63, 3749, 8, 3248, 9, 398, 372, 359, 288, 1475, 63, 3248, 63, 1431, 8, 77, 3248, 12, 5238, 9, 288, 367, 333, 3248, 315, 4877, 63, 5260, 288, 340, 333, 3248, 14, 1989, 63, 5853, 8, 751, 9, 267, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jackkiej/SickRage
lib/unidecode/x0bf.py
253
5010
data = ( 'bbess', # 0x00 'bbeng', # 0x01 'bbej', # 0x02 'bbec', # 0x03 'bbek', # 0x04 'bbet', # 0x05 'bbep', # 0x06 'bbeh', # 0x07 'bbyeo', # 0x08 'bbyeog', # 0x09 'bbyeogg', # 0x0a 'bbyeogs', # 0x0b 'bbyeon', # 0x0c 'bbyeonj', # 0x0d 'bbyeonh', # 0x0e 'bbyeod', # 0x0f 'bbyeol', # 0x10 'bbyeolg', # 0x11 'bbyeolm', # 0x12 'bbyeolb', # 0x13 'bbyeols', # 0x14 'bbyeolt', # 0x15 'bbyeolp', # 0x16 'bbyeolh', # 0x17 'bbyeom', # 0x18 'bbyeob', # 0x19 'bbyeobs', # 0x1a 'bbyeos', # 0x1b 'bbyeoss', # 0x1c 'bbyeong', # 0x1d 'bbyeoj', # 0x1e 'bbyeoc', # 0x1f 'bbyeok', # 0x20 'bbyeot', # 0x21 'bbyeop', # 0x22 'bbyeoh', # 0x23 'bbye', # 0x24 'bbyeg', # 0x25 'bbyegg', # 0x26 'bbyegs', # 0x27 'bbyen', # 0x28 'bbyenj', # 0x29 'bbyenh', # 0x2a 'bbyed', # 0x2b 'bbyel', # 0x2c 'bbyelg', # 0x2d 'bbyelm', # 0x2e 'bbyelb', # 0x2f 'bbyels', # 0x30 'bbyelt', # 0x31 'bbyelp', # 0x32 'bbyelh', # 0x33 'bbyem', # 0x34 'bbyeb', # 0x35 'bbyebs', # 0x36 'bbyes', # 0x37 'bbyess', # 0x38 'bbyeng', # 0x39 'bbyej', # 0x3a 'bbyec', # 0x3b 'bbyek', # 0x3c 'bbyet', # 0x3d 'bbyep', # 0x3e 'bbyeh', # 0x3f 'bbo', # 0x40 'bbog', # 0x41 'bbogg', # 0x42 'bbogs', # 0x43 'bbon', # 0x44 'bbonj', # 0x45 'bbonh', # 0x46 'bbod', # 0x47 'bbol', # 0x48 'bbolg', # 0x49 'bbolm', # 0x4a 'bbolb', # 0x4b 'bbols', # 0x4c 'bbolt', # 0x4d 'bbolp', # 0x4e 'bbolh', # 0x4f 'bbom', # 0x50 'bbob', # 0x51 'bbobs', # 0x52 'bbos', # 0x53 'bboss', # 0x54 'bbong', # 0x55 'bboj', # 0x56 'bboc', # 0x57 'bbok', # 0x58 'bbot', # 0x59 'bbop', # 0x5a 'bboh', # 0x5b 'bbwa', # 0x5c 'bbwag', # 0x5d 'bbwagg', # 0x5e 'bbwags', # 0x5f 'bbwan', # 0x60 'bbwanj', # 0x61 'bbwanh', # 0x62 'bbwad', # 0x63 'bbwal', # 0x64 'bbwalg', # 0x65 'bbwalm', # 0x66 'bbwalb', # 0x67 'bbwals', # 0x68 'bbwalt', # 0x69 'bbwalp', # 0x6a 'bbwalh', # 0x6b 'bbwam', # 0x6c 'bbwab', # 0x6d 'bbwabs', # 0x6e 'bbwas', # 0x6f 'bbwass', # 0x70 'bbwang', # 0x71 'bbwaj', # 0x72 'bbwac', # 0x73 'bbwak', # 0x74 'bbwat', # 0x75 'bbwap', # 0x76 'bbwah', # 0x77 'bbwae', # 0x78 'bbwaeg', # 0x79 'bbwaegg', # 0x7a 'bbwaegs', # 0x7b 'bbwaen', # 0x7c 'bbwaenj', # 0x7d 'bbwaenh', # 0x7e 'bbwaed', # 0x7f 'bbwael', # 0x80 'bbwaelg', # 0x81 'bbwaelm', # 0x82 'bbwaelb', # 0x83 'bbwaels', # 0x84 'bbwaelt', # 0x85 'bbwaelp', # 0x86 'bbwaelh', # 0x87 'bbwaem', # 0x88 'bbwaeb', # 0x89 'bbwaebs', # 0x8a 'bbwaes', # 0x8b 'bbwaess', # 0x8c 'bbwaeng', # 0x8d 'bbwaej', # 0x8e 'bbwaec', # 0x8f 'bbwaek', # 0x90 'bbwaet', # 0x91 'bbwaep', # 0x92 'bbwaeh', # 0x93 'bboe', # 0x94 'bboeg', # 0x95 'bboegg', # 0x96 'bboegs', # 0x97 'bboen', # 0x98 'bboenj', # 0x99 'bboenh', # 0x9a 'bboed', # 0x9b 'bboel', # 0x9c 'bboelg', # 0x9d 'bboelm', # 0x9e 'bboelb', # 0x9f 'bboels', # 0xa0 'bboelt', # 0xa1 'bboelp', # 0xa2 'bboelh', # 0xa3 'bboem', # 0xa4 'bboeb', # 0xa5 'bboebs', # 0xa6 'bboes', # 0xa7 'bboess', # 0xa8 'bboeng', # 0xa9 'bboej', # 0xaa 'bboec', # 0xab 'bboek', # 0xac 'bboet', # 0xad 'bboep', # 0xae 'bboeh', # 0xaf 'bbyo', # 0xb0 'bbyog', # 0xb1 'bbyogg', # 0xb2 'bbyogs', # 0xb3 'bbyon', # 0xb4 'bbyonj', # 0xb5 'bbyonh', # 0xb6 'bbyod', # 0xb7 'bbyol', # 0xb8 'bbyolg', # 0xb9 'bbyolm', # 0xba 'bbyolb', # 0xbb 'bbyols', # 0xbc 'bbyolt', # 0xbd 'bbyolp', # 0xbe 'bbyolh', # 0xbf 'bbyom', # 0xc0 'bbyob', # 0xc1 'bbyobs', # 0xc2 'bbyos', # 0xc3 'bbyoss', # 0xc4 'bbyong', # 0xc5 'bbyoj', # 0xc6 'bbyoc', # 0xc7 'bbyok', # 0xc8 'bbyot', # 0xc9 'bbyop', # 0xca 'bbyoh', # 0xcb 'bbu', # 0xcc 'bbug', # 0xcd 'bbugg', # 0xce 'bbugs', # 0xcf 'bbun', # 0xd0 'bbunj', # 0xd1 'bbunh', # 0xd2 'bbud', # 0xd3 'bbul', # 0xd4 'bbulg', # 0xd5 'bbulm', # 0xd6 'bbulb', # 0xd7 'bbuls', # 0xd8 'bbult', # 0xd9 'bbulp', # 0xda 'bbulh', # 0xdb 'bbum', # 0xdc 'bbub', # 0xdd 'bbubs', # 0xde 'bbus', # 0xdf 'bbuss', # 0xe0 'bbung', # 0xe1 'bbuj', # 0xe2 'bbuc', # 0xe3 'bbuk', # 0xe4 'bbut', # 0xe5 'bbup', # 0xe6 'bbuh', # 0xe7 'bbweo', # 0xe8 'bbweog', # 0xe9 'bbweogg', # 0xea 'bbweogs', # 0xeb 'bbweon', # 0xec 'bbweonj', # 0xed 'bbweonh', # 0xee 'bbweod', # 0xef 'bbweol', # 0xf0 'bbweolg', # 0xf1 'bbweolm', # 0xf2 'bbweolb', # 0xf3 'bbweols', # 0xf4 'bbweolt', # 0xf5 'bbweolp', # 0xf6 'bbweolh', # 0xf7 'bbweom', # 0xf8 'bbweob', # 0xf9 'bbweobs', # 0xfa 'bbweos', # 0xfb 'bbweoss', # 0xfc 'bbweong', # 0xfd 'bbweoj', # 0xfe 'bbweoc', # 0xff )
gpl-3.0
[ 576, 275, 334, 199, 7, 32155, 385, 297, 259, 327, 378, 88, 383, 199, 7, 2501, 7420, 297, 259, 327, 378, 88, 614, 199, 7, 32155, 74, 297, 259, 327, 378, 88, 996, 199, 7, 2501, 825, 297, 259, 327, 378, 88, 1644, 199, 7, 32155, 75, 297, 259, 327, 378, 88, 966, 199, 7, 2501, 386, 297, 259, 327, 378, 88, 1717, 199, 7, 32155, 80, 297, 259, 327, 378, 88, 1690, 199, 7, 66, 25599, 297, 259, 327, 378, 88, 1780, 199, 7, 66, 16481, 79, 297, 259, 327, 378, 88, 2036, 199, 7, 66, 16481, 974, 297, 259, 327, 378, 88, 1643, 199, 7, 66, 16481, 24798, 297, 259, 327, 378, 88, 16, 65, 199, 7, 66, 16481, 79, 458, 297, 259, 327, 378, 88, 16, 66, 199, 7, 66, 16481, 265, 297, 259, 327, 378, 88, 16, 67, 199, 7, 66, 16481, 265, 74, 297, 259, 327, 378, 88, 16, 68, 199, 7, 66, 16481, 265, 72, 297, 259, 327, 378, 88, 16, 69, 199, 7, 66, 16481, 364, 297, 259, 327, 378, 88, 16, 70, 199, 7, 66, 16481, 393, 297, 259, 327, 378, 88, 709, 199, 7, 66, 16481, 393, 71, 297, 259, 327, 378, 88, 845, 199, 7, 66, 16481, 393, 77, 297, 259, 327, 378, 88, 713, 199, 7, 66, 16481, 393, 66, 297, 259, 327, 378, 88, 969, 199, 7, 66, 16481, 1446, 297, 259, 327, 378, 88, 1079, 199, 7, 66, 16481, 28934, 297, 259, 327, 378, 88, 1046, 199, 7, 66, 16481, 393, 80, 297, 259, 327, 378, 88, 975, 199, 7, 66, 16481, 393, 72, 297, 259, 327, 378, 88, 1196, 199, 7, 66, 16481, 676, 297, 259, 327, 378, 88, 1085, 199, 7, 66, 16481, 2873, 297, 259, 327, 378, 88, 1167, 199, 7, 66, 16481, 11226, 297, 259, 327, 378, 88, 17, 65, 199, 7, 66, 16481, 736, 297, 259, 327, 378, 88, 17, 66, 199, 7, 66, 16481, 26890, 297, 259, 327, 378, 88, 17, 67, 199, 7, 66, 16481, 951, 297, 259, 327, 378, 88, 17, 68, 199, 7, 66, 16481, 79, 74, 297, 259, 327, 378, 88, 17, 69, 199, 7, 66, 16481, 679, 297, 259, 327, 378, 88, 17, 70, 199, 7, 66, 16481, 745, 297, 259, 327, 378, 88, 1165, 199, 7, 66, 16481, 357, 297, 259, 327, 378, 88, 2025, 199, 7, 66, 16481, 411, 297, 259, 327, 378, 88, 1081, 199, 7, 66, 16481, 19194, 297, 259, 327, 378, 88, 1789, 199, 7, 66, 16481, 297, 259, 327, 378, 88, 1194, 199, 7, 66, 991, 5902, 297, 259, 327, 378, 88, 821, 199, 7, 66, 991, 5799, 297, 259, 327, 378, 88, 1479, 199, 7, 66, 16481, 458, 297, 259, 327, 378, 88, 1465, 199, 7, 66, 991, 287, 297, 259, 327, 378, 88, 1651, 199, 7, 66, 991, 287, 74, 297, 259, 327, 378, 88, 1398, 199, 7, 66, 991, 287, 72, 297, 259, 327, 378, 88, 18, 65, 199, 7, 66, 991, 379, 297, 259, 327, 378, 88, 18, 66, 199, 7, 66, 991, 352, 297, 259, 327, 378, 88, 18, 67, 199, 7, 66, 991, 352, 71, 297, 259, 327, 378, 88, 18, 68, 199, 7, 66, 991, 21226, 297, 259, 327, 378, 88, 18, 69, 199, 7, 66, 991, 17778, 297, 259, 327, 378, 88, 18, 70, 199, 7, 66, 991, 18099, 297, 259, 327, 378, 88, 1216, 199, 7, 66, 991, 15330, 297, 259, 327, 378, 88, 2192, 199, 7, 66, 991, 1357, 297, 259, 327, 378, 88, 708, 199, 7, 66, 991, 352, 72, 297, 259, 327, 378, 88, 1153, 199, 7, 66, 991, 5633, 297, 259, 327, 378, 88, 1082, 199, 7, 66, 991, 2871, 297, 259, 327, 378, 88, 1276, 199, 7, 66, 16481, 1533, 297, 259, 327, 378, 88, 1344, 199, 7, 66, 991, 397, 297, 259, 327, 378, 88, 1401, 199, 7, 66, 16481, 385, 297, 259, 327, 378, 88, 1703, 199, 7, 66, 991, 7420, 297, 259, 327, 378, 88, 1355, 199, 7, 66, 16481, 74, 297, 259, 327, 378, 88, 19, 65, 199, 7, 66, 991, 825, 297, 259, 327, 378, 88, 19, 66, 199, 7, 66, 991, 5711, 297, 259, 327, 378, 88, 19, 67, 199, 7, 66, 991, 386, 297, 259, 327, 378, 88, 19, 68, 199, 7, 66, 991, 1545, 297, 259, 327, 378, 88, 19, 69, 199, 7, 66, 16481, 72, 297, 259, 327, 378, 88, 19, 70, 199, 7, 66, 656, 297, 259, 327, 378, 88, 2167, 199, 7, 66, 656, 71, 297, 259, 327, 378, 88, 2953, 199, 7, 66, 656, 2721, 297, 259, 327, 378, 88, 2260, 199, 7, 66, 656, 458, 297, 259, 327, 378, 88, 2824, 199, 7, 2501, 265, 297, 259, 327, 378, 88, 1602, 199, 7, 2501, 265, 74, 297, 259, 327, 378, 88, 2322, 199, 7, 2501, 265, 72, 297, 259, 327, 378, 88, 2466, 199, 7, 2501, 364, 297, 259, 327, 378, 88, 2417, 199, 7, 2501, 393, 297, 259, 327, 378, 88, 2006, 199, 7, 2501, 393, 71, 297, 259, 327, 378, 88, 1887, 199, 7, 2501, 393, 77, 297, 259, 327, 378, 88, 20, 65, 199, 7, 2501, 393, 66, 297, 259, 327, 378, 88, 20, 66, 199, 7, 2501, 1446, 297, 259, 327, 378, 88, 20, 67, 199, 7, 2501, 28934, 297, 259, 327, 378, 88, 20, 68, 199, 7, 2501, 393, 80, 297, 259, 327, 378, 88, 20, 69, 199, 7, 2501, 393, 72, 297, 259, 327, 378, 88, 20, 70, 199, 7, 66, 16302, 297, 259, 327, 378, 88, 1400, 199, 7, 66, 7913, 297, 259, 327, 378, 88, 2869, 199, 7, 66, 656, 1533, 297, 259, 327, 378, 88, 2528, 199, 7, 66, 656, 83, 297, 259, 327, 378, 88, 2481, 199, 7, 66, 25020, 297, 259, 327, 378, 88, 1477, 199, 7, 2501, 951, 297, 259, 327, 378, 88, 1229, 199, 7, 66, 656, 74, 297, 259, 327, 378, 88, 1367, 199, 7, 66, 656, 67, 297, 259, 327, 378, 88, 1641, 199, 7, 66, 656, 75, 297, 259, 327, 378, 88, 2010, 199, 7, 2501, 357, 297, 259, 327, 378, 88, 1427, 199, 7, 2501, 411, 297, 259, 327, 378 ]
[ 275, 334, 199, 7, 32155, 385, 297, 259, 327, 378, 88, 383, 199, 7, 2501, 7420, 297, 259, 327, 378, 88, 614, 199, 7, 32155, 74, 297, 259, 327, 378, 88, 996, 199, 7, 2501, 825, 297, 259, 327, 378, 88, 1644, 199, 7, 32155, 75, 297, 259, 327, 378, 88, 966, 199, 7, 2501, 386, 297, 259, 327, 378, 88, 1717, 199, 7, 32155, 80, 297, 259, 327, 378, 88, 1690, 199, 7, 66, 25599, 297, 259, 327, 378, 88, 1780, 199, 7, 66, 16481, 79, 297, 259, 327, 378, 88, 2036, 199, 7, 66, 16481, 974, 297, 259, 327, 378, 88, 1643, 199, 7, 66, 16481, 24798, 297, 259, 327, 378, 88, 16, 65, 199, 7, 66, 16481, 79, 458, 297, 259, 327, 378, 88, 16, 66, 199, 7, 66, 16481, 265, 297, 259, 327, 378, 88, 16, 67, 199, 7, 66, 16481, 265, 74, 297, 259, 327, 378, 88, 16, 68, 199, 7, 66, 16481, 265, 72, 297, 259, 327, 378, 88, 16, 69, 199, 7, 66, 16481, 364, 297, 259, 327, 378, 88, 16, 70, 199, 7, 66, 16481, 393, 297, 259, 327, 378, 88, 709, 199, 7, 66, 16481, 393, 71, 297, 259, 327, 378, 88, 845, 199, 7, 66, 16481, 393, 77, 297, 259, 327, 378, 88, 713, 199, 7, 66, 16481, 393, 66, 297, 259, 327, 378, 88, 969, 199, 7, 66, 16481, 1446, 297, 259, 327, 378, 88, 1079, 199, 7, 66, 16481, 28934, 297, 259, 327, 378, 88, 1046, 199, 7, 66, 16481, 393, 80, 297, 259, 327, 378, 88, 975, 199, 7, 66, 16481, 393, 72, 297, 259, 327, 378, 88, 1196, 199, 7, 66, 16481, 676, 297, 259, 327, 378, 88, 1085, 199, 7, 66, 16481, 2873, 297, 259, 327, 378, 88, 1167, 199, 7, 66, 16481, 11226, 297, 259, 327, 378, 88, 17, 65, 199, 7, 66, 16481, 736, 297, 259, 327, 378, 88, 17, 66, 199, 7, 66, 16481, 26890, 297, 259, 327, 378, 88, 17, 67, 199, 7, 66, 16481, 951, 297, 259, 327, 378, 88, 17, 68, 199, 7, 66, 16481, 79, 74, 297, 259, 327, 378, 88, 17, 69, 199, 7, 66, 16481, 679, 297, 259, 327, 378, 88, 17, 70, 199, 7, 66, 16481, 745, 297, 259, 327, 378, 88, 1165, 199, 7, 66, 16481, 357, 297, 259, 327, 378, 88, 2025, 199, 7, 66, 16481, 411, 297, 259, 327, 378, 88, 1081, 199, 7, 66, 16481, 19194, 297, 259, 327, 378, 88, 1789, 199, 7, 66, 16481, 297, 259, 327, 378, 88, 1194, 199, 7, 66, 991, 5902, 297, 259, 327, 378, 88, 821, 199, 7, 66, 991, 5799, 297, 259, 327, 378, 88, 1479, 199, 7, 66, 16481, 458, 297, 259, 327, 378, 88, 1465, 199, 7, 66, 991, 287, 297, 259, 327, 378, 88, 1651, 199, 7, 66, 991, 287, 74, 297, 259, 327, 378, 88, 1398, 199, 7, 66, 991, 287, 72, 297, 259, 327, 378, 88, 18, 65, 199, 7, 66, 991, 379, 297, 259, 327, 378, 88, 18, 66, 199, 7, 66, 991, 352, 297, 259, 327, 378, 88, 18, 67, 199, 7, 66, 991, 352, 71, 297, 259, 327, 378, 88, 18, 68, 199, 7, 66, 991, 21226, 297, 259, 327, 378, 88, 18, 69, 199, 7, 66, 991, 17778, 297, 259, 327, 378, 88, 18, 70, 199, 7, 66, 991, 18099, 297, 259, 327, 378, 88, 1216, 199, 7, 66, 991, 15330, 297, 259, 327, 378, 88, 2192, 199, 7, 66, 991, 1357, 297, 259, 327, 378, 88, 708, 199, 7, 66, 991, 352, 72, 297, 259, 327, 378, 88, 1153, 199, 7, 66, 991, 5633, 297, 259, 327, 378, 88, 1082, 199, 7, 66, 991, 2871, 297, 259, 327, 378, 88, 1276, 199, 7, 66, 16481, 1533, 297, 259, 327, 378, 88, 1344, 199, 7, 66, 991, 397, 297, 259, 327, 378, 88, 1401, 199, 7, 66, 16481, 385, 297, 259, 327, 378, 88, 1703, 199, 7, 66, 991, 7420, 297, 259, 327, 378, 88, 1355, 199, 7, 66, 16481, 74, 297, 259, 327, 378, 88, 19, 65, 199, 7, 66, 991, 825, 297, 259, 327, 378, 88, 19, 66, 199, 7, 66, 991, 5711, 297, 259, 327, 378, 88, 19, 67, 199, 7, 66, 991, 386, 297, 259, 327, 378, 88, 19, 68, 199, 7, 66, 991, 1545, 297, 259, 327, 378, 88, 19, 69, 199, 7, 66, 16481, 72, 297, 259, 327, 378, 88, 19, 70, 199, 7, 66, 656, 297, 259, 327, 378, 88, 2167, 199, 7, 66, 656, 71, 297, 259, 327, 378, 88, 2953, 199, 7, 66, 656, 2721, 297, 259, 327, 378, 88, 2260, 199, 7, 66, 656, 458, 297, 259, 327, 378, 88, 2824, 199, 7, 2501, 265, 297, 259, 327, 378, 88, 1602, 199, 7, 2501, 265, 74, 297, 259, 327, 378, 88, 2322, 199, 7, 2501, 265, 72, 297, 259, 327, 378, 88, 2466, 199, 7, 2501, 364, 297, 259, 327, 378, 88, 2417, 199, 7, 2501, 393, 297, 259, 327, 378, 88, 2006, 199, 7, 2501, 393, 71, 297, 259, 327, 378, 88, 1887, 199, 7, 2501, 393, 77, 297, 259, 327, 378, 88, 20, 65, 199, 7, 2501, 393, 66, 297, 259, 327, 378, 88, 20, 66, 199, 7, 2501, 1446, 297, 259, 327, 378, 88, 20, 67, 199, 7, 2501, 28934, 297, 259, 327, 378, 88, 20, 68, 199, 7, 2501, 393, 80, 297, 259, 327, 378, 88, 20, 69, 199, 7, 2501, 393, 72, 297, 259, 327, 378, 88, 20, 70, 199, 7, 66, 16302, 297, 259, 327, 378, 88, 1400, 199, 7, 66, 7913, 297, 259, 327, 378, 88, 2869, 199, 7, 66, 656, 1533, 297, 259, 327, 378, 88, 2528, 199, 7, 66, 656, 83, 297, 259, 327, 378, 88, 2481, 199, 7, 66, 25020, 297, 259, 327, 378, 88, 1477, 199, 7, 2501, 951, 297, 259, 327, 378, 88, 1229, 199, 7, 66, 656, 74, 297, 259, 327, 378, 88, 1367, 199, 7, 66, 656, 67, 297, 259, 327, 378, 88, 1641, 199, 7, 66, 656, 75, 297, 259, 327, 378, 88, 2010, 199, 7, 2501, 357, 297, 259, 327, 378, 88, 1427, 199, 7, 2501, 411, 297, 259, 327, 378, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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-packages/pip/_vendor/requests/packages/chardet/mbcsgroupprober.py
2769
1967
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # Shy Shalom - original C code # Proofpoint, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .charsetgroupprober import CharSetGroupProber from .utf8prober import UTF8Prober from .sjisprober import SJISProber from .eucjpprober import EUCJPProber from .gb2312prober import GB2312Prober from .euckrprober import EUCKRProber from .cp949prober import CP949Prober from .big5prober import Big5Prober from .euctwprober import EUCTWProber class MBCSGroupProber(CharSetGroupProber): def __init__(self): CharSetGroupProber.__init__(self) self._mProbers = [ UTF8Prober(), SJISProber(), EUCJPProber(), GB2312Prober(), EUCKRProber(), CP949Prober(), Big5Prober(), EUCTWProber() ] self.reset()
apache-2.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 29347, 5960, 17842, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 12521, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 257, 428, 3577, 5244, 279, 676, 446, 3379, 445, 1233, 199, 3, 257, 2165, 1618, 1403, 12, 3277, 14, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 6043, 923, 19903, 492, 6659, 1084, 2448, 8029, 199, 504, 1275, 1624, 24, 19903, 492, 9094, 24, 8029, 199, 504, 1275, 83, 18941, 19903, 492, 428, 22290, 8029, 199, 504, 1275, 15149, 11538, 19903, 492, 662, 13371, 15819, 8029, 199, 504, 1275, 4908, 16909, 19903, 492, 18553, 16909, 8029, 199, 504, 1275, 69, 10112, 82, 19903, 492, 26007, 27373, 8029, 199, 504, 1275, 1850, 15674, 19903, 492, 19701, 15674, 8029, 199, 504, 1275, 5076, 21, 19903, 492, 13123, 21, 8029, 199, 504, 1275, 69, 918, 87, 19903, 492, 662, 27120, 8029, 421, 199, 533, 19487, 3298, 2448, 8029, 8, 1610, 1084, 2448, 8029, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 1084, 2448, 8029, 855, 826, 721, 277, 9, 267, 291, 423, 77, 8029, 83, 275, 359, 288, 9094, 24, 8029, 1062, 288, 428, 22290, 8029, 1062, 288, 662, 13371, 15819, 8029, 1062, 288, 18553, 16909, 8029, 1062, 288, 26007, 27373, 8029, 1062, 288, 19701, 15674, 8029, 1062, 288, 13123, 21, 8029, 1062, 288, 662, 27120, 8029, 342, 267, 1622, 267, 291, 14, 3958, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 29347, 5960, 17842, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 12521, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 257, 428, 3577, 5244, 279, 676, 446, 3379, 445, 1233, 199, 3, 257, 2165, 1618, 1403, 12, 3277, 14, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 6043, 923, 19903, 492, 6659, 1084, 2448, 8029, 199, 504, 1275, 1624, 24, 19903, 492, 9094, 24, 8029, 199, 504, 1275, 83, 18941, 19903, 492, 428, 22290, 8029, 199, 504, 1275, 15149, 11538, 19903, 492, 662, 13371, 15819, 8029, 199, 504, 1275, 4908, 16909, 19903, 492, 18553, 16909, 8029, 199, 504, 1275, 69, 10112, 82, 19903, 492, 26007, 27373, 8029, 199, 504, 1275, 1850, 15674, 19903, 492, 19701, 15674, 8029, 199, 504, 1275, 5076, 21, 19903, 492, 13123, 21, 8029, 199, 504, 1275, 69, 918, 87, 19903, 492, 662, 27120, 8029, 421, 199, 533, 19487, 3298, 2448, 8029, 8, 1610, 1084, 2448, 8029, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 1084, 2448, 8029, 855, 826, 721, 277, 9, 267, 291, 423, 77, 8029, 83, 275, 359, 288, 9094, 24, 8029, 1062, 288, 428, 22290, 8029, 1062, 288, 662, 13371, 15819, 8029, 1062, 288, 18553, 16909, 8029, 1062, 288, 26007, 27373, 8029, 1062, 288, 19701, 15674, 8029, 1062, 288, 13123, 21, 8029, 1062, 288, 662, 27120, 8029, 342, 267, 1622, 267, 291, 14, 3958, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
drvinceknight/Nashpy
tests/unit/test_game.py
1
20748
""" Tests for the game class """ import unittest import warnings import numpy as np from hypothesis import given from hypothesis.extra.numpy import arrays from hypothesis.strategies import integers import pytest import nashpy as nash import nashpy.learning class TestGame(unittest.TestCase): """ Tests for the game class """ @given(A=arrays(np.int8, (4, 5)), B=arrays(np.int8, (4, 5))) def test_bi_matrix_init(self, A, B): """Test that can create a bi matrix game""" g = nash.Game(A, B) self.assertEqual(g.payoff_matrices, (A, B)) if np.array_equal(A, -B): # Check if A or B are non zero self.assertTrue(g.zero_sum) else: self.assertFalse(g.zero_sum) # Can also init with lists A = A.tolist() B = B.tolist() g = nash.Game(A, B) self.assertTrue(np.array_equal(g.payoff_matrices[0], np.asarray(A))) self.assertTrue(np.array_equal(g.payoff_matrices[1], np.asarray(B))) def test_incorrect_dimensions_init(self): """Tests that ValueError is raised for unequal dimensions""" A = np.array([[1, 2, 3], [4, 5, 6]]) B = np.array([[1, 2], [3, 4]]) with pytest.raises(ValueError): nash.Game(A, B) def test_bi_matrix_repr(self): """Test that can create a bi matrix game""" A = np.array([[1, 2], [2, 1]]) B = np.array([[2, 1], [1, 2]]) g = nash.Game(A, B) string_repr = """Bi matrix game with payoff matrices: Row player: [[1 2] [2 1]] Column player: [[2 1] [1 2]]""" self.assertEqual(g.__repr__(), string_repr) @given(A=arrays(np.int8, (4, 5))) def test_zero_sum_game_init(self, A): """Test that can create a zero sum game""" g = nash.Game(A) self.assertTrue(np.array_equal(g.payoff_matrices[0], A)) self.assertTrue(np.array_equal(g.payoff_matrices[0], -g.payoff_matrices[1])) self.assertTrue(g.zero_sum) # Can also init with lists A = A.tolist() g = nash.Game(A) self.assertTrue(np.array_equal(g.payoff_matrices[0], np.asarray(A))) self.assertTrue(np.array_equal(g.payoff_matrices[0], -g.payoff_matrices[1])) self.assertTrue(g.zero_sum) def test_zero_sum_repr(self): """Test that can create a bi matrix game""" A = np.array([[1, -1], [-1, 1]]) g = nash.Game(A) string_repr = """Zero sum game with payoff matrices: Row player: [[ 1 -1] [-1 1]] Column player: [[-1 1] [ 1 -1]]""" self.assertEqual(g.__repr__(), string_repr) @given(A=arrays(np.int8, (4, 5))) def test_zero_sum_property_from_bi_matrix(self, A): """Test that can create a zero sum game""" B = -A g = nash.Game(A, B) self.assertTrue(g.zero_sum) @given(A=arrays(np.int8, (3, 4)), B=arrays(np.int8, (3, 4))) def test_property_support_enumeration(self, A, B): """Property based test for the equilibria calculation""" g = nash.Game(A, B) with warnings.catch_warnings(): warnings.simplefilter("ignore") for equilibrium in g.support_enumeration(): for i, s in enumerate(equilibrium): # Test that have a probability vector (subject to numerical # error) self.assertAlmostEqual(s.sum(), 1) # Test that it is of the correct size self.assertEqual(s.size, [3, 4][i]) # Test that it is non negative self.assertTrue(all(s >= 0)) def test_support_enumeration_for_bi_matrix(self): """Test for the equilibria calculation support enumeration""" A = np.array([[160, 205, 44], [175, 180, 45], [201, 204, 50], [120, 207, 49]]) B = np.array([[2, 2, 2], [1, 0, 0], [3, 4, 1], [4, 1, 2]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([0, 0, 3 / 4, 1 / 4]), np.array([1 / 28, 27 / 28, 0])) ] for obtained, expected in zip(g.support_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.array_equal(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) A = np.array([[1, 0], [-2, 3]]) B = np.array([[3, 2], [-1, 0]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), (np.array([1 / 2, 1 / 2]), np.array([1 / 2, 1 / 2])), ] for obtained, expected in zip(g.support_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.array_equal(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) A = np.array([[2, 1], [0, 2]]) B = np.array([[2, 0], [1, 2]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), (np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])), ] for obtained, expected in zip(g.support_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.array_equal(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) def test_support_enumeration_for_degenerate_bi_matrix_game(self): """Test for the equilibria calculation support enumeration with a degenerate game""" A = np.array([[-1, 0], [-1, 1]]) B = np.array([[1, 0], [1, -1]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([1, 0])), ] with warnings.catch_warnings(record=True) as w: obtained_equilibria = list(g.support_enumeration()) for obtained, expected in zip(obtained_equilibria, expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.array_equal(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) A = np.array([[3, 3], [2, 5], [0, 6]]) B = np.array([[3, 3], [2, 6], [3, 1]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0, 0]), np.array([1, 0])), (np.array([0, 1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])), ] with warnings.catch_warnings(record=True) as w: obtained_equilibria = list(g.support_enumeration()) for obtained, expected in zip(obtained_equilibria, expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.allclose(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) A = np.array([[0, 0], [0, 0]]) B = np.array([[0, 0], [0, 0]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([1, 0]), np.array([0, 1])), (np.array([0, 1]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), ] with warnings.catch_warnings(record=True) as w: obtained_equilibria = list(g.support_enumeration()) for obtained, expected in zip(obtained_equilibria, expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( np.allclose(s1, s2), msg="obtained: {} !=expected: {}".format(obtained, expected), ) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) def test_support_enumeration_for_deg_bi_matrix_game_with_non_deg(self): A = np.array([[0, 0], [0, 0]]) g = nash.Game(A) with warnings.catch_warnings(record=True) as w: obtained_equilibria = list(g.support_enumeration(non_degenerate=True)) self.assertEqual(len(obtained_equilibria), 4) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) def test_support_enumeration_for_deg_bi_matrix_game_with_low_tol(self): A = np.array([[0, 0], [0, 0]]) g = nash.Game(A) with warnings.catch_warnings(record=True) as w: obtained_equilibria = list(g.support_enumeration(tol=0)) self.assertEqual(len(obtained_equilibria), 4) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) def test_support_enumeration_for_particular_game(self): """ This particular game was raised in https://github.com/drvinceknight/Nashpy/issues/67. Two users reported that it did not return any equilibria under support enumeration. I was unable to reproduce this error locally as I was using a pre compiled install of numpy. However when using a pip installed version I was able to reproduce the error. Rounding the particular input matrices to 5 decimal places however fixes the error. This is an underlying precision error related to numpy (I think). """ A = [ [52.46337363, 69.47195938, 0.0, 54.14372075], [77.0, 88.0, 84.85714286, 92.4], [77.78571429, 87.35294118, 93.5, 91.38461538], [66.37100751, 43.4530444, 0.0, 60.36191831], ] B = [ [23.52690518, 17.35459006, 88.209, 20.8021711], [16.17165, 0.0, 14.00142857, 6.46866], [0.0, 5.76529412, 0.0, 0.0], [15.68327304, 40.68156322, 84.00857143, 11.06596804], ] A = np.round(A, 5) B = np.round(B, 5) game = nash.Game(A, B) eqs = list(game.support_enumeration()) assert len(eqs) == 1 row_strategy, col_strategy = eqs[0] expected_row_strategy, expected_column_strategy = ( np.array([7.33134761e-17, 2.62812089e-01, 7.37187911e-01, 0.00000000e00]), np.array([0.4516129, 0.5483871, 0.0, 0.0]), ) assert np.all(np.isclose(row_strategy, expected_row_strategy)) assert np.all(np.isclose(col_strategy, expected_column_strategy)) def test_vertex_enumeration_for_bi_matrix(self): """Test for the equilibria calculation using vertex enumeration""" A = np.array([[160, 205, 44], [175, 180, 45], [201, 204, 50], [120, 207, 49]]) B = np.array([[2, 2, 2], [1, 0, 0], [3, 4, 1], [4, 1, 2]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([0, 0, 3 / 4, 1 / 4]), np.array([1 / 28, 27 / 28, 0])) ] for obtained, expected in zip(g.vertex_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( all(np.isclose(s1, s2)), msg="obtained: {} !=expected: {}".format(obtained, expected), ) A = np.array([[1, 0], [-2, 3]]) B = np.array([[3, 2], [-1, 0]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), (np.array([1 / 2, 1 / 2]), np.array([1 / 2, 1 / 2])), ] for obtained, expected in zip(g.vertex_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( all(np.isclose(s1, s2)), msg="obtained: {} !=expected: {}".format(obtained, expected), ) A = np.array([[2, 1], [0, 2]]) B = np.array([[2, 0], [1, 2]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), (np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])), ] for obtained, expected in zip(g.vertex_enumeration(), expected_equilibria): for s1, s2 in zip(obtained, expected): self.assertTrue( all(np.isclose(s1, s2)), msg="obtained: {} !=expected: {}".format(obtained, expected), ) def test_lemke_howson_for_bi_matrix(self): """Test for the equilibria calculation using lemke howson""" A = np.array([[160, 205, 44], [175, 180, 45], [201, 204, 50], [120, 207, 49]]) B = np.array([[2, 2, 2], [1, 0, 0], [3, 4, 1], [4, 1, 2]]) g = nash.Game(A, B) expected_equilibria = ( np.array([0, 0, 3 / 4, 1 / 4]), np.array([1 / 28, 27 / 28, 0]), ) equilibria = g.lemke_howson(initial_dropped_label=4) for eq, expected in zip(equilibria, expected_equilibria): self.assertTrue(all(np.isclose(eq, expected))) def test_particular_lemke_howson_raises_warning(self): """ This is a degenerate game so the algorithm fails. This was raised in https://github.com/drvinceknight/Nashpy/issues/35 """ A = np.array([[-1, -1, -1], [0, 0, 0], [-1, -1, -10000]]) B = np.array([[-1, -1, -1], [0, 0, 0], [-1, -1, -10000]]) game = nash.Game(A, B) with warnings.catch_warnings(record=True) as w: eqs = game.lemke_howson(initial_dropped_label=0) self.assertEqual(len(eqs[0]), 2) self.assertEqual(len(eqs[1]), 4) self.assertGreater(len(w), 0) self.assertEqual(w[-1].category, RuntimeWarning) def test_lemke_howson_enumeration(self): """Test for the enumeration of equilibrium using Lemke Howson""" A = np.array([[3, 1], [0, 2]]) B = np.array([[2, 1], [0, 3]]) g = nash.Game(A, B) expected_equilibria = [ (np.array([1, 0]), np.array([1, 0])), (np.array([0, 1]), np.array([0, 1])), ] * 2 equilibria = g.lemke_howson_enumeration() for equilibrium, expected_equilibrium in zip(equilibria, expected_equilibria): for strategy, expected_strategy in zip(equilibrium, expected_equilibrium): self.assertTrue(all(np.isclose(strategy, expected_strategy))) A = np.array([[3, 1], [1, 3]]) B = np.array([[1, 3], [3, 1]]) g = nash.Game(A, B) expected_equilibria = [(np.array([1 / 2, 1 / 2]), np.array([1 / 2, 1 / 2]))] * 4 equilibria = g.lemke_howson_enumeration() for equilibrium, expected_equilibrium in zip(equilibria, expected_equilibria): for strategy, expected_strategy in zip(equilibrium, expected_equilibrium): self.assertTrue(all(np.isclose(strategy, expected_strategy))) def test_get_item(self): """Test solve indifference""" A = np.array([[1, -1], [-1, 1]]) g = nash.Game(A) row_strategy = [0, 1] column_strategy = [1, 0] self.assertTrue( np.array_equal(g[row_strategy, column_strategy], np.array((-1, 1))) ) row_strategy = [1 / 2, 1 / 2] column_strategy = [1 / 2, 1 / 2] self.assertTrue( np.array_equal(g[row_strategy, column_strategy], np.array((0, 0))) ) @given( A=arrays(np.int8, (4, 5)), B=arrays(np.int8, (4, 5)), seed=integers(min_value=0, max_value=2 ** 32 - 1), ) def test_fictitious_play(self, A, B, seed): """Test for the fictitious play algorithm""" g = nash.Game(A, B) iterations = 25 np.random.seed(seed) expected_outcome = tuple( nashpy.learning.fictitious_play.fictitious_play( *g.payoff_matrices, iterations=iterations ) ) np.random.seed(seed) outcome = tuple(g.fictitious_play(iterations=iterations)) assert len(outcome) == iterations + 1 assert len(expected_outcome) == iterations + 1 for plays, expected_plays in zip(outcome, expected_outcome): row_play, column_play = plays expected_row_play, expected_column_play = expected_plays assert np.array_equal(row_play, expected_row_play) assert np.array_equal(column_play, expected_column_play) # assert expected_outcome == outcome @given( A=arrays(np.int8, (4, 3), elements=integers(1, 20)), B=arrays(np.int8, (4, 3), elements=integers(1, 20)), seed=integers(min_value=0, max_value=2 ** 32 - 1), ) def test_stochastic_fictitious_play(self, A, B, seed): """Test for the stochastic fictitious play algorithm""" np.random.seed(seed) iterations = 10 g = nash.Game(A, B) expected_outcome = tuple( nashpy.learning.stochastic_fictitious_play.stochastic_fictitious_play( *g.payoff_matrices, iterations=iterations ) ) np.random.seed(seed) outcome = tuple(g.stochastic_fictitious_play(iterations=iterations)) assert len(outcome) == iterations + 1 assert len(expected_outcome) == iterations + 1 for (plays, distributions), ( expected_plays, expected_distributions, ) in zip(outcome, expected_outcome): row_play, column_play = plays expected_row_play, expected_column_play = expected_plays row_dist, column_dist = distributions expected_row_dist, expected_column_dist = expected_distributions assert np.allclose(column_dist, expected_column_dist) assert np.allclose(row_dist, expected_row_dist) assert np.allclose(column_play, expected_column_play) assert np.allclose(row_play, expected_row_play) def test_replicator_dynamics(self): """Test for the replicator dynamics algorithm""" A = np.array([[3, 2], [4, 1]]) game = nash.Game(A) y0 = np.array([0.9, 0.1]) timepoints = np.linspace(0, 10, 100) xs = game.replicator_dynamics(y0, timepoints) expected_xs = np.array([[0.50449178, 0.49550822]]) assert np.allclose(xs[-1], expected_xs) def test_replicator_dynamics_5x5(self): """Test for the replicator dynamics algorithm with a 5x5 matrix""" A = np.array( [ [3, 2, 4, 2, 3], [5, 1, 1, 3, 2], [6, 2, 3, 2, 1], [1, 3, 4, 7, 2], [1, 4, 4, 1, 3], ] ) game = nash.Game(A) y0 = np.array([0.1, 0.1, 0.3, 0.2, 0.3]) timepoints = np.linspace(0, 10, 100) xs = game.replicator_dynamics(y0, timepoints) expected_xs = np.array( [ [ -5.35867454e-13, -2.93213324e-11, -9.66651436e-13, 1.00000000e00, -1.78136715e-14, ] ] ) assert np.allclose(xs[-1], expected_xs) def test_asymmetric_replicator_dynamics(self): """Test for asymmetric replicator dynamics algorithm""" A = np.array([[5, 1], [4, 2]]) B = np.array([[3, 5], [2, 1]]) game = nash.Game(A, B) x0 = np.array([0.6, 0.4]) y0 = np.array([0.5, 0.5]) timepoints = np.linspace(0, 100, 100) xs_A, xs_B = game.asymmetric_replicator_dynamics( x0=x0, y0=y0, timepoints=timepoints ) expected_A_xs = np.array([0.17404745, 0.82595255]) expected_B_xs = np.array([0.28121086, 0.71878914]) assert np.allclose(xs_A[-1], expected_A_xs) assert np.allclose(xs_B[-1], expected_B_xs) def test_is_best_response(self): """Test for the best response check""" A = np.array([[3, 0], [5, 1]]) B = np.array([[3, 5], [0, 1]]) game = nash.Game(A, B) sigma_r = np.array([0, 1]) sigma_c = np.array([1, 0]) row_check, column_check = game.is_best_response(sigma_r, sigma_c) assert row_check is True assert column_check is False
mit
[ 624, 199, 2925, 367, 314, 9219, 1021, 199, 624, 199, 199, 646, 2882, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 29268, 492, 1627, 199, 504, 29268, 14, 2911, 14, 4714, 492, 6572, 199, 504, 29268, 14, 20694, 1500, 492, 9446, 199, 646, 4613, 199, 199, 646, 302, 1119, 647, 465, 302, 1119, 199, 646, 302, 1119, 647, 14, 10546, 421, 199, 533, 1379, 11454, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 367, 314, 9219, 1021, 272, 408, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1826, 699, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4492, 63, 3642, 63, 826, 8, 277, 12, 437, 12, 699, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 629, 8, 71, 14, 5989, 1997, 63, 19032, 12, 334, 33, 12, 699, 430, 267, 340, 980, 14, 1144, 63, 1452, 8, 33, 12, 446, 34, 304, 221, 327, 2670, 340, 437, 503, 699, 787, 2222, 4697, 288, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 267, 587, 26, 288, 291, 14, 3334, 8, 71, 14, 4262, 63, 1838, 9, 398, 327, 6855, 2597, 4205, 543, 5548, 267, 437, 275, 437, 14, 13633, 342, 267, 699, 275, 699, 14, 13633, 342, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 980, 14, 8748, 8, 33, 1724, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 17, 467, 980, 14, 8748, 8, 34, 1724, 339, 347, 511, 63, 15448, 63, 13320, 63, 826, 8, 277, 304, 267, 408, 2925, 626, 1722, 365, 4915, 367, 625, 1452, 7365, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 3934, 267, 699, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 339, 347, 511, 63, 4492, 63, 3642, 63, 2722, 8, 277, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 18, 12, 413, 3934, 267, 699, 275, 980, 14, 1144, 4038, 18, 12, 413, 467, 359, 17, 12, 499, 3934, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 1059, 63, 2722, 275, 408, 17975, 3634, 9219, 543, 8633, 1997, 12627, 26, 199, 199, 5810, 7748, 26, 199, 9046, 17, 499, 61, 199, 359, 18, 413, 2677, 199, 199, 4547, 7748, 26, 199, 9046, 18, 413, 61, 199, 359, 17, 499, 2677, 624, 267, 291, 14, 629, 8, 71, 855, 2722, 29709, 1059, 63, 2722, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4262, 63, 1838, 63, 5097, 63, 826, 8, 277, 12, 437, 304, 267, 408, 774, 626, 883, 1218, 282, 4697, 3089, 9219, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 437, 430, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 446, 71, 14, 5989, 1997, 63, 19032, 59, 17, 2459, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 398, 327, 6855, 2597, 4205, 543, 5548, 267, 437, 275, 437, 14, 13633, 342, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 980, 14, 8748, 8, 33, 1724, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 446, 71, 14, 5989, 1997, 63, 19032, 59, 17, 2459, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 339, 347, 511, 63, 4262, 63, 1838, 63, 2722, 8, 277, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 446, 17, 467, 5243, 17, 12, 413, 3934, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 1059, 63, 2722, 275, 408, 8681, 3089, 9219, 543, 8633, 1997, 12627, 26, 199, 199, 5810, 7748, 26, 199, 9046, 413, 446, 17, 61, 199, 5243, 17, 221, 413, 2677, 199, 199, 4547, 7748, 26, 199, 59, 1988, 17, 221, 413, 61, 199, 359, 413, 446, 17, 2677, 624, 267, 291, 14, 629, 8, 71, 855, 2722, 29709, 1059, 63, 2722, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4262, 63, 1838, 63, 1829, 63, 504, 63, 4492, 63, 3642, 8, 277, 12, 437, 304, 267, 408, 774, 626, 883, 1218, 282, 4697, 3089, 9219, 624, 267, 699, 275, 446, 33, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 19, 12, 841, 1826, 699, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 19, 12, 841, 1724, 272, 347, 511, 63, 1829, 63, 4058, 63, 14130, 8, 277, 12, 437, 12, 699, 304, 267, 408, 3697, 4079, 511, 367, 314, 325, 783, 773, 23714, 15232, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 543, 3598, 14, 9341, 63, 5451, 837, 288, 3598, 14, 18815, 480, 4247, 531, 288, 367, 325, 783, 773, 322, 453, 315, 486, 14, 4058, 63, 14130, 837, 355, 367, 284, 12, 308, 315, 3874, 8, 69, 783, 773, 322, 453, 304, 490, 327 ]
[ 199, 2925, 367, 314, 9219, 1021, 199, 624, 199, 199, 646, 2882, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 29268, 492, 1627, 199, 504, 29268, 14, 2911, 14, 4714, 492, 6572, 199, 504, 29268, 14, 20694, 1500, 492, 9446, 199, 646, 4613, 199, 199, 646, 302, 1119, 647, 465, 302, 1119, 199, 646, 302, 1119, 647, 14, 10546, 421, 199, 533, 1379, 11454, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 367, 314, 9219, 1021, 272, 408, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1826, 699, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4492, 63, 3642, 63, 826, 8, 277, 12, 437, 12, 699, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 629, 8, 71, 14, 5989, 1997, 63, 19032, 12, 334, 33, 12, 699, 430, 267, 340, 980, 14, 1144, 63, 1452, 8, 33, 12, 446, 34, 304, 221, 327, 2670, 340, 437, 503, 699, 787, 2222, 4697, 288, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 267, 587, 26, 288, 291, 14, 3334, 8, 71, 14, 4262, 63, 1838, 9, 398, 327, 6855, 2597, 4205, 543, 5548, 267, 437, 275, 437, 14, 13633, 342, 267, 699, 275, 699, 14, 13633, 342, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 980, 14, 8748, 8, 33, 1724, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 17, 467, 980, 14, 8748, 8, 34, 1724, 339, 347, 511, 63, 15448, 63, 13320, 63, 826, 8, 277, 304, 267, 408, 2925, 626, 1722, 365, 4915, 367, 625, 1452, 7365, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 12, 650, 467, 359, 20, 12, 959, 12, 1227, 3934, 267, 699, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 19, 12, 841, 3934, 398, 543, 4613, 14, 3536, 8, 3393, 304, 288, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 339, 347, 511, 63, 4492, 63, 3642, 63, 2722, 8, 277, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 499, 467, 359, 18, 12, 413, 3934, 267, 699, 275, 980, 14, 1144, 4038, 18, 12, 413, 467, 359, 17, 12, 499, 3934, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 1059, 63, 2722, 275, 408, 17975, 3634, 9219, 543, 8633, 1997, 12627, 26, 199, 199, 5810, 7748, 26, 199, 9046, 17, 499, 61, 199, 359, 18, 413, 2677, 199, 199, 4547, 7748, 26, 199, 9046, 18, 413, 61, 199, 359, 17, 499, 2677, 624, 267, 291, 14, 629, 8, 71, 855, 2722, 29709, 1059, 63, 2722, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4262, 63, 1838, 63, 5097, 63, 826, 8, 277, 12, 437, 304, 267, 408, 774, 626, 883, 1218, 282, 4697, 3089, 9219, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 437, 430, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 446, 71, 14, 5989, 1997, 63, 19032, 59, 17, 2459, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 398, 327, 6855, 2597, 4205, 543, 5548, 267, 437, 275, 437, 14, 13633, 342, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 980, 14, 8748, 8, 33, 1724, 267, 291, 14, 1815, 8, 1590, 14, 1144, 63, 1452, 8, 71, 14, 5989, 1997, 63, 19032, 59, 16, 467, 446, 71, 14, 5989, 1997, 63, 19032, 59, 17, 2459, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 339, 347, 511, 63, 4262, 63, 1838, 63, 2722, 8, 277, 304, 267, 408, 774, 626, 883, 1218, 282, 12111, 3634, 9219, 624, 267, 437, 275, 980, 14, 1144, 4038, 17, 12, 446, 17, 467, 5243, 17, 12, 413, 3934, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 9, 267, 1059, 63, 2722, 275, 408, 8681, 3089, 9219, 543, 8633, 1997, 12627, 26, 199, 199, 5810, 7748, 26, 199, 9046, 413, 446, 17, 61, 199, 5243, 17, 221, 413, 2677, 199, 199, 4547, 7748, 26, 199, 59, 1988, 17, 221, 413, 61, 199, 359, 413, 446, 17, 2677, 624, 267, 291, 14, 629, 8, 71, 855, 2722, 29709, 1059, 63, 2722, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 20, 12, 959, 1724, 272, 347, 511, 63, 4262, 63, 1838, 63, 1829, 63, 504, 63, 4492, 63, 3642, 8, 277, 12, 437, 304, 267, 408, 774, 626, 883, 1218, 282, 4697, 3089, 9219, 624, 267, 699, 275, 446, 33, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 291, 14, 1815, 8, 71, 14, 4262, 63, 1838, 9, 339, 768, 11809, 8, 33, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 19, 12, 841, 1826, 699, 29, 10095, 8, 1590, 14, 442, 24, 12, 334, 19, 12, 841, 1724, 272, 347, 511, 63, 1829, 63, 4058, 63, 14130, 8, 277, 12, 437, 12, 699, 304, 267, 408, 3697, 4079, 511, 367, 314, 325, 783, 773, 23714, 15232, 624, 267, 486, 275, 302, 1119, 14, 11454, 8, 33, 12, 699, 9, 267, 543, 3598, 14, 9341, 63, 5451, 837, 288, 3598, 14, 18815, 480, 4247, 531, 288, 367, 325, 783, 773, 322, 453, 315, 486, 14, 4058, 63, 14130, 837, 355, 367, 284, 12, 308, 315, 3874, 8, 69, 783, 773, 322, 453, 304, 490, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
RPGOne/Skynet
scikit-learn-0.18.1/sklearn/utils/class_weight.py
29
7411
# Authors: Andreas Mueller # Manoj Kumar # License: BSD 3 clause import warnings import numpy as np from ..externals import six from ..utils.fixes import in1d from .fixes import bincount def compute_class_weight(class_weight, classes, y): """Estimate class weights for unbalanced datasets. Parameters ---------- class_weight : dict, 'balanced' or None If 'balanced', class weights will be given by ``n_samples / (n_classes * np.bincount(y))``. If a dictionary is given, keys are classes and values are corresponding class weights. If None is given, the class weights will be uniform. classes : ndarray Array of the classes occurring in the data, as given by ``np.unique(y_org)`` with ``y_org`` the original class labels. y : array-like, shape (n_samples,) Array of original class labels per sample; Returns ------- class_weight_vect : ndarray, shape (n_classes,) Array with class_weight_vect[i] the weight for i-th class References ---------- The "balanced" heuristic is inspired by Logistic Regression in Rare Events Data, King, Zen, 2001. """ # Import error caused by circular imports. from ..preprocessing import LabelEncoder if set(y) - set(classes): raise ValueError("classes should include all valid labels that can " "be in y") if class_weight is None or len(class_weight) == 0: # uniform class weights weight = np.ones(classes.shape[0], dtype=np.float64, order='C') elif class_weight in ['auto', 'balanced']: # Find the weight of each class as present in y. le = LabelEncoder() y_ind = le.fit_transform(y) if not all(np.in1d(classes, le.classes_)): raise ValueError("classes should have valid labels that are in y") # inversely proportional to the number of samples in the class if class_weight == 'auto': recip_freq = 1. / bincount(y_ind) weight = recip_freq[le.transform(classes)] / np.mean(recip_freq) warnings.warn("The class_weight='auto' heuristic is deprecated in" " 0.17 in favor of a new heuristic " "class_weight='balanced'. 'auto' will be removed in" " 0.19", DeprecationWarning) else: recip_freq = len(y) / (len(le.classes_) * bincount(y_ind).astype(np.float64)) weight = recip_freq[le.transform(classes)] else: # user-defined dictionary weight = np.ones(classes.shape[0], dtype=np.float64, order='C') if not isinstance(class_weight, dict): raise ValueError("class_weight must be dict, 'balanced', or None," " got: %r" % class_weight) for c in class_weight: i = np.searchsorted(classes, c) if i >= len(classes) or classes[i] != c: raise ValueError("Class label %d not present." % c) else: weight[i] = class_weight[c] return weight def compute_sample_weight(class_weight, y, indices=None): """Estimate sample weights by class for unbalanced datasets. Parameters ---------- class_weight : dict, list of dicts, "balanced", or None, optional Weights associated with classes in the form ``{class_label: weight}``. If not given, all classes are supposed to have weight one. For multi-output problems, a list of dicts can be provided in the same order as the columns of y. The "balanced" mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data: ``n_samples / (n_classes * np.bincount(y))``. For multi-output, the weights of each column of y will be multiplied. y : array-like, shape = [n_samples] or [n_samples, n_outputs] Array of original class labels per sample. indices : array-like, shape (n_subsample,), or None Array of indices to be used in a subsample. Can be of length less than n_samples in the case of a subsample, or equal to n_samples in the case of a bootstrap subsample with repeated indices. If None, the sample weight will be calculated over the full sample. Only "auto" is supported for class_weight if this is provided. Returns ------- sample_weight_vect : ndarray, shape (n_samples,) Array with sample weights as applied to the original y """ y = np.atleast_1d(y) if y.ndim == 1: y = np.reshape(y, (-1, 1)) n_outputs = y.shape[1] if isinstance(class_weight, six.string_types): if class_weight not in ['balanced', 'auto']: raise ValueError('The only valid preset for class_weight is ' '"balanced". Given "%s".' % class_weight) elif (indices is not None and not isinstance(class_weight, six.string_types)): raise ValueError('The only valid class_weight for subsampling is ' '"balanced". Given "%s".' % class_weight) elif n_outputs > 1: if (not hasattr(class_weight, "__iter__") or isinstance(class_weight, dict)): raise ValueError("For multi-output, class_weight should be a " "list of dicts, or a valid string.") if len(class_weight) != n_outputs: raise ValueError("For multi-output, number of elements in " "class_weight should match number of outputs.") expanded_class_weight = [] for k in range(n_outputs): y_full = y[:, k] classes_full = np.unique(y_full) classes_missing = None if class_weight in ['balanced', 'auto'] or n_outputs == 1: class_weight_k = class_weight else: class_weight_k = class_weight[k] if indices is not None: # Get class weights for the subsample, covering all classes in # case some labels that were present in the original data are # missing from the sample. y_subsample = y[indices, k] classes_subsample = np.unique(y_subsample) weight_k = np.choose(np.searchsorted(classes_subsample, classes_full), compute_class_weight(class_weight_k, classes_subsample, y_subsample), mode='clip') classes_missing = set(classes_full) - set(classes_subsample) else: weight_k = compute_class_weight(class_weight_k, classes_full, y_full) weight_k = weight_k[np.searchsorted(classes_full, y_full)] if classes_missing: # Make missing classes' weight zero weight_k[in1d(y_full, list(classes_missing))] = 0. expanded_class_weight.append(weight_k) expanded_class_weight = np.prod(expanded_class_weight, axis=0, dtype=np.float64) return expanded_class_weight
bsd-3-clause
[ 3, 6642, 26, 6061, 264, 305, 603, 13086, 1435, 199, 3, 3515, 4688, 79, 74, 1804, 453, 285, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 1208, 14, 26205, 492, 315, 17, 68, 199, 199, 504, 1275, 26205, 492, 2517, 835, 421, 199, 318, 4526, 63, 533, 63, 3463, 8, 533, 63, 3463, 12, 3992, 12, 612, 304, 272, 408, 31020, 1021, 4931, 367, 625, 18923, 13148, 14, 339, 3897, 272, 4143, 272, 1021, 63, 3463, 520, 1211, 12, 283, 18923, 7, 503, 488, 267, 982, 283, 18923, 297, 1021, 4931, 911, 506, 1627, 701, 267, 1124, 78, 63, 3356, 1182, 334, 78, 63, 2888, 627, 980, 14, 1393, 835, 8, 89, 430, 4345, 267, 982, 282, 2600, 365, 1627, 12, 2883, 787, 3992, 436, 1338, 267, 787, 5226, 1021, 4931, 14, 267, 982, 488, 365, 1627, 12, 314, 1021, 4931, 911, 506, 14818, 14, 339, 3992, 520, 6800, 267, 8725, 402, 314, 3992, 4781, 5985, 315, 314, 666, 12, 465, 1627, 701, 267, 1124, 1590, 14, 3235, 8, 89, 63, 1308, 9719, 543, 1124, 89, 63, 1308, 1040, 314, 3379, 1021, 3628, 14, 339, 612, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3379, 1021, 3628, 1126, 2690, 27, 339, 1803, 272, 5514, 272, 1021, 63, 3463, 63, 28122, 520, 6800, 12, 2215, 334, 78, 63, 2888, 4258, 267, 8725, 543, 1021, 63, 3463, 63, 28122, 59, 73, 61, 314, 5401, 367, 284, 13, 273, 1021, 339, 14504, 272, 4143, 272, 710, 298, 18923, 2, 25332, 365, 315, 8721, 581, 701, 272, 5297, 6937, 13262, 315, 820, 1530, 27982, 3918, 12, 1804, 316, 12, 3107, 287, 12, 12521, 14, 272, 408, 272, 327, 3161, 1125, 18104, 701, 15032, 8925, 14, 272, 687, 2508, 21402, 492, 10354, 6679, 339, 340, 663, 8, 89, 9, 446, 663, 8, 2888, 304, 267, 746, 1722, 480, 2888, 1077, 2387, 1006, 1686, 3628, 626, 883, 298, 586, 298, 1235, 315, 612, 531, 272, 340, 1021, 63, 3463, 365, 488, 503, 822, 8, 533, 63, 3463, 9, 508, 378, 26, 267, 327, 14818, 1021, 4931, 267, 5401, 275, 980, 14, 4548, 8, 2888, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 1609, 772, 12, 1865, 534, 35, 358, 272, 916, 1021, 63, 3463, 315, 788, 2495, 297, 283, 18923, 2565, 267, 327, 6668, 314, 5401, 402, 1924, 1021, 465, 3451, 315, 612, 14, 267, 1026, 275, 10354, 6679, 342, 267, 612, 63, 688, 275, 1026, 14, 3269, 63, 4711, 8, 89, 9, 267, 340, 440, 1006, 8, 1590, 14, 262, 17, 68, 8, 2888, 12, 1026, 14, 2888, 63, 2298, 288, 746, 1722, 480, 2888, 1077, 1172, 1686, 3628, 626, 787, 315, 612, 531, 398, 327, 11484, 590, 24382, 279, 370, 314, 1329, 402, 5845, 315, 314, 1021, 267, 340, 1021, 63, 3463, 508, 283, 2495, 356, 288, 295, 6237, 63, 5646, 275, 413, 14, 1182, 2517, 835, 8, 89, 63, 688, 9, 288, 5401, 275, 295, 6237, 63, 5646, 59, 274, 14, 4711, 8, 2888, 1874, 1182, 980, 14, 3670, 8, 264, 6237, 63, 5646, 9, 288, 3598, 14, 4050, 480, 1918, 1021, 63, 3463, 534, 2495, 7, 25332, 365, 5906, 315, 2, 2079, 298, 378, 14, 1196, 315, 17914, 402, 282, 892, 25332, 298, 2079, 298, 533, 63, 3463, 534, 18923, 1370, 283, 2495, 7, 911, 506, 4829, 315, 2, 2079, 298, 378, 14, 1167, 401, 13413, 9, 267, 587, 26, 288, 295, 6237, 63, 5646, 275, 822, 8, 89, 9, 1182, 334, 552, 8, 274, 14, 2888, 4602, 627, 3521, 2517, 835, 8, 89, 63, 688, 680, 6041, 8, 1590, 14, 1609, 772, 430, 288, 5401, 275, 295, 6237, 63, 5646, 59, 274, 14, 4711, 8, 2888, 1874, 272, 587, 26, 267, 327, 922, 13, 4037, 2600, 267, 5401, 275, 980, 14, 4548, 8, 2888, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 1609, 772, 12, 1865, 534, 35, 358, 267, 340, 440, 1228, 8, 533, 63, 3463, 12, 1211, 304, 288, 746, 1722, 480, 533, 63, 3463, 1471, 506, 1211, 12, 283, 18923, 297, 503, 488, 4589, 2490, 298, 4788, 26, 450, 82, 2, 450, 1021, 63, 3463, 9, 267, 367, 286, 315, 1021, 63, 3463, 26, 288, 284, 275, 980, 14, 31698, 8, 2888, 12, 286, 9, 288, 340, 284, 2356, 822, 8, 2888, 9, 503, 3992, 59, 73, 61, 1137, 286, 26, 355, 746, 1722, 480, 2543, 1768, 450, 68, 440, 3451, 2122, 450, 286, 9, 288, 587, 26, 355, 5401, 59, 73, 61, 275, 1021, 63, 3463, 59, 67, 61, 339, 372, 5401, 421, 199, 318, 4526, 63, 3271, 63, 3463, 8, 533, 63, 3463, 12, 612, 12, 4918, 29, 403, 304, 272, 408, 31020, 2690, 4931, 701, 1021, 367, 625, 18923, 13148, 14, 339, 3897, 272, 4143, 272, 1021, 63, 3463, 520, 1211, 12, 769, 402, 10809, 12, 298, 18923, 401, 503, 488, 12, 2716, 267, 2136, 2492, 4568, 543, 3992, 315, 314, 1824, 1124, 91, 533, 63, 1302, 26, 5401, 93, 4345, 267, 982, 440, 1627, 12, 1006, 3992, 787, 20042, 370, 1172, 5401, 1373, 14, 2104, 267, 3510, 13, 1199, 8826, 12, 282, 769, 402, 10809, 883, 506, 2741, 315, 314, 2011, 267, 1865, 465, 314, 4362, 402, 612, 14, 398, 710, 298, 18923, 2, 818, 4440, 314, 1338, 402, 612, 370, 5847, 11311, 267, 4931, 11484, 590, 24382, 279, 370, 1021, 22411, 315, 314, 1324, 666, 26, 267, 1124, 78, 63, 3356, 1182, 334, 78, 63, 2888, 627, 980, 14, 1393, 835, 8, 89, 430, 4345, 398, 2104, 3510, 13, 1199, 12, 314, 4931, 402, 1924, 2763, 402, 612, 911, 506, 29597, 14, 339, 612, 520, 1625, 13, 2930, 12, 2215, 275, 359, 78, 63, 3356, 61, 503, 359, 78, 63, 3356, 12, 302, 63, 4467, 61, 267, 8725, 402, 3379, 1021, 3628, 1126, 2690, 14, 339, 4918, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 954, 3271, 4706, 503, 488, 267, 8725, 402, 4918, 370, 506, 1202, 315, 282, 1007, 3271, 14, 6855, 506, 402, 2582, 6656, 2419, 267, 302, 63, 3356, 315, 314, 1930, 402, 282, 1007, 3271, 12, 503 ]
[ 6642, 26, 6061, 264, 305, 603, 13086, 1435, 199, 3, 3515, 4688, 79, 74, 1804, 453, 285, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 1208, 14, 26205, 492, 315, 17, 68, 199, 199, 504, 1275, 26205, 492, 2517, 835, 421, 199, 318, 4526, 63, 533, 63, 3463, 8, 533, 63, 3463, 12, 3992, 12, 612, 304, 272, 408, 31020, 1021, 4931, 367, 625, 18923, 13148, 14, 339, 3897, 272, 4143, 272, 1021, 63, 3463, 520, 1211, 12, 283, 18923, 7, 503, 488, 267, 982, 283, 18923, 297, 1021, 4931, 911, 506, 1627, 701, 267, 1124, 78, 63, 3356, 1182, 334, 78, 63, 2888, 627, 980, 14, 1393, 835, 8, 89, 430, 4345, 267, 982, 282, 2600, 365, 1627, 12, 2883, 787, 3992, 436, 1338, 267, 787, 5226, 1021, 4931, 14, 267, 982, 488, 365, 1627, 12, 314, 1021, 4931, 911, 506, 14818, 14, 339, 3992, 520, 6800, 267, 8725, 402, 314, 3992, 4781, 5985, 315, 314, 666, 12, 465, 1627, 701, 267, 1124, 1590, 14, 3235, 8, 89, 63, 1308, 9719, 543, 1124, 89, 63, 1308, 1040, 314, 3379, 1021, 3628, 14, 339, 612, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 3356, 4258, 267, 8725, 402, 3379, 1021, 3628, 1126, 2690, 27, 339, 1803, 272, 5514, 272, 1021, 63, 3463, 63, 28122, 520, 6800, 12, 2215, 334, 78, 63, 2888, 4258, 267, 8725, 543, 1021, 63, 3463, 63, 28122, 59, 73, 61, 314, 5401, 367, 284, 13, 273, 1021, 339, 14504, 272, 4143, 272, 710, 298, 18923, 2, 25332, 365, 315, 8721, 581, 701, 272, 5297, 6937, 13262, 315, 820, 1530, 27982, 3918, 12, 1804, 316, 12, 3107, 287, 12, 12521, 14, 272, 408, 272, 327, 3161, 1125, 18104, 701, 15032, 8925, 14, 272, 687, 2508, 21402, 492, 10354, 6679, 339, 340, 663, 8, 89, 9, 446, 663, 8, 2888, 304, 267, 746, 1722, 480, 2888, 1077, 2387, 1006, 1686, 3628, 626, 883, 298, 586, 298, 1235, 315, 612, 531, 272, 340, 1021, 63, 3463, 365, 488, 503, 822, 8, 533, 63, 3463, 9, 508, 378, 26, 267, 327, 14818, 1021, 4931, 267, 5401, 275, 980, 14, 4548, 8, 2888, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 1609, 772, 12, 1865, 534, 35, 358, 272, 916, 1021, 63, 3463, 315, 788, 2495, 297, 283, 18923, 2565, 267, 327, 6668, 314, 5401, 402, 1924, 1021, 465, 3451, 315, 612, 14, 267, 1026, 275, 10354, 6679, 342, 267, 612, 63, 688, 275, 1026, 14, 3269, 63, 4711, 8, 89, 9, 267, 340, 440, 1006, 8, 1590, 14, 262, 17, 68, 8, 2888, 12, 1026, 14, 2888, 63, 2298, 288, 746, 1722, 480, 2888, 1077, 1172, 1686, 3628, 626, 787, 315, 612, 531, 398, 327, 11484, 590, 24382, 279, 370, 314, 1329, 402, 5845, 315, 314, 1021, 267, 340, 1021, 63, 3463, 508, 283, 2495, 356, 288, 295, 6237, 63, 5646, 275, 413, 14, 1182, 2517, 835, 8, 89, 63, 688, 9, 288, 5401, 275, 295, 6237, 63, 5646, 59, 274, 14, 4711, 8, 2888, 1874, 1182, 980, 14, 3670, 8, 264, 6237, 63, 5646, 9, 288, 3598, 14, 4050, 480, 1918, 1021, 63, 3463, 534, 2495, 7, 25332, 365, 5906, 315, 2, 2079, 298, 378, 14, 1196, 315, 17914, 402, 282, 892, 25332, 298, 2079, 298, 533, 63, 3463, 534, 18923, 1370, 283, 2495, 7, 911, 506, 4829, 315, 2, 2079, 298, 378, 14, 1167, 401, 13413, 9, 267, 587, 26, 288, 295, 6237, 63, 5646, 275, 822, 8, 89, 9, 1182, 334, 552, 8, 274, 14, 2888, 4602, 627, 3521, 2517, 835, 8, 89, 63, 688, 680, 6041, 8, 1590, 14, 1609, 772, 430, 288, 5401, 275, 295, 6237, 63, 5646, 59, 274, 14, 4711, 8, 2888, 1874, 272, 587, 26, 267, 327, 922, 13, 4037, 2600, 267, 5401, 275, 980, 14, 4548, 8, 2888, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 1609, 772, 12, 1865, 534, 35, 358, 267, 340, 440, 1228, 8, 533, 63, 3463, 12, 1211, 304, 288, 746, 1722, 480, 533, 63, 3463, 1471, 506, 1211, 12, 283, 18923, 297, 503, 488, 4589, 2490, 298, 4788, 26, 450, 82, 2, 450, 1021, 63, 3463, 9, 267, 367, 286, 315, 1021, 63, 3463, 26, 288, 284, 275, 980, 14, 31698, 8, 2888, 12, 286, 9, 288, 340, 284, 2356, 822, 8, 2888, 9, 503, 3992, 59, 73, 61, 1137, 286, 26, 355, 746, 1722, 480, 2543, 1768, 450, 68, 440, 3451, 2122, 450, 286, 9, 288, 587, 26, 355, 5401, 59, 73, 61, 275, 1021, 63, 3463, 59, 67, 61, 339, 372, 5401, 421, 199, 318, 4526, 63, 3271, 63, 3463, 8, 533, 63, 3463, 12, 612, 12, 4918, 29, 403, 304, 272, 408, 31020, 2690, 4931, 701, 1021, 367, 625, 18923, 13148, 14, 339, 3897, 272, 4143, 272, 1021, 63, 3463, 520, 1211, 12, 769, 402, 10809, 12, 298, 18923, 401, 503, 488, 12, 2716, 267, 2136, 2492, 4568, 543, 3992, 315, 314, 1824, 1124, 91, 533, 63, 1302, 26, 5401, 93, 4345, 267, 982, 440, 1627, 12, 1006, 3992, 787, 20042, 370, 1172, 5401, 1373, 14, 2104, 267, 3510, 13, 1199, 8826, 12, 282, 769, 402, 10809, 883, 506, 2741, 315, 314, 2011, 267, 1865, 465, 314, 4362, 402, 612, 14, 398, 710, 298, 18923, 2, 818, 4440, 314, 1338, 402, 612, 370, 5847, 11311, 267, 4931, 11484, 590, 24382, 279, 370, 1021, 22411, 315, 314, 1324, 666, 26, 267, 1124, 78, 63, 3356, 1182, 334, 78, 63, 2888, 627, 980, 14, 1393, 835, 8, 89, 430, 4345, 398, 2104, 3510, 13, 1199, 12, 314, 4931, 402, 1924, 2763, 402, 612, 911, 506, 29597, 14, 339, 612, 520, 1625, 13, 2930, 12, 2215, 275, 359, 78, 63, 3356, 61, 503, 359, 78, 63, 3356, 12, 302, 63, 4467, 61, 267, 8725, 402, 3379, 1021, 3628, 1126, 2690, 14, 339, 4918, 520, 1625, 13, 2930, 12, 2215, 334, 78, 63, 954, 3271, 4706, 503, 488, 267, 8725, 402, 4918, 370, 506, 1202, 315, 282, 1007, 3271, 14, 6855, 506, 402, 2582, 6656, 2419, 267, 302, 63, 3356, 315, 314, 1930, 402, 282, 1007, 3271, 12, 503, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pombredanne/SmartNotes
appengine_django/db/base.py
58
5010
#!/usr/bin/python2.4 # # Copyright 2008 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """This module looks after initialising the appengine api stubs.""" import logging import os from appengine_django import appid from appengine_django import have_appserver from appengine_django.db.creation import DatabaseCreation from django.db.backends import BaseDatabaseWrapper from django.db.backends import BaseDatabaseFeatures from django.db.backends import BaseDatabaseOperations def get_datastore_paths(): """Returns a tuple with the path to the datastore and history file. The datastore is stored in the same location as dev_appserver uses by default, but the name is altered to be unique to this project so multiple Django projects can be developed on the same machine in parallel. Returns: (datastore_path, history_path) """ from google.appengine.tools import dev_appserver_main datastore_path = dev_appserver_main.DEFAULT_ARGS['datastore_path'] history_path = dev_appserver_main.DEFAULT_ARGS['history_path'] datastore_path = datastore_path.replace("dev_appserver", "django_%s" % appid) history_path = history_path.replace("dev_appserver", "django_%s" % appid) return datastore_path, history_path def get_test_datastore_paths(inmemory=True): """Returns a tuple with the path to the test datastore and history file. If inmemory is true, (None, None) is returned to request an in-memory datastore. If inmemory is false the path returned will be similar to the path returned by get_datastore_paths but with a different name. Returns: (datastore_path, history_path) """ if inmemory: return None, None datastore_path, history_path = get_datastore_paths() datastore_path = datastore_path.replace("datastore", "testdatastore") history_path = history_path.replace("datastore", "testdatastore") return datastore_path, history_path def destroy_datastore(datastore_path, history_path): """Destroys the appengine datastore at the specified paths.""" for path in [datastore_path, history_path]: if not path: continue try: os.remove(path) except OSError, e: if e.errno != 2: logging.error("Failed to clear datastore: %s" % e) class DatabaseError(Exception): """Stub class for database errors. Required by Django""" pass class IntegrityError(Exception): """Stub class for database integrity errors. Required by Django""" pass class DatabaseFeatures(BaseDatabaseFeatures): """Stub class to provide the feaures member expected by Django""" pass class DatabaseOperations(BaseDatabaseOperations): """Stub class to provide the options member expected by Django""" pass class DatabaseWrapper(BaseDatabaseWrapper): """App Engine database definition for Django. This "database" backend does not support any of the standard backend operations. The only task that it performs is to setup the api stubs required by the appengine libraries if they have not already been initialised by an appserver. """ def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.features = DatabaseFeatures() self.ops = DatabaseOperations() self.creation = DatabaseCreation(self) self.use_test_datastore = kwargs.get("use_test_datastore", False) self.test_datastore_inmemory = kwargs.get("test_datastore_inmemory", True) if have_appserver: return self._setup_stubs() def _get_paths(self): if self.use_test_datastore: return get_test_datastore_paths(self.test_datastore_inmemory) else: return get_datastore_paths() def _setup_stubs(self): # If this code is being run without an appserver (eg. via a django # commandline flag) then setup a default stub environment. from google.appengine.tools import dev_appserver_main args = dev_appserver_main.DEFAULT_ARGS.copy() args['datastore_path'], args['history_path'] = self._get_paths() from google.appengine.tools import dev_appserver dev_appserver.SetupStubs(appid, **args) if self.use_test_datastore: logging.debug("Configured API stubs for the test datastore") else: logging.debug("Configured API stubs for the development datastore") def flush(self): """Helper function to remove the current datastore and re-open the stubs""" destroy_datastore(*self._get_paths()) self._setup_stubs() def close(self): pass def _commit(self): pass def cursor(self, *args): pass
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2765, 859, 10734, 2410, 2536, 11136, 314, 1145, 3908, 2986, 22312, 1041, 199, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 1145, 3908, 63, 1176, 492, 1145, 344, 199, 504, 1145, 3908, 63, 1176, 492, 1172, 63, 571, 1000, 199, 504, 1145, 3908, 63, 1176, 14, 697, 14, 8782, 492, 8692, 13921, 421, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 4590, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 10807, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 12929, 421, 199, 318, 664, 63, 11450, 63, 3771, 837, 523, 408, 3407, 282, 2008, 543, 314, 931, 370, 314, 12007, 436, 7994, 570, 14, 819, 710, 12007, 365, 5489, 315, 314, 2011, 2909, 465, 4866, 63, 571, 1000, 4440, 701, 523, 849, 12, 1325, 314, 536, 365, 29815, 370, 506, 3747, 370, 642, 2199, 880, 3663, 523, 5634, 11336, 883, 506, 477, 27813, 641, 314, 2011, 6844, 315, 9861, 14, 819, 1803, 26, 272, 334, 11450, 63, 515, 12, 7994, 63, 515, 9, 523, 408, 523, 687, 6233, 14, 15358, 14, 2537, 492, 4866, 63, 571, 1000, 63, 973, 523, 12007, 63, 515, 275, 4866, 63, 571, 1000, 63, 973, 14, 3472, 63, 13990, 459, 11450, 63, 515, 418, 523, 7994, 63, 515, 275, 4866, 63, 571, 1000, 63, 973, 14, 3472, 63, 13990, 459, 5570, 63, 515, 418, 523, 12007, 63, 515, 275, 12007, 63, 515, 14, 1814, 480, 2374, 63, 571, 1000, 401, 298, 1176, 4970, 83, 2, 450, 1145, 344, 9, 523, 7994, 63, 515, 275, 7994, 63, 515, 14, 1814, 480, 2374, 63, 571, 1000, 401, 298, 1176, 4970, 83, 2, 450, 1145, 344, 9, 523, 372, 12007, 63, 515, 12, 7994, 63, 515, 421, 199, 318, 664, 63, 396, 63, 11450, 63, 3771, 8, 262, 4844, 29, 549, 304, 523, 408, 3407, 282, 2008, 543, 314, 931, 370, 314, 511, 12007, 436, 7994, 570, 14, 819, 982, 315, 4844, 365, 2549, 12, 334, 403, 12, 488, 9, 365, 2138, 370, 1056, 376, 315, 13, 4844, 523, 12007, 14, 982, 315, 4844, 365, 3055, 314, 931, 2138, 911, 506, 8545, 370, 314, 931, 523, 2138, 701, 664, 63, 11450, 63, 3771, 1325, 543, 282, 3365, 536, 14, 819, 1803, 26, 272, 334, 11450, 63, 515, 12, 7994, 63, 515, 9, 523, 408, 523, 340, 315, 4844, 26, 272, 372, 488, 12, 488, 523, 12007, 63, 515, 12, 7994, 63, 515, 275, 664, 63, 11450, 63, 3771, 342, 523, 12007, 63, 515, 275, 12007, 63, 515, 14, 1814, 480, 11450, 401, 298, 396, 11450, 531, 523, 7994, 63, 515, 275, 7994, 63, 515, 14, 1814, 480, 11450, 401, 298, 396, 11450, 531, 523, 372, 12007, 63, 515, 12, 7994, 63, 515, 421, 199, 318, 11972, 63, 11450, 8, 11450, 63, 515, 12, 7994, 63, 515, 304, 523, 408, 8004, 293, 588, 314, 1145, 3908, 12007, 737, 314, 2013, 3792, 1041, 523, 367, 931, 315, 359, 11450, 63, 515, 12, 7994, 63, 515, 2189, 272, 340, 440, 931, 26, 1980, 272, 862, 26, 489, 747, 14, 2168, 8, 515, 9, 272, 871, 6440, 12, 325, 26, 489, 340, 325, 14, 7931, 1137, 499, 26, 267, 2050, 14, 705, 480, 4276, 370, 5436, 12007, 26, 450, 83, 2, 450, 325, 9, 421, 199, 533, 27728, 8, 1726, 304, 523, 408, 8067, 1021, 367, 3050, 2552, 14, 11105, 701, 5634, 624, 523, 986, 421, 199, 533, 26864, 8, 1726, 304, 523, 408, 8067, 1021, 367, 3050, 4661, 12997, 2552, 14, 11105, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 10807, 8, 1563, 7243, 10807, 304, 523, 408, 8067, 1021, 370, 5647, 314, 1964, 65, 1482, 3653, 1420, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 12929, 8, 1563, 7243, 12929, 304, 523, 408, 8067, 1021, 370, 5647, 314, 1511, 3653, 1420, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 4590, 8, 1563, 7243, 4590, 304, 523, 408, 2640, 12580, 3050, 5492, 367, 5634, 14, 819, 961, 298, 4659, 2, 4865, 1630, 440, 2291, 1263, 402, 314, 4465, 4865, 523, 5331, 14, 710, 1454, 2120, 626, 652, 18628, 365, 370, 3272, 314, 2986, 22312, 1415, 523, 701, 314, 1145, 3908, 8363, 340, 2985, 1172, 440, 2575, 2757, 2536, 9096, 701, 376, 523, 1145, 1000, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 7243, 4590, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 272, 291, 14, 3179, 275, 8692, 10807, 342, 272, 291, 14, 1483, 275, 8692, 12929, 342, 272, 291, 14, 8782, 275, 8692, 13921, 8, 277, 9, 272, 291, 14, 1180, 63, 396, 63, 11450, 275, 2074, 14, 362, 480, 1180, 63, 396, 63, 11450, 401, 756, 9, 272, 291, 14, 396, 63, 11450, 63, 262, 4844, 275, 2074, 14, 362, 480, 396, 63, 11450, 63, 262, 4844, 401, 715, 9, 272, 340, 1172, 63, 571, 1000, 26, 489, 372, 272, 291, 423, 2758, 63, 8957, 342, 819, 347, 485, 362, 63, 3771, 8, 277, 304, 272, 340, 291, 14, 1180, 63, 396, 63, 11450, 26, 489, 372, 664, 63, 396, 63, 11450, 63, 3771, 8, 277, 14, 396, 63, 11450, 63, 262, 4844, 9, 272, 587, 26, 489, 372, 664, 63, 11450, 63, 3771, 342, 819, 347, 485, 2758, 63, 8957 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2765, 859, 10734, 2410, 2536, 11136, 314, 1145, 3908, 2986, 22312, 1041, 199, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 1145, 3908, 63, 1176, 492, 1145, 344, 199, 504, 1145, 3908, 63, 1176, 492, 1172, 63, 571, 1000, 199, 504, 1145, 3908, 63, 1176, 14, 697, 14, 8782, 492, 8692, 13921, 421, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 4590, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 10807, 199, 504, 1639, 14, 697, 14, 7765, 492, 29103, 12929, 421, 199, 318, 664, 63, 11450, 63, 3771, 837, 523, 408, 3407, 282, 2008, 543, 314, 931, 370, 314, 12007, 436, 7994, 570, 14, 819, 710, 12007, 365, 5489, 315, 314, 2011, 2909, 465, 4866, 63, 571, 1000, 4440, 701, 523, 849, 12, 1325, 314, 536, 365, 29815, 370, 506, 3747, 370, 642, 2199, 880, 3663, 523, 5634, 11336, 883, 506, 477, 27813, 641, 314, 2011, 6844, 315, 9861, 14, 819, 1803, 26, 272, 334, 11450, 63, 515, 12, 7994, 63, 515, 9, 523, 408, 523, 687, 6233, 14, 15358, 14, 2537, 492, 4866, 63, 571, 1000, 63, 973, 523, 12007, 63, 515, 275, 4866, 63, 571, 1000, 63, 973, 14, 3472, 63, 13990, 459, 11450, 63, 515, 418, 523, 7994, 63, 515, 275, 4866, 63, 571, 1000, 63, 973, 14, 3472, 63, 13990, 459, 5570, 63, 515, 418, 523, 12007, 63, 515, 275, 12007, 63, 515, 14, 1814, 480, 2374, 63, 571, 1000, 401, 298, 1176, 4970, 83, 2, 450, 1145, 344, 9, 523, 7994, 63, 515, 275, 7994, 63, 515, 14, 1814, 480, 2374, 63, 571, 1000, 401, 298, 1176, 4970, 83, 2, 450, 1145, 344, 9, 523, 372, 12007, 63, 515, 12, 7994, 63, 515, 421, 199, 318, 664, 63, 396, 63, 11450, 63, 3771, 8, 262, 4844, 29, 549, 304, 523, 408, 3407, 282, 2008, 543, 314, 931, 370, 314, 511, 12007, 436, 7994, 570, 14, 819, 982, 315, 4844, 365, 2549, 12, 334, 403, 12, 488, 9, 365, 2138, 370, 1056, 376, 315, 13, 4844, 523, 12007, 14, 982, 315, 4844, 365, 3055, 314, 931, 2138, 911, 506, 8545, 370, 314, 931, 523, 2138, 701, 664, 63, 11450, 63, 3771, 1325, 543, 282, 3365, 536, 14, 819, 1803, 26, 272, 334, 11450, 63, 515, 12, 7994, 63, 515, 9, 523, 408, 523, 340, 315, 4844, 26, 272, 372, 488, 12, 488, 523, 12007, 63, 515, 12, 7994, 63, 515, 275, 664, 63, 11450, 63, 3771, 342, 523, 12007, 63, 515, 275, 12007, 63, 515, 14, 1814, 480, 11450, 401, 298, 396, 11450, 531, 523, 7994, 63, 515, 275, 7994, 63, 515, 14, 1814, 480, 11450, 401, 298, 396, 11450, 531, 523, 372, 12007, 63, 515, 12, 7994, 63, 515, 421, 199, 318, 11972, 63, 11450, 8, 11450, 63, 515, 12, 7994, 63, 515, 304, 523, 408, 8004, 293, 588, 314, 1145, 3908, 12007, 737, 314, 2013, 3792, 1041, 523, 367, 931, 315, 359, 11450, 63, 515, 12, 7994, 63, 515, 2189, 272, 340, 440, 931, 26, 1980, 272, 862, 26, 489, 747, 14, 2168, 8, 515, 9, 272, 871, 6440, 12, 325, 26, 489, 340, 325, 14, 7931, 1137, 499, 26, 267, 2050, 14, 705, 480, 4276, 370, 5436, 12007, 26, 450, 83, 2, 450, 325, 9, 421, 199, 533, 27728, 8, 1726, 304, 523, 408, 8067, 1021, 367, 3050, 2552, 14, 11105, 701, 5634, 624, 523, 986, 421, 199, 533, 26864, 8, 1726, 304, 523, 408, 8067, 1021, 367, 3050, 4661, 12997, 2552, 14, 11105, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 10807, 8, 1563, 7243, 10807, 304, 523, 408, 8067, 1021, 370, 5647, 314, 1964, 65, 1482, 3653, 1420, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 12929, 8, 1563, 7243, 12929, 304, 523, 408, 8067, 1021, 370, 5647, 314, 1511, 3653, 1420, 701, 5634, 624, 523, 986, 421, 199, 533, 8692, 4590, 8, 1563, 7243, 4590, 304, 523, 408, 2640, 12580, 3050, 5492, 367, 5634, 14, 819, 961, 298, 4659, 2, 4865, 1630, 440, 2291, 1263, 402, 314, 4465, 4865, 523, 5331, 14, 710, 1454, 2120, 626, 652, 18628, 365, 370, 3272, 314, 2986, 22312, 1415, 523, 701, 314, 1145, 3908, 8363, 340, 2985, 1172, 440, 2575, 2757, 2536, 9096, 701, 376, 523, 1145, 1000, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 7243, 4590, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 272, 291, 14, 3179, 275, 8692, 10807, 342, 272, 291, 14, 1483, 275, 8692, 12929, 342, 272, 291, 14, 8782, 275, 8692, 13921, 8, 277, 9, 272, 291, 14, 1180, 63, 396, 63, 11450, 275, 2074, 14, 362, 480, 1180, 63, 396, 63, 11450, 401, 756, 9, 272, 291, 14, 396, 63, 11450, 63, 262, 4844, 275, 2074, 14, 362, 480, 396, 63, 11450, 63, 262, 4844, 401, 715, 9, 272, 340, 1172, 63, 571, 1000, 26, 489, 372, 272, 291, 423, 2758, 63, 8957, 342, 819, 347, 485, 362, 63, 3771, 8, 277, 304, 272, 340, 291, 14, 1180, 63, 396, 63, 11450, 26, 489, 372, 664, 63, 396, 63, 11450, 63, 3771, 8, 277, 14, 396, 63, 11450, 63, 262, 4844, 9, 272, 587, 26, 489, 372, 664, 63, 11450, 63, 3771, 342, 819, 347, 485, 2758, 63, 8957, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
zenhacklab/OpenBazaar
ecdsa/util.py
14
9864
from __future__ import division import os import math import binascii from hashlib import sha256 from . import der from .curves import orderlen from .six import PY3, int2byte, b, next # RFC5480: # The "unrestricted" algorithm identifier is: # id-ecPublicKey OBJECT IDENTIFIER ::= { # iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } oid_ecPublicKey = (1, 2, 840, 10045, 2, 1) encoded_oid_ecPublicKey = der.encode_oid(*oid_ecPublicKey) def randrange(order, entropy=None): """Return a random integer k such that 1 <= k < order, uniformly distributed across that range. For simplicity, this only behaves well if 'order' is fairly close (but below) a power of 256. The try-try-again algorithm we use takes longer and longer time (on average) to complete as 'order' falls, rising to a maximum of avg=512 loops for the worst-case (256**k)+1 . All of the standard curves behave well. There is a cutoff at 10k loops (which raises RuntimeError) to prevent an infinite loop when something is really broken like the entropy function not working. Note that this function is not declared to be forwards-compatible: we may change the behavior in future releases. The entropy= argument (which should get a callable that behaves like os.entropy) can be used to achieve stability within a given release (for repeatable unit tests), but should not be used as a long-term-compatible key generation algorithm. """ # we could handle arbitrary orders (even 256**k+1) better if we created # candidates bit-wise instead of byte-wise, which would reduce the # worst-case behavior to avg=2 loops, but that would be more complex. The # change would be to round the order up to a power of 256, subtract one # (to get 0xffff..), use that to get a byte-long mask for the top byte, # generate the len-1 entropy bytes, generate one extra byte and mask off # the top bits, then combine it with the rest. Requires jumping back and # forth between strings and integers a lot. if entropy is None: entropy = os.urandom assert order > 1 bytes = orderlen(order) dont_try_forever = 10000 # gives about 2**-60 failures for worst case while dont_try_forever > 0: dont_try_forever -= 1 candidate = string_to_number(entropy(bytes)) + 1 if 1 <= candidate < order: return candidate continue raise RuntimeError("randrange() tried hard but gave up, either something" " is very wrong or you got realllly unlucky. Order was" " %x" % order) class PRNG: # this returns a callable which, when invoked with an integer N, will # return N pseudorandom bytes. Note: this is a short-term PRNG, meant # primarily for the needs of randrange_from_seed__trytryagain(), which # only needs to run it a few times per seed. It does not provide # protection against state compromise (forward security). def __init__(self, seed): self.generator = self.block_generator(seed) def __call__(self, numbytes): a = [next(self.generator) for i in range(numbytes)] if PY3: return bytes(a) else: return "".join(a) def block_generator(self, seed): counter = 0 while True: for byte in sha256(("prng-%d-%s" % (counter, seed)).encode()).digest(): yield byte counter += 1 def randrange_from_seed__overshoot_modulo(seed, order): # hash the data, then turn the digest into a number in [1,order). # # We use David-Sarah Hopwood's suggestion: turn it into a number that's # sufficiently larger than the group order, then modulo it down to fit. # This should give adequate (but not perfect) uniformity, and simple # code. There are other choices: try-try-again is the main one. base = PRNG(seed)(2*orderlen(order)) number = (int(binascii.hexlify(base), 16) % (order-1)) + 1 assert 1 <= number < order, (1, number, order) return number def lsb_of_ones(numbits): return (1 << numbits) - 1 def bits_and_bytes(order): bits = int(math.log(order-1, 2)+1) bytes = bits // 8 extrabits = bits % 8 return bits, bytes, extrabits # the following randrange_from_seed__METHOD() functions take an # arbitrarily-sized secret seed and turn it into a number that obeys the same # range limits as randrange() above. They are meant for deriving consistent # signing keys from a secret rather than generating them randomly, for # example a protocol in which three signing keys are derived from a master # secret. You should use a uniformly-distributed unguessable seed with about # curve.baselen bytes of entropy. To use one, do this: # seed = os.urandom(curve.baselen) # or other starting point # secexp = ecdsa.util.randrange_from_seed__trytryagain(sed, curve.order) # sk = SigningKey.from_secret_exponent(secexp, curve) def randrange_from_seed__truncate_bytes(seed, order, hashmod=sha256): # hash the seed, then turn the digest into a number in [1,order), but # don't worry about trying to uniformly fill the range. This will lose, # on average, four bits of entropy. bits, bytes, extrabits = bits_and_bytes(order) if extrabits: bytes += 1 base = hashmod(seed).digest()[:bytes] base = "\x00"*(bytes-len(base)) + base number = 1+int(binascii.hexlify(base), 16) assert 1 <= number < order return number def randrange_from_seed__truncate_bits(seed, order, hashmod=sha256): # like string_to_randrange_truncate_bytes, but only lose an average of # half a bit bits = int(math.log(order-1, 2)+1) maxbytes = (bits+7) // 8 base = hashmod(seed).digest()[:maxbytes] base = "\x00"*(maxbytes-len(base)) + base topbits = 8*maxbytes - bits if topbits: base = int2byte(ord(base[0]) & lsb_of_ones(topbits)) + base[1:] number = 1+int(binascii.hexlify(base), 16) assert 1 <= number < order return number def randrange_from_seed__trytryagain(seed, order): # figure out exactly how many bits we need (rounded up to the nearest # bit), so we can reduce the chance of looping to less than 0.5 . This is # specified to feed from a byte-oriented PRNG, and discards the # high-order bits of the first byte as necessary to get the right number # of bits. The average number of loops will range from 1.0 (when # order=2**k-1) to 2.0 (when order=2**k+1). assert order > 1 bits, bytes, extrabits = bits_and_bytes(order) generate = PRNG(seed) while True: extrabyte = b("") if extrabits: extrabyte = int2byte(ord(generate(1)) & lsb_of_ones(extrabits)) guess = string_to_number(extrabyte + generate(bytes)) + 1 if 1 <= guess < order: return guess def number_to_string(num, order): l = orderlen(order) fmt_str = "%0" + str(2*l) + "x" string = binascii.unhexlify((fmt_str % num).encode()) assert len(string) == l, (len(string), l) return string def number_to_string_crop(num, order): l = orderlen(order) fmt_str = "%0" + str(2*l) + "x" string = binascii.unhexlify((fmt_str % num).encode()) return string[:l] def string_to_number(string): return int(binascii.hexlify(string), 16) def string_to_number_fixedlen(string, order): l = orderlen(order) assert len(string) == l, (len(string), l) return int(binascii.hexlify(string), 16) # these methods are useful for the sigencode= argument to SK.sign() and the # sigdecode= argument to VK.verify(), and control how the signature is packed # or unpacked. def sigencode_strings(r, s, order): r_str = number_to_string(r, order) s_str = number_to_string(s, order) return (r_str, s_str) def sigencode_string(r, s, order): # for any given curve, the size of the signature numbers is # fixed, so just use simple concatenation r_str, s_str = sigencode_strings(r, s, order) return r_str + s_str def sigencode_der(r, s, order): return der.encode_sequence(der.encode_integer(r), der.encode_integer(s)) # canonical versions of sigencode methods # these enforce low S values, by negating the value (modulo the order) if above order/2 # see CECKey::Sign() https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp#L214 def sigencode_strings_canonize(r, s, order): if s > order / 2: s = order - s return sigencode_strings(r, s, order) def sigencode_string_canonize(r, s, order): if s > order / 2: s = order - s return sigencode_string(r, s, order) def sigencode_der_canonize(r, s, order): if s > order / 2: s = order - s return sigencode_der(r, s, order) def sigdecode_string(signature, order): l = orderlen(order) assert len(signature) == 2*l, (len(signature), 2*l) r = string_to_number_fixedlen(signature[:l], order) s = string_to_number_fixedlen(signature[l:], order) return r, s def sigdecode_strings(rs_strings, order): (r_str, s_str) = rs_strings l = orderlen(order) assert len(r_str) == l, (len(r_str), l) assert len(s_str) == l, (len(s_str), l) r = string_to_number_fixedlen(r_str, order) s = string_to_number_fixedlen(s_str, order) return r, s def sigdecode_der(sig_der, order): #return der.encode_sequence(der.encode_integer(r), der.encode_integer(s)) rs_strings, empty = der.remove_sequence(sig_der) if empty != b(""): raise der.UnexpectedDER("trailing junk after DER sig: %s" % binascii.hexlify(empty)) r, rest = der.remove_integer(rs_strings) s, empty = der.remove_integer(rest) if empty != b(""): raise der.UnexpectedDER("trailing junk after DER numbers: %s" % binascii.hexlify(empty)) return r, s
agpl-3.0
[ 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 646, 3473, 199, 646, 14755, 199, 504, 8337, 492, 7793, 3912, 199, 504, 1275, 492, 16921, 199, 504, 1275, 31559, 492, 1865, 552, 199, 504, 1275, 4174, 492, 7843, 19, 12, 1109, 18, 4414, 12, 330, 12, 2163, 199, 199, 3, 7329, 1477, 1257, 26, 199, 3, 257, 710, 298, 324, 17973, 2, 5563, 5148, 365, 26, 199, 3, 258, 1305, 13, 825, 26238, 28652, 5550, 26179, 16910, 11351, 469, 199, 3, 755, 11601, 8, 17, 9, 3653, 13, 2030, 8, 18, 9, 2739, 8, 13462, 9, 376, 338, 13, 56, 25, 13, 2789, 8, 1960, 2322, 9, 790, 804, 8, 18, 9, 413, 789, 199, 199, 1170, 63, 825, 26238, 275, 334, 17, 12, 499, 12, 29675, 12, 2948, 2322, 12, 499, 12, 413, 9, 199, 8167, 63, 1170, 63, 825, 26238, 275, 16921, 14, 2143, 63, 1170, 2031, 1170, 63, 825, 26238, 9, 199, 199, 318, 10261, 1842, 8, 1648, 12, 19490, 29, 403, 304, 272, 408, 1767, 282, 2196, 3000, 1022, 4066, 626, 413, 2695, 1022, 665, 1865, 12, 14818, 590, 272, 1854, 9371, 626, 1425, 14, 2104, 17553, 3690, 12, 642, 1454, 25113, 5521, 340, 272, 283, 1648, 7, 365, 28092, 590, 4002, 334, 7911, 5084, 9, 282, 7074, 402, 7633, 14, 710, 862, 13, 893, 13, 14199, 272, 5563, 781, 675, 6181, 8088, 436, 8088, 900, 334, 265, 8095, 9, 370, 4890, 465, 272, 283, 1648, 7, 26945, 12, 8012, 1044, 370, 282, 5696, 402, 12402, 29, 7736, 17222, 367, 314, 1319, 270, 13, 2546, 272, 334, 3912, 538, 75, 6393, 17, 1275, 2900, 402, 314, 4465, 1094, 2310, 24062, 5521, 14, 6006, 365, 282, 17875, 737, 272, 1616, 75, 17222, 334, 6777, 6534, 6064, 9, 370, 7981, 376, 15258, 4438, 1380, 272, 6020, 365, 7710, 10529, 2839, 314, 19490, 805, 440, 6449, 14, 339, 3390, 626, 642, 805, 365, 440, 14290, 370, 506, 17465, 13, 6490, 26, 781, 1443, 272, 1570, 314, 5953, 315, 6466, 19015, 14, 710, 19490, 29, 1423, 334, 6777, 272, 1077, 664, 282, 4550, 626, 25113, 2839, 747, 14, 10435, 9, 883, 506, 1202, 370, 272, 32194, 410, 3616, 4453, 282, 1627, 4683, 334, 509, 11982, 461, 4137, 2295, 395, 1325, 272, 1077, 440, 506, 1202, 465, 282, 1846, 13, 5125, 13, 6490, 790, 10152, 5563, 14, 272, 408, 272, 327, 781, 4293, 2429, 9697, 15460, 334, 12056, 7633, 538, 75, 11, 17, 9, 8034, 340, 781, 2737, 272, 327, 15101, 4546, 13, 2605, 3140, 402, 3696, 13, 2605, 12, 1314, 3955, 7114, 314, 272, 327, 1319, 270, 13, 2546, 5953, 370, 12402, 29, 18, 17222, 12, 1325, 626, 3955, 506, 1655, 6114, 14, 710, 272, 327, 1570, 3955, 506, 370, 6168, 314, 1865, 1536, 370, 282, 7074, 402, 7633, 12, 24129, 1373, 272, 327, 334, 475, 664, 378, 27581, 703, 395, 675, 626, 370, 664, 282, 3696, 13, 2809, 3656, 367, 314, 2746, 3696, 12, 272, 327, 3550, 314, 822, 13, 17, 19490, 2783, 12, 3550, 1373, 2402, 3696, 436, 3656, 2331, 272, 327, 314, 2746, 5821, 12, 2066, 13323, 652, 543, 314, 4618, 14, 15127, 14882, 316, 1771, 436, 272, 327, 367, 273, 3382, 3326, 436, 9446, 282, 13918, 14, 339, 340, 19490, 365, 488, 26, 267, 19490, 275, 747, 14, 22776, 272, 702, 1865, 690, 413, 272, 2783, 275, 1865, 552, 8, 1648, 9, 272, 21542, 63, 893, 63, 21327, 275, 11630, 327, 10557, 3595, 499, 25376, 2259, 9081, 367, 1319, 270, 1930, 272, 1830, 21542, 63, 893, 63, 21327, 690, 378, 26, 267, 21542, 63, 893, 63, 21327, 4862, 413, 267, 7627, 275, 1059, 63, 475, 63, 1955, 8, 10435, 8, 2394, 430, 435, 413, 267, 340, 413, 2695, 7627, 665, 1865, 26, 288, 372, 7627, 267, 1980, 272, 746, 6064, 480, 20539, 342, 16416, 7508, 1325, 486, 811, 1536, 12, 1902, 6020, 2, 2432, 298, 365, 7437, 6835, 503, 1265, 4788, 295, 452, 76, 590, 625, 76, 10112, 89, 14, 9240, 1990, 2, 2432, 298, 450, 88, 2, 450, 1865, 9, 199, 199, 533, 12218, 12259, 26, 272, 327, 642, 2529, 282, 4550, 1314, 12, 1380, 10302, 543, 376, 3000, 653, 12, 911, 272, 327, 372, 653, 299, 261, 1181, 269, 1241, 2783, 14, 3390, 26, 642, 365, 282, 3974, 13, 5125, 12218, 12259, 12, 18329, 272, 327, 1979, 30468, 367, 314, 4839, 402, 10261, 1842, 63, 504, 63, 5176, 363, 893, 893, 14199, 1062, 1314, 272, 327, 1454, 4839, 370, 1255, 652, 282, 9284, 5431, 1126, 6347, 14, 2779, 1630, 440, 5647, 272, 327, 23977, 6169, 1174, 1013, 417, 572, 334, 6688, 6391, 680, 272, 347, 636, 826, 721, 277, 12, 6347, 304, 267, 291, 14, 4679, 275, 291, 14, 1457, 63, 4679, 8, 5176, 9, 339, 347, 636, 1250, 721, 277, 12, 1967, 2394, 304, 267, 282, 275, 359, 2184, 8, 277, 14, 4679, 9, 367, 284, 315, 1425, 8, 1507, 2394, 1874, 398, 340, 7843, 19, 26, 288, 372, 2783, 8, 65, 9, 267, 587, 26, 288, 372, 10587, 904, 8, 65, 9, 2378, 347, 1853, 63, 4679, 8, 277, 12, 6347, 304, 267, 7055, 275, 378, 267, 1830, 715, 26, 288, 367, 3696, 315, 7793, 3912, 9313, 2700, 2753, 3295, 68, 3295, 83, 2, 450, 334, 5337, 12, 6347, 4992, 2143, 8801, 5671, 837, 355, 1995, 3696, 288, 7055, 847, 413, 199, 199, 318, 10261, 1842, 63, 504, 63, 5176, 363, 1883, 13927, 357, 63, 1494, 13957, 8, 5176, 12, 1865, 304, 272, 327, 2631, 314, 666, 12, 2066, 7485, 314, 10017, 1901, 282, 1329, 315, 359, 17, 12, 1648, 680, 272, 327, 272, 327, 2136, 675, 20232, 13, 51, 285, 11326, 869, 411, 22736, 1159, 18453, 1636, 26, 7485, 652, 1901, 282, 1329, 626, 1159, 272, 327, 19258, 590, 12142, 2419, 314, 1572, 1865, 12, 2066, 27656, 652, 3224, 370, 5542, 14, 272, 327, 961, 1077, 8120, 282, 271, 392, 323, 334, 7911, 440, 23668, 9, 14818, 1209, 12, 436, 3486, 272, 327, 1233, 14, 6006, 787, 1163, 3415, 26, 862, 13, 893, 13, 14199, 365, 314, 2446, 1373, 14, 272, 1300, 275, 12218, 12259, 8, 5176, 5130, 18, 10, 1648, 552, 8, 1648, 430, 272, 1329, 275, 334, 442, 8, 27460, 14 ]
[ 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 646, 3473, 199, 646, 14755, 199, 504, 8337, 492, 7793, 3912, 199, 504, 1275, 492, 16921, 199, 504, 1275, 31559, 492, 1865, 552, 199, 504, 1275, 4174, 492, 7843, 19, 12, 1109, 18, 4414, 12, 330, 12, 2163, 199, 199, 3, 7329, 1477, 1257, 26, 199, 3, 257, 710, 298, 324, 17973, 2, 5563, 5148, 365, 26, 199, 3, 258, 1305, 13, 825, 26238, 28652, 5550, 26179, 16910, 11351, 469, 199, 3, 755, 11601, 8, 17, 9, 3653, 13, 2030, 8, 18, 9, 2739, 8, 13462, 9, 376, 338, 13, 56, 25, 13, 2789, 8, 1960, 2322, 9, 790, 804, 8, 18, 9, 413, 789, 199, 199, 1170, 63, 825, 26238, 275, 334, 17, 12, 499, 12, 29675, 12, 2948, 2322, 12, 499, 12, 413, 9, 199, 8167, 63, 1170, 63, 825, 26238, 275, 16921, 14, 2143, 63, 1170, 2031, 1170, 63, 825, 26238, 9, 199, 199, 318, 10261, 1842, 8, 1648, 12, 19490, 29, 403, 304, 272, 408, 1767, 282, 2196, 3000, 1022, 4066, 626, 413, 2695, 1022, 665, 1865, 12, 14818, 590, 272, 1854, 9371, 626, 1425, 14, 2104, 17553, 3690, 12, 642, 1454, 25113, 5521, 340, 272, 283, 1648, 7, 365, 28092, 590, 4002, 334, 7911, 5084, 9, 282, 7074, 402, 7633, 14, 710, 862, 13, 893, 13, 14199, 272, 5563, 781, 675, 6181, 8088, 436, 8088, 900, 334, 265, 8095, 9, 370, 4890, 465, 272, 283, 1648, 7, 26945, 12, 8012, 1044, 370, 282, 5696, 402, 12402, 29, 7736, 17222, 367, 314, 1319, 270, 13, 2546, 272, 334, 3912, 538, 75, 6393, 17, 1275, 2900, 402, 314, 4465, 1094, 2310, 24062, 5521, 14, 6006, 365, 282, 17875, 737, 272, 1616, 75, 17222, 334, 6777, 6534, 6064, 9, 370, 7981, 376, 15258, 4438, 1380, 272, 6020, 365, 7710, 10529, 2839, 314, 19490, 805, 440, 6449, 14, 339, 3390, 626, 642, 805, 365, 440, 14290, 370, 506, 17465, 13, 6490, 26, 781, 1443, 272, 1570, 314, 5953, 315, 6466, 19015, 14, 710, 19490, 29, 1423, 334, 6777, 272, 1077, 664, 282, 4550, 626, 25113, 2839, 747, 14, 10435, 9, 883, 506, 1202, 370, 272, 32194, 410, 3616, 4453, 282, 1627, 4683, 334, 509, 11982, 461, 4137, 2295, 395, 1325, 272, 1077, 440, 506, 1202, 465, 282, 1846, 13, 5125, 13, 6490, 790, 10152, 5563, 14, 272, 408, 272, 327, 781, 4293, 2429, 9697, 15460, 334, 12056, 7633, 538, 75, 11, 17, 9, 8034, 340, 781, 2737, 272, 327, 15101, 4546, 13, 2605, 3140, 402, 3696, 13, 2605, 12, 1314, 3955, 7114, 314, 272, 327, 1319, 270, 13, 2546, 5953, 370, 12402, 29, 18, 17222, 12, 1325, 626, 3955, 506, 1655, 6114, 14, 710, 272, 327, 1570, 3955, 506, 370, 6168, 314, 1865, 1536, 370, 282, 7074, 402, 7633, 12, 24129, 1373, 272, 327, 334, 475, 664, 378, 27581, 703, 395, 675, 626, 370, 664, 282, 3696, 13, 2809, 3656, 367, 314, 2746, 3696, 12, 272, 327, 3550, 314, 822, 13, 17, 19490, 2783, 12, 3550, 1373, 2402, 3696, 436, 3656, 2331, 272, 327, 314, 2746, 5821, 12, 2066, 13323, 652, 543, 314, 4618, 14, 15127, 14882, 316, 1771, 436, 272, 327, 367, 273, 3382, 3326, 436, 9446, 282, 13918, 14, 339, 340, 19490, 365, 488, 26, 267, 19490, 275, 747, 14, 22776, 272, 702, 1865, 690, 413, 272, 2783, 275, 1865, 552, 8, 1648, 9, 272, 21542, 63, 893, 63, 21327, 275, 11630, 327, 10557, 3595, 499, 25376, 2259, 9081, 367, 1319, 270, 1930, 272, 1830, 21542, 63, 893, 63, 21327, 690, 378, 26, 267, 21542, 63, 893, 63, 21327, 4862, 413, 267, 7627, 275, 1059, 63, 475, 63, 1955, 8, 10435, 8, 2394, 430, 435, 413, 267, 340, 413, 2695, 7627, 665, 1865, 26, 288, 372, 7627, 267, 1980, 272, 746, 6064, 480, 20539, 342, 16416, 7508, 1325, 486, 811, 1536, 12, 1902, 6020, 2, 2432, 298, 365, 7437, 6835, 503, 1265, 4788, 295, 452, 76, 590, 625, 76, 10112, 89, 14, 9240, 1990, 2, 2432, 298, 450, 88, 2, 450, 1865, 9, 199, 199, 533, 12218, 12259, 26, 272, 327, 642, 2529, 282, 4550, 1314, 12, 1380, 10302, 543, 376, 3000, 653, 12, 911, 272, 327, 372, 653, 299, 261, 1181, 269, 1241, 2783, 14, 3390, 26, 642, 365, 282, 3974, 13, 5125, 12218, 12259, 12, 18329, 272, 327, 1979, 30468, 367, 314, 4839, 402, 10261, 1842, 63, 504, 63, 5176, 363, 893, 893, 14199, 1062, 1314, 272, 327, 1454, 4839, 370, 1255, 652, 282, 9284, 5431, 1126, 6347, 14, 2779, 1630, 440, 5647, 272, 327, 23977, 6169, 1174, 1013, 417, 572, 334, 6688, 6391, 680, 272, 347, 636, 826, 721, 277, 12, 6347, 304, 267, 291, 14, 4679, 275, 291, 14, 1457, 63, 4679, 8, 5176, 9, 339, 347, 636, 1250, 721, 277, 12, 1967, 2394, 304, 267, 282, 275, 359, 2184, 8, 277, 14, 4679, 9, 367, 284, 315, 1425, 8, 1507, 2394, 1874, 398, 340, 7843, 19, 26, 288, 372, 2783, 8, 65, 9, 267, 587, 26, 288, 372, 10587, 904, 8, 65, 9, 2378, 347, 1853, 63, 4679, 8, 277, 12, 6347, 304, 267, 7055, 275, 378, 267, 1830, 715, 26, 288, 367, 3696, 315, 7793, 3912, 9313, 2700, 2753, 3295, 68, 3295, 83, 2, 450, 334, 5337, 12, 6347, 4992, 2143, 8801, 5671, 837, 355, 1995, 3696, 288, 7055, 847, 413, 199, 199, 318, 10261, 1842, 63, 504, 63, 5176, 363, 1883, 13927, 357, 63, 1494, 13957, 8, 5176, 12, 1865, 304, 272, 327, 2631, 314, 666, 12, 2066, 7485, 314, 10017, 1901, 282, 1329, 315, 359, 17, 12, 1648, 680, 272, 327, 272, 327, 2136, 675, 20232, 13, 51, 285, 11326, 869, 411, 22736, 1159, 18453, 1636, 26, 7485, 652, 1901, 282, 1329, 626, 1159, 272, 327, 19258, 590, 12142, 2419, 314, 1572, 1865, 12, 2066, 27656, 652, 3224, 370, 5542, 14, 272, 327, 961, 1077, 8120, 282, 271, 392, 323, 334, 7911, 440, 23668, 9, 14818, 1209, 12, 436, 3486, 272, 327, 1233, 14, 6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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ksmit799/Toontown-Source
toontown/minigame/DistributedVineGameAI.py
1
12010
from DistributedMinigameAI import * from direct.fsm import ClassicFSM, State from direct.fsm import State import VineGameGlobals class DistributedVineGameAI(DistributedMinigameAI): def __init__(self, air, minigameId): try: self.DistributedVineGameAI_initialized except: self.DistributedVineGameAI_initialized = 1 DistributedMinigameAI.__init__(self, air, minigameId) self.gameFSM = ClassicFSM.ClassicFSM('DistributedVineGameAI', [State.State('inactive', self.enterInactive, self.exitInactive, ['play']), State.State('play', self.enterPlay, self.exitPlay, ['cleanup', 'waitShowScores']), State.State('waitShowScores', self.enterWaitShowScores, self.exitWaitShowScores, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, ['inactive'])], 'inactive', 'inactive') self.toonInfo = {} self.addChildGameFSM(self.gameFSM) self.vineSections = [] self.finishedBonus = {} self.finishedTimeLeft = {} self.totalSpiders = 0 self.calculatedPartialBeans = False def generate(self): self.notify.debug('generate') DistributedMinigameAI.generate(self) def delete(self): self.notify.debug('delete') del self.gameFSM DistributedMinigameAI.delete(self) def _playing(self): if not hasattr(self, 'gameFSM'): return False if self.gameFSM.getCurrentState() == None: return False return self.gameFSM.getCurrentState().getName() == 'play' def setGameReady(self): self.notify.debug('setGameReady') for avId in self.avIdList: self.updateToonInfo(avId, vineIndex=0, vineT=VineGameGlobals.VineStartingT) DistributedMinigameAI.setGameReady(self) self.numTreasures = VineGameGlobals.NumVines - 1 self.numTreasuresTaken = 0 self.takenTable = [0] * self.numTreasures for avId in self.scoreDict.keys(): self.scoreDict[avId] = 0 self.finishedBonus[avId] = 0 self.finishedTimeLeft[avId] = -1 def setGameStart(self, timestamp): self.notify.debug('setGameStart') DistributedMinigameAI.setGameStart(self, timestamp) self.gameFSM.request('play') def setGameAbort(self): self.notify.debug('setGameAbort') if self.gameFSM.getCurrentState(): self.gameFSM.request('cleanup') DistributedMinigameAI.setGameAbort(self) def gameOver(self): self.notify.debug('gameOver') vineReached = [] scoreList = [] finishedList = [] timeLeftList = [] for avId in self.avIdList: vineReached.append(self.toonInfo[avId][0]) scoreList.append(self.scoreDict[avId]) finishedList.append(self.finishedBonus[avId]) timeLeftList.append(self.finishedTimeLeft[avId]) totalBats = len(VineGameGlobals.BatInfo[self.getSafezoneId()]) self.air.writeServerEvent('minigame_vine', self.doId, '%s|%s|%s|%s|%s|%s|%s|%s|%s|%s' % (ToontownGlobals.VineGameId, self.getSafezoneId(), self.avIdList, scoreList, self.vineSections, finishedList, timeLeftList, vineReached, self.totalSpiders, totalBats)) self.gameFSM.request('cleanup') DistributedMinigameAI.gameOver(self) def enterInactive(self): self.notify.debug('enterInactive') def exitInactive(self): pass def enterPlay(self): self.notify.debug('enterPlay') self.vines = [] index = 0 taskMgr.doMethodLater(VineGameGlobals.GameDuration, self.timerExpired, self.taskName('gameTimer')) def exitPlay(self): taskMgr.remove(self.taskName('gameTimer')) for vine in self.vines: vine.requestDelete() def enterCleanup(self): self.notify.debug('enterCleanup') self.gameFSM.request('inactive') def exitCleanup(self): pass def claimTreasure(self, treasureNum): if not self._playing(): return avId = self.air.getAvatarIdFromSender() if not self.scoreDict.has_key(avId): self.notify.warning('PROBLEM: avatar %s called claimTreasure(%s) but he is not in the scoreDict: %s. avIdList is: %s' % (avId, treasureNum, self.scoreDict, self.avIdList)) return if treasureNum < 0 or treasureNum >= self.numTreasures: self.air.writeServerEvent('warning', treasureNum, 'MazeGameAI.claimTreasure treasureNum out of range') return if self.takenTable[treasureNum]: return self.takenTable[treasureNum] = 1 avId = self.air.getAvatarIdFromSender() self.sendUpdate('setTreasureGrabbed', [avId, treasureNum]) self.scoreDict[avId] += 1 self.numTreasuresTaken += 1 def timerExpired(self, task): self.notify.debug('timer expired') if not VineGameGlobals.EndlessGame: self.gameFSM.request('waitShowScores') return Task.done def enterWaitShowScores(self): self.notify.debug('enterWaitShowScores') self.awardPartialBeans() taskMgr.doMethodLater(VineGameGlobals.ShowScoresDuration, self.__doneShowingScores, self.taskName('waitShowScores')) def __doneShowingScores(self, task): self.notify.debug('doneShowingScores') self.gameOver() return Task.done def exitWaitShowScores(self): taskMgr.remove(self.taskName('waitShowScores')) def reachedEndVine(self, vineIndex): self.notify.debug('reachedEndVine') return avId = self.air.getAvatarIdFromSender() oldVineIndex = self.toonInfo[avId][0] self.updateToonInfo(avId, vineIndex=vineIndex) if not oldVineIndex == vineIndex: self.checkForEndVine(avId) self.checkForEndGame() def setNewVine(self, avId, vineIndex, vineT, facingRight): self.notify.debug('setNewVine') if not self._playing(): return if avId not in self.avIdList: self.air.writeServerEvent('suspicious', avId, 'VineGameAI.setNewVine: invalid avId') return oldVineIndex = self.toonInfo[avId][0] debugStr = 'setNewVine doId=%s avId=%d vineIndex=%s oldVineIndex=%s' % (self.doId, avId, vineIndex, oldVineIndex) self.updateToonInfo(avId, vineIndex=vineIndex, vineT=vineT, facingRight=facingRight) if not oldVineIndex == vineIndex: self.checkForEndVine(avId) self.checkForEndGame() def checkForEndGame(self): allDone = True for avId in self.toonInfo: if not self.toonInfo[avId][0] == VineGameGlobals.NumVines - 1: allDone = False break if allDone: if not VineGameGlobals.EndlessGame: self.awardPartialBeans() self.sendUpdate('allAtEndVine', []) self.gameOver() def checkForEndVine(self, avId): if self.toonInfo[avId][0] == VineGameGlobals.NumVines - 1: curTime = self.getCurrentGameTime() timeLeft = VineGameGlobals.GameDuration - curTime self.notify.debug('curTime =%s timeLeft = %s' % (curTime, timeLeft)) if not self.scoreDict.has_key(avId): self.notify.warning('PROBLEM: avatar %s called claimTreasure(%s) but he is not in the scoreDict: %s. avIdList is: %s' % (avId, treasureNum, self.scoreDict, self.avIdList)) return addBonus = int(VineGameGlobals.BaseBonusOnEndVine[self.getSafezoneId()] + VineGameGlobals.BonusPerSecondLeft * timeLeft) self.notify.debug('addBOnus = %d' % addBonus) if addBonus < 0: addBonus = 0 self.finishedBonus[avId] = addBonus timeLeftStr = '%.1f' % timeLeft self.finishedTimeLeft[avId] = timeLeftStr self.scoreDict[avId] += addBonus self.sendUpdate('setScore', [avId, self.scoreDict[avId]]) def updateToonInfo(self, avId, vineIndex = None, vineT = None, posX = None, posZ = None, facingRight = None, climbDir = None, velX = None, velZ = None): newVineIndex = vineIndex newVineT = vineT newPosX = posX newPosZ = posZ newFacingRight = facingRight newClimbDir = climbDir newVelX = velX newVelZ = velZ oldInfo = None if self.toonInfo.has_key(avId): oldInfo = self.toonInfo[avId] if vineIndex == None: newVineIndex = oldInfo[0] if vineT == None: newVineT = oldInfo[1] if posX == None: newPosX = oldInfo[2] if posZ == None: newPosZ = oldInfo[3] if facingRight == None: newFacingRight = oldInfo[4] if climbDir == None: newClimbDir = oldInfo[5] if velX == None: newVelX = oldInfo[6] if velZ == None: newVelZ = oldInfo[7] if newVineIndex < -1 or newVineIndex >= VineGameGlobals.NumVines: newVineIndex = 0 if newVineT < 0 or newVineT > 1: pass if not newFacingRight == 0 and not newFacingRight == 1: newFacingRight = 1 if newPosX < -1000 or newPosX > 2000: newPosX = 0 if newPosZ < -100 or newPosZ > 1000: newPosZ = 0 if newVelX < -1000 or newVelX > 1000: newVelX = 0 if newVelZ < -1000 or newVelZ > 1000: newVelZ = 0 newInfo = [newVineIndex, newVineT, newPosX, newPosZ, newFacingRight, newClimbDir, newVelX, newVelZ] self.toonInfo[avId] = newInfo return def setupVineSections(self): szId = self.getSafezoneId() courseWeights = VineGameGlobals.CourseWeights[szId] pool = [[], [], [], [], [], []] for weights in courseWeights: section, chances = weights numSpiders = VineGameGlobals.getNumSpidersInSection(section) pool[numSpiders] += [section] * chances maxSpiders = VineGameGlobals.SpiderLimits[szId] curSpiders = 0 for i in range(4): spidersLeft = maxSpiders - curSpiders validChoices = [] for numSpiders in range(spidersLeft + 1): validChoices += pool[numSpiders] if not validChoices: self.notify.warning('we ran out of valid choices szId=%s, vineSections=%s' % (szId, self.vineSections)) validChoices += [0] section = random.choice(validChoices) curSpiders += VineGameGlobals.getNumSpidersInSection(section) self.vineSections.append(section) self.totalSpiders = curSpiders self.notify.debug('calc vineSections = %s' % self.vineSections) def getVineSections(self): return self.vineSections def setTrolleyZone(self, trolleyZone): DistributedMinigameAI.setTrolleyZone(self, trolleyZone) self.setupVineSections() def awardPartialBeans(self): if self.calculatedPartialBeans: return self.calculatedPartialBeans = True for avId in self.avIdList: vineIndex = self.toonInfo[avId][0] if not vineIndex == VineGameGlobals.NumVines - 1: partialBeans = int(vineIndex / 5.0) if self.scoreDict.has_key(avId): self.scoreDict[avId] += partialBeans self.sendUpdate('setScore', [avId, self.scoreDict[avId]])
mit
[ 504, 17484, 4649, 528, 313, 7730, 492, 627, 199, 504, 4125, 14, 23078, 492, 8465, 2608, 67, 38, 4029, 12, 8511, 199, 504, 4125, 14, 23078, 492, 8511, 199, 646, 812, 1132, 11454, 21675, 199, 199, 533, 17484, 54, 1132, 11454, 7730, 8, 27398, 4649, 528, 313, 7730, 304, 339, 347, 636, 826, 721, 277, 12, 12321, 12, 1748, 528, 313, 1304, 304, 267, 862, 26, 288, 291, 14, 27398, 54, 1132, 11454, 7730, 63, 12486, 267, 871, 26, 288, 291, 14, 27398, 54, 1132, 11454, 7730, 63, 12486, 275, 413, 288, 17484, 4649, 528, 313, 7730, 855, 826, 721, 277, 12, 12321, 12, 1748, 528, 313, 1304, 9, 288, 291, 14, 5097, 38, 4029, 275, 8465, 2608, 67, 38, 4029, 14, 30722, 67, 38, 4029, 360, 27398, 54, 1132, 11454, 7730, 297, 359, 2223, 14, 2223, 360, 16856, 297, 291, 14, 4200, 31047, 12, 291, 14, 2224, 31047, 12, 788, 2802, 3815, 1467, 8511, 14, 2223, 360, 2802, 297, 291, 14, 4200, 9651, 12, 291, 14, 2224, 9651, 12, 788, 7661, 297, 283, 2573, 6824, 29654, 3815, 1467, 8511, 14, 2223, 360, 2573, 6824, 29654, 297, 291, 14, 4200, 7536, 6824, 29654, 12, 291, 14, 2224, 7536, 6824, 29654, 12, 788, 7661, 3815, 1467, 8511, 14, 2223, 360, 7661, 297, 291, 14, 4200, 7891, 12, 291, 14, 2224, 7891, 12, 788, 16856, 1105, 467, 283, 16856, 297, 283, 16856, 358, 288, 291, 14, 475, 265, 2354, 275, 1052, 288, 291, 14, 23897, 11454, 38, 4029, 8, 277, 14, 5097, 38, 4029, 9, 288, 291, 14, 86, 1132, 29881, 275, 942, 288, 291, 14, 8669, 34, 265, 527, 275, 1052, 288, 291, 14, 8669, 1366, 8185, 275, 1052, 288, 291, 14, 2923, 51, 1038, 7735, 275, 378, 288, 291, 14, 13494, 972, 18192, 3655, 796, 275, 756, 339, 347, 3550, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 4208, 358, 267, 17484, 4649, 528, 313, 7730, 14, 4208, 8, 277, 9, 339, 347, 3145, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 1807, 358, 267, 2150, 291, 14, 5097, 38, 4029, 267, 17484, 4649, 528, 313, 7730, 14, 1807, 8, 277, 9, 339, 347, 485, 22224, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 283, 5097, 38, 4029, 735, 288, 372, 756, 267, 340, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 342, 508, 488, 26, 288, 372, 756, 267, 372, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 1252, 16405, 342, 508, 283, 2802, 7, 339, 347, 663, 11454, 17960, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 17960, 358, 267, 367, 2289, 1304, 315, 291, 14, 1214, 1304, 1296, 26, 288, 291, 14, 873, 32435, 2354, 8, 1214, 1304, 12, 373, 1132, 2681, 29, 16, 12, 373, 1132, 52, 29, 54, 1132, 11454, 21675, 14, 54, 1132, 14139, 52, 9, 398, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 17960, 8, 277, 9, 267, 291, 14, 1507, 52, 264, 305, 1482, 275, 812, 1132, 11454, 21675, 14, 5667, 54, 3746, 446, 413, 267, 291, 14, 1507, 52, 264, 305, 1482, 22620, 917, 275, 378, 267, 291, 14, 28549, 3186, 275, 359, 16, 61, 627, 291, 14, 1507, 52, 264, 305, 1482, 267, 367, 2289, 1304, 315, 291, 14, 3397, 2141, 14, 1612, 837, 288, 291, 14, 3397, 2141, 59, 1214, 1304, 61, 275, 378, 288, 291, 14, 8669, 34, 265, 527, 59, 1214, 1304, 61, 275, 378, 288, 291, 14, 8669, 1366, 8185, 59, 1214, 1304, 61, 275, 446, 17, 339, 347, 663, 11454, 3162, 8, 277, 12, 4913, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 3162, 358, 267, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 3162, 8, 277, 12, 4913, 9, 267, 291, 14, 5097, 38, 4029, 14, 1069, 360, 2802, 358, 339, 347, 663, 11454, 16682, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 16682, 358, 267, 340, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 837, 288, 291, 14, 5097, 38, 4029, 14, 1069, 360, 7661, 358, 267, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 16682, 8, 277, 9, 339, 347, 9219, 5674, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 5097, 5674, 358, 267, 373, 1132, 497, 4583, 275, 942, 267, 5396, 1296, 275, 942, 267, 9158, 1296, 275, 942, 267, 900, 8185, 1296, 275, 942, 267, 367, 2289, 1304, 315, 291, 14, 1214, 1304, 1296, 26, 288, 373, 1132, 497, 4583, 14, 740, 8, 277, 14, 475, 265, 2354, 59, 1214, 1304, 1527, 16, 566, 288, 5396, 1296, 14, 740, 8, 277, 14, 3397, 2141, 59, 1214, 1304, 566, 288, 9158, 1296, 14, 740, 8, 277, 14, 8669, 34, 265, 527, 59, 1214, 1304, 566, 288, 900, 8185, 1296, 14, 740, 8, 277, 14, 8669, 1366, 8185, 59, 1214, 1304, 566, 398, 3141, 34, 1956, 275, 822, 8, 54, 1132, 11454, 21675, 14, 34, 292, 2354, 59, 277, 14, 362, 11090, 2619, 1304, 9383, 267, 291, 14, 8387, 14, 952, 3120, 2390, 360, 827, 528, 313, 63, 86, 1132, 297, 291, 14, 1117, 1304, 12, 1543, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 7, 450, 334, 32435, 16231, 21675, 14, 54, 1132, 11454, 1304, 12, 268, 291, 14, 362, 11090, 2619, 1304, 1062, 268, 291, 14, 1214, 1304, 1296, 12, 268, 5396, 1296, 12, 268, 291, 14, 86, 1132, 29881, 12, 268, 9158, 1296, 12, 268, 900, 8185, 1296, 12, 268, 373, 1132, 497, 4583, 12, 268, 291, 14, 2923, 51, 1038, 7735, 12, 268, 3141, 34, 1956, 430, 267, 291, 14, 5097, 38, 4029, 14, 1069, 360, 7661, 358, 267, 17484, 4649, 528, 313, 7730, 14, 5097, 5674, 8, 277, 9, 339, 347, 9509, 31047, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 4200, 31047, 358, 339, 347, 4458, 31047, 8, 277, 304, 267, 986, 339, 347, 9509, 9651, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 4200, 9651, 358, 267, 291, 14, 86, 3746, 275, 942, 267, 1478, 275, 378, 267, 2120, 20752, 14, 1117, 3767, 22028, 8, 54, 1132, 11454, 21675, 14, 11454, 13283, 12, 291, 14 ]
[ 17484, 4649, 528, 313, 7730, 492, 627, 199, 504, 4125, 14, 23078, 492, 8465, 2608, 67, 38, 4029, 12, 8511, 199, 504, 4125, 14, 23078, 492, 8511, 199, 646, 812, 1132, 11454, 21675, 199, 199, 533, 17484, 54, 1132, 11454, 7730, 8, 27398, 4649, 528, 313, 7730, 304, 339, 347, 636, 826, 721, 277, 12, 12321, 12, 1748, 528, 313, 1304, 304, 267, 862, 26, 288, 291, 14, 27398, 54, 1132, 11454, 7730, 63, 12486, 267, 871, 26, 288, 291, 14, 27398, 54, 1132, 11454, 7730, 63, 12486, 275, 413, 288, 17484, 4649, 528, 313, 7730, 855, 826, 721, 277, 12, 12321, 12, 1748, 528, 313, 1304, 9, 288, 291, 14, 5097, 38, 4029, 275, 8465, 2608, 67, 38, 4029, 14, 30722, 67, 38, 4029, 360, 27398, 54, 1132, 11454, 7730, 297, 359, 2223, 14, 2223, 360, 16856, 297, 291, 14, 4200, 31047, 12, 291, 14, 2224, 31047, 12, 788, 2802, 3815, 1467, 8511, 14, 2223, 360, 2802, 297, 291, 14, 4200, 9651, 12, 291, 14, 2224, 9651, 12, 788, 7661, 297, 283, 2573, 6824, 29654, 3815, 1467, 8511, 14, 2223, 360, 2573, 6824, 29654, 297, 291, 14, 4200, 7536, 6824, 29654, 12, 291, 14, 2224, 7536, 6824, 29654, 12, 788, 7661, 3815, 1467, 8511, 14, 2223, 360, 7661, 297, 291, 14, 4200, 7891, 12, 291, 14, 2224, 7891, 12, 788, 16856, 1105, 467, 283, 16856, 297, 283, 16856, 358, 288, 291, 14, 475, 265, 2354, 275, 1052, 288, 291, 14, 23897, 11454, 38, 4029, 8, 277, 14, 5097, 38, 4029, 9, 288, 291, 14, 86, 1132, 29881, 275, 942, 288, 291, 14, 8669, 34, 265, 527, 275, 1052, 288, 291, 14, 8669, 1366, 8185, 275, 1052, 288, 291, 14, 2923, 51, 1038, 7735, 275, 378, 288, 291, 14, 13494, 972, 18192, 3655, 796, 275, 756, 339, 347, 3550, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 4208, 358, 267, 17484, 4649, 528, 313, 7730, 14, 4208, 8, 277, 9, 339, 347, 3145, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 1807, 358, 267, 2150, 291, 14, 5097, 38, 4029, 267, 17484, 4649, 528, 313, 7730, 14, 1807, 8, 277, 9, 339, 347, 485, 22224, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 283, 5097, 38, 4029, 735, 288, 372, 756, 267, 340, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 342, 508, 488, 26, 288, 372, 756, 267, 372, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 1252, 16405, 342, 508, 283, 2802, 7, 339, 347, 663, 11454, 17960, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 17960, 358, 267, 367, 2289, 1304, 315, 291, 14, 1214, 1304, 1296, 26, 288, 291, 14, 873, 32435, 2354, 8, 1214, 1304, 12, 373, 1132, 2681, 29, 16, 12, 373, 1132, 52, 29, 54, 1132, 11454, 21675, 14, 54, 1132, 14139, 52, 9, 398, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 17960, 8, 277, 9, 267, 291, 14, 1507, 52, 264, 305, 1482, 275, 812, 1132, 11454, 21675, 14, 5667, 54, 3746, 446, 413, 267, 291, 14, 1507, 52, 264, 305, 1482, 22620, 917, 275, 378, 267, 291, 14, 28549, 3186, 275, 359, 16, 61, 627, 291, 14, 1507, 52, 264, 305, 1482, 267, 367, 2289, 1304, 315, 291, 14, 3397, 2141, 14, 1612, 837, 288, 291, 14, 3397, 2141, 59, 1214, 1304, 61, 275, 378, 288, 291, 14, 8669, 34, 265, 527, 59, 1214, 1304, 61, 275, 378, 288, 291, 14, 8669, 1366, 8185, 59, 1214, 1304, 61, 275, 446, 17, 339, 347, 663, 11454, 3162, 8, 277, 12, 4913, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 3162, 358, 267, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 3162, 8, 277, 12, 4913, 9, 267, 291, 14, 5097, 38, 4029, 14, 1069, 360, 2802, 358, 339, 347, 663, 11454, 16682, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 409, 11454, 16682, 358, 267, 340, 291, 14, 5097, 38, 4029, 14, 16662, 2223, 837, 288, 291, 14, 5097, 38, 4029, 14, 1069, 360, 7661, 358, 267, 17484, 4649, 528, 313, 7730, 14, 409, 11454, 16682, 8, 277, 9, 339, 347, 9219, 5674, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 5097, 5674, 358, 267, 373, 1132, 497, 4583, 275, 942, 267, 5396, 1296, 275, 942, 267, 9158, 1296, 275, 942, 267, 900, 8185, 1296, 275, 942, 267, 367, 2289, 1304, 315, 291, 14, 1214, 1304, 1296, 26, 288, 373, 1132, 497, 4583, 14, 740, 8, 277, 14, 475, 265, 2354, 59, 1214, 1304, 1527, 16, 566, 288, 5396, 1296, 14, 740, 8, 277, 14, 3397, 2141, 59, 1214, 1304, 566, 288, 9158, 1296, 14, 740, 8, 277, 14, 8669, 34, 265, 527, 59, 1214, 1304, 566, 288, 900, 8185, 1296, 14, 740, 8, 277, 14, 8669, 1366, 8185, 59, 1214, 1304, 566, 398, 3141, 34, 1956, 275, 822, 8, 54, 1132, 11454, 21675, 14, 34, 292, 2354, 59, 277, 14, 362, 11090, 2619, 1304, 9383, 267, 291, 14, 8387, 14, 952, 3120, 2390, 360, 827, 528, 313, 63, 86, 1132, 297, 291, 14, 1117, 1304, 12, 1543, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 15287, 83, 7, 450, 334, 32435, 16231, 21675, 14, 54, 1132, 11454, 1304, 12, 268, 291, 14, 362, 11090, 2619, 1304, 1062, 268, 291, 14, 1214, 1304, 1296, 12, 268, 5396, 1296, 12, 268, 291, 14, 86, 1132, 29881, 12, 268, 9158, 1296, 12, 268, 900, 8185, 1296, 12, 268, 373, 1132, 497, 4583, 12, 268, 291, 14, 2923, 51, 1038, 7735, 12, 268, 3141, 34, 1956, 430, 267, 291, 14, 5097, 38, 4029, 14, 1069, 360, 7661, 358, 267, 17484, 4649, 528, 313, 7730, 14, 5097, 5674, 8, 277, 9, 339, 347, 9509, 31047, 8, 277, 304, 267, 291, 14, 6814, 14, 1757, 360, 4200, 31047, 358, 339, 347, 4458, 31047, 8, 277, 304, 267, 986, 339, 347, 9509, 9651,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bdarnell/tornado
maint/benchmark/chunk_benchmark.py
10
1622
#!/usr/bin/env python # # Downloads a large file in chunked encoding with both curl and simple clients import logging from tornado.curl_httpclient import CurlAsyncHTTPClient from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.ioloop import IOLoop from tornado.options import define, options, parse_command_line from tornado.web import RequestHandler, Application try: xrange except NameError: xrange = range define('port', default=8888) define('num_chunks', default=1000) define('chunk_size', default=2048) class ChunkHandler(RequestHandler): def get(self): for i in xrange(options.num_chunks): self.write('A' * options.chunk_size) self.flush() self.finish() def main(): parse_command_line() app = Application([('/', ChunkHandler)]) app.listen(options.port, address='127.0.0.1') def callback(response): response.rethrow() assert len(response.body) == (options.num_chunks * options.chunk_size) logging.warning("fetch completed in %s seconds", response.request_time) IOLoop.current().stop() logging.warning("Starting fetch with curl client") curl_client = CurlAsyncHTTPClient() curl_client.fetch('http://localhost:%d/' % options.port, callback=callback) IOLoop.current().start() logging.warning("Starting fetch with simple client") simple_client = SimpleAsyncHTTPClient() simple_client.fetch('http://localhost:%d/' % options.port, callback=callback) IOLoop.current().start() if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 13392, 3640, 282, 7031, 570, 315, 22180, 2644, 543, 3865, 26145, 436, 3486, 13431, 199, 199, 646, 2050, 199, 504, 12148, 14, 17096, 63, 1014, 1258, 492, 445, 633, 12807, 27757, 199, 504, 12148, 14, 4129, 63, 1014, 1258, 492, 5870, 12807, 27757, 199, 504, 12148, 14, 27212, 492, 25584, 199, 504, 12148, 14, 1419, 492, 5627, 12, 1511, 12, 2198, 63, 1531, 63, 604, 199, 504, 12148, 14, 2520, 492, 4784, 2461, 12, 13515, 199, 199, 893, 26, 272, 4945, 199, 2590, 12746, 26, 272, 4945, 275, 1425, 199, 199, 4640, 360, 719, 297, 849, 29, 14871, 9, 199, 4640, 360, 1507, 63, 10660, 297, 849, 29, 5279, 9, 199, 4640, 360, 4604, 63, 890, 297, 849, 29, 18343, 9, 421, 199, 533, 25246, 2461, 8, 11149, 304, 272, 347, 664, 8, 277, 304, 267, 367, 284, 315, 4945, 8, 1419, 14, 1507, 63, 10660, 304, 288, 291, 14, 952, 360, 33, 7, 627, 1511, 14, 4604, 63, 890, 9, 288, 291, 14, 4939, 342, 267, 291, 14, 8192, 342, 421, 199, 318, 2446, 837, 272, 2198, 63, 1531, 63, 604, 342, 272, 1145, 275, 13515, 779, 10998, 25246, 2461, 3948, 272, 1145, 14, 5859, 8, 1419, 14, 719, 12, 2287, 534, 4195, 14, 16, 14, 16, 14, 17, 358, 339, 347, 3233, 8, 1310, 304, 267, 1177, 14, 264, 11964, 342, 267, 702, 822, 8, 1310, 14, 2030, 9, 508, 334, 1419, 14, 1507, 63, 10660, 627, 1511, 14, 4604, 63, 890, 9, 267, 2050, 14, 3764, 480, 3535, 9709, 315, 450, 83, 4696, 401, 1177, 14, 1069, 63, 521, 9, 267, 25584, 14, 1818, 1252, 2379, 342, 339, 2050, 14, 3764, 480, 14139, 5267, 543, 26145, 1890, 531, 272, 26145, 63, 1258, 275, 445, 633, 12807, 27757, 342, 272, 26145, 63, 1258, 14, 3535, 360, 1014, 921, 5967, 2689, 68, 4805, 450, 1511, 14, 719, 12, 1993, 3233, 29, 3058, 9, 272, 25584, 14, 1818, 1252, 928, 342, 339, 2050, 14, 3764, 480, 14139, 5267, 543, 3486, 1890, 531, 272, 3486, 63, 1258, 275, 5870, 12807, 27757, 342, 272, 3486, 63, 1258, 14, 3535, 360, 1014, 921, 5967, 2689, 68, 4805, 450, 1511, 14, 719, 12, 717, 3233, 29, 3058, 9, 272, 25584, 14, 1818, 1252, 928, 342, 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, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 13392, 3640, 282, 7031, 570, 315, 22180, 2644, 543, 3865, 26145, 436, 3486, 13431, 199, 199, 646, 2050, 199, 504, 12148, 14, 17096, 63, 1014, 1258, 492, 445, 633, 12807, 27757, 199, 504, 12148, 14, 4129, 63, 1014, 1258, 492, 5870, 12807, 27757, 199, 504, 12148, 14, 27212, 492, 25584, 199, 504, 12148, 14, 1419, 492, 5627, 12, 1511, 12, 2198, 63, 1531, 63, 604, 199, 504, 12148, 14, 2520, 492, 4784, 2461, 12, 13515, 199, 199, 893, 26, 272, 4945, 199, 2590, 12746, 26, 272, 4945, 275, 1425, 199, 199, 4640, 360, 719, 297, 849, 29, 14871, 9, 199, 4640, 360, 1507, 63, 10660, 297, 849, 29, 5279, 9, 199, 4640, 360, 4604, 63, 890, 297, 849, 29, 18343, 9, 421, 199, 533, 25246, 2461, 8, 11149, 304, 272, 347, 664, 8, 277, 304, 267, 367, 284, 315, 4945, 8, 1419, 14, 1507, 63, 10660, 304, 288, 291, 14, 952, 360, 33, 7, 627, 1511, 14, 4604, 63, 890, 9, 288, 291, 14, 4939, 342, 267, 291, 14, 8192, 342, 421, 199, 318, 2446, 837, 272, 2198, 63, 1531, 63, 604, 342, 272, 1145, 275, 13515, 779, 10998, 25246, 2461, 3948, 272, 1145, 14, 5859, 8, 1419, 14, 719, 12, 2287, 534, 4195, 14, 16, 14, 16, 14, 17, 358, 339, 347, 3233, 8, 1310, 304, 267, 1177, 14, 264, 11964, 342, 267, 702, 822, 8, 1310, 14, 2030, 9, 508, 334, 1419, 14, 1507, 63, 10660, 627, 1511, 14, 4604, 63, 890, 9, 267, 2050, 14, 3764, 480, 3535, 9709, 315, 450, 83, 4696, 401, 1177, 14, 1069, 63, 521, 9, 267, 25584, 14, 1818, 1252, 2379, 342, 339, 2050, 14, 3764, 480, 14139, 5267, 543, 26145, 1890, 531, 272, 26145, 63, 1258, 275, 445, 633, 12807, 27757, 342, 272, 26145, 63, 1258, 14, 3535, 360, 1014, 921, 5967, 2689, 68, 4805, 450, 1511, 14, 719, 12, 1993, 3233, 29, 3058, 9, 272, 25584, 14, 1818, 1252, 928, 342, 339, 2050, 14, 3764, 480, 14139, 5267, 543, 3486, 1890, 531, 272, 3486, 63, 1258, 275, 5870, 12807, 27757, 342, 272, 3486, 63, 1258, 14, 3535, 360, 1014, 921, 5967, 2689, 68, 4805, 450, 1511, 14, 719, 12, 717, 3233, 29, 3058, 9, 272, 25584, 14, 1818, 1252, 928, 342, 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, 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, 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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 ]
claudep/translate
translate/convert/test_po2mozlang.py
1
2512
#!/usr/bin/env python # -*- coding: utf-8 -*- from translate.convert import po2mozlang, test_convert from translate.misc import wStringIO from translate.storage import po class TestPO2Lang: def po2lang(self, posource): """helper that converts po source to .lang source without requiring files""" inputfile = wStringIO.StringIO(posource) inputpo = po.pofile(inputfile) convertor = po2mozlang.po2lang(mark_active=False) outputlang = convertor.convertstore(inputpo) return outputlang def test_simple(self): """check the simplest case of merging a translation""" posource = '''#: prop\nmsgid "Source"\nmsgstr "Target"\n''' propexpected = ''';Source\nTarget\n''' langfile = self.po2lang(posource) print(langfile.serialize()) assert langfile.serialize() == propexpected def test_comment(self): """Simple # comments""" posource = '''#. Comment\n#: prop\nmsgid "Source"\nmsgstr "Target"\n''' propexpected = '''# Comment\n;Source\nTarget\n''' langfile = self.po2lang(posource) print(langfile.serialize()) assert langfile.serialize() == propexpected def test_fuzzy(self): """What happens with a fuzzy string""" posource = '''#. Comment\n#: prop\n#, fuzzy\nmsgid "Source"\nmsgstr "Target"\n''' propexpected = '''# Comment\n;Source\nSource\n''' langfile = self.po2lang(posource) print(langfile.serialize()) assert langfile.serialize() == propexpected def test_ok_marker(self): """The {ok} marker""" posource = '''#: prop\nmsgid "Same"\nmsgstr "Same"\n''' propexpected = ''';Same\nSame {ok}\n''' langfile = self.po2lang(posource) print(langfile.serialize()) assert langfile.serialize() == propexpected class TestPO2LangCommand(test_convert.TestConvertCommand, TestPO2Lang): """Tests running actual po2prop commands on files""" convertmodule = po2mozlang defaultoptions = {"progress": "none"} def test_help(self): """tests getting help""" options = test_convert.TestConvertCommand.test_help(self) options = self.help_check(options, "-t TEMPLATE, --template=TEMPLATE") options = self.help_check(options, "--threshold=PERCENT") options = self.help_check(options, "--fuzzy") options = self.help_check(options, "--mark-active") options = self.help_check(options, "--nofuzzy", last=True)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 9028, 14, 3916, 492, 1115, 18, 23120, 4159, 12, 511, 63, 3916, 199, 504, 9028, 14, 9923, 492, 336, 6424, 199, 504, 9028, 14, 3494, 492, 1115, 421, 199, 533, 1379, 1512, 18, 14654, 26, 339, 347, 1115, 18, 4159, 8, 277, 12, 2086, 616, 304, 267, 408, 3676, 626, 15373, 1115, 1350, 370, 1275, 4159, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 3957, 269, 275, 1115, 18, 23120, 4159, 14, 555, 18, 4159, 8, 1657, 63, 2682, 29, 797, 9, 267, 1072, 4159, 275, 3957, 269, 14, 3916, 1617, 8, 1210, 555, 9, 267, 372, 1072, 4159, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 408, 1074, 314, 3486, 270, 1930, 402, 22537, 282, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 5931, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 27, 2980, 60, 78, 4277, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 3349, 8, 277, 304, 267, 408, 3184, 327, 6786, 624, 267, 2086, 616, 275, 1449, 31827, 6819, 60, 78, 12573, 5931, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 3, 6819, 60, 78, 27, 2980, 60, 78, 4277, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 24529, 8, 277, 304, 267, 408, 21015, 10986, 543, 282, 24101, 1059, 624, 267, 2086, 616, 275, 1449, 31827, 6819, 60, 78, 12573, 5931, 60, 78, 3, 12, 24101, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 3, 6819, 60, 78, 27, 2980, 60, 78, 2980, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 745, 63, 4211, 8, 277, 304, 267, 408, 1918, 469, 745, 93, 3608, 624, 267, 2086, 616, 275, 1449, 12573, 5931, 60, 78, 15245, 298, 8479, 3212, 78, 23367, 298, 8479, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 27, 8479, 60, 78, 8479, 469, 745, 4988, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 421, 199, 533, 1379, 1512, 18, 14654, 3110, 8, 396, 63, 3916, 14, 774, 7306, 3110, 12, 1379, 1512, 18, 14654, 304, 272, 408, 2925, 3879, 3503, 1115, 18, 4469, 3718, 641, 1584, 624, 272, 3957, 578, 275, 1115, 18, 23120, 4159, 272, 849, 1419, 275, 2420, 5734, 582, 298, 3592, 3570, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 408, 2219, 10232, 1720, 624, 267, 1511, 275, 511, 63, 3916, 14, 774, 7306, 3110, 14, 396, 63, 3437, 8, 277, 9, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 3905, 84, 24877, 12, 1553, 1160, 29, 7433, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 7227, 29, 4227, 17349, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 24529, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 1657, 13, 2682, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 889, 24529, 401, 2061, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 9028, 14, 3916, 492, 1115, 18, 23120, 4159, 12, 511, 63, 3916, 199, 504, 9028, 14, 9923, 492, 336, 6424, 199, 504, 9028, 14, 3494, 492, 1115, 421, 199, 533, 1379, 1512, 18, 14654, 26, 339, 347, 1115, 18, 4159, 8, 277, 12, 2086, 616, 304, 267, 408, 3676, 626, 15373, 1115, 1350, 370, 1275, 4159, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 3957, 269, 275, 1115, 18, 23120, 4159, 14, 555, 18, 4159, 8, 1657, 63, 2682, 29, 797, 9, 267, 1072, 4159, 275, 3957, 269, 14, 3916, 1617, 8, 1210, 555, 9, 267, 372, 1072, 4159, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 408, 1074, 314, 3486, 270, 1930, 402, 22537, 282, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 5931, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 27, 2980, 60, 78, 4277, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 3349, 8, 277, 304, 267, 408, 3184, 327, 6786, 624, 267, 2086, 616, 275, 1449, 31827, 6819, 60, 78, 12573, 5931, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 3, 6819, 60, 78, 27, 2980, 60, 78, 4277, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 24529, 8, 277, 304, 267, 408, 21015, 10986, 543, 282, 24101, 1059, 624, 267, 2086, 616, 275, 1449, 31827, 6819, 60, 78, 12573, 5931, 60, 78, 3, 12, 24101, 60, 78, 15245, 298, 2980, 3212, 78, 23367, 298, 4277, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 3, 6819, 60, 78, 27, 2980, 60, 78, 2980, 60, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 339, 347, 511, 63, 745, 63, 4211, 8, 277, 304, 267, 408, 1918, 469, 745, 93, 3608, 624, 267, 2086, 616, 275, 1449, 12573, 5931, 60, 78, 15245, 298, 8479, 3212, 78, 23367, 298, 8479, 3212, 78, 2344, 267, 557, 16531, 1043, 275, 1449, 27, 8479, 60, 78, 8479, 469, 745, 4988, 78, 2344, 267, 6339, 493, 275, 291, 14, 555, 18, 4159, 8, 555, 1365, 9, 267, 870, 8, 4159, 493, 14, 3549, 1012, 267, 702, 6339, 493, 14, 3549, 342, 508, 557, 16531, 1043, 421, 199, 533, 1379, 1512, 18, 14654, 3110, 8, 396, 63, 3916, 14, 774, 7306, 3110, 12, 1379, 1512, 18, 14654, 304, 272, 408, 2925, 3879, 3503, 1115, 18, 4469, 3718, 641, 1584, 624, 272, 3957, 578, 275, 1115, 18, 23120, 4159, 272, 849, 1419, 275, 2420, 5734, 582, 298, 3592, 3570, 339, 347, 511, 63, 3437, 8, 277, 304, 267, 408, 2219, 10232, 1720, 624, 267, 1511, 275, 511, 63, 3916, 14, 774, 7306, 3110, 14, 396, 63, 3437, 8, 277, 9, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 3905, 84, 24877, 12, 1553, 1160, 29, 7433, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 7227, 29, 4227, 17349, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 24529, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 1657, 13, 2682, 531, 267, 1511, 275, 291, 14, 3437, 63, 1074, 8, 1419, 12, 4320, 889, 24529, 401, 2061, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
onceuponatimeforever/oh-mainline
vendor/packages/scrapy/scrapy/http/response/dammit.py
16
11593
""" This module contains a fork of the UnicodeDammit class from BeautifulSoup, that expliclty disabled any usage of chardet library. The UnicodeDammit class is used as a last resource for detecting the encoding of a response. """ import re import codecs chardet = None # we don't want to use chardet since it's very slow, class UnicodeDammit: """A class for detecting the encoding of a *ML document and converting it to a Unicode string. If the source encoding is windows-1252, can replace MS smart quotes with their HTML or XML equivalents.""" # This dictionary maps commonly seen values for "charset" in HTML # meta tags to the corresponding Python codec names. It only covers # values that aren't in Python's aliases and can't be determined # by the heuristics in find_codec. CHARSET_ALIASES = { "macintosh" : "mac-roman", "x-sjis" : "shift-jis" } def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml', isHTML=False): self.declaredHTMLEncoding = None self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup, isHTML) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) return u = None for proposedEncoding in overrideEncodings: u = self._convertFrom(proposedEncoding) if u: break if not u: for proposedEncoding in (documentEncoding, sniffedEncoding): u = self._convertFrom(proposedEncoding) if u: break # If no luck and we have auto-detection library, try that: if not u and chardet and not isinstance(self.markup, unicode): u = self._convertFrom(chardet.detect(self.markup)['encoding']) # As a last resort, try utf-8 and windows-1252: if not u: for proposed_encoding in ("utf-8", "windows-1252"): u = self._convertFrom(proposed_encoding) if u: break self.unicode = u if not u: self.originalEncoding = None def _subMSChar(self, orig): """Changes a MS smart quote character to an XML or HTML entity.""" sub = self.MS_CHARS.get(orig) if isinstance(sub, tuple): if self.smartQuotesTo == 'xml': sub = '&#x%s;' % sub[1] else: sub = '&%s;' % sub[0] return sub def _convertFrom(self, proposed): proposed = self.find_codec(proposed) if not proposed or proposed in self.triedEncodings: return None self.triedEncodings.append(proposed) markup = self.markup # Convert smart quotes to HTML if coming from an encoding # that might have them. if self.smartQuotesTo and proposed.lower() in("windows-1252", "iso-8859-1", "iso-8859-2"): markup = re.compile("([\x80-\x9f])").sub \ (lambda(x): self._subMSChar(x.group(1)), markup) try: # print "Trying to convert document to %s" % proposed u = self._toUnicode(markup, proposed) self.markup = u self.originalEncoding = proposed except Exception, e: # print "That didn't work!" # print e return None #print "Correct encoding: %s" % proposed return self.markup def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' # strip Byte Order Mark (if present) if (len(data) >= 4) and (data[:2] == '\xfe\xff') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16be' data = data[2:] elif (len(data) >= 4) and (data[:2] == '\xff\xfe') \ and (data[2:4] != '\x00\x00'): encoding = 'utf-16le' data = data[2:] elif data[:3] == '\xef\xbb\xbf': encoding = 'utf-8' data = data[3:] elif data[:4] == '\x00\x00\xfe\xff': encoding = 'utf-32be' data = data[4:] elif data[:4] == '\xff\xfe\x00\x00': encoding = 'utf-32le' data = data[4:] newdata = unicode(data, encoding) return newdata def _detectEncoding(self, xml_data, isHTML=False): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) elif xml_data[:4] == '\x00\x3c\x00\x3f': # UTF-16BE sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data, 'utf-16be').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == '\xfe\xff') \ and (xml_data[2:4] != '\x00\x00'): # UTF-16BE with BOM sniffed_xml_encoding = 'utf-16be' xml_data = unicode(xml_data[2:], 'utf-16be').encode('utf-8') elif xml_data[:4] == '\x3c\x00\x3f\x00': # UTF-16LE sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data, 'utf-16le').encode('utf-8') elif (len(xml_data) >= 4) and (xml_data[:2] == '\xff\xfe') and \ (xml_data[2:4] != '\x00\x00'): # UTF-16LE with BOM sniffed_xml_encoding = 'utf-16le' xml_data = unicode(xml_data[2:], 'utf-16le').encode('utf-8') elif xml_data[:4] == '\x00\x00\x00\x3c': # UTF-32BE sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data, 'utf-32be').encode('utf-8') elif xml_data[:4] == '\x3c\x00\x00\x00': # UTF-32LE sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data, 'utf-32le').encode('utf-8') elif xml_data[:4] == '\x00\x00\xfe\xff': # UTF-32BE with BOM sniffed_xml_encoding = 'utf-32be' xml_data = unicode(xml_data[4:], 'utf-32be').encode('utf-8') elif xml_data[:4] == '\xff\xfe\x00\x00': # UTF-32LE with BOM sniffed_xml_encoding = 'utf-32le' xml_data = unicode(xml_data[4:], 'utf-32le').encode('utf-8') elif xml_data[:3] == '\xef\xbb\xbf': # UTF-8 with BOM sniffed_xml_encoding = 'utf-8' xml_data = unicode(xml_data[3:], 'utf-8').encode('utf-8') else: sniffed_xml_encoding = 'ascii' pass except: xml_encoding_match = None xml_encoding_match = re.compile( '^<\?.*encoding=[\'"](.*?)[\'"].*\?>').match(xml_data) if not xml_encoding_match and isHTML: regexp = re.compile('<\s*meta[^>]+charset=([^>]*?)[;\'">]', re.I) xml_encoding_match = regexp.search(xml_data) if xml_encoding_match is not None: xml_encoding = xml_encoding_match.groups()[0].lower() if isHTML: self.declaredHTMLEncoding = xml_encoding if sniffed_xml_encoding and \ (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode', 'iso-10646-ucs-4', 'ucs-4', 'csucs4', 'utf-16', 'utf-32', 'utf_16', 'utf_32', 'utf16', 'u16')): xml_encoding = sniffed_xml_encoding return xml_data, xml_encoding, sniffed_xml_encoding def find_codec(self, charset): return self._codec(self.CHARSET_ALIASES.get(charset, charset)) \ or (charset and self._codec(charset.replace("-", ""))) \ or (charset and self._codec(charset.replace("-", "_"))) \ or charset def _codec(self, charset): if not charset: return charset codec = None try: codecs.lookup(charset) codec = charset except (LookupError, ValueError): pass return codec EBCDIC_TO_ASCII_MAP = None def _ebcdic_to_ascii(self, s): c = self.__class__ if not c.EBCDIC_TO_ASCII_MAP: emap = (0,1,2,3,156,9,134,127,151,141,142,11,12,13,14,15, 16,17,18,19,157,133,8,135,24,25,146,143,28,29,30,31, 128,129,130,131,132,10,23,27,136,137,138,139,140,5,6,7, 144,145,22,147,148,149,150,4,152,153,154,155,20,21,158,26, 32,160,161,162,163,164,165,166,167,168,91,46,60,40,43,33, 38,169,170,171,172,173,174,175,176,177,93,36,42,41,59,94, 45,47,178,179,180,181,182,183,184,185,124,44,37,95,62,63, 186,187,188,189,190,191,192,193,194,96,58,35,64,39,61,34, 195,97,98,99,100,101,102,103,104,105,196,197,198,199,200, 201,202,106,107,108,109,110,111,112,113,114,203,204,205, 206,207,208,209,126,115,116,117,118,119,120,121,122,210, 211,212,213,214,215,216,217,218,219,220,221,222,223,224, 225,226,227,228,229,230,231,123,65,66,67,68,69,70,71,72, 73,232,233,234,235,236,237,125,74,75,76,77,78,79,80,81, 82,238,239,240,241,242,243,92,159,83,84,85,86,87,88,89, 90,244,245,246,247,248,249,48,49,50,51,52,53,54,55,56,57, 250,251,252,253,254,255) import string c.EBCDIC_TO_ASCII_MAP = string.maketrans( \ ''.join(map(chr, range(256))), ''.join(map(chr, emap))) return s.translate(c.EBCDIC_TO_ASCII_MAP) MS_CHARS = { '\x80' : ('euro', '20AC'), '\x81' : ' ', '\x82' : ('sbquo', '201A'), '\x83' : ('fnof', '192'), '\x84' : ('bdquo', '201E'), '\x85' : ('hellip', '2026'), '\x86' : ('dagger', '2020'), '\x87' : ('Dagger', '2021'), '\x88' : ('circ', '2C6'), '\x89' : ('permil', '2030'), '\x8A' : ('Scaron', '160'), '\x8B' : ('lsaquo', '2039'), '\x8C' : ('OElig', '152'), '\x8D' : '?', '\x8E' : ('#x17D', '17D'), '\x8F' : '?', '\x90' : '?', '\x91' : ('lsquo', '2018'), '\x92' : ('rsquo', '2019'), '\x93' : ('ldquo', '201C'), '\x94' : ('rdquo', '201D'), '\x95' : ('bull', '2022'), '\x96' : ('ndash', '2013'), '\x97' : ('mdash', '2014'), '\x98' : ('tilde', '2DC'), '\x99' : ('trade', '2122'), '\x9a' : ('scaron', '161'), '\x9b' : ('rsaquo', '203A'), '\x9c' : ('oelig', '153'), '\x9d' : '?', '\x9e' : ('#x17E', '17E'), '\x9f' : ('Yuml', ''),} #######################################################################
agpl-3.0
[ 624, 199, 2765, 859, 3509, 282, 14926, 402, 314, 6140, 36, 28980, 1021, 687, 17132, 12, 626, 199, 1474, 317, 429, 369, 6980, 1263, 4503, 402, 28470, 3555, 14, 199, 199, 1918, 6140, 36, 28980, 1021, 365, 1202, 465, 282, 2061, 2073, 367, 9696, 316, 314, 2644, 199, 1618, 282, 1177, 14, 199, 624, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 1560, 9886, 275, 488, 327, 781, 2793, 1133, 2934, 370, 675, 28470, 3967, 652, 1159, 7437, 11999, 12, 199, 199, 533, 6140, 36, 28980, 26, 272, 408, 33, 1021, 367, 9696, 316, 314, 2644, 402, 282, 627, 1698, 2213, 436, 272, 13806, 652, 370, 282, 6140, 1059, 14, 982, 314, 1350, 2644, 365, 272, 10061, 13, 19364, 12, 883, 3350, 14282, 11179, 9344, 543, 3932, 4163, 503, 4692, 272, 7353, 83, 1041, 339, 327, 961, 2600, 9033, 28829, 6775, 1338, 367, 298, 6043, 2, 315, 4163, 272, 327, 3404, 3762, 370, 314, 5226, 2018, 9076, 1561, 14, 2779, 1454, 25858, 272, 327, 1338, 626, 10621, 1133, 315, 2018, 1159, 5481, 436, 883, 1133, 506, 12037, 272, 327, 701, 314, 946, 300, 631, 2932, 315, 2342, 63, 9276, 14, 272, 8518, 3597, 63, 12644, 654, 275, 469, 298, 3088, 9924, 609, 2, 520, 298, 3088, 13, 20971, 401, 717, 298, 88, 13, 83, 18941, 2, 520, 298, 4723, 13, 18941, 2, 789, 339, 347, 636, 826, 721, 277, 12, 9189, 12, 4278, 30046, 6034, 326, 11179, 2371, 6510, 1378, 534, 1652, 297, 365, 4943, 29, 797, 304, 267, 291, 14, 13545, 31428, 78, 1523, 275, 488, 267, 291, 14, 10131, 12, 2213, 7630, 12, 6895, 15126, 379, 7630, 275, 971, 2151, 291, 423, 13552, 7630, 8, 10131, 12, 365, 4943, 9, 267, 291, 14, 7853, 2371, 6510, 1378, 275, 11179, 2371, 6510, 1378, 267, 291, 14, 599, 379, 30046, 275, 942, 267, 340, 9189, 508, 2125, 503, 1228, 8, 10131, 12, 2649, 304, 288, 291, 14, 5043, 7630, 275, 488, 288, 291, 14, 2975, 275, 2649, 8, 10131, 9, 288, 372, 398, 399, 275, 488, 267, 367, 14075, 7630, 315, 4278, 30046, 26, 288, 399, 275, 291, 423, 29760, 8, 15676, 7630, 9, 288, 340, 399, 26, 2059, 267, 340, 440, 399, 26, 288, 367, 14075, 7630, 315, 334, 3554, 7630, 12, 6895, 15126, 379, 7630, 304, 355, 399, 275, 291, 423, 29760, 8, 15676, 7630, 9, 355, 340, 399, 26, 2059, 398, 327, 982, 949, 634, 10112, 436, 781, 1172, 2599, 13, 11934, 3555, 12, 862, 626, 26, 267, 340, 440, 399, 436, 28470, 436, 440, 1228, 8, 277, 14, 10131, 12, 2649, 304, 288, 399, 275, 291, 423, 29760, 8, 1560, 9886, 14, 13552, 8, 277, 14, 10131, 11820, 2991, 1105, 398, 327, 3709, 282, 2061, 522, 361, 12, 862, 2774, 13, 24, 436, 10061, 13, 19364, 26, 267, 340, 440, 399, 26, 288, 367, 14075, 63, 2991, 315, 1689, 1624, 13, 24, 401, 298, 8258, 13, 19364, 2349, 355, 399, 275, 291, 423, 29760, 8, 15676, 63, 2991, 9, 355, 340, 399, 26, 2059, 398, 291, 14, 2975, 275, 399, 267, 340, 440, 399, 26, 291, 14, 5043, 7630, 275, 488, 339, 347, 485, 954, 3053, 1610, 8, 277, 12, 2306, 304, 267, 408, 13907, 282, 14282, 11179, 6313, 4528, 370, 376, 4692, 503, 4163, 267, 4642, 1041, 267, 1007, 275, 291, 14, 3053, 63, 16326, 14, 362, 8, 2981, 9, 267, 340, 1228, 8, 954, 12, 2008, 304, 288, 340, 291, 14, 7853, 2371, 6510, 1378, 508, 283, 1652, 356, 355, 1007, 275, 7673, 3, 88, 5, 83, 8942, 450, 1007, 59, 17, 61, 288, 587, 26, 355, 1007, 275, 7673, 5, 83, 8942, 450, 1007, 59, 16, 61, 267, 372, 1007, 339, 347, 485, 29760, 8, 277, 12, 14075, 304, 267, 14075, 275, 291, 14, 1623, 63, 9276, 8, 15676, 9, 267, 340, 440, 14075, 503, 14075, 315, 291, 14, 599, 379, 30046, 26, 288, 372, 488, 267, 291, 14, 599, 379, 30046, 14, 740, 8, 15676, 9, 267, 9189, 275, 291, 14, 10131, 398, 327, 7905, 11179, 9344, 370, 4163, 340, 17262, 687, 376, 2644, 267, 327, 626, 5594, 1172, 3062, 14, 267, 340, 291, 14, 7853, 2371, 6510, 1378, 436, 14075, 14, 2325, 342, 315, 480, 8258, 13, 19364, 401, 10028, 298, 4595, 13, 4830, 13, 17, 401, 10028, 298, 4595, 13, 4830, 13, 18, 2349, 288, 9189, 275, 295, 14, 2014, 480, 16510, 88, 1257, 2696, 88, 25, 70, 566, 3471, 954, 971, 2151, 334, 2734, 8, 88, 304, 291, 423, 954, 3053, 1610, 8, 88, 14, 923, 8, 17, 1826, 1993, 9189, 9, 398, 862, 26, 288, 327, 870, 298, 27693, 370, 3957, 2213, 370, 450, 83, 2, 450, 14075, 288, 399, 275, 291, 423, 475, 7087, 8, 10131, 12, 14075, 9, 288, 291, 14, 10131, 275, 399, 288, 291, 14, 5043, 7630, 275, 14075, 267, 871, 2186, 12, 325, 26, 288, 327, 870, 298, 17231, 9980, 1133, 1736, 9539, 288, 327, 870, 325, 288, 372, 488, 267, 327, 1361, 298, 19993, 2644, 26, 450, 83, 2, 450, 14075, 267, 372, 291, 14, 10131, 339, 347, 485, 475, 7087, 8, 277, 12, 666, 12, 2644, 304, 267, 1449, 13735, 282, 1059, 436, 2399, 2644, 12, 4849, 83, 314, 1059, 1901, 6140, 14, 267, 450, 2991, 365, 282, 1059, 18054, 701, 14134, 14, 8602, 2344, 398, 327, 6202, 20301, 9240, 7173, 334, 692, 3451, 9, 267, 340, 334, 552, 8, 576, 9, 2356, 841, 9, 436, 334, 576, 1491, 18, 61, 508, 1557, 8371, 60, 3581, 358, 971, 2049, 436, 334, 576, 59, 18, 26, 20, 61, 1137, 1557, 88, 383, 60, 88, 383, 735, 288, 2644, 275, 283, 1624, 13, 975, 1235, 7, 288, 666, 275, 666, 59, 18, 2938, 267, 916, 334, 552, 8, 576, 9, 2356, 841, 9, 436, 334, 576, 1491, 18, 61, 508, 1557, 3581, 60, 8371, 358, 971, 326, 436, 334, 576, 59, 18, 26, 20, 61, 1137, 1557, 88, 383, 60, 88, 383, 735, 288, 2644, 275, 283, 1624, 13, 975, 274, 7, 288, 666, 275, 666, 59, 18, 2938, 267, 916, 666, 1491, 19, 61, 508, 1557, 9532, 60, 9932, 60, 9566, 356, 288, 2644, 275, 283, 1624, 13, 24, 7, 288, 666, 275, 666, 59 ]
[ 199, 2765, 859, 3509, 282, 14926, 402, 314, 6140, 36, 28980, 1021, 687, 17132, 12, 626, 199, 1474, 317, 429, 369, 6980, 1263, 4503, 402, 28470, 3555, 14, 199, 199, 1918, 6140, 36, 28980, 1021, 365, 1202, 465, 282, 2061, 2073, 367, 9696, 316, 314, 2644, 199, 1618, 282, 1177, 14, 199, 624, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 1560, 9886, 275, 488, 327, 781, 2793, 1133, 2934, 370, 675, 28470, 3967, 652, 1159, 7437, 11999, 12, 199, 199, 533, 6140, 36, 28980, 26, 272, 408, 33, 1021, 367, 9696, 316, 314, 2644, 402, 282, 627, 1698, 2213, 436, 272, 13806, 652, 370, 282, 6140, 1059, 14, 982, 314, 1350, 2644, 365, 272, 10061, 13, 19364, 12, 883, 3350, 14282, 11179, 9344, 543, 3932, 4163, 503, 4692, 272, 7353, 83, 1041, 339, 327, 961, 2600, 9033, 28829, 6775, 1338, 367, 298, 6043, 2, 315, 4163, 272, 327, 3404, 3762, 370, 314, 5226, 2018, 9076, 1561, 14, 2779, 1454, 25858, 272, 327, 1338, 626, 10621, 1133, 315, 2018, 1159, 5481, 436, 883, 1133, 506, 12037, 272, 327, 701, 314, 946, 300, 631, 2932, 315, 2342, 63, 9276, 14, 272, 8518, 3597, 63, 12644, 654, 275, 469, 298, 3088, 9924, 609, 2, 520, 298, 3088, 13, 20971, 401, 717, 298, 88, 13, 83, 18941, 2, 520, 298, 4723, 13, 18941, 2, 789, 339, 347, 636, 826, 721, 277, 12, 9189, 12, 4278, 30046, 6034, 326, 11179, 2371, 6510, 1378, 534, 1652, 297, 365, 4943, 29, 797, 304, 267, 291, 14, 13545, 31428, 78, 1523, 275, 488, 267, 291, 14, 10131, 12, 2213, 7630, 12, 6895, 15126, 379, 7630, 275, 971, 2151, 291, 423, 13552, 7630, 8, 10131, 12, 365, 4943, 9, 267, 291, 14, 7853, 2371, 6510, 1378, 275, 11179, 2371, 6510, 1378, 267, 291, 14, 599, 379, 30046, 275, 942, 267, 340, 9189, 508, 2125, 503, 1228, 8, 10131, 12, 2649, 304, 288, 291, 14, 5043, 7630, 275, 488, 288, 291, 14, 2975, 275, 2649, 8, 10131, 9, 288, 372, 398, 399, 275, 488, 267, 367, 14075, 7630, 315, 4278, 30046, 26, 288, 399, 275, 291, 423, 29760, 8, 15676, 7630, 9, 288, 340, 399, 26, 2059, 267, 340, 440, 399, 26, 288, 367, 14075, 7630, 315, 334, 3554, 7630, 12, 6895, 15126, 379, 7630, 304, 355, 399, 275, 291, 423, 29760, 8, 15676, 7630, 9, 355, 340, 399, 26, 2059, 398, 327, 982, 949, 634, 10112, 436, 781, 1172, 2599, 13, 11934, 3555, 12, 862, 626, 26, 267, 340, 440, 399, 436, 28470, 436, 440, 1228, 8, 277, 14, 10131, 12, 2649, 304, 288, 399, 275, 291, 423, 29760, 8, 1560, 9886, 14, 13552, 8, 277, 14, 10131, 11820, 2991, 1105, 398, 327, 3709, 282, 2061, 522, 361, 12, 862, 2774, 13, 24, 436, 10061, 13, 19364, 26, 267, 340, 440, 399, 26, 288, 367, 14075, 63, 2991, 315, 1689, 1624, 13, 24, 401, 298, 8258, 13, 19364, 2349, 355, 399, 275, 291, 423, 29760, 8, 15676, 63, 2991, 9, 355, 340, 399, 26, 2059, 398, 291, 14, 2975, 275, 399, 267, 340, 440, 399, 26, 291, 14, 5043, 7630, 275, 488, 339, 347, 485, 954, 3053, 1610, 8, 277, 12, 2306, 304, 267, 408, 13907, 282, 14282, 11179, 6313, 4528, 370, 376, 4692, 503, 4163, 267, 4642, 1041, 267, 1007, 275, 291, 14, 3053, 63, 16326, 14, 362, 8, 2981, 9, 267, 340, 1228, 8, 954, 12, 2008, 304, 288, 340, 291, 14, 7853, 2371, 6510, 1378, 508, 283, 1652, 356, 355, 1007, 275, 7673, 3, 88, 5, 83, 8942, 450, 1007, 59, 17, 61, 288, 587, 26, 355, 1007, 275, 7673, 5, 83, 8942, 450, 1007, 59, 16, 61, 267, 372, 1007, 339, 347, 485, 29760, 8, 277, 12, 14075, 304, 267, 14075, 275, 291, 14, 1623, 63, 9276, 8, 15676, 9, 267, 340, 440, 14075, 503, 14075, 315, 291, 14, 599, 379, 30046, 26, 288, 372, 488, 267, 291, 14, 599, 379, 30046, 14, 740, 8, 15676, 9, 267, 9189, 275, 291, 14, 10131, 398, 327, 7905, 11179, 9344, 370, 4163, 340, 17262, 687, 376, 2644, 267, 327, 626, 5594, 1172, 3062, 14, 267, 340, 291, 14, 7853, 2371, 6510, 1378, 436, 14075, 14, 2325, 342, 315, 480, 8258, 13, 19364, 401, 10028, 298, 4595, 13, 4830, 13, 17, 401, 10028, 298, 4595, 13, 4830, 13, 18, 2349, 288, 9189, 275, 295, 14, 2014, 480, 16510, 88, 1257, 2696, 88, 25, 70, 566, 3471, 954, 971, 2151, 334, 2734, 8, 88, 304, 291, 423, 954, 3053, 1610, 8, 88, 14, 923, 8, 17, 1826, 1993, 9189, 9, 398, 862, 26, 288, 327, 870, 298, 27693, 370, 3957, 2213, 370, 450, 83, 2, 450, 14075, 288, 399, 275, 291, 423, 475, 7087, 8, 10131, 12, 14075, 9, 288, 291, 14, 10131, 275, 399, 288, 291, 14, 5043, 7630, 275, 14075, 267, 871, 2186, 12, 325, 26, 288, 327, 870, 298, 17231, 9980, 1133, 1736, 9539, 288, 327, 870, 325, 288, 372, 488, 267, 327, 1361, 298, 19993, 2644, 26, 450, 83, 2, 450, 14075, 267, 372, 291, 14, 10131, 339, 347, 485, 475, 7087, 8, 277, 12, 666, 12, 2644, 304, 267, 1449, 13735, 282, 1059, 436, 2399, 2644, 12, 4849, 83, 314, 1059, 1901, 6140, 14, 267, 450, 2991, 365, 282, 1059, 18054, 701, 14134, 14, 8602, 2344, 398, 327, 6202, 20301, 9240, 7173, 334, 692, 3451, 9, 267, 340, 334, 552, 8, 576, 9, 2356, 841, 9, 436, 334, 576, 1491, 18, 61, 508, 1557, 8371, 60, 3581, 358, 971, 2049, 436, 334, 576, 59, 18, 26, 20, 61, 1137, 1557, 88, 383, 60, 88, 383, 735, 288, 2644, 275, 283, 1624, 13, 975, 1235, 7, 288, 666, 275, 666, 59, 18, 2938, 267, 916, 334, 552, 8, 576, 9, 2356, 841, 9, 436, 334, 576, 1491, 18, 61, 508, 1557, 3581, 60, 8371, 358, 971, 326, 436, 334, 576, 59, 18, 26, 20, 61, 1137, 1557, 88, 383, 60, 88, 383, 735, 288, 2644, 275, 283, 1624, 13, 975, 274, 7, 288, 666, 275, 666, 59, 18, 2938, 267, 916, 666, 1491, 19, 61, 508, 1557, 9532, 60, 9932, 60, 9566, 356, 288, 2644, 275, 283, 1624, 13, 24, 7, 288, 666, 275, 666, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
camptocamp/ngo-addons-backport
addons/account/account_financial_report.py
52
7727
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from datetime import datetime from dateutil.relativedelta import relativedelta from operator import itemgetter from openerp import netsvc from openerp import pooler from openerp.osv import fields, osv import openerp.addons.decimal_precision as dp from openerp.tools.translate import _ # --------------------------------------------------------- # Account Financial Report # --------------------------------------------------------- class account_financial_report(osv.osv): _name = "account.financial.report" _description = "Account Report" def _get_level(self, cr, uid, ids, field_name, arg, context=None): '''Returns a dictionary with key=the ID of a record and value = the level of this record in the tree structure.''' res = {} for report in self.browse(cr, uid, ids, context=context): level = 0 if report.parent_id: level = report.parent_id.level + 1 res[report.id] = level return res def _get_children_by_order(self, cr, uid, ids, context=None): '''returns a dictionary with the key= the ID of a record and value = all its children, computed recursively, and sorted by sequence. Ready for the printing''' res = [] for id in ids: res.append(id) ids2 = self.search(cr, uid, [('parent_id', '=', id)], order='sequence ASC', context=context) res += self._get_children_by_order(cr, uid, ids2, context=context) return res def _get_balance(self, cr, uid, ids, field_names, args, context=None): '''returns a dictionary with key=the ID of a record and value=the balance amount computed for this record. If the record is of type : 'accounts' : it's the sum of the linked accounts 'account_type' : it's the sum of leaf accoutns with such an account_type 'account_report' : it's the amount of the related report 'sum' : it's the sum of the children of this record (aka a 'view' record)''' account_obj = self.pool.get('account.account') res = {} for report in self.browse(cr, uid, ids, context=context): if report.id in res: continue res[report.id] = dict((fn, 0.0) for fn in field_names) if report.type == 'accounts': # it's the sum of the linked accounts for a in report.account_ids: for field in field_names: res[report.id][field] += getattr(a, field) elif report.type == 'account_type': # it's the sum the leaf accounts with such an account type report_types = [x.id for x in report.account_type_ids] account_ids = account_obj.search(cr, uid, [('user_type','in', report_types), ('type','!=','view')], context=context) for a in account_obj.browse(cr, uid, account_ids, context=context): for field in field_names: res[report.id][field] += getattr(a, field) elif report.type == 'account_report' and report.account_report_id: # it's the amount of the linked report res2 = self._get_balance(cr, uid, [report.account_report_id.id], field_names, False, context=context) for key, value in res2.items(): for field in field_names: res[report.id][field] += value[field] elif report.type == 'sum': # it's the sum of the children of this account.report res2 = self._get_balance(cr, uid, [rec.id for rec in report.children_ids], field_names, False, context=context) for key, value in res2.items(): for field in field_names: res[report.id][field] += value[field] return res _columns = { 'name': fields.char('Report Name', size=128, required=True, translate=True), 'parent_id': fields.many2one('account.financial.report', 'Parent'), 'children_ids': fields.one2many('account.financial.report', 'parent_id', 'Account Report'), 'sequence': fields.integer('Sequence'), 'balance': fields.function(_get_balance, 'Balance', multi='balance'), 'debit': fields.function(_get_balance, 'Debit', multi='balance'), 'credit': fields.function(_get_balance, 'Credit', multi="balance"), 'level': fields.function(_get_level, string='Level', store=True, type='integer'), 'type': fields.selection([ ('sum','View'), ('accounts','Accounts'), ('account_type','Account Type'), ('account_report','Report Value'), ],'Type'), 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), 'account_report_id': fields.many2one('account.financial.report', 'Report Value'), 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'), 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), 'display_detail': fields.selection([ ('no_detail','No detail'), ('detail_flat','Display children flat'), ('detail_with_hierarchy','Display children with hierarchy') ], 'Display details'), 'style_overwrite': fields.selection([ (0, 'Automatic formatting'), (1,'Main Title 1 (bold, underlined)'), (2,'Title 2 (bold)'), (3,'Title 3 (bold, smaller)'), (4,'Normal Text'), (5,'Italic Text (smaller)'), (6,'Smallest Text'), ],'Financial Report Style', help="You can set up here the format you want this record to be displayed. If you leave the automatic formatting, it will be computed based on the financial reports hierarchy (auto-computed field 'level')."), } _defaults = { 'type': 'sum', 'display_detail': 'detail_flat', 'sign': 1, 'style_overwrite': 0, } account_financial_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 22208, 14, 32300, 492, 20599, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 5166, 492, 1851, 10599, 199, 504, 5166, 492, 1115, 79, 1435, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 646, 5166, 14, 10788, 14, 6355, 63, 6833, 465, 12392, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 3, 9527, 9960, 199, 3, 9973, 11711, 24409, 11774, 199, 3, 9527, 9960, 199, 199, 533, 2933, 63, 2408, 24409, 63, 3070, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 2408, 24409, 14, 3070, 2, 272, 485, 1802, 275, 298, 6009, 11774, 2, 339, 347, 485, 362, 63, 1896, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 1449, 3407, 282, 2600, 543, 790, 29, 1589, 2870, 402, 282, 2777, 436, 574, 275, 314, 2166, 402, 642, 257, 288, 2777, 315, 314, 3123, 5523, 10595, 267, 522, 275, 1052, 267, 367, 3622, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2166, 275, 378, 288, 340, 3622, 14, 1708, 63, 344, 26, 355, 2166, 275, 3622, 14, 1708, 63, 344, 14, 1896, 435, 413, 288, 522, 59, 3070, 14, 344, 61, 275, 2166, 267, 372, 522, 339, 347, 485, 362, 63, 3223, 63, 991, 63, 1648, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1449, 5808, 282, 2600, 543, 314, 790, 29, 314, 2870, 402, 282, 2777, 436, 574, 275, 1006, 2399, 4978, 12, 1779, 9235, 15035, 12, 436, 3355, 701, 3414, 14, 5574, 89, 367, 314, 16116, 2344, 267, 522, 275, 942, 267, 367, 1305, 315, 2762, 26, 288, 522, 14, 740, 8, 344, 9, 288, 2762, 18, 275, 291, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1708, 63, 344, 297, 6291, 1305, 4360, 1865, 534, 4041, 20955, 297, 1067, 29, 1100, 9, 288, 522, 847, 291, 423, 362, 63, 3223, 63, 991, 63, 1648, 8, 1556, 12, 1747, 12, 2762, 18, 12, 1067, 29, 1100, 9, 267, 372, 522, 339, 347, 485, 362, 63, 7358, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 1247, 12, 1249, 12, 1067, 29, 403, 304, 267, 1449, 5808, 282, 2600, 543, 790, 29, 1589, 2870, 402, 282, 2777, 436, 574, 29, 1589, 14094, 5982, 221, 1779, 9235, 367, 642, 2777, 14, 982, 314, 2777, 365, 402, 730, 10619, 26, 2049, 283, 8370, 7, 10619, 26, 652, 1159, 314, 3089, 402, 314, 10632, 12639, 2049, 283, 2048, 63, 466, 7, 10619, 26, 652, 1159, 314, 3089, 402, 11747, 1066, 31009, 561, 543, 4066, 376, 2933, 63, 466, 2049, 283, 2048, 63, 3070, 7, 10619, 26, 652, 1159, 314, 5982, 402, 314, 4048, 3622, 2049, 283, 1838, 7, 10619, 26, 652, 1159, 314, 3089, 402, 314, 4978, 402, 642, 2777, 334, 24685, 282, 283, 1345, 7, 2777, 9, 2344, 267, 2933, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 358, 267, 522, 275, 1052, 267, 367, 3622, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 3622, 14, 344, 315, 522, 26, 355, 1980, 288, 522, 59, 3070, 14, 344, 61, 275, 1211, 1332, 2324, 12, 378, 14, 16, 9, 367, 4325, 315, 901, 63, 1247, 9, 288, 340, 3622, 14, 466, 508, 283, 8370, 356, 355, 327, 652, 1159, 314, 3089, 402, 314, 10632, 12639, 355, 367, 282, 315, 3622, 14, 2048, 63, 1580, 26, 490, 367, 901, 315, 901, 63, 1247, 26, 717, 522, 59, 3070, 14, 344, 1527, 698, 61, 847, 2519, 8, 65, 12, 901, 9, 288, 916, 3622, 14, 466, 508, 283, 2048, 63, 466, 356, 355, 327, 652, 1159, 314, 3089, 314, 11747, 12639, 543, 4066, 376, 2933, 730, 355, 3622, 63, 1313, 275, 359, 88, 14, 344, 367, 671, 315, 3622, 14, 2048, 63, 466, 63, 1580, 61, 355, 2933, 63, 1580, 275, 2933, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 751, 63, 466, 1673, 262, 297, 3622, 63, 1313, 395, 661, 466, 1673, 1111, 1673, 1345, 2665, 1067, 29, 1100, 9, 355, 367, 282, 315, 2933, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2933, 63, 1580, 12, 1067, 29, 1100, 304, 490, 367, 901, 315, 901, 63, 1247, 26, 717, 522, 59, 3070, 14, 344, 1527, 698, 61, 847, 2519, 8, 65, 12, 901, 9, 288, 916, 3622, 14, 466, 508, 283, 2048, 63, 3070, 7, 436, 3622, 14, 2048, 63, 3070, 63, 344, 26, 355, 327, 652, 1159, 314, 5982, 402, 314, 10632, 3622, 355, 522, 18, 275, 291, 423, 362, 63, 7358, 8, 1556, 12, 1747, 12, 359, 3070, 14, 2048, 63, 3070, 63, 344, 14, 344, 467, 901, 63, 1247, 12, 756, 12, 1067, 29, 1100, 9, 355, 367, 790, 12, 574, 315 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 22208, 14, 32300, 492, 20599, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 5166, 492, 1851, 10599, 199, 504, 5166, 492, 1115, 79, 1435, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 646, 5166, 14, 10788, 14, 6355, 63, 6833, 465, 12392, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 3, 9527, 9960, 199, 3, 9973, 11711, 24409, 11774, 199, 3, 9527, 9960, 199, 199, 533, 2933, 63, 2408, 24409, 63, 3070, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 2408, 24409, 14, 3070, 2, 272, 485, 1802, 275, 298, 6009, 11774, 2, 339, 347, 485, 362, 63, 1896, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 1449, 3407, 282, 2600, 543, 790, 29, 1589, 2870, 402, 282, 2777, 436, 574, 275, 314, 2166, 402, 642, 257, 288, 2777, 315, 314, 3123, 5523, 10595, 267, 522, 275, 1052, 267, 367, 3622, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2166, 275, 378, 288, 340, 3622, 14, 1708, 63, 344, 26, 355, 2166, 275, 3622, 14, 1708, 63, 344, 14, 1896, 435, 413, 288, 522, 59, 3070, 14, 344, 61, 275, 2166, 267, 372, 522, 339, 347, 485, 362, 63, 3223, 63, 991, 63, 1648, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1449, 5808, 282, 2600, 543, 314, 790, 29, 314, 2870, 402, 282, 2777, 436, 574, 275, 1006, 2399, 4978, 12, 1779, 9235, 15035, 12, 436, 3355, 701, 3414, 14, 5574, 89, 367, 314, 16116, 2344, 267, 522, 275, 942, 267, 367, 1305, 315, 2762, 26, 288, 522, 14, 740, 8, 344, 9, 288, 2762, 18, 275, 291, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1708, 63, 344, 297, 6291, 1305, 4360, 1865, 534, 4041, 20955, 297, 1067, 29, 1100, 9, 288, 522, 847, 291, 423, 362, 63, 3223, 63, 991, 63, 1648, 8, 1556, 12, 1747, 12, 2762, 18, 12, 1067, 29, 1100, 9, 267, 372, 522, 339, 347, 485, 362, 63, 7358, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 1247, 12, 1249, 12, 1067, 29, 403, 304, 267, 1449, 5808, 282, 2600, 543, 790, 29, 1589, 2870, 402, 282, 2777, 436, 574, 29, 1589, 14094, 5982, 221, 1779, 9235, 367, 642, 2777, 14, 982, 314, 2777, 365, 402, 730, 10619, 26, 2049, 283, 8370, 7, 10619, 26, 652, 1159, 314, 3089, 402, 314, 10632, 12639, 2049, 283, 2048, 63, 466, 7, 10619, 26, 652, 1159, 314, 3089, 402, 11747, 1066, 31009, 561, 543, 4066, 376, 2933, 63, 466, 2049, 283, 2048, 63, 3070, 7, 10619, 26, 652, 1159, 314, 5982, 402, 314, 4048, 3622, 2049, 283, 1838, 7, 10619, 26, 652, 1159, 314, 3089, 402, 314, 4978, 402, 642, 2777, 334, 24685, 282, 283, 1345, 7, 2777, 9, 2344, 267, 2933, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 358, 267, 522, 275, 1052, 267, 367, 3622, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 3622, 14, 344, 315, 522, 26, 355, 1980, 288, 522, 59, 3070, 14, 344, 61, 275, 1211, 1332, 2324, 12, 378, 14, 16, 9, 367, 4325, 315, 901, 63, 1247, 9, 288, 340, 3622, 14, 466, 508, 283, 8370, 356, 355, 327, 652, 1159, 314, 3089, 402, 314, 10632, 12639, 355, 367, 282, 315, 3622, 14, 2048, 63, 1580, 26, 490, 367, 901, 315, 901, 63, 1247, 26, 717, 522, 59, 3070, 14, 344, 1527, 698, 61, 847, 2519, 8, 65, 12, 901, 9, 288, 916, 3622, 14, 466, 508, 283, 2048, 63, 466, 356, 355, 327, 652, 1159, 314, 3089, 314, 11747, 12639, 543, 4066, 376, 2933, 730, 355, 3622, 63, 1313, 275, 359, 88, 14, 344, 367, 671, 315, 3622, 14, 2048, 63, 466, 63, 1580, 61, 355, 2933, 63, 1580, 275, 2933, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 751, 63, 466, 1673, 262, 297, 3622, 63, 1313, 395, 661, 466, 1673, 1111, 1673, 1345, 2665, 1067, 29, 1100, 9, 355, 367, 282, 315, 2933, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2933, 63, 1580, 12, 1067, 29, 1100, 304, 490, 367, 901, 315, 901, 63, 1247, 26, 717, 522, 59, 3070, 14, 344, 1527, 698, 61, 847, 2519, 8, 65, 12, 901, 9, 288, 916, 3622, 14, 466, 508, 283, 2048, 63, 3070, 7, 436, 3622, 14, 2048, 63, 3070, 63, 344, 26, 355, 327, 652, 1159, 314, 5982, 402, 314, 10632, 3622, 355, 522, 18, 275, 291, 423, 362, 63, 7358, 8, 1556, 12, 1747, 12, 359, 3070, 14, 2048, 63, 3070, 63, 344, 14, 344, 467, 901, 63, 1247, 12, 756, 12, 1067, 29, 1100, 9, 355, 367, 790, 12, 574, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bealdav/OpenUpgrade
addons/account_followup/account_followup.py
32
28544
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv from lxml import etree from openerp.tools.translate import _ class followup(osv.osv): _name = 'account_followup.followup' _description = 'Account Follow-up' _rec_name = 'name' _columns = { 'followup_line': fields.one2many('account_followup.followup.line', 'followup_id', 'Follow-up'), 'company_id': fields.many2one('res.company', 'Company', required=True), 'name': fields.related('company_id', 'name', string = "Name", readonly=True, type="char"), } _defaults = { 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account_followup.followup', context=c), } _sql_constraints = [('company_uniq', 'unique(company_id)', 'Only one follow-up per company is allowed')] class followup_line(osv.osv): def _get_default_template(self, cr, uid, ids, context=None): try: return self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup_default')[1] except ValueError: return False _name = 'account_followup.followup.line' _description = 'Follow-up Criteria' _columns = { 'name': fields.char('Follow-Up Action', size=64, required=True), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of follow-up lines."), 'delay': fields.integer('Due Days', help="The number of days after the due date of the invoice to wait before sending the reminder. Could be negative if you want to send a polite alert beforehand.", required=True), 'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"), 'description': fields.text('Printed Message', translate=True), 'send_email':fields.boolean('Send an Email', help="When processing, it will send an email"), 'send_letter':fields.boolean('Send a Letter', help="When processing, it will print a letter"), 'manual_action':fields.boolean('Manual Action', help="When processing, it will set the manual action to be taken for that customer. "), 'manual_action_note':fields.text('Action To Do', placeholder="e.g. Give a phone call, check with others , ..."), 'manual_action_responsible_id':fields.many2one('res.users', 'Assign a Responsible', ondelete='set null'), 'email_template_id':fields.many2one('email.template', 'Email Template', ondelete='set null'), } _order = 'delay' _sql_constraints = [('days_uniq', 'unique(followup_id, delay)', 'Days of the follow-up levels must be different')] _defaults = { 'send_email': True, 'send_letter': True, 'manual_action':False, 'description': """ Dear %(partner_name)s, Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take appropriate measures in order to carry out this payment in the next 8 days. Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to contact our accounting department. Best Regards, """, 'email_template_id': _get_default_template, } def _check_description(self, cr, uid, ids, context=None): for line in self.browse(cr, uid, ids, context=context): if line.description: try: line.description % {'partner_name': '', 'date':'', 'user_signature': '', 'company_name': ''} except: return False return True _constraints = [ (_check_description, 'Your description is invalid, use the right legend or %% if you want to use the percent character.', ['description']), ] class account_move_line(osv.osv): def _get_result(self, cr, uid, ids, name, arg, context=None): res = {} for aml in self.browse(cr, uid, ids, context=context): res[aml.id] = aml.debit - aml.credit return res _inherit = 'account.move.line' _columns = { 'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level', ondelete='restrict'), #restrict deletion of the followup line 'followup_date': fields.date('Latest Follow-up', select=True), 'result':fields.function(_get_result, type='float', method=True, string="Balance") #'balance' field is not the same } class res_partner(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False): res = super(res_partner, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) context = context or {} if view_type == 'form' and context.get('Followupfirst'): doc = etree.XML(res['arch'], parser=None, base_url=None) first_node = doc.xpath("//page[@name='followup_tab']") root = first_node[0].getparent() root.insert(0, first_node[0]) res['arch'] = etree.tostring(doc, encoding="utf-8") return res def _get_latest(self, cr, uid, ids, names, arg, context=None, company_id=None): res={} if company_id == None: company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id else: company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) for partner in self.browse(cr, uid, ids, context=context): amls = partner.unreconciled_aml_ids latest_date = False latest_level = False latest_days = False latest_level_without_lit = False latest_days_without_lit = False for aml in amls: if (aml.company_id == company) and (aml.followup_line_id != False) and (not latest_days or latest_days < aml.followup_line_id.delay): latest_days = aml.followup_line_id.delay latest_level = aml.followup_line_id.id if (aml.company_id == company) and (not latest_date or latest_date < aml.followup_date): latest_date = aml.followup_date if (aml.company_id == company) and (aml.blocked == False) and (aml.followup_line_id != False and (not latest_days_without_lit or latest_days_without_lit < aml.followup_line_id.delay)): latest_days_without_lit = aml.followup_line_id.delay latest_level_without_lit = aml.followup_line_id.id res[partner.id] = {'latest_followup_date': latest_date, 'latest_followup_level_id': latest_level, 'latest_followup_level_id_without_lit': latest_level_without_lit} return res def do_partner_manual_action(self, cr, uid, partner_ids, context=None): #partner_ids -> res.partner for partner in self.browse(cr, uid, partner_ids, context=context): #Check action: check if the action was not empty, if not add action_text= "" if partner.payment_next_action: action_text = (partner.payment_next_action or '') + "\n" + (partner.latest_followup_level_id_without_lit.manual_action_note or '') else: action_text = partner.latest_followup_level_id_without_lit.manual_action_note or '' #Check date: only change when it did not exist already action_date = partner.payment_next_action_date or fields.date.context_today(self, cr, uid, context=context) # Check responsible: if partner has not got a responsible already, take from follow-up responsible_id = False if partner.payment_responsible_id: responsible_id = partner.payment_responsible_id.id else: p = partner.latest_followup_level_id_without_lit.manual_action_responsible_id responsible_id = p and p.id or False self.write(cr, uid, [partner.id], {'payment_next_action_date': action_date, 'payment_next_action': action_text, 'payment_responsible_id': responsible_id}) def do_partner_print(self, cr, uid, wizard_partner_ids, data, context=None): #wizard_partner_ids are ids from special view, not from res.partner if not wizard_partner_ids: return {} data['partner_ids'] = wizard_partner_ids datas = { 'ids': wizard_partner_ids, 'model': 'account_followup.followup', 'form': data } return self.pool['report'].get_action(cr, uid, [], 'account_followup.report_followup', data=datas, context=context) def do_partner_mail(self, cr, uid, partner_ids, context=None): if context is None: context = {} ctx = context.copy() ctx['followup'] = True #partner_ids are res.partner ids # If not defined by latest follow-up level, it will be the default template if it can find it mtp = self.pool.get('email.template') unknown_mails = 0 for partner in self.browse(cr, uid, partner_ids, context=ctx): if partner.email and partner.email.strip(): level = partner.latest_followup_level_id_without_lit if level and level.send_email and level.email_template_id and level.email_template_id.id: mtp.send_mail(cr, uid, level.email_template_id.id, partner.id, context=ctx) else: mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup_default') mtp.send_mail(cr, uid, mail_template_id[1], partner.id, context=ctx) else: unknown_mails = unknown_mails + 1 action_text = _("Email not sent because of email address of partner not filled in") if partner.payment_next_action_date: payment_action_date = min(fields.date.context_today(self, cr, uid, context=ctx), partner.payment_next_action_date) else: payment_action_date = fields.date.context_today(self, cr, uid, context=ctx) if partner.payment_next_action: payment_next_action = partner.payment_next_action + " \n " + action_text else: payment_next_action = action_text self.write(cr, uid, [partner.id], {'payment_next_action_date': payment_action_date, 'payment_next_action': payment_next_action}, context=ctx) return unknown_mails def get_followup_table_html(self, cr, uid, ids, context=None): """ Build the html tables to be included in emails send to partners, when reminding them their overdue invoices. :param ids: [id] of the partner for whom we are building the tables :rtype: string """ from report import account_followup_print assert len(ids) == 1 if context is None: context = {} partner = self.browse(cr, uid, ids[0], context=context) #copy the context to not change global context. Overwrite it because _() looks for the lang in local variable 'context'. #Set the language to use = the partner language context = dict(context, lang=partner.lang) followup_table = '' if partner.unreconciled_aml_ids: company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id current_date = fields.date.context_today(self, cr, uid, context=context) rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser") final_res = rml_parse._lines_get_with_partner(partner, company.id) for currency_dict in final_res: currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'] followup_table += ''' <table border="2" width=100%%> <tr> <td>''' + _("Invoice Date") + '''</td> <td>''' + _("Description") + '''</td> <td>''' + _("Reference") + '''</td> <td>''' + _("Due Date") + '''</td> <td>''' + _("Amount") + " (%s)" % (currency.symbol) + '''</td> <td>''' + _("Lit.") + '''</td> </tr> ''' total = 0 for aml in currency_dict['line']: block = aml['blocked'] and 'X' or ' ' total += aml['balance'] strbegin = "<TD>" strend = "</TD>" date = aml['date_maturity'] or aml['date'] if date <= current_date and aml['balance'] > 0: strbegin = "<TD><B>" strend = "</B></TD>" followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['name'] + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>" total = reduce(lambda x, y: x+y['balance'], currency_dict['line'], 0.00) total = rml_parse.formatLang(total, dp='Account', currency_obj=currency) followup_table += '''<tr> </tr> </table> <center>''' + _("Amount due") + ''' : %s </center>''' % (total) return followup_table def write(self, cr, uid, ids, vals, context=None): if vals.get("payment_responsible_id", False): for part in self.browse(cr, uid, ids, context=context): if part.payment_responsible_id <> vals["payment_responsible_id"]: #Find partner_id of user put as responsible responsible_partner_id = self.pool.get("res.users").browse(cr, uid, vals['payment_responsible_id'], context=context).partner_id.id self.pool.get("mail.thread").message_post(cr, uid, 0, body = _("You became responsible to do the next action for the payment follow-up of") + " <b><a href='#id=" + str(part.id) + "&view_type=form&model=res.partner'> " + part.name + " </a></b>", type = 'comment', subtype = "mail.mt_comment", context = context, model = 'res.partner', res_id = part.id, partner_ids = [responsible_partner_id]) return super(res_partner, self).write(cr, uid, ids, vals, context=context) def action_done(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context=context) def do_button_print(self, cr, uid, ids, context=None): assert(len(ids) == 1) company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id #search if the partner has accounting entries to print. If not, it may not be present in the #psql view the report is based on, so we need to stop the user here. if not self.pool.get('account.move.line').search(cr, uid, [ ('partner_id', '=', ids[0]), ('account_id.type', '=', 'receivable'), ('reconcile_id', '=', False), ('state', '!=', 'draft'), ('company_id', '=', company_id), ], context=context): raise osv.except_osv(_('Error!'),_("The partner does not have any accounting entries to print in the overdue report for the current company.")) self.message_post(cr, uid, [ids[0]], body=_('Printed overdue payments report'), context=context) #build the id of this partner in the psql view. Could be replaced by a search with [('company_id', '=', company_id),('partner_id', '=', ids[0])] wizard_partner_ids = [ids[0] * 10000 + company_id] followup_ids = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)], context=context) if not followup_ids: raise osv.except_osv(_('Error!'),_("There is no followup plan defined for the current company.")) data = { 'date': fields.date.today(), 'followup_id': followup_ids[0], } #call the print overdue report on this partner return self.do_partner_print(cr, uid, wizard_partner_ids, data, context=context) def _get_amounts_and_date(self, cr, uid, ids, name, arg, context=None): ''' Function that computes values for the followup functional fields. Note that 'payment_amount_due' is similar to 'credit' field on res.partner except it filters on user's company. ''' res = {} company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id current_date = fields.date.context_today(self, cr, uid, context=context) for partner in self.browse(cr, uid, ids, context=context): worst_due_date = False amount_due = amount_overdue = 0.0 for aml in partner.unreconciled_aml_ids: if (aml.company_id == company): date_maturity = aml.date_maturity or aml.date if not worst_due_date or date_maturity < worst_due_date: worst_due_date = date_maturity amount_due += aml.result if (date_maturity <= current_date): amount_overdue += aml.result res[partner.id] = {'payment_amount_due': amount_due, 'payment_amount_overdue': amount_overdue, 'payment_earliest_due_date': worst_due_date} return res def _get_followup_overdue_query(self, cr, uid, args, overdue_only=False, context=None): ''' This function is used to build the query and arguments to use when making a search on functional fields * payment_amount_due * payment_amount_overdue Basically, the query is exactly the same except that for overdue there is an extra clause in the WHERE. :param args: arguments given to the search in the usual domain notation (list of tuples) :param overdue_only: option to add the extra argument to filter on overdue accounting entries or not :returns: a tuple with * the query to execute as first element * the arguments for the execution of this query :rtype: (string, []) ''' company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id having_where_clause = ' AND '.join(map(lambda x: '(SUM(bal2) %s %%s)' % (x[1]), args)) having_values = [x[2] for x in args] query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) overdue_only_str = overdue_only and 'AND date_maturity <= NOW()' or '' return ('''SELECT pid AS partner_id, SUM(bal2) FROM (SELECT CASE WHEN bal IS NOT NULL THEN bal ELSE 0.0 END AS bal2, p.id as pid FROM (SELECT (debit-credit) AS bal, partner_id FROM account_move_line l WHERE account_id IN (SELECT id FROM account_account WHERE type=\'receivable\' AND active) ''' + overdue_only_str + ''' AND reconcile_id IS NULL AND company_id = %s AND ''' + query + ''') AS l RIGHT JOIN res_partner p ON p.id = partner_id ) AS pl GROUP BY pid HAVING ''' + having_where_clause, [company_id] + having_values) def _payment_overdue_search(self, cr, uid, obj, name, args, context=None): if not args: return [] query, query_args = self._get_followup_overdue_query(cr, uid, args, overdue_only=True, context=context) cr.execute(query, query_args) res = cr.fetchall() if not res: return [('id','=','0')] return [('id','in', [x[0] for x in res])] def _payment_earliest_date_search(self, cr, uid, obj, name, args, context=None): if not args: return [] company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id having_where_clause = ' AND '.join(map(lambda x: '(MIN(l.date_maturity) %s %%s)' % (x[1]), args)) having_values = [x[2] for x in args] query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) cr.execute('SELECT partner_id FROM account_move_line l '\ 'WHERE account_id IN '\ '(SELECT id FROM account_account '\ 'WHERE type=\'receivable\' AND active) '\ 'AND l.company_id = %s ' 'AND reconcile_id IS NULL '\ 'AND '+query+' '\ 'AND partner_id IS NOT NULL '\ 'GROUP BY partner_id HAVING '+ having_where_clause, [company_id] + having_values) res = cr.fetchall() if not res: return [('id','=','0')] return [('id','in', [x[0] for x in res])] def _payment_due_search(self, cr, uid, obj, name, args, context=None): if not args: return [] query, query_args = self._get_followup_overdue_query(cr, uid, args, overdue_only=False, context=context) cr.execute(query, query_args) res = cr.fetchall() if not res: return [('id','=','0')] return [('id','in', [x[0] for x in res])] def _get_partners(self, cr, uid, ids, context=None): #this function search for the partners linked to all account.move.line 'ids' that have been changed partners = set() for aml in self.browse(cr, uid, ids, context=context): if aml.partner_id: partners.add(aml.partner_id.id) return list(partners) _inherit = "res.partner" _columns = { 'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible', help="Optionally you can assign a user to this field, which will make him responsible for the action.", track_visibility="onchange"), 'payment_note':fields.text('Customer Payment Promise', help="Payment Note", track_visibility="onchange"), 'payment_next_action':fields.text('Next Action', help="This is the next action to be taken. It will automatically be set when the partner gets a follow-up level that requires a manual action. ", track_visibility="onchange"), 'payment_next_action_date':fields.date('Next Action Date', help="This is when the manual follow-up is needed. " \ "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. "\ "Can be practical to set manually e.g. to see if he keeps his promises."), 'unreconciled_aml_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', False), '&', ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]), 'latest_followup_date':fields.function(_get_latest, method=True, type='date', string="Latest Follow-up Date", help="Latest date that the follow-up level of the partner was changed", store=False, multi="latest"), 'latest_followup_level_id':fields.function(_get_latest, method=True, type='many2one', relation='account_followup.followup.line', string="Latest Follow-up Level", help="The maximum follow-up level", store={ 'res.partner': (lambda self, cr, uid, ids, c: ids,[],10), 'account.move.line': (_get_partners, ['followup_line_id'], 10), }, multi="latest"), 'latest_followup_level_id_without_lit':fields.function(_get_latest, method=True, type='many2one', relation='account_followup.followup.line', string="Latest Follow-up Level without litigation", help="The maximum follow-up level without taking into account the account move lines with litigation", store={ 'res.partner': (lambda self, cr, uid, ids, c: ids,[],10), 'account.move.line': (_get_partners, ['followup_line_id'], 10), }, multi="latest"), 'payment_amount_due':fields.function(_get_amounts_and_date, type='float', string="Amount Due", store = False, multi="followup", fnct_search=_payment_due_search), 'payment_amount_overdue':fields.function(_get_amounts_and_date, type='float', string="Amount Overdue", store = False, multi="followup", fnct_search = _payment_overdue_search), 'payment_earliest_due_date':fields.function(_get_amounts_and_date, type='date', string = "Worst Due Date", multi="followup", fnct_search=_payment_earliest_date_search), } class account_config_settings(osv.TransientModel): _name = 'account.config.settings' _inherit = 'account.config.settings' def open_followup_level_form(self, cr, uid, ids, context=None): res_ids = self.pool.get('account_followup.followup').search(cr, uid, [], context=context) return { 'type': 'ir.actions.act_window', 'name': 'Payment Follow-ups', 'res_model': 'account_followup.followup', 'res_id': res_ids and res_ids[0] or False, 'view_mode': 'form,tree', } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 14490, 492, 7559, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 2035, 384, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 2048, 63, 25872, 14, 25872, 7, 272, 485, 1802, 275, 283, 6009, 21876, 13, 384, 7, 272, 485, 2761, 63, 354, 275, 283, 354, 7, 272, 485, 3406, 275, 469, 267, 283, 25872, 63, 604, 356, 1504, 14, 368, 18, 3479, 360, 2048, 63, 25872, 14, 25872, 14, 604, 297, 283, 25872, 63, 344, 297, 283, 18696, 13, 384, 659, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 1415, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 2407, 360, 4627, 63, 344, 297, 283, 354, 297, 1059, 275, 298, 985, 401, 6863, 29, 549, 12, 730, 628, 1560, 1288, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 2400, 308, 12, 2467, 12, 1747, 12, 286, 26, 308, 14, 2293, 14, 362, 360, 470, 14, 4627, 31238, 4627, 63, 885, 63, 362, 8, 1556, 12, 1747, 12, 283, 2048, 63, 25872, 14, 25872, 297, 1067, 29, 67, 395, 272, 789, 272, 485, 3009, 63, 9882, 275, 4274, 4627, 63, 22484, 297, 283, 3235, 8, 4627, 63, 344, 3196, 283, 5903, 1373, 2035, 13, 384, 1126, 7233, 365, 4370, 5440, 221, 421, 199, 533, 2035, 384, 63, 604, 8, 4795, 14, 4795, 304, 339, 347, 485, 362, 63, 885, 63, 1160, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 862, 26, 288, 372, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 25872, 297, 283, 2123, 63, 1160, 63, 2048, 63, 25872, 63, 885, 5832, 17, 61, 267, 871, 1722, 26, 288, 372, 756, 339, 485, 354, 275, 283, 2048, 63, 25872, 14, 25872, 14, 604, 7, 272, 485, 1802, 275, 283, 18696, 13, 384, 445, 7527, 65, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 18696, 13, 1721, 10033, 297, 1568, 29, 772, 12, 1415, 29, 549, 395, 267, 283, 4041, 356, 1504, 14, 4115, 360, 5826, 297, 1720, 628, 39, 7602, 314, 3414, 1865, 1380, 20589, 282, 769, 402, 2035, 13, 384, 2385, 7651, 267, 283, 5814, 356, 1504, 14, 4115, 360, 36, 310, 577, 5758, 297, 1720, 628, 1918, 1329, 402, 7609, 2410, 314, 7037, 1434, 402, 314, 8485, 370, 3618, 2544, 10209, 314, 295, 24820, 14, 221, 18615, 506, 6946, 340, 1265, 2934, 370, 3222, 282, 1115, 5333, 10459, 2544, 6868, 4765, 1415, 29, 549, 395, 267, 283, 25872, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 63, 25872, 14, 25872, 297, 283, 18696, 738, 1190, 297, 1415, 29, 549, 12, 16549, 628, 15377, 1288, 267, 283, 1802, 356, 1504, 14, 505, 360, 9779, 9082, 6430, 297, 9028, 29, 549, 395, 267, 283, 2254, 63, 2123, 356, 955, 14, 4871, 360, 6795, 376, 11426, 297, 1720, 628, 11423, 6661, 12, 652, 911, 3222, 376, 3031, 1288, 267, 283, 2254, 63, 9269, 356, 955, 14, 4871, 360, 6795, 282, 12230, 351, 297, 1720, 628, 11423, 6661, 12, 652, 911, 870, 282, 8082, 1288, 267, 283, 9285, 63, 1287, 356, 955, 14, 4871, 360, 22382, 10033, 297, 1720, 628, 11423, 6661, 12, 652, 911, 663, 314, 8722, 1595, 370, 506, 9394, 367, 626, 15229, 14, 26261, 267, 283, 9285, 63, 1287, 63, 4610, 356, 955, 14, 505, 360, 3310, 4005, 4226, 297, 10069, 628, 69, 14, 71, 14, 25495, 282, 14617, 1240, 12, 1104, 543, 11789, 2360, 2263, 1288, 267, 283, 9285, 63, 1287, 63, 3853, 1164, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 9595, 282, 3591, 678, 1164, 297, 16549, 534, 409, 2973, 659, 267, 283, 2123, 63, 1160, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 2123, 14, 1160, 297, 283, 7035, 5458, 297, 16549, 534, 409, 2973, 659, 272, 789, 272, 485, 1648, 275, 283, 5814, 7, 272, 485, 3009, 63, 9882, 275, 4274, 4899, 63, 22484, 297, 283, 3235, 8, 25872, 63, 344, 12, 7339, 3196, 283, 25589, 402, 314, 2035, 13, 384, 11106, 1471, 506, 3365, 5440, 272, 485, 4322, 275, 469, 267, 283, 2254, 63, 2123, 356, 715, 12, 267, 283, 2254, 63, 9269, 356, 715, 12, 267, 283, 9285, 63, 1287, 356, 797, 12, 267, 283, 1802, 356, 408, 267, 1487, 285, 2818, 3899, 63, 354, 9, 83, 12, 199, 199, 1726, 6326, 340, 2337, 1990, 282, 27572, 1728, 402, 4154, 83, 12, 652, 12237, 626, 314, 2569, 5982, 2612, 588, 625, 16555, 14, 7754, 12, 5452, 5827, 17616, 1482, 315, 1865, 370, 25176, 734, 642, 11628, 315, 314, 2163, 1695, 7609, 14, 199, 199, 55, 3857, 2195, 11628, 1172, 2757, 9590, 18906, 734, 2410 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 14490, 492, 7559, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 2035, 384, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 2048, 63, 25872, 14, 25872, 7, 272, 485, 1802, 275, 283, 6009, 21876, 13, 384, 7, 272, 485, 2761, 63, 354, 275, 283, 354, 7, 272, 485, 3406, 275, 469, 267, 283, 25872, 63, 604, 356, 1504, 14, 368, 18, 3479, 360, 2048, 63, 25872, 14, 25872, 14, 604, 297, 283, 25872, 63, 344, 297, 283, 18696, 13, 384, 659, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 1415, 29, 549, 395, 267, 283, 354, 356, 1504, 14, 2407, 360, 4627, 63, 344, 297, 283, 354, 297, 1059, 275, 298, 985, 401, 6863, 29, 549, 12, 730, 628, 1560, 1288, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 2400, 308, 12, 2467, 12, 1747, 12, 286, 26, 308, 14, 2293, 14, 362, 360, 470, 14, 4627, 31238, 4627, 63, 885, 63, 362, 8, 1556, 12, 1747, 12, 283, 2048, 63, 25872, 14, 25872, 297, 1067, 29, 67, 395, 272, 789, 272, 485, 3009, 63, 9882, 275, 4274, 4627, 63, 22484, 297, 283, 3235, 8, 4627, 63, 344, 3196, 283, 5903, 1373, 2035, 13, 384, 1126, 7233, 365, 4370, 5440, 221, 421, 199, 533, 2035, 384, 63, 604, 8, 4795, 14, 4795, 304, 339, 347, 485, 362, 63, 885, 63, 1160, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 862, 26, 288, 372, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 25872, 297, 283, 2123, 63, 1160, 63, 2048, 63, 25872, 63, 885, 5832, 17, 61, 267, 871, 1722, 26, 288, 372, 756, 339, 485, 354, 275, 283, 2048, 63, 25872, 14, 25872, 14, 604, 7, 272, 485, 1802, 275, 283, 18696, 13, 384, 445, 7527, 65, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 18696, 13, 1721, 10033, 297, 1568, 29, 772, 12, 1415, 29, 549, 395, 267, 283, 4041, 356, 1504, 14, 4115, 360, 5826, 297, 1720, 628, 39, 7602, 314, 3414, 1865, 1380, 20589, 282, 769, 402, 2035, 13, 384, 2385, 7651, 267, 283, 5814, 356, 1504, 14, 4115, 360, 36, 310, 577, 5758, 297, 1720, 628, 1918, 1329, 402, 7609, 2410, 314, 7037, 1434, 402, 314, 8485, 370, 3618, 2544, 10209, 314, 295, 24820, 14, 221, 18615, 506, 6946, 340, 1265, 2934, 370, 3222, 282, 1115, 5333, 10459, 2544, 6868, 4765, 1415, 29, 549, 395, 267, 283, 25872, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 63, 25872, 14, 25872, 297, 283, 18696, 738, 1190, 297, 1415, 29, 549, 12, 16549, 628, 15377, 1288, 267, 283, 1802, 356, 1504, 14, 505, 360, 9779, 9082, 6430, 297, 9028, 29, 549, 395, 267, 283, 2254, 63, 2123, 356, 955, 14, 4871, 360, 6795, 376, 11426, 297, 1720, 628, 11423, 6661, 12, 652, 911, 3222, 376, 3031, 1288, 267, 283, 2254, 63, 9269, 356, 955, 14, 4871, 360, 6795, 282, 12230, 351, 297, 1720, 628, 11423, 6661, 12, 652, 911, 870, 282, 8082, 1288, 267, 283, 9285, 63, 1287, 356, 955, 14, 4871, 360, 22382, 10033, 297, 1720, 628, 11423, 6661, 12, 652, 911, 663, 314, 8722, 1595, 370, 506, 9394, 367, 626, 15229, 14, 26261, 267, 283, 9285, 63, 1287, 63, 4610, 356, 955, 14, 505, 360, 3310, 4005, 4226, 297, 10069, 628, 69, 14, 71, 14, 25495, 282, 14617, 1240, 12, 1104, 543, 11789, 2360, 2263, 1288, 267, 283, 9285, 63, 1287, 63, 3853, 1164, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 9595, 282, 3591, 678, 1164, 297, 16549, 534, 409, 2973, 659, 267, 283, 2123, 63, 1160, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 2123, 14, 1160, 297, 283, 7035, 5458, 297, 16549, 534, 409, 2973, 659, 272, 789, 272, 485, 1648, 275, 283, 5814, 7, 272, 485, 3009, 63, 9882, 275, 4274, 4899, 63, 22484, 297, 283, 3235, 8, 25872, 63, 344, 12, 7339, 3196, 283, 25589, 402, 314, 2035, 13, 384, 11106, 1471, 506, 3365, 5440, 272, 485, 4322, 275, 469, 267, 283, 2254, 63, 2123, 356, 715, 12, 267, 283, 2254, 63, 9269, 356, 715, 12, 267, 283, 9285, 63, 1287, 356, 797, 12, 267, 283, 1802, 356, 408, 267, 1487, 285, 2818, 3899, 63, 354, 9, 83, 12, 199, 199, 1726, 6326, 340, 2337, 1990, 282, 27572, 1728, 402, 4154, 83, 12, 652, 12237, 626, 314, 2569, 5982, 2612, 588, 625, 16555, 14, 7754, 12, 5452, 5827, 17616, 1482, 315, 1865, 370, 25176, 734, 642, 11628, 315, 314, 2163, 1695, 7609, 14, 199, 199, 55, 3857, 2195, 11628, 1172, 2757, 9590, 18906, 734, 2410, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sexroute/commandergenius
project/jni/python/src/Lib/idlelib/tabbedpages.py
142
18188
"""An implementation of tabbed pages using only standard Tkinter. Originally developed for use in IDLE. Based on tabpage.py. Classes exported: TabbedPageSet -- A Tkinter implementation of a tabbed-page widget. TabSet -- A widget containing tabs (buttons) in one or more rows. """ from Tkinter import * class InvalidNameError(Exception): pass class AlreadyExistsError(Exception): pass class TabSet(Frame): """A widget containing tabs (buttons) in one or more rows. Only one tab may be selected at a time. """ def __init__(self, page_set, select_command, tabs=None, n_rows=1, max_tabs_per_row=5, expand_tabs=False, **kw): """Constructor arguments: select_command -- A callable which will be called when a tab is selected. It is called with the name of the selected tab as an argument. tabs -- A list of strings, the names of the tabs. Should be specified in the desired tab order. The first tab will be the default and first active tab. If tabs is None or empty, the TabSet will be initialized empty. n_rows -- Number of rows of tabs to be shown. If n_rows <= 0 or is None, then the number of rows will be decided by TabSet. See _arrange_tabs() for details. max_tabs_per_row -- Used for deciding how many rows of tabs are needed, when the number of rows is not constant. See _arrange_tabs() for details. """ Frame.__init__(self, page_set, **kw) self.select_command = select_command self.n_rows = n_rows self.max_tabs_per_row = max_tabs_per_row self.expand_tabs = expand_tabs self.page_set = page_set self._tabs = {} self._tab2row = {} if tabs: self._tab_names = list(tabs) else: self._tab_names = [] self._selected_tab = None self._tab_rows = [] self.padding_frame = Frame(self, height=2, borderwidth=0, relief=FLAT, background=self.cget('background')) self.padding_frame.pack(side=TOP, fill=X, expand=False) self._arrange_tabs() def add_tab(self, tab_name): """Add a new tab with the name given in tab_name.""" if not tab_name: raise InvalidNameError("Invalid Tab name: '%s'" % tab_name) if tab_name in self._tab_names: raise AlreadyExistsError("Tab named '%s' already exists" %tab_name) self._tab_names.append(tab_name) self._arrange_tabs() def remove_tab(self, tab_name): """Remove the tab named <tab_name>""" if not tab_name in self._tab_names: raise KeyError("No such Tab: '%s" % page_name) self._tab_names.remove(tab_name) self._arrange_tabs() def set_selected_tab(self, tab_name): """Show the tab named <tab_name> as the selected one""" if tab_name == self._selected_tab: return if tab_name is not None and tab_name not in self._tabs: raise KeyError("No such Tab: '%s" % page_name) # deselect the current selected tab if self._selected_tab is not None: self._tabs[self._selected_tab].set_normal() self._selected_tab = None if tab_name is not None: # activate the tab named tab_name self._selected_tab = tab_name tab = self._tabs[tab_name] tab.set_selected() # move the tab row with the selected tab to the bottom tab_row = self._tab2row[tab] tab_row.pack_forget() tab_row.pack(side=TOP, fill=X, expand=0) def _add_tab_row(self, tab_names, expand_tabs): if not tab_names: return tab_row = Frame(self) tab_row.pack(side=TOP, fill=X, expand=0) self._tab_rows.append(tab_row) for tab_name in tab_names: tab = TabSet.TabButton(tab_name, self.select_command, tab_row, self) if expand_tabs: tab.pack(side=LEFT, fill=X, expand=True) else: tab.pack(side=LEFT) self._tabs[tab_name] = tab self._tab2row[tab] = tab_row # tab is the last one created in the above loop tab.is_last_in_row = True def _reset_tab_rows(self): while self._tab_rows: tab_row = self._tab_rows.pop() tab_row.destroy() self._tab2row = {} def _arrange_tabs(self): """ Arrange the tabs in rows, in the order in which they were added. If n_rows >= 1, this will be the number of rows used. Otherwise the number of rows will be calculated according to the number of tabs and max_tabs_per_row. In this case, the number of rows may change when adding/removing tabs. """ # remove all tabs and rows for tab_name in self._tabs.keys(): self._tabs.pop(tab_name).destroy() self._reset_tab_rows() if not self._tab_names: return if self.n_rows is not None and self.n_rows > 0: n_rows = self.n_rows else: # calculate the required number of rows n_rows = (len(self._tab_names) - 1) // self.max_tabs_per_row + 1 # not expanding the tabs with more than one row is very ugly expand_tabs = self.expand_tabs or n_rows > 1 i = 0 # index in self._tab_names for row_index in xrange(n_rows): # calculate required number of tabs in this row n_tabs = (len(self._tab_names) - i - 1) // (n_rows - row_index) + 1 tab_names = self._tab_names[i:i + n_tabs] i += n_tabs self._add_tab_row(tab_names, expand_tabs) # re-select selected tab so it is properly displayed selected = self._selected_tab self.set_selected_tab(None) if selected in self._tab_names: self.set_selected_tab(selected) class TabButton(Frame): """A simple tab-like widget.""" bw = 2 # borderwidth def __init__(self, name, select_command, tab_row, tab_set): """Constructor arguments: name -- The tab's name, which will appear in its button. select_command -- The command to be called upon selection of the tab. It is called with the tab's name as an argument. """ Frame.__init__(self, tab_row, borderwidth=self.bw, relief=RAISED) self.name = name self.select_command = select_command self.tab_set = tab_set self.is_last_in_row = False self.button = Radiobutton( self, text=name, command=self._select_event, padx=5, pady=1, takefocus=FALSE, indicatoron=FALSE, highlightthickness=0, selectcolor='', borderwidth=0) self.button.pack(side=LEFT, fill=X, expand=True) self._init_masks() self.set_normal() def _select_event(self, *args): """Event handler for tab selection. With TabbedPageSet, this calls TabbedPageSet.change_page, so that selecting a tab changes the page. Note that this does -not- call set_selected -- it will be called by TabSet.set_selected_tab, which should be called when whatever the tabs are related to changes. """ self.select_command(self.name) return def set_selected(self): """Assume selected look""" self._place_masks(selected=True) def set_normal(self): """Assume normal look""" self._place_masks(selected=False) def _init_masks(self): page_set = self.tab_set.page_set background = page_set.pages_frame.cget('background') # mask replaces the middle of the border with the background color self.mask = Frame(page_set, borderwidth=0, relief=FLAT, background=background) # mskl replaces the bottom-left corner of the border with a normal # left border self.mskl = Frame(page_set, borderwidth=0, relief=FLAT, background=background) self.mskl.ml = Frame(self.mskl, borderwidth=self.bw, relief=RAISED) self.mskl.ml.place(x=0, y=-self.bw, width=2*self.bw, height=self.bw*4) # mskr replaces the bottom-right corner of the border with a normal # right border self.mskr = Frame(page_set, borderwidth=0, relief=FLAT, background=background) self.mskr.mr = Frame(self.mskr, borderwidth=self.bw, relief=RAISED) def _place_masks(self, selected=False): height = self.bw if selected: height += self.bw self.mask.place(in_=self, relx=0.0, x=0, rely=1.0, y=0, relwidth=1.0, width=0, relheight=0.0, height=height) self.mskl.place(in_=self, relx=0.0, x=-self.bw, rely=1.0, y=0, relwidth=0.0, width=self.bw, relheight=0.0, height=height) page_set = self.tab_set.page_set if selected and ((not self.is_last_in_row) or (self.winfo_rootx() + self.winfo_width() < page_set.winfo_rootx() + page_set.winfo_width()) ): # for a selected tab, if its rightmost edge isn't on the # rightmost edge of the page set, the right mask should be one # borderwidth shorter (vertically) height -= self.bw self.mskr.place(in_=self, relx=1.0, x=0, rely=1.0, y=0, relwidth=0.0, width=self.bw, relheight=0.0, height=height) self.mskr.mr.place(x=-self.bw, y=-self.bw, width=2*self.bw, height=height + self.bw*2) # finally, lower the tab set so that all of the frames we just # placed hide it self.tab_set.lower() class TabbedPageSet(Frame): """A Tkinter tabbed-pane widget. Constains set of 'pages' (or 'panes') with tabs above for selecting which page is displayed. Only one page will be displayed at a time. Pages may be accessed through the 'pages' attribute, which is a dictionary of pages, using the name given as the key. A page is an instance of a subclass of Tk's Frame widget. The page widgets will be created (and destroyed when required) by the TabbedPageSet. Do not call the page's pack/place/grid/destroy methods. Pages may be added or removed at any time using the add_page() and remove_page() methods. """ class Page(object): """Abstract base class for TabbedPageSet's pages. Subclasses must override the _show() and _hide() methods. """ uses_grid = False def __init__(self, page_set): self.frame = Frame(page_set, borderwidth=2, relief=RAISED) def _show(self): raise NotImplementedError def _hide(self): raise NotImplementedError class PageRemove(Page): """Page class using the grid placement manager's "remove" mechanism.""" uses_grid = True def _show(self): self.frame.grid(row=0, column=0, sticky=NSEW) def _hide(self): self.frame.grid_remove() class PageLift(Page): """Page class using the grid placement manager's "lift" mechanism.""" uses_grid = True def __init__(self, page_set): super(TabbedPageSet.PageLift, self).__init__(page_set) self.frame.grid(row=0, column=0, sticky=NSEW) self.frame.lower() def _show(self): self.frame.lift() def _hide(self): self.frame.lower() class PagePackForget(Page): """Page class using the pack placement manager's "forget" mechanism.""" def _show(self): self.frame.pack(fill=BOTH, expand=True) def _hide(self): self.frame.pack_forget() def __init__(self, parent, page_names=None, page_class=PageLift, n_rows=1, max_tabs_per_row=5, expand_tabs=False, **kw): """Constructor arguments: page_names -- A list of strings, each will be the dictionary key to a page's widget, and the name displayed on the page's tab. Should be specified in the desired page order. The first page will be the default and first active page. If page_names is None or empty, the TabbedPageSet will be initialized empty. n_rows, max_tabs_per_row -- Parameters for the TabSet which will manage the tabs. See TabSet's docs for details. page_class -- Pages can be shown/hidden using three mechanisms: * PageLift - All pages will be rendered one on top of the other. When a page is selected, it will be brought to the top, thus hiding all other pages. Using this method, the TabbedPageSet will not be resized when pages are switched. (It may still be resized when pages are added/removed.) * PageRemove - When a page is selected, the currently showing page is hidden, and the new page shown in its place. Using this method, the TabbedPageSet may resize when pages are changed. * PagePackForget - This mechanism uses the pack placement manager. When a page is shown it is packed, and when it is hidden it is unpacked (i.e. pack_forget). This mechanism may also cause the TabbedPageSet to resize when the page is changed. """ Frame.__init__(self, parent, **kw) self.page_class = page_class self.pages = {} self._pages_order = [] self._current_page = None self._default_page = None self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.pages_frame = Frame(self) self.pages_frame.grid(row=1, column=0, sticky=NSEW) if self.page_class.uses_grid: self.pages_frame.columnconfigure(0, weight=1) self.pages_frame.rowconfigure(0, weight=1) # the order of the following commands is important self._tab_set = TabSet(self, self.change_page, n_rows=n_rows, max_tabs_per_row=max_tabs_per_row, expand_tabs=expand_tabs) if page_names: for name in page_names: self.add_page(name) self._tab_set.grid(row=0, column=0, sticky=NSEW) self.change_page(self._default_page) def add_page(self, page_name): """Add a new page with the name given in page_name.""" if not page_name: raise InvalidNameError("Invalid TabPage name: '%s'" % page_name) if page_name in self.pages: raise AlreadyExistsError( "TabPage named '%s' already exists" % page_name) self.pages[page_name] = self.page_class(self.pages_frame) self._pages_order.append(page_name) self._tab_set.add_tab(page_name) if len(self.pages) == 1: # adding first page self._default_page = page_name self.change_page(page_name) def remove_page(self, page_name): """Destroy the page whose name is given in page_name.""" if not page_name in self.pages: raise KeyError("No such TabPage: '%s" % page_name) self._pages_order.remove(page_name) # handle removing last remaining, default, or currently shown page if len(self._pages_order) > 0: if page_name == self._default_page: # set a new default page self._default_page = self._pages_order[0] else: self._default_page = None if page_name == self._current_page: self.change_page(self._default_page) self._tab_set.remove_tab(page_name) page = self.pages.pop(page_name) page.frame.destroy() def change_page(self, page_name): """Show the page whose name is given in page_name.""" if self._current_page == page_name: return if page_name is not None and page_name not in self.pages: raise KeyError("No such TabPage: '%s'" % page_name) if self._current_page is not None: self.pages[self._current_page]._hide() self._current_page = None if page_name is not None: self._current_page = page_name self.pages[page_name]._show() self._tab_set.set_selected_tab(page_name) if __name__ == '__main__': # test dialog root=Tk() tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'], n_rows=0, expand_tabs=False, ) tabPage.pack(side=TOP, expand=TRUE, fill=BOTH) Label(tabPage.pages['Foobar'].frame, text='Foo', pady=20).pack() Label(tabPage.pages['Foobar'].frame, text='Bar', pady=20).pack() Label(tabPage.pages['Baz'].frame, text='Baz').pack() entryPgName=Entry(root) buttonAdd=Button(root, text='Add Page', command=lambda:tabPage.add_page(entryPgName.get())) buttonRemove=Button(root, text='Remove Page', command=lambda:tabPage.remove_page(entryPgName.get())) labelPgName=Label(root, text='name of page to add/remove:') buttonAdd.pack(padx=5, pady=5) buttonRemove.pack(padx=5, pady=5) labelPgName.pack(padx=5) entryPgName.pack(padx=5) root.mainloop()
lgpl-2.1
[ 624, 2493, 4514, 402, 5174, 6123, 6497, 1808, 1454, 4465, 16826, 14, 199, 199, 12834, 1183, 477, 27813, 367, 675, 315, 23240, 14, 21311, 641, 5174, 1606, 14, 647, 14, 199, 199, 15711, 16629, 26, 199, 7690, 6123, 3276, 1084, 1553, 437, 16826, 4514, 402, 282, 5174, 6123, 13, 1606, 3938, 14, 199, 7690, 1084, 1553, 437, 3938, 3035, 12187, 334, 15687, 9, 315, 1373, 503, 1655, 4730, 14, 199, 199, 624, 199, 504, 16826, 492, 627, 199, 199, 533, 6378, 985, 547, 8, 1726, 304, 986, 199, 533, 21086, 23839, 8, 1726, 304, 986, 421, 199, 533, 23159, 1084, 8, 3160, 304, 272, 408, 33, 3938, 3035, 12187, 334, 15687, 9, 315, 1373, 503, 1655, 4730, 14, 339, 5972, 1373, 5174, 1443, 506, 4895, 737, 282, 900, 14, 339, 408, 272, 347, 636, 826, 721, 277, 12, 2034, 63, 409, 12, 3504, 63, 1531, 12, 326, 12187, 29, 403, 12, 302, 63, 3838, 29, 17, 12, 1390, 63, 8741, 63, 529, 63, 1143, 29, 21, 12, 326, 6544, 63, 8741, 29, 797, 12, 1011, 829, 304, 267, 408, 11447, 2368, 26, 398, 3504, 63, 1531, 1553, 437, 4550, 1314, 911, 506, 2797, 1380, 282, 5174, 365, 267, 4895, 14, 2779, 365, 2797, 543, 314, 536, 402, 314, 4895, 5174, 465, 376, 267, 1423, 14, 398, 12187, 1553, 437, 769, 402, 3326, 12, 314, 1561, 402, 314, 12187, 14, 7719, 506, 2013, 315, 267, 314, 6387, 5174, 1865, 14, 710, 1642, 5174, 911, 506, 314, 849, 436, 1642, 267, 4702, 5174, 14, 982, 12187, 365, 488, 503, 2701, 12, 314, 23159, 1084, 911, 506, 10038, 267, 2701, 14, 398, 302, 63, 3838, 1553, 4860, 402, 4730, 402, 12187, 370, 506, 9164, 14, 982, 302, 63, 3838, 2695, 378, 503, 365, 267, 488, 12, 2066, 314, 1329, 402, 4730, 911, 506, 12985, 770, 701, 23159, 1084, 14, 1666, 267, 485, 285, 1842, 63, 8741, 342, 367, 2436, 14, 398, 1390, 63, 8741, 63, 529, 63, 1143, 1553, 8051, 367, 477, 7504, 316, 4212, 5002, 4730, 402, 12187, 787, 4346, 12, 267, 1380, 314, 1329, 402, 4730, 365, 440, 4413, 14, 1666, 485, 285, 1842, 63, 8741, 342, 367, 267, 2436, 14, 398, 408, 267, 11726, 855, 826, 721, 277, 12, 2034, 63, 409, 12, 1011, 829, 9, 267, 291, 14, 2416, 63, 1531, 275, 3504, 63, 1531, 267, 291, 14, 78, 63, 3838, 275, 302, 63, 3838, 267, 291, 14, 988, 63, 8741, 63, 529, 63, 1143, 275, 1390, 63, 8741, 63, 529, 63, 1143, 267, 291, 14, 4441, 63, 8741, 275, 6544, 63, 8741, 267, 291, 14, 1606, 63, 409, 275, 2034, 63, 409, 398, 291, 423, 8741, 275, 1052, 267, 291, 423, 2902, 18, 1143, 275, 1052, 267, 340, 12187, 26, 288, 291, 423, 2902, 63, 1247, 275, 769, 8, 8741, 9, 267, 587, 26, 288, 291, 423, 2902, 63, 1247, 275, 942, 267, 291, 423, 5511, 63, 2902, 275, 488, 267, 291, 423, 2902, 63, 3838, 275, 942, 398, 291, 14, 8358, 63, 1943, 275, 11726, 8, 277, 12, 4569, 29, 18, 12, 3521, 9162, 2063, 29, 16, 12, 28958, 29, 3143, 619, 12, 3521, 8020, 29, 277, 14, 67, 362, 360, 7451, 1333, 267, 291, 14, 8358, 63, 1943, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 797, 9, 398, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 1050, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 1123, 282, 892, 5174, 543, 314, 536, 1627, 315, 5174, 63, 354, 1041, 267, 340, 440, 5174, 63, 354, 26, 288, 746, 6378, 985, 547, 480, 3364, 23159, 536, 26, 1543, 83, 4065, 450, 5174, 63, 354, 9, 267, 340, 5174, 63, 354, 315, 291, 423, 2902, 63, 1247, 26, 288, 746, 21086, 23839, 480, 7690, 4310, 1543, 83, 7, 2575, 3495, 2, 450, 2902, 63, 354, 9, 398, 291, 423, 2902, 63, 1247, 14, 740, 8, 2902, 63, 354, 9, 267, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 2813, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 5587, 314, 5174, 4310, 665, 2902, 63, 354, 11193, 267, 340, 440, 5174, 63, 354, 315, 291, 423, 2902, 63, 1247, 26, 288, 746, 4067, 480, 1944, 4066, 23159, 26, 1543, 83, 2, 450, 2034, 63, 354, 9, 398, 291, 423, 2902, 63, 1247, 14, 2168, 8, 2902, 63, 354, 9, 267, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 663, 63, 5511, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 6824, 314, 5174, 4310, 665, 2902, 63, 354, 30, 465, 314, 4895, 1373, 624, 267, 340, 5174, 63, 354, 508, 291, 423, 5511, 63, 2902, 26, 288, 372, 267, 340, 5174, 63, 354, 365, 440, 488, 436, 5174, 63, 354, 440, 315, 291, 423, 8741, 26, 288, 746, 4067, 480, 1944, 4066, 23159, 26, 1543, 83, 2, 450, 2034, 63, 354, 9, 398, 327, 477, 2416, 314, 1453, 4895, 5174, 267, 340, 291, 423, 5511, 63, 2902, 365, 440, 488, 26, 288, 291, 423, 8741, 59, 277, 423, 5511, 63, 2902, 1055, 409, 63, 3302, 342, 267, 291, 423, 5511, 63, 2902, 275, 488, 398, 340, 5174, 63, 354, 365, 440, 488, 26, 288, 327, 15422, 314, 5174, 4310, 5174, 63, 354, 288, 291, 423, 5511, 63, 2902, 275, 5174, 63, 354, 288, 5174, 275, 291, 423, 8741, 59, 2902, 63, 354, 61, 288, 5174, 14, 409, 63, 5511, 342, 288, 327, 4057, 314, 5174, 1962, 543, 314, 4895, 5174, 370, 314, 9048, 288, 5174, 63, 1143, 275, 291, 423, 2902, 18, 1143, 59, 2902, 61, 288, 5174, 63, 1143, 14, 1389, 63, 28767, 342, 288, 5174, 63, 1143, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 16, 9, 339, 347, 485, 525, 63, 2902, 63, 1143, 8, 277, 12, 5174, 63, 1247, 12, 6544, 63, 8741, 304, 267, 340, 440, 5174, 63, 1247, 26, 288, 372, 398, 5174, 63, 1143, 275, 11726, 8, 277, 9, 267, 5174, 63, 1143, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 16, 9, 267, 291, 423, 2902, 63, 3838, 14, 740, 8, 2902, 63, 1143, 9, 398, 367, 5174, 63 ]
[ 2493, 4514, 402, 5174, 6123, 6497, 1808, 1454, 4465, 16826, 14, 199, 199, 12834, 1183, 477, 27813, 367, 675, 315, 23240, 14, 21311, 641, 5174, 1606, 14, 647, 14, 199, 199, 15711, 16629, 26, 199, 7690, 6123, 3276, 1084, 1553, 437, 16826, 4514, 402, 282, 5174, 6123, 13, 1606, 3938, 14, 199, 7690, 1084, 1553, 437, 3938, 3035, 12187, 334, 15687, 9, 315, 1373, 503, 1655, 4730, 14, 199, 199, 624, 199, 504, 16826, 492, 627, 199, 199, 533, 6378, 985, 547, 8, 1726, 304, 986, 199, 533, 21086, 23839, 8, 1726, 304, 986, 421, 199, 533, 23159, 1084, 8, 3160, 304, 272, 408, 33, 3938, 3035, 12187, 334, 15687, 9, 315, 1373, 503, 1655, 4730, 14, 339, 5972, 1373, 5174, 1443, 506, 4895, 737, 282, 900, 14, 339, 408, 272, 347, 636, 826, 721, 277, 12, 2034, 63, 409, 12, 3504, 63, 1531, 12, 326, 12187, 29, 403, 12, 302, 63, 3838, 29, 17, 12, 1390, 63, 8741, 63, 529, 63, 1143, 29, 21, 12, 326, 6544, 63, 8741, 29, 797, 12, 1011, 829, 304, 267, 408, 11447, 2368, 26, 398, 3504, 63, 1531, 1553, 437, 4550, 1314, 911, 506, 2797, 1380, 282, 5174, 365, 267, 4895, 14, 2779, 365, 2797, 543, 314, 536, 402, 314, 4895, 5174, 465, 376, 267, 1423, 14, 398, 12187, 1553, 437, 769, 402, 3326, 12, 314, 1561, 402, 314, 12187, 14, 7719, 506, 2013, 315, 267, 314, 6387, 5174, 1865, 14, 710, 1642, 5174, 911, 506, 314, 849, 436, 1642, 267, 4702, 5174, 14, 982, 12187, 365, 488, 503, 2701, 12, 314, 23159, 1084, 911, 506, 10038, 267, 2701, 14, 398, 302, 63, 3838, 1553, 4860, 402, 4730, 402, 12187, 370, 506, 9164, 14, 982, 302, 63, 3838, 2695, 378, 503, 365, 267, 488, 12, 2066, 314, 1329, 402, 4730, 911, 506, 12985, 770, 701, 23159, 1084, 14, 1666, 267, 485, 285, 1842, 63, 8741, 342, 367, 2436, 14, 398, 1390, 63, 8741, 63, 529, 63, 1143, 1553, 8051, 367, 477, 7504, 316, 4212, 5002, 4730, 402, 12187, 787, 4346, 12, 267, 1380, 314, 1329, 402, 4730, 365, 440, 4413, 14, 1666, 485, 285, 1842, 63, 8741, 342, 367, 267, 2436, 14, 398, 408, 267, 11726, 855, 826, 721, 277, 12, 2034, 63, 409, 12, 1011, 829, 9, 267, 291, 14, 2416, 63, 1531, 275, 3504, 63, 1531, 267, 291, 14, 78, 63, 3838, 275, 302, 63, 3838, 267, 291, 14, 988, 63, 8741, 63, 529, 63, 1143, 275, 1390, 63, 8741, 63, 529, 63, 1143, 267, 291, 14, 4441, 63, 8741, 275, 6544, 63, 8741, 267, 291, 14, 1606, 63, 409, 275, 2034, 63, 409, 398, 291, 423, 8741, 275, 1052, 267, 291, 423, 2902, 18, 1143, 275, 1052, 267, 340, 12187, 26, 288, 291, 423, 2902, 63, 1247, 275, 769, 8, 8741, 9, 267, 587, 26, 288, 291, 423, 2902, 63, 1247, 275, 942, 267, 291, 423, 5511, 63, 2902, 275, 488, 267, 291, 423, 2902, 63, 3838, 275, 942, 398, 291, 14, 8358, 63, 1943, 275, 11726, 8, 277, 12, 4569, 29, 18, 12, 3521, 9162, 2063, 29, 16, 12, 28958, 29, 3143, 619, 12, 3521, 8020, 29, 277, 14, 67, 362, 360, 7451, 1333, 267, 291, 14, 8358, 63, 1943, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 797, 9, 398, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 1050, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 1123, 282, 892, 5174, 543, 314, 536, 1627, 315, 5174, 63, 354, 1041, 267, 340, 440, 5174, 63, 354, 26, 288, 746, 6378, 985, 547, 480, 3364, 23159, 536, 26, 1543, 83, 4065, 450, 5174, 63, 354, 9, 267, 340, 5174, 63, 354, 315, 291, 423, 2902, 63, 1247, 26, 288, 746, 21086, 23839, 480, 7690, 4310, 1543, 83, 7, 2575, 3495, 2, 450, 2902, 63, 354, 9, 398, 291, 423, 2902, 63, 1247, 14, 740, 8, 2902, 63, 354, 9, 267, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 2813, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 5587, 314, 5174, 4310, 665, 2902, 63, 354, 11193, 267, 340, 440, 5174, 63, 354, 315, 291, 423, 2902, 63, 1247, 26, 288, 746, 4067, 480, 1944, 4066, 23159, 26, 1543, 83, 2, 450, 2034, 63, 354, 9, 398, 291, 423, 2902, 63, 1247, 14, 2168, 8, 2902, 63, 354, 9, 267, 291, 423, 285, 1842, 63, 8741, 342, 339, 347, 663, 63, 5511, 63, 2902, 8, 277, 12, 5174, 63, 354, 304, 267, 408, 6824, 314, 5174, 4310, 665, 2902, 63, 354, 30, 465, 314, 4895, 1373, 624, 267, 340, 5174, 63, 354, 508, 291, 423, 5511, 63, 2902, 26, 288, 372, 267, 340, 5174, 63, 354, 365, 440, 488, 436, 5174, 63, 354, 440, 315, 291, 423, 8741, 26, 288, 746, 4067, 480, 1944, 4066, 23159, 26, 1543, 83, 2, 450, 2034, 63, 354, 9, 398, 327, 477, 2416, 314, 1453, 4895, 5174, 267, 340, 291, 423, 5511, 63, 2902, 365, 440, 488, 26, 288, 291, 423, 8741, 59, 277, 423, 5511, 63, 2902, 1055, 409, 63, 3302, 342, 267, 291, 423, 5511, 63, 2902, 275, 488, 398, 340, 5174, 63, 354, 365, 440, 488, 26, 288, 327, 15422, 314, 5174, 4310, 5174, 63, 354, 288, 291, 423, 5511, 63, 2902, 275, 5174, 63, 354, 288, 5174, 275, 291, 423, 8741, 59, 2902, 63, 354, 61, 288, 5174, 14, 409, 63, 5511, 342, 288, 327, 4057, 314, 5174, 1962, 543, 314, 4895, 5174, 370, 314, 9048, 288, 5174, 63, 1143, 275, 291, 423, 2902, 18, 1143, 59, 2902, 61, 288, 5174, 63, 1143, 14, 1389, 63, 28767, 342, 288, 5174, 63, 1143, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 16, 9, 339, 347, 485, 525, 63, 2902, 63, 1143, 8, 277, 12, 5174, 63, 1247, 12, 6544, 63, 8741, 304, 267, 340, 440, 5174, 63, 1247, 26, 288, 372, 398, 5174, 63, 1143, 275, 11726, 8, 277, 9, 267, 5174, 63, 1143, 14, 1389, 8, 2441, 29, 11422, 12, 5554, 29, 56, 12, 6544, 29, 16, 9, 267, 291, 423, 2902, 63, 3838, 14, 740, 8, 2902, 63, 1143, 9, 398, 367, 5174, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Jobava/csvkit
tests/test_utilities/test_csvjson.py
20
4672
#!/usr/bin/env python import json import six try: import unittest2 as unittest except ImportError: import unittest from csvkit.exceptions import NonUniqueKeyColumnException from csvkit.utilities.csvjson import CSVJSON class TestCSVJSON(unittest.TestCase): def test_simple(self): args = ['examples/dummy.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() js = json.loads(output_file.getvalue()) self.assertDictEqual(js[0], {"a": "1", "c": "3", "b": "2"}) def test_indentation(self): args = ['-i', '4', 'examples/dummy.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() js = json.loads(output_file.getvalue()) self.assertDictEqual(js[0], {"a": "1", "c": "3", "b": "2"}) def test_keying(self): args = ['-k', 'a', 'examples/dummy.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() js = json.loads(output_file.getvalue()) self.assertDictEqual(js, { "1": {"a": "1", "c": "3", "b": "2"} }) def test_duplicate_keys(self): args = ['-k', 'a', 'examples/dummy3.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) self.assertRaises(NonUniqueKeyColumnException, utility.main) def test_geojson(self): args = ['--lat', 'latitude', '--lon', 'longitude', 'examples/test_geo.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() geojson = json.loads(output_file.getvalue()) self.assertEqual(geojson['type'], 'FeatureCollection') self.assertFalse('crs' in geojson) self.assertEqual(geojson['bbox'], [-95.334619, 32.299076986939205, -95.250699, 32.351434]) self.assertEqual(len(geojson['features']), 17) for feature in geojson['features']: self.assertEqual(feature['type'], 'Feature') self.assertFalse('id' in feature) self.assertEqual(len(feature['properties']), 10) geometry = feature['geometry'] self.assertEqual(len(geometry['coordinates']), 2) self.assertTrue(isinstance(geometry['coordinates'][0], float)) self.assertTrue(isinstance(geometry['coordinates'][1], float)) def test_geojson_with_id(self): args = ['--lat', 'latitude', '--lon', 'longitude', '-k', 'slug', 'examples/test_geo.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() geojson = json.loads(output_file.getvalue()) self.assertEqual(geojson['type'], 'FeatureCollection') self.assertFalse('crs' in geojson) self.assertEqual(geojson['bbox'], [-95.334619, 32.299076986939205, -95.250699, 32.351434]) self.assertEqual(len(geojson['features']), 17) for feature in geojson['features']: self.assertEqual(feature['type'], 'Feature') self.assertTrue('id' in feature) self.assertEqual(len(feature['properties']), 9) geometry = feature['geometry'] self.assertEqual(len(geometry['coordinates']), 2) self.assertTrue(isinstance(geometry['coordinates'][0], float)) self.assertTrue(isinstance(geometry['coordinates'][1], float)) def test_geojson_with_crs(self): args = ['--lat', 'latitude', '--lon', 'longitude', '--crs', 'EPSG:4269', 'examples/test_geo.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() geojson = json.loads(output_file.getvalue()) self.assertEqual(geojson['type'], 'FeatureCollection') self.assertTrue('crs' in geojson) self.assertEqual(geojson['bbox'], [-95.334619, 32.299076986939205, -95.250699, 32.351434]) self.assertEqual(len(geojson['features']), 17) crs = geojson['crs'] self.assertEqual(crs['type'], 'name') self.assertEqual(crs['properties']['name'], 'EPSG:4269') def test_json_streaming(self): args = ['--stream', 'examples/dummy3.csv'] output_file = six.StringIO() utility = CSVJSON(args, output_file) utility.main() result = list(map(json.loads, output_file.getvalue().splitlines())) self.assertEqual(len(result), 2) self.assertDictEqual(result[0], {"a": "1", "c": "3", "b": "2"}) self.assertDictEqual(result[1], {"a": "1", "c": "5", "b": "4"})
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2022, 199, 199, 646, 3816, 199, 199, 893, 26, 272, 492, 2882, 18, 465, 2882, 199, 2590, 3545, 26, 272, 492, 2882, 199, 199, 504, 7392, 6065, 14, 3924, 492, 10172, 11427, 1197, 4547, 1726, 199, 504, 7392, 6065, 14, 16355, 14, 4737, 1001, 492, 14689, 6243, 199, 199, 533, 1379, 19018, 6243, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4129, 8, 277, 304, 267, 1249, 275, 788, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 398, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 59, 16, 467, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 5984, 339, 347, 511, 63, 25152, 8, 277, 304, 267, 1249, 275, 11573, 73, 297, 283, 20, 297, 283, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 398, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 59, 16, 467, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 5984, 339, 347, 511, 63, 498, 316, 8, 277, 304, 267, 1249, 275, 11573, 75, 297, 283, 65, 297, 283, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 12, 469, 298, 17, 582, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 3570, 3828, 339, 347, 511, 63, 11081, 63, 1612, 8, 277, 304, 267, 1249, 275, 11573, 75, 297, 283, 65, 297, 283, 8589, 15, 5869, 19, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 398, 291, 14, 1855, 8, 6932, 11427, 1197, 4547, 1726, 12, 11420, 14, 973, 9, 339, 347, 511, 63, 27043, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 283, 5968, 7768, 358, 267, 291, 14, 3334, 360, 19034, 7, 315, 8509, 1001, 9, 267, 291, 14, 629, 8, 27043, 459, 11246, 995, 5243, 2720, 14, 8425, 30270, 12, 4337, 14, 10488, 1780, 1876, 13254, 1355, 10629, 12, 446, 2720, 14, 821, 1690, 1020, 12, 4337, 14, 1276, 1079, 1082, 566, 267, 291, 14, 629, 8, 552, 8, 27043, 459, 3179, 3815, 5557, 9, 398, 367, 3878, 315, 8509, 1001, 459, 3179, 2565, 288, 291, 14, 629, 8, 4445, 459, 466, 995, 283, 5968, 358, 288, 291, 14, 3334, 360, 344, 7, 315, 3878, 9, 288, 291, 14, 629, 8, 552, 8, 4445, 459, 3282, 3815, 1616, 9, 7846, 3400, 275, 3878, 459, 7660, 418, 953, 291, 14, 629, 8, 552, 8, 7660, 459, 12924, 3815, 499, 9, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 16, 467, 2069, 430, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 17, 467, 2069, 430, 339, 347, 511, 63, 27043, 63, 1045, 63, 344, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 2475, 75, 297, 283, 5464, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 283, 5968, 7768, 358, 267, 291, 14, 3334, 360, 19034, 7, 315, 8509, 1001, 9, 267, 291, 14, 629, 8, 27043, 459, 11246, 995, 5243, 2720, 14, 8425, 30270, 12, 4337, 14, 10488, 1780, 1876, 13254, 1355, 10629, 12, 446, 2720, 14, 821, 1690, 1020, 12, 4337, 14, 1276, 1079, 1082, 566, 267, 291, 14, 629, 8, 552, 8, 27043, 459, 3179, 3815, 5557, 9, 398, 367, 3878, 315, 8509, 1001, 459, 3179, 2565, 288, 291, 14, 629, 8, 4445, 459, 466, 995, 283, 5968, 358, 288, 291, 14, 1815, 360, 344, 7, 315, 3878, 9, 288, 291, 14, 629, 8, 552, 8, 4445, 459, 3282, 3815, 1749, 9, 7846, 3400, 275, 3878, 459, 7660, 418, 953, 291, 14, 629, 8, 552, 8, 7660, 459, 12924, 3815, 499, 9, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 16, 467, 2069, 430, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 17, 467, 2069, 430, 339, 347, 511, 63, 27043, 63, 1045, 63, 19034, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 2850, 19034, 297, 283, 19672, 26, 20, 12442, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 283, 5968, 7768, 358, 267, 291, 14, 1815, 360, 19034, 7, 315, 8509, 1001, 9, 267, 291, 14, 629, 8, 27043, 459, 11246, 995, 5243, 2720, 14, 8425, 30270, 12, 4337, 14, 10488, 1780, 1876, 13254, 1355, 10629, 12, 446, 2720 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2022, 199, 199, 646, 3816, 199, 199, 893, 26, 272, 492, 2882, 18, 465, 2882, 199, 2590, 3545, 26, 272, 492, 2882, 199, 199, 504, 7392, 6065, 14, 3924, 492, 10172, 11427, 1197, 4547, 1726, 199, 504, 7392, 6065, 14, 16355, 14, 4737, 1001, 492, 14689, 6243, 199, 199, 533, 1379, 19018, 6243, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4129, 8, 277, 304, 267, 1249, 275, 788, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 398, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 59, 16, 467, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 5984, 339, 347, 511, 63, 25152, 8, 277, 304, 267, 1249, 275, 11573, 73, 297, 283, 20, 297, 283, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 398, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 59, 16, 467, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 5984, 339, 347, 511, 63, 498, 316, 8, 277, 304, 267, 1249, 275, 11573, 75, 297, 283, 65, 297, 283, 8589, 15, 5869, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8586, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 19512, 8, 3596, 12, 469, 298, 17, 582, 2420, 65, 582, 298, 17, 401, 298, 67, 582, 298, 19, 401, 298, 66, 582, 298, 18, 3570, 3828, 339, 347, 511, 63, 11081, 63, 1612, 8, 277, 304, 267, 1249, 275, 11573, 75, 297, 283, 65, 297, 283, 8589, 15, 5869, 19, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 398, 291, 14, 1855, 8, 6932, 11427, 1197, 4547, 1726, 12, 11420, 14, 973, 9, 339, 347, 511, 63, 27043, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 283, 5968, 7768, 358, 267, 291, 14, 3334, 360, 19034, 7, 315, 8509, 1001, 9, 267, 291, 14, 629, 8, 27043, 459, 11246, 995, 5243, 2720, 14, 8425, 30270, 12, 4337, 14, 10488, 1780, 1876, 13254, 1355, 10629, 12, 446, 2720, 14, 821, 1690, 1020, 12, 4337, 14, 1276, 1079, 1082, 566, 267, 291, 14, 629, 8, 552, 8, 27043, 459, 3179, 3815, 5557, 9, 398, 367, 3878, 315, 8509, 1001, 459, 3179, 2565, 288, 291, 14, 629, 8, 4445, 459, 466, 995, 283, 5968, 358, 288, 291, 14, 3334, 360, 344, 7, 315, 3878, 9, 288, 291, 14, 629, 8, 552, 8, 4445, 459, 3282, 3815, 1616, 9, 7846, 3400, 275, 3878, 459, 7660, 418, 953, 291, 14, 629, 8, 552, 8, 7660, 459, 12924, 3815, 499, 9, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 16, 467, 2069, 430, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 17, 467, 2069, 430, 339, 347, 511, 63, 27043, 63, 1045, 63, 344, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 2475, 75, 297, 283, 5464, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 283, 5968, 7768, 358, 267, 291, 14, 3334, 360, 19034, 7, 315, 8509, 1001, 9, 267, 291, 14, 629, 8, 27043, 459, 11246, 995, 5243, 2720, 14, 8425, 30270, 12, 4337, 14, 10488, 1780, 1876, 13254, 1355, 10629, 12, 446, 2720, 14, 821, 1690, 1020, 12, 4337, 14, 1276, 1079, 1082, 566, 267, 291, 14, 629, 8, 552, 8, 27043, 459, 3179, 3815, 5557, 9, 398, 367, 3878, 315, 8509, 1001, 459, 3179, 2565, 288, 291, 14, 629, 8, 4445, 459, 466, 995, 283, 5968, 358, 288, 291, 14, 1815, 360, 344, 7, 315, 3878, 9, 288, 291, 14, 629, 8, 552, 8, 4445, 459, 3282, 3815, 1749, 9, 7846, 3400, 275, 3878, 459, 7660, 418, 953, 291, 14, 629, 8, 552, 8, 7660, 459, 12924, 3815, 499, 9, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 16, 467, 2069, 430, 288, 291, 14, 1815, 8, 6074, 8, 7660, 459, 12924, 3488, 17, 467, 2069, 430, 339, 347, 511, 63, 27043, 63, 1045, 63, 19034, 8, 277, 304, 267, 1249, 275, 14574, 4452, 297, 283, 13331, 297, 2850, 5298, 297, 283, 13803, 297, 2850, 19034, 297, 283, 19672, 26, 20, 12442, 297, 283, 8589, 15, 396, 63, 6721, 14, 4737, 418, 267, 1072, 63, 493, 275, 3816, 14, 6424, 342, 2728, 11420, 275, 14689, 6243, 8, 589, 12, 1072, 63, 493, 9, 267, 11420, 14, 973, 342, 398, 8509, 1001, 275, 2022, 14, 3640, 8, 1199, 63, 493, 14, 7150, 1012, 398, 291, 14, 629, 8, 27043, 459, 466, 995, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
burkesquires/pyeq2
ExtendedVersionHandlers/ExtendedVersionHandler_Inverse.py
3
1956
from __future__ import print_function from __future__ import unicode_literals from __future__ import absolute_import # pyeq2 is a collection of equations expressed as Python classes # # Copyright (C) 2013 James R. Phillips # 2548 Vera Cruz Drive # Birmingham, AL 35235 USA # # email: zunzun@zunzun.com # # License: BSD-style (see LICENSE.txt in main source directory) import pyeq2 from . import IExtendedVersionHandler class ExtendedVersionHandler_Inverse(IExtendedVersionHandler.IExtendedVersionHandler): def AssembleDisplayHTML(self, inModel): if inModel.GetDimensionality() == 2: return inModel._HTML + '<br>' + inModel._leftSideHTML + ' = x / ' + inModel._leftSideHTML else: return inModel._HTML + '<br>' + inModel._leftSideHTML + ' = xy / ' + inModel._leftSideHTML def AssembleDisplayName(self, inModel): return'Inverse ' + inModel._baseName def AssembleSourceCodeName(self, inModel): return inModel.__module__.split('.')[-1] + '_' + inModel.__class__.__name__ + "_Inverse" def AssembleCoefficientDesignators(self, inModel): return inModel._coefficientDesignators # overridden from abstract parent class def AppendAdditionalCoefficientBounds(self, inModel): return def AssembleOutputSourceCodeCPP(self, inModel): if inModel.GetDimensionality() == 2: return inModel.SpecificCodeCPP() + "\ttemp = x_in / temp;\n" else: return inModel.SpecificCodeCPP() + "\ttemp = (x_in * y_in) / temp;\n" def GetAdditionalModelPredictions(self, inBaseModelCalculation, inCoeffs, inDataCacheDictionary, inModel): if inModel.GetDimensionality() == 2: return self.ConvertInfAndNanToLargeNumber(inDataCacheDictionary['X'] / inBaseModelCalculation) else: return self.ConvertInfAndNanToLargeNumber(inDataCacheDictionary['XY'] / inBaseModelCalculation)
bsd-2-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 3, 259, 1134, 4077, 18, 365, 282, 3245, 402, 26426, 19147, 465, 2018, 3992, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6171, 1603, 14015, 820, 14, 11308, 8148, 1190, 199, 3, 259, 499, 17054, 5444, 65, 445, 6558, 90, 577, 6053, 199, 3, 259, 699, 723, 14566, 10670, 12, 12112, 650, 2528, 1276, 8217, 199, 3, 199, 3, 259, 3031, 26, 1315, 324, 90, 324, 32, 90, 324, 90, 324, 14, 957, 199, 3, 199, 3, 259, 844, 26, 6289, 13, 2487, 334, 3239, 5113, 14, 2424, 315, 2446, 1350, 2082, 9, 199, 199, 646, 1134, 4077, 18, 199, 504, 1275, 492, 473, 14107, 3353, 2461, 421, 199, 533, 13706, 3353, 2461, 63, 28274, 8, 41, 14107, 3353, 2461, 14, 41, 14107, 3353, 2461, 304, 2286, 347, 3709, 8834, 7687, 4943, 8, 277, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 315, 1685, 423, 4943, 435, 2650, 3289, 3524, 435, 315, 1685, 423, 3039, 15414, 4943, 435, 283, 275, 671, 1182, 283, 435, 315, 1685, 423, 3039, 15414, 4943, 267, 587, 26, 288, 372, 315, 1685, 423, 4943, 435, 2650, 3289, 3524, 435, 315, 1685, 423, 3039, 15414, 4943, 435, 283, 275, 13222, 1182, 283, 435, 315, 1685, 423, 3039, 15414, 4943, 2378, 347, 3709, 8834, 24885, 8, 277, 12, 315, 1685, 304, 267, 372, 7, 28274, 283, 435, 315, 1685, 423, 1095, 985, 2378, 347, 3709, 8834, 2980, 3034, 985, 8, 277, 12, 315, 1685, 304, 267, 372, 315, 1685, 855, 578, 4343, 1294, 29084, 17, 61, 435, 14135, 435, 315, 1685, 855, 533, 4914, 354, 363, 435, 2668, 28274, 2, 2378, 347, 3709, 8834, 967, 21069, 20924, 2750, 8, 277, 12, 315, 1685, 304, 267, 372, 315, 1685, 423, 21329, 20924, 2750, 2378, 327, 10087, 687, 9006, 1676, 1021, 272, 347, 18726, 8824, 967, 21069, 23557, 8, 277, 12, 315, 1685, 304, 267, 372, 2378, 347, 3709, 8834, 2959, 2980, 3034, 14533, 8, 277, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 315, 1685, 14, 16786, 3034, 14533, 342, 435, 1867, 84, 808, 275, 671, 63, 262, 1182, 2388, 3779, 78, 2, 267, 587, 26, 288, 372, 315, 1685, 14, 16786, 3034, 14533, 342, 435, 1867, 84, 808, 275, 334, 88, 63, 262, 627, 612, 63, 262, 9, 1182, 2388, 3779, 78, 2, 2378, 347, 2372, 8824, 1685, 14730, 2452, 8, 277, 12, 315, 27687, 13862, 425, 12, 315, 967, 3609, 83, 12, 315, 1451, 4437, 11728, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 291, 14, 7306, 17354, 3325, 27531, 1378, 17149, 3259, 8, 262, 1451, 4437, 11728, 459, 56, 418, 1182, 315, 27687, 13862, 425, 9, 267, 587, 26, 288, 372, 291, 14, 7306, 17354, 3325, 27531, 1378, 17149, 3259, 8, 262, 1451, 4437, 11728, 459, 8195, 418, 1182, 315, 27687, 13862, 425, 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 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 3, 259, 1134, 4077, 18, 365, 282, 3245, 402, 26426, 19147, 465, 2018, 3992, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 6171, 1603, 14015, 820, 14, 11308, 8148, 1190, 199, 3, 259, 499, 17054, 5444, 65, 445, 6558, 90, 577, 6053, 199, 3, 259, 699, 723, 14566, 10670, 12, 12112, 650, 2528, 1276, 8217, 199, 3, 199, 3, 259, 3031, 26, 1315, 324, 90, 324, 32, 90, 324, 90, 324, 14, 957, 199, 3, 199, 3, 259, 844, 26, 6289, 13, 2487, 334, 3239, 5113, 14, 2424, 315, 2446, 1350, 2082, 9, 199, 199, 646, 1134, 4077, 18, 199, 504, 1275, 492, 473, 14107, 3353, 2461, 421, 199, 533, 13706, 3353, 2461, 63, 28274, 8, 41, 14107, 3353, 2461, 14, 41, 14107, 3353, 2461, 304, 2286, 347, 3709, 8834, 7687, 4943, 8, 277, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 315, 1685, 423, 4943, 435, 2650, 3289, 3524, 435, 315, 1685, 423, 3039, 15414, 4943, 435, 283, 275, 671, 1182, 283, 435, 315, 1685, 423, 3039, 15414, 4943, 267, 587, 26, 288, 372, 315, 1685, 423, 4943, 435, 2650, 3289, 3524, 435, 315, 1685, 423, 3039, 15414, 4943, 435, 283, 275, 13222, 1182, 283, 435, 315, 1685, 423, 3039, 15414, 4943, 2378, 347, 3709, 8834, 24885, 8, 277, 12, 315, 1685, 304, 267, 372, 7, 28274, 283, 435, 315, 1685, 423, 1095, 985, 2378, 347, 3709, 8834, 2980, 3034, 985, 8, 277, 12, 315, 1685, 304, 267, 372, 315, 1685, 855, 578, 4343, 1294, 29084, 17, 61, 435, 14135, 435, 315, 1685, 855, 533, 4914, 354, 363, 435, 2668, 28274, 2, 2378, 347, 3709, 8834, 967, 21069, 20924, 2750, 8, 277, 12, 315, 1685, 304, 267, 372, 315, 1685, 423, 21329, 20924, 2750, 2378, 327, 10087, 687, 9006, 1676, 1021, 272, 347, 18726, 8824, 967, 21069, 23557, 8, 277, 12, 315, 1685, 304, 267, 372, 2378, 347, 3709, 8834, 2959, 2980, 3034, 14533, 8, 277, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 315, 1685, 14, 16786, 3034, 14533, 342, 435, 1867, 84, 808, 275, 671, 63, 262, 1182, 2388, 3779, 78, 2, 267, 587, 26, 288, 372, 315, 1685, 14, 16786, 3034, 14533, 342, 435, 1867, 84, 808, 275, 334, 88, 63, 262, 627, 612, 63, 262, 9, 1182, 2388, 3779, 78, 2, 2378, 347, 2372, 8824, 1685, 14730, 2452, 8, 277, 12, 315, 27687, 13862, 425, 12, 315, 967, 3609, 83, 12, 315, 1451, 4437, 11728, 12, 315, 1685, 304, 267, 340, 315, 1685, 14, 1002, 17905, 6712, 342, 508, 499, 26, 288, 372, 291, 14, 7306, 17354, 3325, 27531, 1378, 17149, 3259, 8, 262, 1451, 4437, 11728, 459, 56, 418, 1182, 315, 27687, 13862, 425, 9, 267, 587, 26, 288, 372, 291, 14, 7306, 17354, 3325, 27531, 1378, 17149, 3259, 8, 262, 1451, 4437, 11728, 459, 8195, 418, 1182, 315, 27687, 13862, 425, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xNovax/SickRage
lib/feedcache/test_cache.py
28
10024
#!/usr/bin/env python # # Copyright 2007 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Unittests for feedcache.cache """ __module_id__ = "$Id$" import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(name)s %(message)s', ) logger = logging.getLogger('feedcache.test_cache') # # Import system modules # import copy import time import unittest import UserDict # # Import local modules # import cache from test_server import HTTPTestBase, TestHTTPServer # # Module # class CacheTestBase(HTTPTestBase): CACHE_TTL = 30 def setUp(self): HTTPTestBase.setUp(self) self.storage = self.getStorage() self.cache = cache.Cache(self.storage, timeToLiveSeconds=self.CACHE_TTL, userAgent='feedcache.test', ) return def getStorage(self): "Return a cache storage for the test." return {} class CacheTest(CacheTestBase): CACHE_TTL = 30 def getServer(self): "These tests do not want to use the ETag or If-Modified-Since headers" return TestHTTPServer(applyModifiedHeaders=False) def testRetrieveNotInCache(self): # Retrieve data not already in the cache. feed_data = self.cache.fetch(self.TEST_URL) self.failUnless(feed_data) self.failUnlessEqual(feed_data.feed.title, 'CacheTest test data') return def testRetrieveIsInCache(self): # Retrieve data which is alread in the cache, # and verify that the second copy is identitical # to the first. # First fetch feed_data = self.cache.fetch(self.TEST_URL) # Second fetch feed_data2 = self.cache.fetch(self.TEST_URL) # Since it is the in-memory storage, we should have the # exact same object. self.failUnless(feed_data is feed_data2) return def testExpireDataInCache(self): # Retrieve data which is in the cache but which # has expired and verify that the second copy # is different from the first. # First fetch feed_data = self.cache.fetch(self.TEST_URL) # Change the timeout and sleep to move the clock self.cache.time_to_live = 0 time.sleep(1) # Second fetch feed_data2 = self.cache.fetch(self.TEST_URL) # Since we reparsed, the cache response should be different. self.failIf(feed_data is feed_data2) return def testForceUpdate(self): # Force cache to retrieve data which is alread in the cache, # and verify that the new data is different. # Pre-populate the storage with bad data self.cache.storage[self.TEST_URL] = (time.time() + 100, self.id()) # Fetch the data feed_data = self.cache.fetch(self.TEST_URL, force_update=True) self.failIfEqual(feed_data, self.id()) return def testOfflineMode(self): # Retrieve data which is alread in the cache, # whether it is expired or not. # Pre-populate the storage with data self.cache.storage[self.TEST_URL] = (0, self.id()) # Fetch it feed_data = self.cache.fetch(self.TEST_URL, offline=True) self.failUnlessEqual(feed_data, self.id()) return def testUnicodeURL(self): # Pass in a URL which is unicode url = unicode(self.TEST_URL) feed_data = self.cache.fetch(url) storage = self.cache.storage key = unicode(self.TEST_URL).encode('UTF-8') # Verify that the storage has a key self.failUnless(key in storage) # Now pull the data from the storage directly storage_timeout, storage_data = self.cache.storage.get(key) self.failUnlessEqual(feed_data, storage_data) return class SingleWriteMemoryStorage(UserDict.UserDict): """Cache storage which only allows the cache value for a URL to be updated one time. """ def __setitem__(self, url, data): if url in self.keys(): modified, existing = self[url] # Allow the modified time to change, # but not the feed content. if data[1] != existing: raise AssertionError('Trying to update cache for %s to %s' \ % (url, data)) UserDict.UserDict.__setitem__(self, url, data) return class CacheConditionalGETTest(CacheTestBase): CACHE_TTL = 0 def getStorage(self): return SingleWriteMemoryStorage() def testFetchOnceForEtag(self): # Fetch data which has a valid ETag value, and verify # that while we hit the server twice the response # codes cause us to use the same data. # First fetch populates the cache response1 = self.cache.fetch(self.TEST_URL) self.failUnlessEqual(response1.feed.title, 'CacheTest test data') # Remove the modified setting from the cache so we know # the next time we check the etag will be used # to check for updates. Since we are using an in-memory # cache, modifying response1 updates the cache storage # directly. response1['modified'] = None # This should result in a 304 status, and no data from # the server. That means the cache won't try to # update the storage, so our SingleWriteMemoryStorage # should not raise and we should have the same # response object. response2 = self.cache.fetch(self.TEST_URL) self.failUnless(response1 is response2) # Should have hit the server twice self.failUnlessEqual(self.server.getNumRequests(), 2) return def testFetchOnceForModifiedTime(self): # Fetch data which has a valid Last-Modified value, and verify # that while we hit the server twice the response # codes cause us to use the same data. # First fetch populates the cache response1 = self.cache.fetch(self.TEST_URL) self.failUnlessEqual(response1.feed.title, 'CacheTest test data') # Remove the etag setting from the cache so we know # the next time we check the modified time will be used # to check for updates. Since we are using an in-memory # cache, modifying response1 updates the cache storage # directly. response1['etag'] = None # This should result in a 304 status, and no data from # the server. That means the cache won't try to # update the storage, so our SingleWriteMemoryStorage # should not raise and we should have the same # response object. response2 = self.cache.fetch(self.TEST_URL) self.failUnless(response1 is response2) # Should have hit the server twice self.failUnlessEqual(self.server.getNumRequests(), 2) return class CacheRedirectHandlingTest(CacheTestBase): def _test(self, response): # Set up the server to redirect requests, # then verify that the cache is not updated # for the original or new URL and that the # redirect status is fed back to us with # the fetched data. self.server.setResponse(response, '/redirected') response1 = self.cache.fetch(self.TEST_URL) # The response should include the status code we set self.failUnlessEqual(response1.get('status'), response) # The response should include the new URL, too self.failUnlessEqual(response1.href, self.TEST_URL + 'redirected') # The response should not have been cached under either URL self.failIf(self.TEST_URL in self.storage) self.failIf(self.TEST_URL + 'redirected' in self.storage) return def test301(self): self._test(301) def test302(self): self._test(302) def test303(self): self._test(303) def test307(self): self._test(307) class CachePurgeTest(CacheTestBase): def testPurgeAll(self): # Remove everything from the cache self.cache.fetch(self.TEST_URL) self.failUnless(self.storage.keys(), 'Have no data in the cache storage') self.cache.purge(None) self.failIf(self.storage.keys(), 'Still have data in the cache storage') return def testPurgeByAge(self): # Remove old content from the cache self.cache.fetch(self.TEST_URL) self.failUnless(self.storage.keys(), 'have no data in the cache storage') time.sleep(1) remains = (time.time(), copy.deepcopy(self.storage[self.TEST_URL][1])) self.storage['http://this.should.remain/'] = remains self.cache.purge(1) self.failUnlessEqual(self.storage.keys(), ['http://this.should.remain/']) return if __name__ == '__main__': unittest.main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 577, 810, 71, 869, 1697, 20059, 14, 199, 3, 199, 3, 199, 3, 12793, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 577, 810, 71, 199, 3, 869, 1697, 20059, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 199, 3, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 6791, 199, 3, 4983, 14, 199, 3, 199, 3, 3506, 10134, 869, 14952, 6588, 46, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 4141, 12, 199, 3, 6931, 11727, 5292, 2990, 1634, 3169, 2401, 3092, 12, 1621, 199, 3, 4825, 6461, 7000, 3506, 10134, 869, 14952, 6588, 46, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 199, 3, 9110, 6736, 1549, 1821, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 199, 3, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 199, 3, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 199, 624, 1358, 1770, 83, 367, 4733, 1637, 14, 1637, 199, 199, 624, 199, 199, 363, 578, 63, 344, 363, 275, 7880, 1304, 17351, 199, 199, 646, 2050, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 12, 490, 1475, 29342, 18331, 9, 83, 2818, 20056, 7216, 24, 83, 2818, 354, 9, 83, 2818, 1188, 9, 83, 297, 490, 776, 199, 2921, 275, 2050, 14, 5572, 360, 3871, 1637, 14, 396, 63, 1637, 358, 199, 199, 3, 199, 3, 3161, 2656, 4621, 199, 3, 199, 646, 1331, 199, 646, 900, 199, 646, 2882, 199, 646, 32241, 199, 199, 3, 199, 3, 3161, 2257, 4621, 199, 3, 199, 646, 2581, 199, 504, 511, 63, 1000, 492, 3101, 14440, 12, 1379, 14938, 199, 199, 3, 199, 3, 5673, 199, 3, 421, 199, 533, 11977, 14440, 8, 2856, 14440, 304, 339, 7240, 4576, 63, 25567, 275, 4233, 339, 347, 3613, 8, 277, 304, 267, 3101, 14440, 14, 5996, 8, 277, 9, 398, 291, 14, 3494, 275, 291, 14, 362, 6408, 342, 267, 291, 14, 1637, 275, 2581, 14, 4437, 8, 277, 14, 3494, 12, 639, 900, 1378, 17458, 13165, 29, 277, 14, 8677, 63, 25567, 12, 639, 922, 7788, 534, 3871, 1637, 14, 396, 297, 639, 776, 267, 372, 339, 347, 664, 6408, 8, 277, 304, 267, 298, 1767, 282, 2581, 4887, 367, 314, 511, 2122, 267, 372, 1052, 421, 199, 533, 11977, 774, 8, 4437, 14440, 304, 339, 7240, 4576, 63, 25567, 275, 4233, 339, 347, 664, 3120, 8, 277, 304, 267, 298, 20676, 2295, 886, 440, 2934, 370, 675, 314, 662, 1931, 503, 982, 13, 11911, 13, 24430, 2323, 2, 267, 372, 1379, 14938, 8, 4998, 11911, 9883, 29, 797, 9, 339, 347, 511, 15310, 1763, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 440, 2575, 315, 314, 2581, 14, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 267, 291, 14, 7589, 8, 3871, 63, 576, 9, 267, 291, 14, 14247, 8, 3871, 63, 576, 14, 3871, 14, 1213, 12, 283, 4437, 774, 511, 666, 358, 267, 372, 339, 347, 511, 15310, 1831, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 436, 4911, 626, 314, 3499, 1331, 365, 6120, 280, 3294, 267, 327, 370, 314, 1642, 14, 398, 327, 7758, 5267, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 16707, 5267, 267, 4733, 63, 576, 18, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 9336, 652, 365, 314, 315, 13, 4844, 4887, 12, 781, 1077, 1172, 314, 267, 327, 5835, 2011, 909, 14, 267, 291, 14, 7589, 8, 3871, 63, 576, 365, 4733, 63, 576, 18, 9, 267, 372, 339, 347, 511, 14000, 264, 1451, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 315, 314, 2581, 1325, 1314, 267, 327, 965, 14721, 436, 4911, 626, 314, 3499, 1331, 267, 327, 365, 3365, 687, 314, 1642, 14, 398, 327, 7758, 5267, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 7743, 314, 2653, 436, 9435, 370, 4057, 314, 12516, 267, 291, 14, 1637, 14, 521, 63, 475, 63, 6442, 275, 378, 267, 900, 14, 4532, 8, 17, 9, 398, 327, 16707, 5267, 267, 4733, 63, 576, 18, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 9336, 781, 295, 6751, 12, 314, 2581, 1177, 1077, 506, 3365, 14, 267, 291, 14, 19670, 8, 3871, 63, 576, 365, 4733, 63, 576, 18, 9, 267, 372, 339, 347, 511, 13606, 4152, 8, 277, 304, 267, 327, 18771, 2581, 370, 8044, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 436, 4911, 626, 314, 892, 666, 365, 3365, 14, 398, 327, 5543, 13, 13817, 314, 4887, 543, 4875, 666, 267, 291, 14, 1637, 14, 3494, 59, 277, 14, 2864, 63, 2632, 61, 275, 334, 521, 14, 521, 342, 435, 2948, 12, 291, 14, 344, 1012, 398, 327, 16347, 314, 666, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 12, 3542, 63, 873, 29, 549, 9, 398, 291, 14, 19670, 591, 8, 3871, 63, 576, 12, 291, 14, 344, 1012, 267, 372, 339, 347, 511, 5195, 604, 1385, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 3775, 652, 365, 14721, 503, 440, 14, 398, 327, 5543, 13, 13817, 314, 4887, 543, 666, 267, 291, 14, 1637, 14, 3494, 59, 277, 14, 2864, 63, 2632, 61, 275, 334, 16 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 577, 810, 71, 869, 1697, 20059, 14, 199, 3, 199, 3, 199, 3, 12793, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 577, 810, 71, 199, 3, 869, 1697, 20059, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 1126, 24522, 370, 199, 3, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 6791, 199, 3, 4983, 14, 199, 3, 199, 3, 3506, 10134, 869, 14952, 6588, 46, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 4141, 12, 199, 3, 6931, 11727, 5292, 2990, 1634, 3169, 2401, 3092, 12, 1621, 199, 3, 4825, 6461, 7000, 3506, 10134, 869, 14952, 6588, 46, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 199, 3, 9110, 6736, 1549, 1821, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 199, 3, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 199, 3, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 199, 624, 1358, 1770, 83, 367, 4733, 1637, 14, 1637, 199, 199, 624, 199, 199, 363, 578, 63, 344, 363, 275, 7880, 1304, 17351, 199, 199, 646, 2050, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 12, 490, 1475, 29342, 18331, 9, 83, 2818, 20056, 7216, 24, 83, 2818, 354, 9, 83, 2818, 1188, 9, 83, 297, 490, 776, 199, 2921, 275, 2050, 14, 5572, 360, 3871, 1637, 14, 396, 63, 1637, 358, 199, 199, 3, 199, 3, 3161, 2656, 4621, 199, 3, 199, 646, 1331, 199, 646, 900, 199, 646, 2882, 199, 646, 32241, 199, 199, 3, 199, 3, 3161, 2257, 4621, 199, 3, 199, 646, 2581, 199, 504, 511, 63, 1000, 492, 3101, 14440, 12, 1379, 14938, 199, 199, 3, 199, 3, 5673, 199, 3, 421, 199, 533, 11977, 14440, 8, 2856, 14440, 304, 339, 7240, 4576, 63, 25567, 275, 4233, 339, 347, 3613, 8, 277, 304, 267, 3101, 14440, 14, 5996, 8, 277, 9, 398, 291, 14, 3494, 275, 291, 14, 362, 6408, 342, 267, 291, 14, 1637, 275, 2581, 14, 4437, 8, 277, 14, 3494, 12, 639, 900, 1378, 17458, 13165, 29, 277, 14, 8677, 63, 25567, 12, 639, 922, 7788, 534, 3871, 1637, 14, 396, 297, 639, 776, 267, 372, 339, 347, 664, 6408, 8, 277, 304, 267, 298, 1767, 282, 2581, 4887, 367, 314, 511, 2122, 267, 372, 1052, 421, 199, 533, 11977, 774, 8, 4437, 14440, 304, 339, 7240, 4576, 63, 25567, 275, 4233, 339, 347, 664, 3120, 8, 277, 304, 267, 298, 20676, 2295, 886, 440, 2934, 370, 675, 314, 662, 1931, 503, 982, 13, 11911, 13, 24430, 2323, 2, 267, 372, 1379, 14938, 8, 4998, 11911, 9883, 29, 797, 9, 339, 347, 511, 15310, 1763, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 440, 2575, 315, 314, 2581, 14, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 267, 291, 14, 7589, 8, 3871, 63, 576, 9, 267, 291, 14, 14247, 8, 3871, 63, 576, 14, 3871, 14, 1213, 12, 283, 4437, 774, 511, 666, 358, 267, 372, 339, 347, 511, 15310, 1831, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 436, 4911, 626, 314, 3499, 1331, 365, 6120, 280, 3294, 267, 327, 370, 314, 1642, 14, 398, 327, 7758, 5267, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 16707, 5267, 267, 4733, 63, 576, 18, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 9336, 652, 365, 314, 315, 13, 4844, 4887, 12, 781, 1077, 1172, 314, 267, 327, 5835, 2011, 909, 14, 267, 291, 14, 7589, 8, 3871, 63, 576, 365, 4733, 63, 576, 18, 9, 267, 372, 339, 347, 511, 14000, 264, 1451, 607, 4437, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 315, 314, 2581, 1325, 1314, 267, 327, 965, 14721, 436, 4911, 626, 314, 3499, 1331, 267, 327, 365, 3365, 687, 314, 1642, 14, 398, 327, 7758, 5267, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 7743, 314, 2653, 436, 9435, 370, 4057, 314, 12516, 267, 291, 14, 1637, 14, 521, 63, 475, 63, 6442, 275, 378, 267, 900, 14, 4532, 8, 17, 9, 398, 327, 16707, 5267, 267, 4733, 63, 576, 18, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 9, 398, 327, 9336, 781, 295, 6751, 12, 314, 2581, 1177, 1077, 506, 3365, 14, 267, 291, 14, 19670, 8, 3871, 63, 576, 365, 4733, 63, 576, 18, 9, 267, 372, 339, 347, 511, 13606, 4152, 8, 277, 304, 267, 327, 18771, 2581, 370, 8044, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 436, 4911, 626, 314, 892, 666, 365, 3365, 14, 398, 327, 5543, 13, 13817, 314, 4887, 543, 4875, 666, 267, 291, 14, 1637, 14, 3494, 59, 277, 14, 2864, 63, 2632, 61, 275, 334, 521, 14, 521, 342, 435, 2948, 12, 291, 14, 344, 1012, 398, 327, 16347, 314, 666, 267, 4733, 63, 576, 275, 291, 14, 1637, 14, 3535, 8, 277, 14, 2864, 63, 2632, 12, 3542, 63, 873, 29, 549, 9, 398, 291, 14, 19670, 591, 8, 3871, 63, 576, 12, 291, 14, 344, 1012, 267, 372, 339, 347, 511, 5195, 604, 1385, 8, 277, 304, 267, 327, 13939, 666, 1314, 365, 741, 739, 315, 314, 2581, 12, 267, 327, 3775, 652, 365, 14721, 503, 440, 14, 398, 327, 5543, 13, 13817, 314, 4887, 543, 666, 267, 291, 14, 1637, 14, 3494, 59, 277, 14, 2864, 63, 2632, 61, 275, 334, 16, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pakoito/DT3
DT3Core/3rdParty/freetype-2.4.7/src/tools/glnames.py
360
105239
#!/usr/bin/env python # # # FreeType 2 glyph name builder # # Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. """\ usage: %s <output-file> This python script generates the glyph names tables defined in the `psnames' module. Its single argument is the name of the header file to be created. """ import sys, string, struct, re, os.path # This table lists the glyphs according to the Macintosh specification. # It is used by the TrueType Postscript names table. # # See # # http://fonts.apple.com/TTRefMan/RM06/Chap6post.html # # for the official list. # mac_standard_names = \ [ # 0 ".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", # 10 "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", # 20 "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", # 30 "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", # 40 "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", # 50 "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", # 60 "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", # 70 "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", # 80 "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", # 90 "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", # 100 "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", # 110 "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", # 120 "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", # 130 "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", # 140 "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", # 150 "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", # 160 "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", # 170 "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", # 180 "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", # 190 "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", # 200 "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", # 210 "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", # 220 "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", # 230 "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", # 240 "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", # 250 "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat" ] # The list of standard `SID' glyph names. For the official list, # see Annex A of document at # # http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf . # sid_standard_names = \ [ # 0 ".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", # 10 "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", # 20 "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", # 30 "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", # 40 "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", # 50 "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", # 60 "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", # 70 "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", # 80 "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", # 90 "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", # 100 "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", # 110 "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", # 120 "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", # 130 "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", # 140 "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", # 150 "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", # 160 "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", # 170 "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", # 180 "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", # 190 "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", # 200 "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", # 210 "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", # 220 "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", # 230 "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", # 240 "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", # 250 "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", # 260 "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", # 270 "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", # 280 "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", # 290 "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", # 300 "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", # 310 "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", # 320 "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", # 330 "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", # 340 "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", # 350 "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", # 360 "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", # 370 "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", # 380 "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", # 390 "Semibold" ] # This table maps character codes of the Adobe Standard Type 1 # encoding to glyph indices in the sid_standard_names table. # t1_standard_encoding = \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 0, 111, 112, 113, 114, 0, 115, 116, 117, 118, 119, 120, 121, 122, 0, 123, 0, 124, 125, 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 139, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, 0, 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0 ] # This table maps character codes of the Adobe Expert Type 1 # encoding to glyph indices in the sid_standard_names table. # t1_expert_encoding = \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 229, 230, 0, 231, 232, 233, 234, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 252, 0, 253, 254, 255, 256, 257, 0, 0, 0, 258, 0, 0, 259, 260, 261, 262, 0, 0, 263, 264, 265, 0, 266, 109, 110, 267, 268, 269, 0, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 304, 305, 306, 0, 0, 307, 308, 309, 310, 311, 0, 312, 0, 0, 313, 0, 0, 314, 315, 0, 0, 316, 317, 318, 0, 0, 0, 158, 155, 163, 319, 320, 321, 322, 323, 324, 325, 0, 0, 326, 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378 ] # This data has been taken literally from the files `glyphlist.txt' # and `zapfdingbats.txt' version 2.0, Sept 2002. It is available from # # http://sourceforge.net/adobe/aglfn/ # adobe_glyph_list = """\ A;0041 AE;00C6 AEacute;01FC AEmacron;01E2 AEsmall;F7E6 Aacute;00C1 Aacutesmall;F7E1 Abreve;0102 Abreveacute;1EAE Abrevecyrillic;04D0 Abrevedotbelow;1EB6 Abrevegrave;1EB0 Abrevehookabove;1EB2 Abrevetilde;1EB4 Acaron;01CD Acircle;24B6 Acircumflex;00C2 Acircumflexacute;1EA4 Acircumflexdotbelow;1EAC Acircumflexgrave;1EA6 Acircumflexhookabove;1EA8 Acircumflexsmall;F7E2 Acircumflextilde;1EAA Acute;F6C9 Acutesmall;F7B4 Acyrillic;0410 Adblgrave;0200 Adieresis;00C4 Adieresiscyrillic;04D2 Adieresismacron;01DE Adieresissmall;F7E4 Adotbelow;1EA0 Adotmacron;01E0 Agrave;00C0 Agravesmall;F7E0 Ahookabove;1EA2 Aiecyrillic;04D4 Ainvertedbreve;0202 Alpha;0391 Alphatonos;0386 Amacron;0100 Amonospace;FF21 Aogonek;0104 Aring;00C5 Aringacute;01FA Aringbelow;1E00 Aringsmall;F7E5 Asmall;F761 Atilde;00C3 Atildesmall;F7E3 Aybarmenian;0531 B;0042 Bcircle;24B7 Bdotaccent;1E02 Bdotbelow;1E04 Becyrillic;0411 Benarmenian;0532 Beta;0392 Bhook;0181 Blinebelow;1E06 Bmonospace;FF22 Brevesmall;F6F4 Bsmall;F762 Btopbar;0182 C;0043 Caarmenian;053E Cacute;0106 Caron;F6CA Caronsmall;F6F5 Ccaron;010C Ccedilla;00C7 Ccedillaacute;1E08 Ccedillasmall;F7E7 Ccircle;24B8 Ccircumflex;0108 Cdot;010A Cdotaccent;010A Cedillasmall;F7B8 Chaarmenian;0549 Cheabkhasiancyrillic;04BC Checyrillic;0427 Chedescenderabkhasiancyrillic;04BE Chedescendercyrillic;04B6 Chedieresiscyrillic;04F4 Cheharmenian;0543 Chekhakassiancyrillic;04CB Cheverticalstrokecyrillic;04B8 Chi;03A7 Chook;0187 Circumflexsmall;F6F6 Cmonospace;FF23 Coarmenian;0551 Csmall;F763 D;0044 DZ;01F1 DZcaron;01C4 Daarmenian;0534 Dafrican;0189 Dcaron;010E Dcedilla;1E10 Dcircle;24B9 Dcircumflexbelow;1E12 Dcroat;0110 Ddotaccent;1E0A Ddotbelow;1E0C Decyrillic;0414 Deicoptic;03EE Delta;2206 Deltagreek;0394 Dhook;018A Dieresis;F6CB DieresisAcute;F6CC DieresisGrave;F6CD Dieresissmall;F7A8 Digammagreek;03DC Djecyrillic;0402 Dlinebelow;1E0E Dmonospace;FF24 Dotaccentsmall;F6F7 Dslash;0110 Dsmall;F764 Dtopbar;018B Dz;01F2 Dzcaron;01C5 Dzeabkhasiancyrillic;04E0 Dzecyrillic;0405 Dzhecyrillic;040F E;0045 Eacute;00C9 Eacutesmall;F7E9 Ebreve;0114 Ecaron;011A Ecedillabreve;1E1C Echarmenian;0535 Ecircle;24BA Ecircumflex;00CA Ecircumflexacute;1EBE Ecircumflexbelow;1E18 Ecircumflexdotbelow;1EC6 Ecircumflexgrave;1EC0 Ecircumflexhookabove;1EC2 Ecircumflexsmall;F7EA Ecircumflextilde;1EC4 Ecyrillic;0404 Edblgrave;0204 Edieresis;00CB Edieresissmall;F7EB Edot;0116 Edotaccent;0116 Edotbelow;1EB8 Efcyrillic;0424 Egrave;00C8 Egravesmall;F7E8 Eharmenian;0537 Ehookabove;1EBA Eightroman;2167 Einvertedbreve;0206 Eiotifiedcyrillic;0464 Elcyrillic;041B Elevenroman;216A Emacron;0112 Emacronacute;1E16 Emacrongrave;1E14 Emcyrillic;041C Emonospace;FF25 Encyrillic;041D Endescendercyrillic;04A2 Eng;014A Enghecyrillic;04A4 Enhookcyrillic;04C7 Eogonek;0118 Eopen;0190 Epsilon;0395 Epsilontonos;0388 Ercyrillic;0420 Ereversed;018E Ereversedcyrillic;042D Escyrillic;0421 Esdescendercyrillic;04AA Esh;01A9 Esmall;F765 Eta;0397 Etarmenian;0538 Etatonos;0389 Eth;00D0 Ethsmall;F7F0 Etilde;1EBC Etildebelow;1E1A Euro;20AC Ezh;01B7 Ezhcaron;01EE Ezhreversed;01B8 F;0046 Fcircle;24BB Fdotaccent;1E1E Feharmenian;0556 Feicoptic;03E4 Fhook;0191 Fitacyrillic;0472 Fiveroman;2164 Fmonospace;FF26 Fourroman;2163 Fsmall;F766 G;0047 GBsquare;3387 Gacute;01F4 Gamma;0393 Gammaafrican;0194 Gangiacoptic;03EA Gbreve;011E Gcaron;01E6 Gcedilla;0122 Gcircle;24BC Gcircumflex;011C Gcommaaccent;0122 Gdot;0120 Gdotaccent;0120 Gecyrillic;0413 Ghadarmenian;0542 Ghemiddlehookcyrillic;0494 Ghestrokecyrillic;0492 Gheupturncyrillic;0490 Ghook;0193 Gimarmenian;0533 Gjecyrillic;0403 Gmacron;1E20 Gmonospace;FF27 Grave;F6CE Gravesmall;F760 Gsmall;F767 Gsmallhook;029B Gstroke;01E4 H;0048 H18533;25CF H18543;25AA H18551;25AB H22073;25A1 HPsquare;33CB Haabkhasiancyrillic;04A8 Hadescendercyrillic;04B2 Hardsigncyrillic;042A Hbar;0126 Hbrevebelow;1E2A Hcedilla;1E28 Hcircle;24BD Hcircumflex;0124 Hdieresis;1E26 Hdotaccent;1E22 Hdotbelow;1E24 Hmonospace;FF28 Hoarmenian;0540 Horicoptic;03E8 Hsmall;F768 Hungarumlaut;F6CF Hungarumlautsmall;F6F8 Hzsquare;3390 I;0049 IAcyrillic;042F IJ;0132 IUcyrillic;042E Iacute;00CD Iacutesmall;F7ED Ibreve;012C Icaron;01CF Icircle;24BE Icircumflex;00CE Icircumflexsmall;F7EE Icyrillic;0406 Idblgrave;0208 Idieresis;00CF Idieresisacute;1E2E Idieresiscyrillic;04E4 Idieresissmall;F7EF Idot;0130 Idotaccent;0130 Idotbelow;1ECA Iebrevecyrillic;04D6 Iecyrillic;0415 Ifraktur;2111 Igrave;00CC Igravesmall;F7EC Ihookabove;1EC8 Iicyrillic;0418 Iinvertedbreve;020A Iishortcyrillic;0419 Imacron;012A Imacroncyrillic;04E2 Imonospace;FF29 Iniarmenian;053B Iocyrillic;0401 Iogonek;012E Iota;0399 Iotaafrican;0196 Iotadieresis;03AA Iotatonos;038A Ismall;F769 Istroke;0197 Itilde;0128 Itildebelow;1E2C Izhitsacyrillic;0474 Izhitsadblgravecyrillic;0476 J;004A Jaarmenian;0541 Jcircle;24BF Jcircumflex;0134 Jecyrillic;0408 Jheharmenian;054B Jmonospace;FF2A Jsmall;F76A K;004B KBsquare;3385 KKsquare;33CD Kabashkircyrillic;04A0 Kacute;1E30 Kacyrillic;041A Kadescendercyrillic;049A Kahookcyrillic;04C3 Kappa;039A Kastrokecyrillic;049E Kaverticalstrokecyrillic;049C Kcaron;01E8 Kcedilla;0136 Kcircle;24C0 Kcommaaccent;0136 Kdotbelow;1E32 Keharmenian;0554 Kenarmenian;053F Khacyrillic;0425 Kheicoptic;03E6 Khook;0198 Kjecyrillic;040C Klinebelow;1E34 Kmonospace;FF2B Koppacyrillic;0480 Koppagreek;03DE Ksicyrillic;046E Ksmall;F76B L;004C LJ;01C7 LL;F6BF Lacute;0139 Lambda;039B Lcaron;013D Lcedilla;013B Lcircle;24C1 Lcircumflexbelow;1E3C Lcommaaccent;013B Ldot;013F Ldotaccent;013F Ldotbelow;1E36 Ldotbelowmacron;1E38 Liwnarmenian;053C Lj;01C8 Ljecyrillic;0409 Llinebelow;1E3A Lmonospace;FF2C Lslash;0141 Lslashsmall;F6F9 Lsmall;F76C M;004D MBsquare;3386 Macron;F6D0 Macronsmall;F7AF Macute;1E3E Mcircle;24C2 Mdotaccent;1E40 Mdotbelow;1E42 Menarmenian;0544 Mmonospace;FF2D Msmall;F76D Mturned;019C Mu;039C N;004E NJ;01CA Nacute;0143 Ncaron;0147 Ncedilla;0145 Ncircle;24C3 Ncircumflexbelow;1E4A Ncommaaccent;0145 Ndotaccent;1E44 Ndotbelow;1E46 Nhookleft;019D Nineroman;2168 Nj;01CB Njecyrillic;040A Nlinebelow;1E48 Nmonospace;FF2E Nowarmenian;0546 Nsmall;F76E Ntilde;00D1 Ntildesmall;F7F1 Nu;039D O;004F OE;0152 OEsmall;F6FA Oacute;00D3 Oacutesmall;F7F3 Obarredcyrillic;04E8 Obarreddieresiscyrillic;04EA Obreve;014E Ocaron;01D1 Ocenteredtilde;019F Ocircle;24C4 Ocircumflex;00D4 Ocircumflexacute;1ED0 Ocircumflexdotbelow;1ED8 Ocircumflexgrave;1ED2 Ocircumflexhookabove;1ED4 Ocircumflexsmall;F7F4 Ocircumflextilde;1ED6 Ocyrillic;041E Odblacute;0150 Odblgrave;020C Odieresis;00D6 Odieresiscyrillic;04E6 Odieresissmall;F7F6 Odotbelow;1ECC Ogoneksmall;F6FB Ograve;00D2 Ogravesmall;F7F2 Oharmenian;0555 Ohm;2126 Ohookabove;1ECE Ohorn;01A0 Ohornacute;1EDA Ohorndotbelow;1EE2 Ohorngrave;1EDC Ohornhookabove;1EDE Ohorntilde;1EE0 Ohungarumlaut;0150 Oi;01A2 Oinvertedbreve;020E Omacron;014C Omacronacute;1E52 Omacrongrave;1E50 Omega;2126 Omegacyrillic;0460 Omegagreek;03A9 Omegaroundcyrillic;047A Omegatitlocyrillic;047C Omegatonos;038F Omicron;039F Omicrontonos;038C Omonospace;FF2F Oneroman;2160 Oogonek;01EA Oogonekmacron;01EC Oopen;0186 Oslash;00D8 Oslashacute;01FE Oslashsmall;F7F8 Osmall;F76F Ostrokeacute;01FE Otcyrillic;047E Otilde;00D5 Otildeacute;1E4C Otildedieresis;1E4E Otildesmall;F7F5 P;0050 Pacute;1E54 Pcircle;24C5 Pdotaccent;1E56 Pecyrillic;041F Peharmenian;054A Pemiddlehookcyrillic;04A6 Phi;03A6 Phook;01A4 Pi;03A0 Piwrarmenian;0553 Pmonospace;FF30 Psi;03A8 Psicyrillic;0470 Psmall;F770 Q;0051 Qcircle;24C6 Qmonospace;FF31 Qsmall;F771 R;0052 Raarmenian;054C Racute;0154 Rcaron;0158 Rcedilla;0156 Rcircle;24C7 Rcommaaccent;0156 Rdblgrave;0210 Rdotaccent;1E58 Rdotbelow;1E5A Rdotbelowmacron;1E5C Reharmenian;0550 Rfraktur;211C Rho;03A1 Ringsmall;F6FC Rinvertedbreve;0212 Rlinebelow;1E5E Rmonospace;FF32 Rsmall;F772 Rsmallinverted;0281 Rsmallinvertedsuperior;02B6 S;0053 SF010000;250C SF020000;2514 SF030000;2510 SF040000;2518 SF050000;253C SF060000;252C SF070000;2534 SF080000;251C SF090000;2524 SF100000;2500 SF110000;2502 SF190000;2561 SF200000;2562 SF210000;2556 SF220000;2555 SF230000;2563 SF240000;2551 SF250000;2557 SF260000;255D SF270000;255C SF280000;255B SF360000;255E SF370000;255F SF380000;255A SF390000;2554 SF400000;2569 SF410000;2566 SF420000;2560 SF430000;2550 SF440000;256C SF450000;2567 SF460000;2568 SF470000;2564 SF480000;2565 SF490000;2559 SF500000;2558 SF510000;2552 SF520000;2553 SF530000;256B SF540000;256A Sacute;015A Sacutedotaccent;1E64 Sampigreek;03E0 Scaron;0160 Scarondotaccent;1E66 Scaronsmall;F6FD Scedilla;015E Schwa;018F Schwacyrillic;04D8 Schwadieresiscyrillic;04DA Scircle;24C8 Scircumflex;015C Scommaaccent;0218 Sdotaccent;1E60 Sdotbelow;1E62 Sdotbelowdotaccent;1E68 Seharmenian;054D Sevenroman;2166 Shaarmenian;0547 Shacyrillic;0428 Shchacyrillic;0429 Sheicoptic;03E2 Shhacyrillic;04BA Shimacoptic;03EC Sigma;03A3 Sixroman;2165 Smonospace;FF33 Softsigncyrillic;042C Ssmall;F773 Stigmagreek;03DA T;0054 Tau;03A4 Tbar;0166 Tcaron;0164 Tcedilla;0162 Tcircle;24C9 Tcircumflexbelow;1E70 Tcommaaccent;0162 Tdotaccent;1E6A Tdotbelow;1E6C Tecyrillic;0422 Tedescendercyrillic;04AC Tenroman;2169 Tetsecyrillic;04B4 Theta;0398 Thook;01AC Thorn;00DE Thornsmall;F7FE Threeroman;2162 Tildesmall;F6FE Tiwnarmenian;054F Tlinebelow;1E6E Tmonospace;FF34 Toarmenian;0539 Tonefive;01BC Tonesix;0184 Tonetwo;01A7 Tretroflexhook;01AE Tsecyrillic;0426 Tshecyrillic;040B Tsmall;F774 Twelveroman;216B Tworoman;2161 U;0055 Uacute;00DA Uacutesmall;F7FA Ubreve;016C Ucaron;01D3 Ucircle;24CA Ucircumflex;00DB Ucircumflexbelow;1E76 Ucircumflexsmall;F7FB Ucyrillic;0423 Udblacute;0170 Udblgrave;0214 Udieresis;00DC Udieresisacute;01D7 Udieresisbelow;1E72 Udieresiscaron;01D9 Udieresiscyrillic;04F0 Udieresisgrave;01DB Udieresismacron;01D5 Udieresissmall;F7FC Udotbelow;1EE4 Ugrave;00D9 Ugravesmall;F7F9 Uhookabove;1EE6 Uhorn;01AF Uhornacute;1EE8 Uhorndotbelow;1EF0 Uhorngrave;1EEA Uhornhookabove;1EEC Uhorntilde;1EEE Uhungarumlaut;0170 Uhungarumlautcyrillic;04F2 Uinvertedbreve;0216 Ukcyrillic;0478 Umacron;016A Umacroncyrillic;04EE Umacrondieresis;1E7A Umonospace;FF35 Uogonek;0172 Upsilon;03A5 Upsilon1;03D2 Upsilonacutehooksymbolgreek;03D3 Upsilonafrican;01B1 Upsilondieresis;03AB Upsilondieresishooksymbolgreek;03D4 Upsilonhooksymbol;03D2 Upsilontonos;038E Uring;016E Ushortcyrillic;040E Usmall;F775 Ustraightcyrillic;04AE Ustraightstrokecyrillic;04B0 Utilde;0168 Utildeacute;1E78 Utildebelow;1E74 V;0056 Vcircle;24CB Vdotbelow;1E7E Vecyrillic;0412 Vewarmenian;054E Vhook;01B2 Vmonospace;FF36 Voarmenian;0548 Vsmall;F776 Vtilde;1E7C W;0057 Wacute;1E82 Wcircle;24CC Wcircumflex;0174 Wdieresis;1E84 Wdotaccent;1E86 Wdotbelow;1E88 Wgrave;1E80 Wmonospace;FF37 Wsmall;F777 X;0058 Xcircle;24CD Xdieresis;1E8C Xdotaccent;1E8A Xeharmenian;053D Xi;039E Xmonospace;FF38 Xsmall;F778 Y;0059 Yacute;00DD Yacutesmall;F7FD Yatcyrillic;0462 Ycircle;24CE Ycircumflex;0176 Ydieresis;0178 Ydieresissmall;F7FF Ydotaccent;1E8E Ydotbelow;1EF4 Yericyrillic;042B Yerudieresiscyrillic;04F8 Ygrave;1EF2 Yhook;01B3 Yhookabove;1EF6 Yiarmenian;0545 Yicyrillic;0407 Yiwnarmenian;0552 Ymonospace;FF39 Ysmall;F779 Ytilde;1EF8 Yusbigcyrillic;046A Yusbigiotifiedcyrillic;046C Yuslittlecyrillic;0466 Yuslittleiotifiedcyrillic;0468 Z;005A Zaarmenian;0536 Zacute;0179 Zcaron;017D Zcaronsmall;F6FF Zcircle;24CF Zcircumflex;1E90 Zdot;017B Zdotaccent;017B Zdotbelow;1E92 Zecyrillic;0417 Zedescendercyrillic;0498 Zedieresiscyrillic;04DE Zeta;0396 Zhearmenian;053A Zhebrevecyrillic;04C1 Zhecyrillic;0416 Zhedescendercyrillic;0496 Zhedieresiscyrillic;04DC Zlinebelow;1E94 Zmonospace;FF3A Zsmall;F77A Zstroke;01B5 a;0061 aabengali;0986 aacute;00E1 aadeva;0906 aagujarati;0A86 aagurmukhi;0A06 aamatragurmukhi;0A3E aarusquare;3303 aavowelsignbengali;09BE aavowelsigndeva;093E aavowelsigngujarati;0ABE abbreviationmarkarmenian;055F abbreviationsigndeva;0970 abengali;0985 abopomofo;311A abreve;0103 abreveacute;1EAF abrevecyrillic;04D1 abrevedotbelow;1EB7 abrevegrave;1EB1 abrevehookabove;1EB3 abrevetilde;1EB5 acaron;01CE acircle;24D0 acircumflex;00E2 acircumflexacute;1EA5 acircumflexdotbelow;1EAD acircumflexgrave;1EA7 acircumflexhookabove;1EA9 acircumflextilde;1EAB acute;00B4 acutebelowcmb;0317 acutecmb;0301 acutecomb;0301 acutedeva;0954 acutelowmod;02CF acutetonecmb;0341 acyrillic;0430 adblgrave;0201 addakgurmukhi;0A71 adeva;0905 adieresis;00E4 adieresiscyrillic;04D3 adieresismacron;01DF adotbelow;1EA1 adotmacron;01E1 ae;00E6 aeacute;01FD aekorean;3150 aemacron;01E3 afii00208;2015 afii08941;20A4 afii10017;0410 afii10018;0411 afii10019;0412 afii10020;0413 afii10021;0414 afii10022;0415 afii10023;0401 afii10024;0416 afii10025;0417 afii10026;0418 afii10027;0419 afii10028;041A afii10029;041B afii10030;041C afii10031;041D afii10032;041E afii10033;041F afii10034;0420 afii10035;0421 afii10036;0422 afii10037;0423 afii10038;0424 afii10039;0425 afii10040;0426 afii10041;0427 afii10042;0428 afii10043;0429 afii10044;042A afii10045;042B afii10046;042C afii10047;042D afii10048;042E afii10049;042F afii10050;0490 afii10051;0402 afii10052;0403 afii10053;0404 afii10054;0405 afii10055;0406 afii10056;0407 afii10057;0408 afii10058;0409 afii10059;040A afii10060;040B afii10061;040C afii10062;040E afii10063;F6C4 afii10064;F6C5 afii10065;0430 afii10066;0431 afii10067;0432 afii10068;0433 afii10069;0434 afii10070;0435 afii10071;0451 afii10072;0436 afii10073;0437 afii10074;0438 afii10075;0439 afii10076;043A afii10077;043B afii10078;043C afii10079;043D afii10080;043E afii10081;043F afii10082;0440 afii10083;0441 afii10084;0442 afii10085;0443 afii10086;0444 afii10087;0445 afii10088;0446 afii10089;0447 afii10090;0448 afii10091;0449 afii10092;044A afii10093;044B afii10094;044C afii10095;044D afii10096;044E afii10097;044F afii10098;0491 afii10099;0452 afii10100;0453 afii10101;0454 afii10102;0455 afii10103;0456 afii10104;0457 afii10105;0458 afii10106;0459 afii10107;045A afii10108;045B afii10109;045C afii10110;045E afii10145;040F afii10146;0462 afii10147;0472 afii10148;0474 afii10192;F6C6 afii10193;045F afii10194;0463 afii10195;0473 afii10196;0475 afii10831;F6C7 afii10832;F6C8 afii10846;04D9 afii299;200E afii300;200F afii301;200D afii57381;066A afii57388;060C afii57392;0660 afii57393;0661 afii57394;0662 afii57395;0663 afii57396;0664 afii57397;0665 afii57398;0666 afii57399;0667 afii57400;0668 afii57401;0669 afii57403;061B afii57407;061F afii57409;0621 afii57410;0622 afii57411;0623 afii57412;0624 afii57413;0625 afii57414;0626 afii57415;0627 afii57416;0628 afii57417;0629 afii57418;062A afii57419;062B afii57420;062C afii57421;062D afii57422;062E afii57423;062F afii57424;0630 afii57425;0631 afii57426;0632 afii57427;0633 afii57428;0634 afii57429;0635 afii57430;0636 afii57431;0637 afii57432;0638 afii57433;0639 afii57434;063A afii57440;0640 afii57441;0641 afii57442;0642 afii57443;0643 afii57444;0644 afii57445;0645 afii57446;0646 afii57448;0648 afii57449;0649 afii57450;064A afii57451;064B afii57452;064C afii57453;064D afii57454;064E afii57455;064F afii57456;0650 afii57457;0651 afii57458;0652 afii57470;0647 afii57505;06A4 afii57506;067E afii57507;0686 afii57508;0698 afii57509;06AF afii57511;0679 afii57512;0688 afii57513;0691 afii57514;06BA afii57519;06D2 afii57534;06D5 afii57636;20AA afii57645;05BE afii57658;05C3 afii57664;05D0 afii57665;05D1 afii57666;05D2 afii57667;05D3 afii57668;05D4 afii57669;05D5 afii57670;05D6 afii57671;05D7 afii57672;05D8 afii57673;05D9 afii57674;05DA afii57675;05DB afii57676;05DC afii57677;05DD afii57678;05DE afii57679;05DF afii57680;05E0 afii57681;05E1 afii57682;05E2 afii57683;05E3 afii57684;05E4 afii57685;05E5 afii57686;05E6 afii57687;05E7 afii57688;05E8 afii57689;05E9 afii57690;05EA afii57694;FB2A afii57695;FB2B afii57700;FB4B afii57705;FB1F afii57716;05F0 afii57717;05F1 afii57718;05F2 afii57723;FB35 afii57793;05B4 afii57794;05B5 afii57795;05B6 afii57796;05BB afii57797;05B8 afii57798;05B7 afii57799;05B0 afii57800;05B2 afii57801;05B1 afii57802;05B3 afii57803;05C2 afii57804;05C1 afii57806;05B9 afii57807;05BC afii57839;05BD afii57841;05BF afii57842;05C0 afii57929;02BC afii61248;2105 afii61289;2113 afii61352;2116 afii61573;202C afii61574;202D afii61575;202E afii61664;200C afii63167;066D afii64937;02BD agrave;00E0 agujarati;0A85 agurmukhi;0A05 ahiragana;3042 ahookabove;1EA3 aibengali;0990 aibopomofo;311E aideva;0910 aiecyrillic;04D5 aigujarati;0A90 aigurmukhi;0A10 aimatragurmukhi;0A48 ainarabic;0639 ainfinalarabic;FECA aininitialarabic;FECB ainmedialarabic;FECC ainvertedbreve;0203 aivowelsignbengali;09C8 aivowelsigndeva;0948 aivowelsigngujarati;0AC8 akatakana;30A2 akatakanahalfwidth;FF71 akorean;314F alef;05D0 alefarabic;0627 alefdageshhebrew;FB30 aleffinalarabic;FE8E alefhamzaabovearabic;0623 alefhamzaabovefinalarabic;FE84 alefhamzabelowarabic;0625 alefhamzabelowfinalarabic;FE88 alefhebrew;05D0 aleflamedhebrew;FB4F alefmaddaabovearabic;0622 alefmaddaabovefinalarabic;FE82 alefmaksuraarabic;0649 alefmaksurafinalarabic;FEF0 alefmaksurainitialarabic;FEF3 alefmaksuramedialarabic;FEF4 alefpatahhebrew;FB2E alefqamatshebrew;FB2F aleph;2135 allequal;224C alpha;03B1 alphatonos;03AC amacron;0101 amonospace;FF41 ampersand;0026 ampersandmonospace;FF06 ampersandsmall;F726 amsquare;33C2 anbopomofo;3122 angbopomofo;3124 angkhankhuthai;0E5A angle;2220 anglebracketleft;3008 anglebracketleftvertical;FE3F anglebracketright;3009 anglebracketrightvertical;FE40 angleleft;2329 angleright;232A angstrom;212B anoteleia;0387 anudattadeva;0952 anusvarabengali;0982 anusvaradeva;0902 anusvaragujarati;0A82 aogonek;0105 apaatosquare;3300 aparen;249C apostrophearmenian;055A apostrophemod;02BC apple;F8FF approaches;2250 approxequal;2248 approxequalorimage;2252 approximatelyequal;2245 araeaekorean;318E araeakorean;318D arc;2312 arighthalfring;1E9A aring;00E5 aringacute;01FB aringbelow;1E01 arrowboth;2194 arrowdashdown;21E3 arrowdashleft;21E0 arrowdashright;21E2 arrowdashup;21E1 arrowdblboth;21D4 arrowdbldown;21D3 arrowdblleft;21D0 arrowdblright;21D2 arrowdblup;21D1 arrowdown;2193 arrowdownleft;2199 arrowdownright;2198 arrowdownwhite;21E9 arrowheaddownmod;02C5 arrowheadleftmod;02C2 arrowheadrightmod;02C3 arrowheadupmod;02C4 arrowhorizex;F8E7 arrowleft;2190 arrowleftdbl;21D0 arrowleftdblstroke;21CD arrowleftoverright;21C6 arrowleftwhite;21E6 arrowright;2192 arrowrightdblstroke;21CF arrowrightheavy;279E arrowrightoverleft;21C4 arrowrightwhite;21E8 arrowtableft;21E4 arrowtabright;21E5 arrowup;2191 arrowupdn;2195 arrowupdnbse;21A8 arrowupdownbase;21A8 arrowupleft;2196 arrowupleftofdown;21C5 arrowupright;2197 arrowupwhite;21E7 arrowvertex;F8E6 asciicircum;005E asciicircummonospace;FF3E asciitilde;007E asciitildemonospace;FF5E ascript;0251 ascriptturned;0252 asmallhiragana;3041 asmallkatakana;30A1 asmallkatakanahalfwidth;FF67 asterisk;002A asteriskaltonearabic;066D asteriskarabic;066D asteriskmath;2217 asteriskmonospace;FF0A asterisksmall;FE61 asterism;2042 asuperior;F6E9 asymptoticallyequal;2243 at;0040 atilde;00E3 atmonospace;FF20 atsmall;FE6B aturned;0250 aubengali;0994 aubopomofo;3120 audeva;0914 augujarati;0A94 augurmukhi;0A14 aulengthmarkbengali;09D7 aumatragurmukhi;0A4C auvowelsignbengali;09CC auvowelsigndeva;094C auvowelsigngujarati;0ACC avagrahadeva;093D aybarmenian;0561 ayin;05E2 ayinaltonehebrew;FB20 ayinhebrew;05E2 b;0062 babengali;09AC backslash;005C backslashmonospace;FF3C badeva;092C bagujarati;0AAC bagurmukhi;0A2C bahiragana;3070 bahtthai;0E3F bakatakana;30D0 bar;007C barmonospace;FF5C bbopomofo;3105 bcircle;24D1 bdotaccent;1E03 bdotbelow;1E05 beamedsixteenthnotes;266C because;2235 becyrillic;0431 beharabic;0628 behfinalarabic;FE90 behinitialarabic;FE91 behiragana;3079 behmedialarabic;FE92 behmeeminitialarabic;FC9F behmeemisolatedarabic;FC08 behnoonfinalarabic;FC6D bekatakana;30D9 benarmenian;0562 bet;05D1 beta;03B2 betasymbolgreek;03D0 betdagesh;FB31 betdageshhebrew;FB31 bethebrew;05D1 betrafehebrew;FB4C bhabengali;09AD bhadeva;092D bhagujarati;0AAD bhagurmukhi;0A2D bhook;0253 bihiragana;3073 bikatakana;30D3 bilabialclick;0298 bindigurmukhi;0A02 birusquare;3331 blackcircle;25CF blackdiamond;25C6 blackdownpointingtriangle;25BC blackleftpointingpointer;25C4 blackleftpointingtriangle;25C0 blacklenticularbracketleft;3010 blacklenticularbracketleftvertical;FE3B blacklenticularbracketright;3011 blacklenticularbracketrightvertical;FE3C blacklowerlefttriangle;25E3 blacklowerrighttriangle;25E2 blackrectangle;25AC blackrightpointingpointer;25BA blackrightpointingtriangle;25B6 blacksmallsquare;25AA blacksmilingface;263B blacksquare;25A0 blackstar;2605 blackupperlefttriangle;25E4 blackupperrighttriangle;25E5 blackuppointingsmalltriangle;25B4 blackuppointingtriangle;25B2 blank;2423 blinebelow;1E07 block;2588 bmonospace;FF42 bobaimaithai;0E1A bohiragana;307C bokatakana;30DC bparen;249D bqsquare;33C3 braceex;F8F4 braceleft;007B braceleftbt;F8F3 braceleftmid;F8F2 braceleftmonospace;FF5B braceleftsmall;FE5B bracelefttp;F8F1 braceleftvertical;FE37 braceright;007D bracerightbt;F8FE bracerightmid;F8FD bracerightmonospace;FF5D bracerightsmall;FE5C bracerighttp;F8FC bracerightvertical;FE38 bracketleft;005B bracketleftbt;F8F0 bracketleftex;F8EF bracketleftmonospace;FF3B bracketlefttp;F8EE bracketright;005D bracketrightbt;F8FB bracketrightex;F8FA bracketrightmonospace;FF3D bracketrighttp;F8F9 breve;02D8 brevebelowcmb;032E brevecmb;0306 breveinvertedbelowcmb;032F breveinvertedcmb;0311 breveinverteddoublecmb;0361 bridgebelowcmb;032A bridgeinvertedbelowcmb;033A brokenbar;00A6 bstroke;0180 bsuperior;F6EA btopbar;0183 buhiragana;3076 bukatakana;30D6 bullet;2022 bulletinverse;25D8 bulletoperator;2219 bullseye;25CE c;0063 caarmenian;056E cabengali;099A cacute;0107 cadeva;091A cagujarati;0A9A cagurmukhi;0A1A calsquare;3388 candrabindubengali;0981 candrabinducmb;0310 candrabindudeva;0901 candrabindugujarati;0A81 capslock;21EA careof;2105 caron;02C7 caronbelowcmb;032C caroncmb;030C carriagereturn;21B5 cbopomofo;3118 ccaron;010D ccedilla;00E7 ccedillaacute;1E09 ccircle;24D2 ccircumflex;0109 ccurl;0255 cdot;010B cdotaccent;010B cdsquare;33C5 cedilla;00B8 cedillacmb;0327 cent;00A2 centigrade;2103 centinferior;F6DF centmonospace;FFE0 centoldstyle;F7A2 centsuperior;F6E0 chaarmenian;0579 chabengali;099B chadeva;091B chagujarati;0A9B chagurmukhi;0A1B chbopomofo;3114 cheabkhasiancyrillic;04BD checkmark;2713 checyrillic;0447 chedescenderabkhasiancyrillic;04BF chedescendercyrillic;04B7 chedieresiscyrillic;04F5 cheharmenian;0573 chekhakassiancyrillic;04CC cheverticalstrokecyrillic;04B9 chi;03C7 chieuchacirclekorean;3277 chieuchaparenkorean;3217 chieuchcirclekorean;3269 chieuchkorean;314A chieuchparenkorean;3209 chochangthai;0E0A chochanthai;0E08 chochingthai;0E09 chochoethai;0E0C chook;0188 cieucacirclekorean;3276 cieucaparenkorean;3216 cieuccirclekorean;3268 cieuckorean;3148 cieucparenkorean;3208 cieucuparenkorean;321C circle;25CB circlemultiply;2297 circleot;2299 circleplus;2295 circlepostalmark;3036 circlewithlefthalfblack;25D0 circlewithrighthalfblack;25D1 circumflex;02C6 circumflexbelowcmb;032D circumflexcmb;0302 clear;2327 clickalveolar;01C2 clickdental;01C0 clicklateral;01C1 clickretroflex;01C3 club;2663 clubsuitblack;2663 clubsuitwhite;2667 cmcubedsquare;33A4 cmonospace;FF43 cmsquaredsquare;33A0 coarmenian;0581 colon;003A colonmonetary;20A1 colonmonospace;FF1A colonsign;20A1 colonsmall;FE55 colontriangularhalfmod;02D1 colontriangularmod;02D0 comma;002C commaabovecmb;0313 commaaboverightcmb;0315 commaaccent;F6C3 commaarabic;060C commaarmenian;055D commainferior;F6E1 commamonospace;FF0C commareversedabovecmb;0314 commareversedmod;02BD commasmall;FE50 commasuperior;F6E2 commaturnedabovecmb;0312 commaturnedmod;02BB compass;263C congruent;2245 contourintegral;222E control;2303 controlACK;0006 controlBEL;0007 controlBS;0008 controlCAN;0018 controlCR;000D controlDC1;0011 controlDC2;0012 controlDC3;0013 controlDC4;0014 controlDEL;007F controlDLE;0010 controlEM;0019 controlENQ;0005 controlEOT;0004 controlESC;001B controlETB;0017 controlETX;0003 controlFF;000C controlFS;001C controlGS;001D controlHT;0009 controlLF;000A controlNAK;0015 controlRS;001E controlSI;000F controlSO;000E controlSOT;0002 controlSTX;0001 controlSUB;001A controlSYN;0016 controlUS;001F controlVT;000B copyright;00A9 copyrightsans;F8E9 copyrightserif;F6D9 cornerbracketleft;300C cornerbracketlefthalfwidth;FF62 cornerbracketleftvertical;FE41 cornerbracketright;300D cornerbracketrighthalfwidth;FF63 cornerbracketrightvertical;FE42 corporationsquare;337F cosquare;33C7 coverkgsquare;33C6 cparen;249E cruzeiro;20A2 cstretched;0297 curlyand;22CF curlyor;22CE currency;00A4 cyrBreve;F6D1 cyrFlex;F6D2 cyrbreve;F6D4 cyrflex;F6D5 d;0064 daarmenian;0564 dabengali;09A6 dadarabic;0636 dadeva;0926 dadfinalarabic;FEBE dadinitialarabic;FEBF dadmedialarabic;FEC0 dagesh;05BC dageshhebrew;05BC dagger;2020 daggerdbl;2021 dagujarati;0AA6 dagurmukhi;0A26 dahiragana;3060 dakatakana;30C0 dalarabic;062F dalet;05D3 daletdagesh;FB33 daletdageshhebrew;FB33 dalethatafpatah;05D3 05B2 dalethatafpatahhebrew;05D3 05B2 dalethatafsegol;05D3 05B1 dalethatafsegolhebrew;05D3 05B1 dalethebrew;05D3 dalethiriq;05D3 05B4 dalethiriqhebrew;05D3 05B4 daletholam;05D3 05B9 daletholamhebrew;05D3 05B9 daletpatah;05D3 05B7 daletpatahhebrew;05D3 05B7 daletqamats;05D3 05B8 daletqamatshebrew;05D3 05B8 daletqubuts;05D3 05BB daletqubutshebrew;05D3 05BB daletsegol;05D3 05B6 daletsegolhebrew;05D3 05B6 daletsheva;05D3 05B0 daletshevahebrew;05D3 05B0 dalettsere;05D3 05B5 dalettserehebrew;05D3 05B5 dalfinalarabic;FEAA dammaarabic;064F dammalowarabic;064F dammatanaltonearabic;064C dammatanarabic;064C danda;0964 dargahebrew;05A7 dargalefthebrew;05A7 dasiapneumatacyrilliccmb;0485 dblGrave;F6D3 dblanglebracketleft;300A dblanglebracketleftvertical;FE3D dblanglebracketright;300B dblanglebracketrightvertical;FE3E dblarchinvertedbelowcmb;032B dblarrowleft;21D4 dblarrowright;21D2 dbldanda;0965 dblgrave;F6D6 dblgravecmb;030F dblintegral;222C dbllowline;2017 dbllowlinecmb;0333 dbloverlinecmb;033F dblprimemod;02BA dblverticalbar;2016 dblverticallineabovecmb;030E dbopomofo;3109 dbsquare;33C8 dcaron;010F dcedilla;1E11 dcircle;24D3 dcircumflexbelow;1E13 dcroat;0111 ddabengali;09A1 ddadeva;0921 ddagujarati;0AA1 ddagurmukhi;0A21 ddalarabic;0688 ddalfinalarabic;FB89 dddhadeva;095C ddhabengali;09A2 ddhadeva;0922 ddhagujarati;0AA2 ddhagurmukhi;0A22 ddotaccent;1E0B ddotbelow;1E0D decimalseparatorarabic;066B decimalseparatorpersian;066B decyrillic;0434 degree;00B0 dehihebrew;05AD dehiragana;3067 deicoptic;03EF dekatakana;30C7 deleteleft;232B deleteright;2326 delta;03B4 deltaturned;018D denominatorminusonenumeratorbengali;09F8 dezh;02A4 dhabengali;09A7 dhadeva;0927 dhagujarati;0AA7 dhagurmukhi;0A27 dhook;0257 dialytikatonos;0385 dialytikatonoscmb;0344 diamond;2666 diamondsuitwhite;2662 dieresis;00A8 dieresisacute;F6D7 dieresisbelowcmb;0324 dieresiscmb;0308 dieresisgrave;F6D8 dieresistonos;0385 dihiragana;3062 dikatakana;30C2 dittomark;3003 divide;00F7 divides;2223 divisionslash;2215 djecyrillic;0452 dkshade;2593 dlinebelow;1E0F dlsquare;3397 dmacron;0111 dmonospace;FF44 dnblock;2584 dochadathai;0E0E dodekthai;0E14 dohiragana;3069 dokatakana;30C9 dollar;0024 dollarinferior;F6E3 dollarmonospace;FF04 dollaroldstyle;F724 dollarsmall;FE69 dollarsuperior;F6E4 dong;20AB dorusquare;3326 dotaccent;02D9 dotaccentcmb;0307 dotbelowcmb;0323 dotbelowcomb;0323 dotkatakana;30FB dotlessi;0131 dotlessj;F6BE dotlessjstrokehook;0284 dotmath;22C5 dottedcircle;25CC doubleyodpatah;FB1F doubleyodpatahhebrew;FB1F downtackbelowcmb;031E downtackmod;02D5 dparen;249F dsuperior;F6EB dtail;0256 dtopbar;018C duhiragana;3065 dukatakana;30C5 dz;01F3 dzaltone;02A3 dzcaron;01C6 dzcurl;02A5 dzeabkhasiancyrillic;04E1 dzecyrillic;0455 dzhecyrillic;045F e;0065 eacute;00E9 earth;2641 ebengali;098F ebopomofo;311C ebreve;0115 ecandradeva;090D ecandragujarati;0A8D ecandravowelsigndeva;0945 ecandravowelsigngujarati;0AC5 ecaron;011B ecedillabreve;1E1D echarmenian;0565 echyiwnarmenian;0587 ecircle;24D4 ecircumflex;00EA ecircumflexacute;1EBF ecircumflexbelow;1E19 ecircumflexdotbelow;1EC7 ecircumflexgrave;1EC1 ecircumflexhookabove;1EC3 ecircumflextilde;1EC5 ecyrillic;0454 edblgrave;0205 edeva;090F edieresis;00EB edot;0117 edotaccent;0117 edotbelow;1EB9 eegurmukhi;0A0F eematragurmukhi;0A47 efcyrillic;0444 egrave;00E8 egujarati;0A8F eharmenian;0567 ehbopomofo;311D ehiragana;3048 ehookabove;1EBB eibopomofo;311F eight;0038 eightarabic;0668 eightbengali;09EE eightcircle;2467 eightcircleinversesansserif;2791 eightdeva;096E eighteencircle;2471 eighteenparen;2485 eighteenperiod;2499 eightgujarati;0AEE eightgurmukhi;0A6E eighthackarabic;0668 eighthangzhou;3028 eighthnotebeamed;266B eightideographicparen;3227 eightinferior;2088 eightmonospace;FF18 eightoldstyle;F738 eightparen;247B eightperiod;248F eightpersian;06F8 eightroman;2177 eightsuperior;2078 eightthai;0E58 einvertedbreve;0207 eiotifiedcyrillic;0465 ekatakana;30A8 ekatakanahalfwidth;FF74 ekonkargurmukhi;0A74 ekorean;3154 elcyrillic;043B element;2208 elevencircle;246A elevenparen;247E elevenperiod;2492 elevenroman;217A ellipsis;2026 ellipsisvertical;22EE emacron;0113 emacronacute;1E17 emacrongrave;1E15 emcyrillic;043C emdash;2014 emdashvertical;FE31 emonospace;FF45 emphasismarkarmenian;055B emptyset;2205 enbopomofo;3123 encyrillic;043D endash;2013 endashvertical;FE32 endescendercyrillic;04A3 eng;014B engbopomofo;3125 enghecyrillic;04A5 enhookcyrillic;04C8 enspace;2002 eogonek;0119 eokorean;3153 eopen;025B eopenclosed;029A eopenreversed;025C eopenreversedclosed;025E eopenreversedhook;025D eparen;24A0 epsilon;03B5 epsilontonos;03AD equal;003D equalmonospace;FF1D equalsmall;FE66 equalsuperior;207C equivalence;2261 erbopomofo;3126 ercyrillic;0440 ereversed;0258 ereversedcyrillic;044D escyrillic;0441 esdescendercyrillic;04AB esh;0283 eshcurl;0286 eshortdeva;090E eshortvowelsigndeva;0946 eshreversedloop;01AA eshsquatreversed;0285 esmallhiragana;3047 esmallkatakana;30A7 esmallkatakanahalfwidth;FF6A estimated;212E esuperior;F6EC eta;03B7 etarmenian;0568 etatonos;03AE eth;00F0 etilde;1EBD etildebelow;1E1B etnahtafoukhhebrew;0591 etnahtafoukhlefthebrew;0591 etnahtahebrew;0591 etnahtalefthebrew;0591 eturned;01DD eukorean;3161 euro;20AC evowelsignbengali;09C7 evowelsigndeva;0947 evowelsigngujarati;0AC7 exclam;0021 exclamarmenian;055C exclamdbl;203C exclamdown;00A1 exclamdownsmall;F7A1 exclammonospace;FF01 exclamsmall;F721 existential;2203 ezh;0292 ezhcaron;01EF ezhcurl;0293 ezhreversed;01B9 ezhtail;01BA f;0066 fadeva;095E fagurmukhi;0A5E fahrenheit;2109 fathaarabic;064E fathalowarabic;064E fathatanarabic;064B fbopomofo;3108 fcircle;24D5 fdotaccent;1E1F feharabic;0641 feharmenian;0586 fehfinalarabic;FED2 fehinitialarabic;FED3 fehmedialarabic;FED4 feicoptic;03E5 female;2640 ff;FB00 ffi;FB03 ffl;FB04 fi;FB01 fifteencircle;246E fifteenparen;2482 fifteenperiod;2496 figuredash;2012 filledbox;25A0 filledrect;25AC finalkaf;05DA finalkafdagesh;FB3A finalkafdageshhebrew;FB3A finalkafhebrew;05DA finalkafqamats;05DA 05B8 finalkafqamatshebrew;05DA 05B8 finalkafsheva;05DA 05B0 finalkafshevahebrew;05DA 05B0 finalmem;05DD finalmemhebrew;05DD finalnun;05DF finalnunhebrew;05DF finalpe;05E3 finalpehebrew;05E3 finaltsadi;05E5 finaltsadihebrew;05E5 firsttonechinese;02C9 fisheye;25C9 fitacyrillic;0473 five;0035 fivearabic;0665 fivebengali;09EB fivecircle;2464 fivecircleinversesansserif;278E fivedeva;096B fiveeighths;215D fivegujarati;0AEB fivegurmukhi;0A6B fivehackarabic;0665 fivehangzhou;3025 fiveideographicparen;3224 fiveinferior;2085 fivemonospace;FF15 fiveoldstyle;F735 fiveparen;2478 fiveperiod;248C fivepersian;06F5 fiveroman;2174 fivesuperior;2075 fivethai;0E55 fl;FB02 florin;0192 fmonospace;FF46 fmsquare;3399 fofanthai;0E1F fofathai;0E1D fongmanthai;0E4F forall;2200 four;0034 fourarabic;0664 fourbengali;09EA fourcircle;2463 fourcircleinversesansserif;278D fourdeva;096A fourgujarati;0AEA fourgurmukhi;0A6A fourhackarabic;0664 fourhangzhou;3024 fourideographicparen;3223 fourinferior;2084 fourmonospace;FF14 fournumeratorbengali;09F7 fouroldstyle;F734 fourparen;2477 fourperiod;248B fourpersian;06F4 fourroman;2173 foursuperior;2074 fourteencircle;246D fourteenparen;2481 fourteenperiod;2495 fourthai;0E54 fourthtonechinese;02CB fparen;24A1 fraction;2044 franc;20A3 g;0067 gabengali;0997 gacute;01F5 gadeva;0917 gafarabic;06AF gaffinalarabic;FB93 gafinitialarabic;FB94 gafmedialarabic;FB95 gagujarati;0A97 gagurmukhi;0A17 gahiragana;304C gakatakana;30AC gamma;03B3 gammalatinsmall;0263 gammasuperior;02E0 gangiacoptic;03EB gbopomofo;310D gbreve;011F gcaron;01E7 gcedilla;0123 gcircle;24D6 gcircumflex;011D gcommaaccent;0123 gdot;0121 gdotaccent;0121 gecyrillic;0433 gehiragana;3052 gekatakana;30B2 geometricallyequal;2251 gereshaccenthebrew;059C gereshhebrew;05F3 gereshmuqdamhebrew;059D germandbls;00DF gershayimaccenthebrew;059E gershayimhebrew;05F4 getamark;3013 ghabengali;0998 ghadarmenian;0572 ghadeva;0918 ghagujarati;0A98 ghagurmukhi;0A18 ghainarabic;063A ghainfinalarabic;FECE ghaininitialarabic;FECF ghainmedialarabic;FED0 ghemiddlehookcyrillic;0495 ghestrokecyrillic;0493 gheupturncyrillic;0491 ghhadeva;095A ghhagurmukhi;0A5A ghook;0260 ghzsquare;3393 gihiragana;304E gikatakana;30AE gimarmenian;0563 gimel;05D2 gimeldagesh;FB32 gimeldageshhebrew;FB32 gimelhebrew;05D2 gjecyrillic;0453 glottalinvertedstroke;01BE glottalstop;0294 glottalstopinverted;0296 glottalstopmod;02C0 glottalstopreversed;0295 glottalstopreversedmod;02C1 glottalstopreversedsuperior;02E4 glottalstopstroke;02A1 glottalstopstrokereversed;02A2 gmacron;1E21 gmonospace;FF47 gohiragana;3054 gokatakana;30B4 gparen;24A2 gpasquare;33AC gradient;2207 grave;0060 gravebelowcmb;0316 gravecmb;0300 gravecomb;0300 gravedeva;0953 gravelowmod;02CE gravemonospace;FF40 gravetonecmb;0340 greater;003E greaterequal;2265 greaterequalorless;22DB greatermonospace;FF1E greaterorequivalent;2273 greaterorless;2277 greateroverequal;2267 greatersmall;FE65 gscript;0261 gstroke;01E5 guhiragana;3050 guillemotleft;00AB guillemotright;00BB guilsinglleft;2039 guilsinglright;203A gukatakana;30B0 guramusquare;3318 gysquare;33C9 h;0068 haabkhasiancyrillic;04A9 haaltonearabic;06C1 habengali;09B9 hadescendercyrillic;04B3 hadeva;0939 hagujarati;0AB9 hagurmukhi;0A39 haharabic;062D hahfinalarabic;FEA2 hahinitialarabic;FEA3 hahiragana;306F hahmedialarabic;FEA4 haitusquare;332A hakatakana;30CF hakatakanahalfwidth;FF8A halantgurmukhi;0A4D hamzaarabic;0621 hamzadammaarabic;0621 064F hamzadammatanarabic;0621 064C hamzafathaarabic;0621 064E hamzafathatanarabic;0621 064B hamzalowarabic;0621 hamzalowkasraarabic;0621 0650 hamzalowkasratanarabic;0621 064D hamzasukunarabic;0621 0652 hangulfiller;3164 hardsigncyrillic;044A harpoonleftbarbup;21BC harpoonrightbarbup;21C0 hasquare;33CA hatafpatah;05B2 hatafpatah16;05B2 hatafpatah23;05B2 hatafpatah2f;05B2 hatafpatahhebrew;05B2 hatafpatahnarrowhebrew;05B2 hatafpatahquarterhebrew;05B2 hatafpatahwidehebrew;05B2 hatafqamats;05B3 hatafqamats1b;05B3 hatafqamats28;05B3 hatafqamats34;05B3 hatafqamatshebrew;05B3 hatafqamatsnarrowhebrew;05B3 hatafqamatsquarterhebrew;05B3 hatafqamatswidehebrew;05B3 hatafsegol;05B1 hatafsegol17;05B1 hatafsegol24;05B1 hatafsegol30;05B1 hatafsegolhebrew;05B1 hatafsegolnarrowhebrew;05B1 hatafsegolquarterhebrew;05B1 hatafsegolwidehebrew;05B1 hbar;0127 hbopomofo;310F hbrevebelow;1E2B hcedilla;1E29 hcircle;24D7 hcircumflex;0125 hdieresis;1E27 hdotaccent;1E23 hdotbelow;1E25 he;05D4 heart;2665 heartsuitblack;2665 heartsuitwhite;2661 hedagesh;FB34 hedageshhebrew;FB34 hehaltonearabic;06C1 heharabic;0647 hehebrew;05D4 hehfinalaltonearabic;FBA7 hehfinalalttwoarabic;FEEA hehfinalarabic;FEEA hehhamzaabovefinalarabic;FBA5 hehhamzaaboveisolatedarabic;FBA4 hehinitialaltonearabic;FBA8 hehinitialarabic;FEEB hehiragana;3078 hehmedialaltonearabic;FBA9 hehmedialarabic;FEEC heiseierasquare;337B hekatakana;30D8 hekatakanahalfwidth;FF8D hekutaarusquare;3336 henghook;0267 herutusquare;3339 het;05D7 hethebrew;05D7 hhook;0266 hhooksuperior;02B1 hieuhacirclekorean;327B hieuhaparenkorean;321B hieuhcirclekorean;326D hieuhkorean;314E hieuhparenkorean;320D hihiragana;3072 hikatakana;30D2 hikatakanahalfwidth;FF8B hiriq;05B4 hiriq14;05B4 hiriq21;05B4 hiriq2d;05B4 hiriqhebrew;05B4 hiriqnarrowhebrew;05B4 hiriqquarterhebrew;05B4 hiriqwidehebrew;05B4 hlinebelow;1E96 hmonospace;FF48 hoarmenian;0570 hohipthai;0E2B hohiragana;307B hokatakana;30DB hokatakanahalfwidth;FF8E holam;05B9 holam19;05B9 holam26;05B9 holam32;05B9 holamhebrew;05B9 holamnarrowhebrew;05B9 holamquarterhebrew;05B9 holamwidehebrew;05B9 honokhukthai;0E2E hookabovecomb;0309 hookcmb;0309 hookpalatalizedbelowcmb;0321 hookretroflexbelowcmb;0322 hoonsquare;3342 horicoptic;03E9 horizontalbar;2015 horncmb;031B hotsprings;2668 house;2302 hparen;24A3 hsuperior;02B0 hturned;0265 huhiragana;3075 huiitosquare;3333 hukatakana;30D5 hukatakanahalfwidth;FF8C hungarumlaut;02DD hungarumlautcmb;030B hv;0195 hyphen;002D hypheninferior;F6E5 hyphenmonospace;FF0D hyphensmall;FE63 hyphensuperior;F6E6 hyphentwo;2010 i;0069 iacute;00ED iacyrillic;044F ibengali;0987 ibopomofo;3127 ibreve;012D icaron;01D0 icircle;24D8 icircumflex;00EE icyrillic;0456 idblgrave;0209 ideographearthcircle;328F ideographfirecircle;328B ideographicallianceparen;323F ideographiccallparen;323A ideographiccentrecircle;32A5 ideographicclose;3006 ideographiccomma;3001 ideographiccommaleft;FF64 ideographiccongratulationparen;3237 ideographiccorrectcircle;32A3 ideographicearthparen;322F ideographicenterpriseparen;323D ideographicexcellentcircle;329D ideographicfestivalparen;3240 ideographicfinancialcircle;3296 ideographicfinancialparen;3236 ideographicfireparen;322B ideographichaveparen;3232 ideographichighcircle;32A4 ideographiciterationmark;3005 ideographiclaborcircle;3298 ideographiclaborparen;3238 ideographicleftcircle;32A7 ideographiclowcircle;32A6 ideographicmedicinecircle;32A9 ideographicmetalparen;322E ideographicmoonparen;322A ideographicnameparen;3234 ideographicperiod;3002 ideographicprintcircle;329E ideographicreachparen;3243 ideographicrepresentparen;3239 ideographicresourceparen;323E ideographicrightcircle;32A8 ideographicsecretcircle;3299 ideographicselfparen;3242 ideographicsocietyparen;3233 ideographicspace;3000 ideographicspecialparen;3235 ideographicstockparen;3231 ideographicstudyparen;323B ideographicsunparen;3230 ideographicsuperviseparen;323C ideographicwaterparen;322C ideographicwoodparen;322D ideographiczero;3007 ideographmetalcircle;328E ideographmooncircle;328A ideographnamecircle;3294 ideographsuncircle;3290 ideographwatercircle;328C ideographwoodcircle;328D ideva;0907 idieresis;00EF idieresisacute;1E2F idieresiscyrillic;04E5 idotbelow;1ECB iebrevecyrillic;04D7 iecyrillic;0435 ieungacirclekorean;3275 ieungaparenkorean;3215 ieungcirclekorean;3267 ieungkorean;3147 ieungparenkorean;3207 igrave;00EC igujarati;0A87 igurmukhi;0A07 ihiragana;3044 ihookabove;1EC9 iibengali;0988 iicyrillic;0438 iideva;0908 iigujarati;0A88 iigurmukhi;0A08 iimatragurmukhi;0A40 iinvertedbreve;020B iishortcyrillic;0439 iivowelsignbengali;09C0 iivowelsigndeva;0940 iivowelsigngujarati;0AC0 ij;0133 ikatakana;30A4 ikatakanahalfwidth;FF72 ikorean;3163 ilde;02DC iluyhebrew;05AC imacron;012B imacroncyrillic;04E3 imageorapproximatelyequal;2253 imatragurmukhi;0A3F imonospace;FF49 increment;2206 infinity;221E iniarmenian;056B integral;222B integralbottom;2321 integralbt;2321 integralex;F8F5 integraltop;2320 integraltp;2320 intersection;2229 intisquare;3305 invbullet;25D8 invcircle;25D9 invsmileface;263B iocyrillic;0451 iogonek;012F iota;03B9 iotadieresis;03CA iotadieresistonos;0390 iotalatin;0269 iotatonos;03AF iparen;24A4 irigurmukhi;0A72 ismallhiragana;3043 ismallkatakana;30A3 ismallkatakanahalfwidth;FF68 issharbengali;09FA istroke;0268 isuperior;F6ED iterationhiragana;309D iterationkatakana;30FD itilde;0129 itildebelow;1E2D iubopomofo;3129 iucyrillic;044E ivowelsignbengali;09BF ivowelsigndeva;093F ivowelsigngujarati;0ABF izhitsacyrillic;0475 izhitsadblgravecyrillic;0477 j;006A jaarmenian;0571 jabengali;099C jadeva;091C jagujarati;0A9C jagurmukhi;0A1C jbopomofo;3110 jcaron;01F0 jcircle;24D9 jcircumflex;0135 jcrossedtail;029D jdotlessstroke;025F jecyrillic;0458 jeemarabic;062C jeemfinalarabic;FE9E jeeminitialarabic;FE9F jeemmedialarabic;FEA0 jeharabic;0698 jehfinalarabic;FB8B jhabengali;099D jhadeva;091D jhagujarati;0A9D jhagurmukhi;0A1D jheharmenian;057B jis;3004 jmonospace;FF4A jparen;24A5 jsuperior;02B2 k;006B kabashkircyrillic;04A1 kabengali;0995 kacute;1E31 kacyrillic;043A kadescendercyrillic;049B kadeva;0915 kaf;05DB kafarabic;0643 kafdagesh;FB3B kafdageshhebrew;FB3B kaffinalarabic;FEDA kafhebrew;05DB kafinitialarabic;FEDB kafmedialarabic;FEDC kafrafehebrew;FB4D kagujarati;0A95 kagurmukhi;0A15 kahiragana;304B kahookcyrillic;04C4 kakatakana;30AB kakatakanahalfwidth;FF76 kappa;03BA kappasymbolgreek;03F0 kapyeounmieumkorean;3171 kapyeounphieuphkorean;3184 kapyeounpieupkorean;3178 kapyeounssangpieupkorean;3179 karoriisquare;330D kashidaautoarabic;0640 kashidaautonosidebearingarabic;0640 kasmallkatakana;30F5 kasquare;3384 kasraarabic;0650 kasratanarabic;064D kastrokecyrillic;049F katahiraprolongmarkhalfwidth;FF70 kaverticalstrokecyrillic;049D kbopomofo;310E kcalsquare;3389 kcaron;01E9 kcedilla;0137 kcircle;24DA kcommaaccent;0137 kdotbelow;1E33 keharmenian;0584 kehiragana;3051 kekatakana;30B1 kekatakanahalfwidth;FF79 kenarmenian;056F kesmallkatakana;30F6 kgreenlandic;0138 khabengali;0996 khacyrillic;0445 khadeva;0916 khagujarati;0A96 khagurmukhi;0A16 khaharabic;062E khahfinalarabic;FEA6 khahinitialarabic;FEA7 khahmedialarabic;FEA8 kheicoptic;03E7 khhadeva;0959 khhagurmukhi;0A59 khieukhacirclekorean;3278 khieukhaparenkorean;3218 khieukhcirclekorean;326A khieukhkorean;314B khieukhparenkorean;320A khokhaithai;0E02 khokhonthai;0E05 khokhuatthai;0E03 khokhwaithai;0E04 khomutthai;0E5B khook;0199 khorakhangthai;0E06 khzsquare;3391 kihiragana;304D kikatakana;30AD kikatakanahalfwidth;FF77 kiroguramusquare;3315 kiromeetorusquare;3316 kirosquare;3314 kiyeokacirclekorean;326E kiyeokaparenkorean;320E kiyeokcirclekorean;3260 kiyeokkorean;3131 kiyeokparenkorean;3200 kiyeoksioskorean;3133 kjecyrillic;045C klinebelow;1E35 klsquare;3398 kmcubedsquare;33A6 kmonospace;FF4B kmsquaredsquare;33A2 kohiragana;3053 kohmsquare;33C0 kokaithai;0E01 kokatakana;30B3 kokatakanahalfwidth;FF7A kooposquare;331E koppacyrillic;0481 koreanstandardsymbol;327F koroniscmb;0343 kparen;24A6 kpasquare;33AA ksicyrillic;046F ktsquare;33CF kturned;029E kuhiragana;304F kukatakana;30AF kukatakanahalfwidth;FF78 kvsquare;33B8 kwsquare;33BE l;006C labengali;09B2 lacute;013A ladeva;0932 lagujarati;0AB2 lagurmukhi;0A32 lakkhangyaothai;0E45 lamaleffinalarabic;FEFC lamalefhamzaabovefinalarabic;FEF8 lamalefhamzaaboveisolatedarabic;FEF7 lamalefhamzabelowfinalarabic;FEFA lamalefhamzabelowisolatedarabic;FEF9 lamalefisolatedarabic;FEFB lamalefmaddaabovefinalarabic;FEF6 lamalefmaddaaboveisolatedarabic;FEF5 lamarabic;0644 lambda;03BB lambdastroke;019B lamed;05DC lameddagesh;FB3C lameddageshhebrew;FB3C lamedhebrew;05DC lamedholam;05DC 05B9 lamedholamdagesh;05DC 05B9 05BC lamedholamdageshhebrew;05DC 05B9 05BC lamedholamhebrew;05DC 05B9 lamfinalarabic;FEDE lamhahinitialarabic;FCCA laminitialarabic;FEDF lamjeeminitialarabic;FCC9 lamkhahinitialarabic;FCCB lamlamhehisolatedarabic;FDF2 lammedialarabic;FEE0 lammeemhahinitialarabic;FD88 lammeeminitialarabic;FCCC lammeemjeeminitialarabic;FEDF FEE4 FEA0 lammeemkhahinitialarabic;FEDF FEE4 FEA8 largecircle;25EF lbar;019A lbelt;026C lbopomofo;310C lcaron;013E lcedilla;013C lcircle;24DB lcircumflexbelow;1E3D lcommaaccent;013C ldot;0140 ldotaccent;0140 ldotbelow;1E37 ldotbelowmacron;1E39 leftangleabovecmb;031A lefttackbelowcmb;0318 less;003C lessequal;2264 lessequalorgreater;22DA lessmonospace;FF1C lessorequivalent;2272 lessorgreater;2276 lessoverequal;2266 lesssmall;FE64 lezh;026E lfblock;258C lhookretroflex;026D lira;20A4 liwnarmenian;056C lj;01C9 ljecyrillic;0459 ll;F6C0 lladeva;0933 llagujarati;0AB3 llinebelow;1E3B llladeva;0934 llvocalicbengali;09E1 llvocalicdeva;0961 llvocalicvowelsignbengali;09E3 llvocalicvowelsigndeva;0963 lmiddletilde;026B lmonospace;FF4C lmsquare;33D0 lochulathai;0E2C logicaland;2227 logicalnot;00AC logicalnotreversed;2310 logicalor;2228 lolingthai;0E25 longs;017F lowlinecenterline;FE4E lowlinecmb;0332 lowlinedashed;FE4D lozenge;25CA lparen;24A7 lslash;0142 lsquare;2113 lsuperior;F6EE ltshade;2591 luthai;0E26 lvocalicbengali;098C lvocalicdeva;090C lvocalicvowelsignbengali;09E2 lvocalicvowelsigndeva;0962 lxsquare;33D3 m;006D mabengali;09AE macron;00AF macronbelowcmb;0331 macroncmb;0304 macronlowmod;02CD macronmonospace;FFE3 macute;1E3F madeva;092E magujarati;0AAE magurmukhi;0A2E mahapakhhebrew;05A4 mahapakhlefthebrew;05A4 mahiragana;307E maichattawalowleftthai;F895 maichattawalowrightthai;F894 maichattawathai;0E4B maichattawaupperleftthai;F893 maieklowleftthai;F88C maieklowrightthai;F88B maiekthai;0E48 maiekupperleftthai;F88A maihanakatleftthai;F884 maihanakatthai;0E31 maitaikhuleftthai;F889 maitaikhuthai;0E47 maitholowleftthai;F88F maitholowrightthai;F88E maithothai;0E49 maithoupperleftthai;F88D maitrilowleftthai;F892 maitrilowrightthai;F891 maitrithai;0E4A maitriupperleftthai;F890 maiyamokthai;0E46 makatakana;30DE makatakanahalfwidth;FF8F male;2642 mansyonsquare;3347 maqafhebrew;05BE mars;2642 masoracirclehebrew;05AF masquare;3383 mbopomofo;3107 mbsquare;33D4 mcircle;24DC mcubedsquare;33A5 mdotaccent;1E41 mdotbelow;1E43 meemarabic;0645 meemfinalarabic;FEE2 meeminitialarabic;FEE3 meemmedialarabic;FEE4 meemmeeminitialarabic;FCD1 meemmeemisolatedarabic;FC48 meetorusquare;334D mehiragana;3081 meizierasquare;337E mekatakana;30E1 mekatakanahalfwidth;FF92 mem;05DE memdagesh;FB3E memdageshhebrew;FB3E memhebrew;05DE menarmenian;0574 merkhahebrew;05A5 merkhakefulahebrew;05A6 merkhakefulalefthebrew;05A6 merkhalefthebrew;05A5 mhook;0271 mhzsquare;3392 middledotkatakanahalfwidth;FF65 middot;00B7 mieumacirclekorean;3272 mieumaparenkorean;3212 mieumcirclekorean;3264 mieumkorean;3141 mieumpansioskorean;3170 mieumparenkorean;3204 mieumpieupkorean;316E mieumsioskorean;316F mihiragana;307F mikatakana;30DF mikatakanahalfwidth;FF90 minus;2212 minusbelowcmb;0320 minuscircle;2296 minusmod;02D7 minusplus;2213 minute;2032 miribaarusquare;334A mirisquare;3349 mlonglegturned;0270 mlsquare;3396 mmcubedsquare;33A3 mmonospace;FF4D mmsquaredsquare;339F mohiragana;3082 mohmsquare;33C1 mokatakana;30E2 mokatakanahalfwidth;FF93 molsquare;33D6 momathai;0E21 moverssquare;33A7 moverssquaredsquare;33A8 mparen;24A8 mpasquare;33AB mssquare;33B3 msuperior;F6EF mturned;026F mu;00B5 mu1;00B5 muasquare;3382 muchgreater;226B muchless;226A mufsquare;338C mugreek;03BC mugsquare;338D muhiragana;3080 mukatakana;30E0 mukatakanahalfwidth;FF91 mulsquare;3395 multiply;00D7 mumsquare;339B munahhebrew;05A3 munahlefthebrew;05A3 musicalnote;266A musicalnotedbl;266B musicflatsign;266D musicsharpsign;266F mussquare;33B2 muvsquare;33B6 muwsquare;33BC mvmegasquare;33B9 mvsquare;33B7 mwmegasquare;33BF mwsquare;33BD n;006E nabengali;09A8 nabla;2207 nacute;0144 nadeva;0928 nagujarati;0AA8 nagurmukhi;0A28 nahiragana;306A nakatakana;30CA nakatakanahalfwidth;FF85 napostrophe;0149 nasquare;3381 nbopomofo;310B nbspace;00A0 ncaron;0148 ncedilla;0146 ncircle;24DD ncircumflexbelow;1E4B ncommaaccent;0146 ndotaccent;1E45 ndotbelow;1E47 nehiragana;306D nekatakana;30CD nekatakanahalfwidth;FF88 newsheqelsign;20AA nfsquare;338B ngabengali;0999 ngadeva;0919 ngagujarati;0A99 ngagurmukhi;0A19 ngonguthai;0E07 nhiragana;3093 nhookleft;0272 nhookretroflex;0273 nieunacirclekorean;326F nieunaparenkorean;320F nieuncieuckorean;3135 nieuncirclekorean;3261 nieunhieuhkorean;3136 nieunkorean;3134 nieunpansioskorean;3168 nieunparenkorean;3201 nieunsioskorean;3167 nieuntikeutkorean;3166 nihiragana;306B nikatakana;30CB nikatakanahalfwidth;FF86 nikhahitleftthai;F899 nikhahitthai;0E4D nine;0039 ninearabic;0669 ninebengali;09EF ninecircle;2468 ninecircleinversesansserif;2792 ninedeva;096F ninegujarati;0AEF ninegurmukhi;0A6F ninehackarabic;0669 ninehangzhou;3029 nineideographicparen;3228 nineinferior;2089 ninemonospace;FF19 nineoldstyle;F739 nineparen;247C nineperiod;2490 ninepersian;06F9 nineroman;2178 ninesuperior;2079 nineteencircle;2472 nineteenparen;2486 nineteenperiod;249A ninethai;0E59 nj;01CC njecyrillic;045A nkatakana;30F3 nkatakanahalfwidth;FF9D nlegrightlong;019E nlinebelow;1E49 nmonospace;FF4E nmsquare;339A nnabengali;09A3 nnadeva;0923 nnagujarati;0AA3 nnagurmukhi;0A23 nnnadeva;0929 nohiragana;306E nokatakana;30CE nokatakanahalfwidth;FF89 nonbreakingspace;00A0 nonenthai;0E13 nonuthai;0E19 noonarabic;0646 noonfinalarabic;FEE6 noonghunnaarabic;06BA noonghunnafinalarabic;FB9F noonhehinitialarabic;FEE7 FEEC nooninitialarabic;FEE7 noonjeeminitialarabic;FCD2 noonjeemisolatedarabic;FC4B noonmedialarabic;FEE8 noonmeeminitialarabic;FCD5 noonmeemisolatedarabic;FC4E noonnoonfinalarabic;FC8D notcontains;220C notelement;2209 notelementof;2209 notequal;2260 notgreater;226F notgreaternorequal;2271 notgreaternorless;2279 notidentical;2262 notless;226E notlessnorequal;2270 notparallel;2226 notprecedes;2280 notsubset;2284 notsucceeds;2281 notsuperset;2285 nowarmenian;0576 nparen;24A9 nssquare;33B1 nsuperior;207F ntilde;00F1 nu;03BD nuhiragana;306C nukatakana;30CC nukatakanahalfwidth;FF87 nuktabengali;09BC nuktadeva;093C nuktagujarati;0ABC nuktagurmukhi;0A3C numbersign;0023 numbersignmonospace;FF03 numbersignsmall;FE5F numeralsigngreek;0374 numeralsignlowergreek;0375 numero;2116 nun;05E0 nundagesh;FB40 nundageshhebrew;FB40 nunhebrew;05E0 nvsquare;33B5 nwsquare;33BB nyabengali;099E nyadeva;091E nyagujarati;0A9E nyagurmukhi;0A1E o;006F oacute;00F3 oangthai;0E2D obarred;0275 obarredcyrillic;04E9 obarreddieresiscyrillic;04EB obengali;0993 obopomofo;311B obreve;014F ocandradeva;0911 ocandragujarati;0A91 ocandravowelsigndeva;0949 ocandravowelsigngujarati;0AC9 ocaron;01D2 ocircle;24DE ocircumflex;00F4 ocircumflexacute;1ED1 ocircumflexdotbelow;1ED9 ocircumflexgrave;1ED3 ocircumflexhookabove;1ED5 ocircumflextilde;1ED7 ocyrillic;043E odblacute;0151 odblgrave;020D odeva;0913 odieresis;00F6 odieresiscyrillic;04E7 odotbelow;1ECD oe;0153 oekorean;315A ogonek;02DB ogonekcmb;0328 ograve;00F2 ogujarati;0A93 oharmenian;0585 ohiragana;304A ohookabove;1ECF ohorn;01A1 ohornacute;1EDB ohorndotbelow;1EE3 ohorngrave;1EDD ohornhookabove;1EDF ohorntilde;1EE1 ohungarumlaut;0151 oi;01A3 oinvertedbreve;020F okatakana;30AA okatakanahalfwidth;FF75 okorean;3157 olehebrew;05AB omacron;014D omacronacute;1E53 omacrongrave;1E51 omdeva;0950 omega;03C9 omega1;03D6 omegacyrillic;0461 omegalatinclosed;0277 omegaroundcyrillic;047B omegatitlocyrillic;047D omegatonos;03CE omgujarati;0AD0 omicron;03BF omicrontonos;03CC omonospace;FF4F one;0031 onearabic;0661 onebengali;09E7 onecircle;2460 onecircleinversesansserif;278A onedeva;0967 onedotenleader;2024 oneeighth;215B onefitted;F6DC onegujarati;0AE7 onegurmukhi;0A67 onehackarabic;0661 onehalf;00BD onehangzhou;3021 oneideographicparen;3220 oneinferior;2081 onemonospace;FF11 onenumeratorbengali;09F4 oneoldstyle;F731 oneparen;2474 oneperiod;2488 onepersian;06F1 onequarter;00BC oneroman;2170 onesuperior;00B9 onethai;0E51 onethird;2153 oogonek;01EB oogonekmacron;01ED oogurmukhi;0A13 oomatragurmukhi;0A4B oopen;0254 oparen;24AA openbullet;25E6 option;2325 ordfeminine;00AA ordmasculine;00BA orthogonal;221F oshortdeva;0912 oshortvowelsigndeva;094A oslash;00F8 oslashacute;01FF osmallhiragana;3049 osmallkatakana;30A9 osmallkatakanahalfwidth;FF6B ostrokeacute;01FF osuperior;F6F0 otcyrillic;047F otilde;00F5 otildeacute;1E4D otildedieresis;1E4F oubopomofo;3121 overline;203E overlinecenterline;FE4A overlinecmb;0305 overlinedashed;FE49 overlinedblwavy;FE4C overlinewavy;FE4B overscore;00AF ovowelsignbengali;09CB ovowelsigndeva;094B ovowelsigngujarati;0ACB p;0070 paampssquare;3380 paasentosquare;332B pabengali;09AA pacute;1E55 padeva;092A pagedown;21DF pageup;21DE pagujarati;0AAA pagurmukhi;0A2A pahiragana;3071 paiyannoithai;0E2F pakatakana;30D1 palatalizationcyrilliccmb;0484 palochkacyrillic;04C0 pansioskorean;317F paragraph;00B6 parallel;2225 parenleft;0028 parenleftaltonearabic;FD3E parenleftbt;F8ED parenleftex;F8EC parenleftinferior;208D parenleftmonospace;FF08 parenleftsmall;FE59 parenleftsuperior;207D parenlefttp;F8EB parenleftvertical;FE35 parenright;0029 parenrightaltonearabic;FD3F parenrightbt;F8F8 parenrightex;F8F7 parenrightinferior;208E parenrightmonospace;FF09 parenrightsmall;FE5A parenrightsuperior;207E parenrighttp;F8F6 parenrightvertical;FE36 partialdiff;2202 paseqhebrew;05C0 pashtahebrew;0599 pasquare;33A9 patah;05B7 patah11;05B7 patah1d;05B7 patah2a;05B7 patahhebrew;05B7 patahnarrowhebrew;05B7 patahquarterhebrew;05B7 patahwidehebrew;05B7 pazerhebrew;05A1 pbopomofo;3106 pcircle;24DF pdotaccent;1E57 pe;05E4 pecyrillic;043F pedagesh;FB44 pedageshhebrew;FB44 peezisquare;333B pefinaldageshhebrew;FB43 peharabic;067E peharmenian;057A pehebrew;05E4 pehfinalarabic;FB57 pehinitialarabic;FB58 pehiragana;307A pehmedialarabic;FB59 pekatakana;30DA pemiddlehookcyrillic;04A7 perafehebrew;FB4E percent;0025 percentarabic;066A percentmonospace;FF05 percentsmall;FE6A period;002E periodarmenian;0589 periodcentered;00B7 periodhalfwidth;FF61 periodinferior;F6E7 periodmonospace;FF0E periodsmall;FE52 periodsuperior;F6E8 perispomenigreekcmb;0342 perpendicular;22A5 perthousand;2030 peseta;20A7 pfsquare;338A phabengali;09AB phadeva;092B phagujarati;0AAB phagurmukhi;0A2B phi;03C6 phi1;03D5 phieuphacirclekorean;327A phieuphaparenkorean;321A phieuphcirclekorean;326C phieuphkorean;314D phieuphparenkorean;320C philatin;0278 phinthuthai;0E3A phisymbolgreek;03D5 phook;01A5 phophanthai;0E1E phophungthai;0E1C phosamphaothai;0E20 pi;03C0 pieupacirclekorean;3273 pieupaparenkorean;3213 pieupcieuckorean;3176 pieupcirclekorean;3265 pieupkiyeokkorean;3172 pieupkorean;3142 pieupparenkorean;3205 pieupsioskiyeokkorean;3174 pieupsioskorean;3144 pieupsiostikeutkorean;3175 pieupthieuthkorean;3177 pieuptikeutkorean;3173 pihiragana;3074 pikatakana;30D4 pisymbolgreek;03D6 piwrarmenian;0583 plus;002B plusbelowcmb;031F pluscircle;2295 plusminus;00B1 plusmod;02D6 plusmonospace;FF0B plussmall;FE62 plussuperior;207A pmonospace;FF50 pmsquare;33D8 pohiragana;307D pointingindexdownwhite;261F pointingindexleftwhite;261C pointingindexrightwhite;261E pointingindexupwhite;261D pokatakana;30DD poplathai;0E1B postalmark;3012 postalmarkface;3020 pparen;24AB precedes;227A prescription;211E primemod;02B9 primereversed;2035 product;220F projective;2305 prolongedkana;30FC propellor;2318 propersubset;2282 propersuperset;2283 proportion;2237 proportional;221D psi;03C8 psicyrillic;0471 psilipneumatacyrilliccmb;0486 pssquare;33B0 puhiragana;3077 pukatakana;30D7 pvsquare;33B4 pwsquare;33BA q;0071 qadeva;0958 qadmahebrew;05A8 qafarabic;0642 qaffinalarabic;FED6 qafinitialarabic;FED7 qafmedialarabic;FED8 qamats;05B8 qamats10;05B8 qamats1a;05B8 qamats1c;05B8 qamats27;05B8 qamats29;05B8 qamats33;05B8 qamatsde;05B8 qamatshebrew;05B8 qamatsnarrowhebrew;05B8 qamatsqatanhebrew;05B8 qamatsqatannarrowhebrew;05B8 qamatsqatanquarterhebrew;05B8 qamatsqatanwidehebrew;05B8 qamatsquarterhebrew;05B8 qamatswidehebrew;05B8 qarneyparahebrew;059F qbopomofo;3111 qcircle;24E0 qhook;02A0 qmonospace;FF51 qof;05E7 qofdagesh;FB47 qofdageshhebrew;FB47 qofhatafpatah;05E7 05B2 qofhatafpatahhebrew;05E7 05B2 qofhatafsegol;05E7 05B1 qofhatafsegolhebrew;05E7 05B1 qofhebrew;05E7 qofhiriq;05E7 05B4 qofhiriqhebrew;05E7 05B4 qofholam;05E7 05B9 qofholamhebrew;05E7 05B9 qofpatah;05E7 05B7 qofpatahhebrew;05E7 05B7 qofqamats;05E7 05B8 qofqamatshebrew;05E7 05B8 qofqubuts;05E7 05BB qofqubutshebrew;05E7 05BB qofsegol;05E7 05B6 qofsegolhebrew;05E7 05B6 qofsheva;05E7 05B0 qofshevahebrew;05E7 05B0 qoftsere;05E7 05B5 qoftserehebrew;05E7 05B5 qparen;24AC quarternote;2669 qubuts;05BB qubuts18;05BB qubuts25;05BB qubuts31;05BB qubutshebrew;05BB qubutsnarrowhebrew;05BB qubutsquarterhebrew;05BB qubutswidehebrew;05BB question;003F questionarabic;061F questionarmenian;055E questiondown;00BF questiondownsmall;F7BF questiongreek;037E questionmonospace;FF1F questionsmall;F73F quotedbl;0022 quotedblbase;201E quotedblleft;201C quotedblmonospace;FF02 quotedblprime;301E quotedblprimereversed;301D quotedblright;201D quoteleft;2018 quoteleftreversed;201B quotereversed;201B quoteright;2019 quoterightn;0149 quotesinglbase;201A quotesingle;0027 quotesinglemonospace;FF07 r;0072 raarmenian;057C rabengali;09B0 racute;0155 radeva;0930 radical;221A radicalex;F8E5 radoverssquare;33AE radoverssquaredsquare;33AF radsquare;33AD rafe;05BF rafehebrew;05BF ragujarati;0AB0 ragurmukhi;0A30 rahiragana;3089 rakatakana;30E9 rakatakanahalfwidth;FF97 ralowerdiagonalbengali;09F1 ramiddlediagonalbengali;09F0 ramshorn;0264 ratio;2236 rbopomofo;3116 rcaron;0159 rcedilla;0157 rcircle;24E1 rcommaaccent;0157 rdblgrave;0211 rdotaccent;1E59 rdotbelow;1E5B rdotbelowmacron;1E5D referencemark;203B reflexsubset;2286 reflexsuperset;2287 registered;00AE registersans;F8E8 registerserif;F6DA reharabic;0631 reharmenian;0580 rehfinalarabic;FEAE rehiragana;308C rehyehaleflamarabic;0631 FEF3 FE8E 0644 rekatakana;30EC rekatakanahalfwidth;FF9A resh;05E8 reshdageshhebrew;FB48 reshhatafpatah;05E8 05B2 reshhatafpatahhebrew;05E8 05B2 reshhatafsegol;05E8 05B1 reshhatafsegolhebrew;05E8 05B1 reshhebrew;05E8 reshhiriq;05E8 05B4 reshhiriqhebrew;05E8 05B4 reshholam;05E8 05B9 reshholamhebrew;05E8 05B9 reshpatah;05E8 05B7 reshpatahhebrew;05E8 05B7 reshqamats;05E8 05B8 reshqamatshebrew;05E8 05B8 reshqubuts;05E8 05BB reshqubutshebrew;05E8 05BB reshsegol;05E8 05B6 reshsegolhebrew;05E8 05B6 reshsheva;05E8 05B0 reshshevahebrew;05E8 05B0 reshtsere;05E8 05B5 reshtserehebrew;05E8 05B5 reversedtilde;223D reviahebrew;0597 reviamugrashhebrew;0597 revlogicalnot;2310 rfishhook;027E rfishhookreversed;027F rhabengali;09DD rhadeva;095D rho;03C1 rhook;027D rhookturned;027B rhookturnedsuperior;02B5 rhosymbolgreek;03F1 rhotichookmod;02DE rieulacirclekorean;3271 rieulaparenkorean;3211 rieulcirclekorean;3263 rieulhieuhkorean;3140 rieulkiyeokkorean;313A rieulkiyeoksioskorean;3169 rieulkorean;3139 rieulmieumkorean;313B rieulpansioskorean;316C rieulparenkorean;3203 rieulphieuphkorean;313F rieulpieupkorean;313C rieulpieupsioskorean;316B rieulsioskorean;313D rieulthieuthkorean;313E rieultikeutkorean;316A rieulyeorinhieuhkorean;316D rightangle;221F righttackbelowcmb;0319 righttriangle;22BF rihiragana;308A rikatakana;30EA rikatakanahalfwidth;FF98 ring;02DA ringbelowcmb;0325 ringcmb;030A ringhalfleft;02BF ringhalfleftarmenian;0559 ringhalfleftbelowcmb;031C ringhalfleftcentered;02D3 ringhalfright;02BE ringhalfrightbelowcmb;0339 ringhalfrightcentered;02D2 rinvertedbreve;0213 rittorusquare;3351 rlinebelow;1E5F rlongleg;027C rlonglegturned;027A rmonospace;FF52 rohiragana;308D rokatakana;30ED rokatakanahalfwidth;FF9B roruathai;0E23 rparen;24AD rrabengali;09DC rradeva;0931 rragurmukhi;0A5C rreharabic;0691 rrehfinalarabic;FB8D rrvocalicbengali;09E0 rrvocalicdeva;0960 rrvocalicgujarati;0AE0 rrvocalicvowelsignbengali;09C4 rrvocalicvowelsigndeva;0944 rrvocalicvowelsigngujarati;0AC4 rsuperior;F6F1 rtblock;2590 rturned;0279 rturnedsuperior;02B4 ruhiragana;308B rukatakana;30EB rukatakanahalfwidth;FF99 rupeemarkbengali;09F2 rupeesignbengali;09F3 rupiah;F6DD ruthai;0E24 rvocalicbengali;098B rvocalicdeva;090B rvocalicgujarati;0A8B rvocalicvowelsignbengali;09C3 rvocalicvowelsigndeva;0943 rvocalicvowelsigngujarati;0AC3 s;0073 sabengali;09B8 sacute;015B sacutedotaccent;1E65 sadarabic;0635 sadeva;0938 sadfinalarabic;FEBA sadinitialarabic;FEBB sadmedialarabic;FEBC sagujarati;0AB8 sagurmukhi;0A38 sahiragana;3055 sakatakana;30B5 sakatakanahalfwidth;FF7B sallallahoualayhewasallamarabic;FDFA samekh;05E1 samekhdagesh;FB41 samekhdageshhebrew;FB41 samekhhebrew;05E1 saraaathai;0E32 saraaethai;0E41 saraaimaimalaithai;0E44 saraaimaimuanthai;0E43 saraamthai;0E33 saraathai;0E30 saraethai;0E40 saraiileftthai;F886 saraiithai;0E35 saraileftthai;F885 saraithai;0E34 saraothai;0E42 saraueeleftthai;F888 saraueethai;0E37 saraueleftthai;F887 sarauethai;0E36 sarauthai;0E38 sarauuthai;0E39 sbopomofo;3119 scaron;0161 scarondotaccent;1E67 scedilla;015F schwa;0259 schwacyrillic;04D9 schwadieresiscyrillic;04DB schwahook;025A scircle;24E2 scircumflex;015D scommaaccent;0219 sdotaccent;1E61 sdotbelow;1E63 sdotbelowdotaccent;1E69 seagullbelowcmb;033C second;2033 secondtonechinese;02CA section;00A7 seenarabic;0633 seenfinalarabic;FEB2 seeninitialarabic;FEB3 seenmedialarabic;FEB4 segol;05B6 segol13;05B6 segol1f;05B6 segol2c;05B6 segolhebrew;05B6 segolnarrowhebrew;05B6 segolquarterhebrew;05B6 segoltahebrew;0592 segolwidehebrew;05B6 seharmenian;057D sehiragana;305B sekatakana;30BB sekatakanahalfwidth;FF7E semicolon;003B semicolonarabic;061B semicolonmonospace;FF1B semicolonsmall;FE54 semivoicedmarkkana;309C semivoicedmarkkanahalfwidth;FF9F sentisquare;3322 sentosquare;3323 seven;0037 sevenarabic;0667 sevenbengali;09ED sevencircle;2466 sevencircleinversesansserif;2790 sevendeva;096D seveneighths;215E sevengujarati;0AED sevengurmukhi;0A6D sevenhackarabic;0667 sevenhangzhou;3027 sevenideographicparen;3226 seveninferior;2087 sevenmonospace;FF17 sevenoldstyle;F737 sevenparen;247A sevenperiod;248E sevenpersian;06F7 sevenroman;2176 sevensuperior;2077 seventeencircle;2470 seventeenparen;2484 seventeenperiod;2498 seventhai;0E57 sfthyphen;00AD shaarmenian;0577 shabengali;09B6 shacyrillic;0448 shaddaarabic;0651 shaddadammaarabic;FC61 shaddadammatanarabic;FC5E shaddafathaarabic;FC60 shaddafathatanarabic;0651 064B shaddakasraarabic;FC62 shaddakasratanarabic;FC5F shade;2592 shadedark;2593 shadelight;2591 shademedium;2592 shadeva;0936 shagujarati;0AB6 shagurmukhi;0A36 shalshelethebrew;0593 shbopomofo;3115 shchacyrillic;0449 sheenarabic;0634 sheenfinalarabic;FEB6 sheeninitialarabic;FEB7 sheenmedialarabic;FEB8 sheicoptic;03E3 sheqel;20AA sheqelhebrew;20AA sheva;05B0 sheva115;05B0 sheva15;05B0 sheva22;05B0 sheva2e;05B0 shevahebrew;05B0 shevanarrowhebrew;05B0 shevaquarterhebrew;05B0 shevawidehebrew;05B0 shhacyrillic;04BB shimacoptic;03ED shin;05E9 shindagesh;FB49 shindageshhebrew;FB49 shindageshshindot;FB2C shindageshshindothebrew;FB2C shindageshsindot;FB2D shindageshsindothebrew;FB2D shindothebrew;05C1 shinhebrew;05E9 shinshindot;FB2A shinshindothebrew;FB2A shinsindot;FB2B shinsindothebrew;FB2B shook;0282 sigma;03C3 sigma1;03C2 sigmafinal;03C2 sigmalunatesymbolgreek;03F2 sihiragana;3057 sikatakana;30B7 sikatakanahalfwidth;FF7C siluqhebrew;05BD siluqlefthebrew;05BD similar;223C sindothebrew;05C2 siosacirclekorean;3274 siosaparenkorean;3214 sioscieuckorean;317E sioscirclekorean;3266 sioskiyeokkorean;317A sioskorean;3145 siosnieunkorean;317B siosparenkorean;3206 siospieupkorean;317D siostikeutkorean;317C six;0036 sixarabic;0666 sixbengali;09EC sixcircle;2465 sixcircleinversesansserif;278F sixdeva;096C sixgujarati;0AEC sixgurmukhi;0A6C sixhackarabic;0666 sixhangzhou;3026 sixideographicparen;3225 sixinferior;2086 sixmonospace;FF16 sixoldstyle;F736 sixparen;2479 sixperiod;248D sixpersian;06F6 sixroman;2175 sixsuperior;2076 sixteencircle;246F sixteencurrencydenominatorbengali;09F9 sixteenparen;2483 sixteenperiod;2497 sixthai;0E56 slash;002F slashmonospace;FF0F slong;017F slongdotaccent;1E9B smileface;263A smonospace;FF53 sofpasuqhebrew;05C3 softhyphen;00AD softsigncyrillic;044C sohiragana;305D sokatakana;30BD sokatakanahalfwidth;FF7F soliduslongoverlaycmb;0338 solidusshortoverlaycmb;0337 sorusithai;0E29 sosalathai;0E28 sosothai;0E0B sosuathai;0E2A space;0020 spacehackarabic;0020 spade;2660 spadesuitblack;2660 spadesuitwhite;2664 sparen;24AE squarebelowcmb;033B squarecc;33C4 squarecm;339D squarediagonalcrosshatchfill;25A9 squarehorizontalfill;25A4 squarekg;338F squarekm;339E squarekmcapital;33CE squareln;33D1 squarelog;33D2 squaremg;338E squaremil;33D5 squaremm;339C squaremsquared;33A1 squareorthogonalcrosshatchfill;25A6 squareupperlefttolowerrightfill;25A7 squareupperrighttolowerleftfill;25A8 squareverticalfill;25A5 squarewhitewithsmallblack;25A3 srsquare;33DB ssabengali;09B7 ssadeva;0937 ssagujarati;0AB7 ssangcieuckorean;3149 ssanghieuhkorean;3185 ssangieungkorean;3180 ssangkiyeokkorean;3132 ssangnieunkorean;3165 ssangpieupkorean;3143 ssangsioskorean;3146 ssangtikeutkorean;3138 ssuperior;F6F2 sterling;00A3 sterlingmonospace;FFE1 strokelongoverlaycmb;0336 strokeshortoverlaycmb;0335 subset;2282 subsetnotequal;228A subsetorequal;2286 succeeds;227B suchthat;220B suhiragana;3059 sukatakana;30B9 sukatakanahalfwidth;FF7D sukunarabic;0652 summation;2211 sun;263C superset;2283 supersetnotequal;228B supersetorequal;2287 svsquare;33DC syouwaerasquare;337C t;0074 tabengali;09A4 tackdown;22A4 tackleft;22A3 tadeva;0924 tagujarati;0AA4 tagurmukhi;0A24 taharabic;0637 tahfinalarabic;FEC2 tahinitialarabic;FEC3 tahiragana;305F tahmedialarabic;FEC4 taisyouerasquare;337D takatakana;30BF takatakanahalfwidth;FF80 tatweelarabic;0640 tau;03C4 tav;05EA tavdages;FB4A tavdagesh;FB4A tavdageshhebrew;FB4A tavhebrew;05EA tbar;0167 tbopomofo;310A tcaron;0165 tccurl;02A8 tcedilla;0163 tcheharabic;0686 tchehfinalarabic;FB7B tchehinitialarabic;FB7C tchehmedialarabic;FB7D tchehmeeminitialarabic;FB7C FEE4 tcircle;24E3 tcircumflexbelow;1E71 tcommaaccent;0163 tdieresis;1E97 tdotaccent;1E6B tdotbelow;1E6D tecyrillic;0442 tedescendercyrillic;04AD teharabic;062A tehfinalarabic;FE96 tehhahinitialarabic;FCA2 tehhahisolatedarabic;FC0C tehinitialarabic;FE97 tehiragana;3066 tehjeeminitialarabic;FCA1 tehjeemisolatedarabic;FC0B tehmarbutaarabic;0629 tehmarbutafinalarabic;FE94 tehmedialarabic;FE98 tehmeeminitialarabic;FCA4 tehmeemisolatedarabic;FC0E tehnoonfinalarabic;FC73 tekatakana;30C6 tekatakanahalfwidth;FF83 telephone;2121 telephoneblack;260E telishagedolahebrew;05A0 telishaqetanahebrew;05A9 tencircle;2469 tenideographicparen;3229 tenparen;247D tenperiod;2491 tenroman;2179 tesh;02A7 tet;05D8 tetdagesh;FB38 tetdageshhebrew;FB38 tethebrew;05D8 tetsecyrillic;04B5 tevirhebrew;059B tevirlefthebrew;059B thabengali;09A5 thadeva;0925 thagujarati;0AA5 thagurmukhi;0A25 thalarabic;0630 thalfinalarabic;FEAC thanthakhatlowleftthai;F898 thanthakhatlowrightthai;F897 thanthakhatthai;0E4C thanthakhatupperleftthai;F896 theharabic;062B thehfinalarabic;FE9A thehinitialarabic;FE9B thehmedialarabic;FE9C thereexists;2203 therefore;2234 theta;03B8 theta1;03D1 thetasymbolgreek;03D1 thieuthacirclekorean;3279 thieuthaparenkorean;3219 thieuthcirclekorean;326B thieuthkorean;314C thieuthparenkorean;320B thirteencircle;246C thirteenparen;2480 thirteenperiod;2494 thonangmonthothai;0E11 thook;01AD thophuthaothai;0E12 thorn;00FE thothahanthai;0E17 thothanthai;0E10 thothongthai;0E18 thothungthai;0E16 thousandcyrillic;0482 thousandsseparatorarabic;066C thousandsseparatorpersian;066C three;0033 threearabic;0663 threebengali;09E9 threecircle;2462 threecircleinversesansserif;278C threedeva;0969 threeeighths;215C threegujarati;0AE9 threegurmukhi;0A69 threehackarabic;0663 threehangzhou;3023 threeideographicparen;3222 threeinferior;2083 threemonospace;FF13 threenumeratorbengali;09F6 threeoldstyle;F733 threeparen;2476 threeperiod;248A threepersian;06F3 threequarters;00BE threequartersemdash;F6DE threeroman;2172 threesuperior;00B3 threethai;0E53 thzsquare;3394 tihiragana;3061 tikatakana;30C1 tikatakanahalfwidth;FF81 tikeutacirclekorean;3270 tikeutaparenkorean;3210 tikeutcirclekorean;3262 tikeutkorean;3137 tikeutparenkorean;3202 tilde;02DC tildebelowcmb;0330 tildecmb;0303 tildecomb;0303 tildedoublecmb;0360 tildeoperator;223C tildeoverlaycmb;0334 tildeverticalcmb;033E timescircle;2297 tipehahebrew;0596 tipehalefthebrew;0596 tippigurmukhi;0A70 titlocyrilliccmb;0483 tiwnarmenian;057F tlinebelow;1E6F tmonospace;FF54 toarmenian;0569 tohiragana;3068 tokatakana;30C8 tokatakanahalfwidth;FF84 tonebarextrahighmod;02E5 tonebarextralowmod;02E9 tonebarhighmod;02E6 tonebarlowmod;02E8 tonebarmidmod;02E7 tonefive;01BD tonesix;0185 tonetwo;01A8 tonos;0384 tonsquare;3327 topatakthai;0E0F tortoiseshellbracketleft;3014 tortoiseshellbracketleftsmall;FE5D tortoiseshellbracketleftvertical;FE39 tortoiseshellbracketright;3015 tortoiseshellbracketrightsmall;FE5E tortoiseshellbracketrightvertical;FE3A totaothai;0E15 tpalatalhook;01AB tparen;24AF trademark;2122 trademarksans;F8EA trademarkserif;F6DB tretroflexhook;0288 triagdn;25BC triaglf;25C4 triagrt;25BA triagup;25B2 ts;02A6 tsadi;05E6 tsadidagesh;FB46 tsadidageshhebrew;FB46 tsadihebrew;05E6 tsecyrillic;0446 tsere;05B5 tsere12;05B5 tsere1e;05B5 tsere2b;05B5 tserehebrew;05B5 tserenarrowhebrew;05B5 tserequarterhebrew;05B5 tserewidehebrew;05B5 tshecyrillic;045B tsuperior;F6F3 ttabengali;099F ttadeva;091F ttagujarati;0A9F ttagurmukhi;0A1F tteharabic;0679 ttehfinalarabic;FB67 ttehinitialarabic;FB68 ttehmedialarabic;FB69 tthabengali;09A0 tthadeva;0920 tthagujarati;0AA0 tthagurmukhi;0A20 tturned;0287 tuhiragana;3064 tukatakana;30C4 tukatakanahalfwidth;FF82 tusmallhiragana;3063 tusmallkatakana;30C3 tusmallkatakanahalfwidth;FF6F twelvecircle;246B twelveparen;247F twelveperiod;2493 twelveroman;217B twentycircle;2473 twentyhangzhou;5344 twentyparen;2487 twentyperiod;249B two;0032 twoarabic;0662 twobengali;09E8 twocircle;2461 twocircleinversesansserif;278B twodeva;0968 twodotenleader;2025 twodotleader;2025 twodotleadervertical;FE30 twogujarati;0AE8 twogurmukhi;0A68 twohackarabic;0662 twohangzhou;3022 twoideographicparen;3221 twoinferior;2082 twomonospace;FF12 twonumeratorbengali;09F5 twooldstyle;F732 twoparen;2475 twoperiod;2489 twopersian;06F2 tworoman;2171 twostroke;01BB twosuperior;00B2 twothai;0E52 twothirds;2154 u;0075 uacute;00FA ubar;0289 ubengali;0989 ubopomofo;3128 ubreve;016D ucaron;01D4 ucircle;24E4 ucircumflex;00FB ucircumflexbelow;1E77 ucyrillic;0443 udattadeva;0951 udblacute;0171 udblgrave;0215 udeva;0909 udieresis;00FC udieresisacute;01D8 udieresisbelow;1E73 udieresiscaron;01DA udieresiscyrillic;04F1 udieresisgrave;01DC udieresismacron;01D6 udotbelow;1EE5 ugrave;00F9 ugujarati;0A89 ugurmukhi;0A09 uhiragana;3046 uhookabove;1EE7 uhorn;01B0 uhornacute;1EE9 uhorndotbelow;1EF1 uhorngrave;1EEB uhornhookabove;1EED uhorntilde;1EEF uhungarumlaut;0171 uhungarumlautcyrillic;04F3 uinvertedbreve;0217 ukatakana;30A6 ukatakanahalfwidth;FF73 ukcyrillic;0479 ukorean;315C umacron;016B umacroncyrillic;04EF umacrondieresis;1E7B umatragurmukhi;0A41 umonospace;FF55 underscore;005F underscoredbl;2017 underscoremonospace;FF3F underscorevertical;FE33 underscorewavy;FE4F union;222A universal;2200 uogonek;0173 uparen;24B0 upblock;2580 upperdothebrew;05C4 upsilon;03C5 upsilondieresis;03CB upsilondieresistonos;03B0 upsilonlatin;028A upsilontonos;03CD uptackbelowcmb;031D uptackmod;02D4 uragurmukhi;0A73 uring;016F ushortcyrillic;045E usmallhiragana;3045 usmallkatakana;30A5 usmallkatakanahalfwidth;FF69 ustraightcyrillic;04AF ustraightstrokecyrillic;04B1 utilde;0169 utildeacute;1E79 utildebelow;1E75 uubengali;098A uudeva;090A uugujarati;0A8A uugurmukhi;0A0A uumatragurmukhi;0A42 uuvowelsignbengali;09C2 uuvowelsigndeva;0942 uuvowelsigngujarati;0AC2 uvowelsignbengali;09C1 uvowelsigndeva;0941 uvowelsigngujarati;0AC1 v;0076 vadeva;0935 vagujarati;0AB5 vagurmukhi;0A35 vakatakana;30F7 vav;05D5 vavdagesh;FB35 vavdagesh65;FB35 vavdageshhebrew;FB35 vavhebrew;05D5 vavholam;FB4B vavholamhebrew;FB4B vavvavhebrew;05F0 vavyodhebrew;05F1 vcircle;24E5 vdotbelow;1E7F vecyrillic;0432 veharabic;06A4 vehfinalarabic;FB6B vehinitialarabic;FB6C vehmedialarabic;FB6D vekatakana;30F9 venus;2640 verticalbar;007C verticallineabovecmb;030D verticallinebelowcmb;0329 verticallinelowmod;02CC verticallinemod;02C8 vewarmenian;057E vhook;028B vikatakana;30F8 viramabengali;09CD viramadeva;094D viramagujarati;0ACD visargabengali;0983 visargadeva;0903 visargagujarati;0A83 vmonospace;FF56 voarmenian;0578 voicediterationhiragana;309E voicediterationkatakana;30FE voicedmarkkana;309B voicedmarkkanahalfwidth;FF9E vokatakana;30FA vparen;24B1 vtilde;1E7D vturned;028C vuhiragana;3094 vukatakana;30F4 w;0077 wacute;1E83 waekorean;3159 wahiragana;308F wakatakana;30EF wakatakanahalfwidth;FF9C wakorean;3158 wasmallhiragana;308E wasmallkatakana;30EE wattosquare;3357 wavedash;301C wavyunderscorevertical;FE34 wawarabic;0648 wawfinalarabic;FEEE wawhamzaabovearabic;0624 wawhamzaabovefinalarabic;FE86 wbsquare;33DD wcircle;24E6 wcircumflex;0175 wdieresis;1E85 wdotaccent;1E87 wdotbelow;1E89 wehiragana;3091 weierstrass;2118 wekatakana;30F1 wekorean;315E weokorean;315D wgrave;1E81 whitebullet;25E6 whitecircle;25CB whitecircleinverse;25D9 whitecornerbracketleft;300E whitecornerbracketleftvertical;FE43 whitecornerbracketright;300F whitecornerbracketrightvertical;FE44 whitediamond;25C7 whitediamondcontainingblacksmalldiamond;25C8 whitedownpointingsmalltriangle;25BF whitedownpointingtriangle;25BD whiteleftpointingsmalltriangle;25C3 whiteleftpointingtriangle;25C1 whitelenticularbracketleft;3016 whitelenticularbracketright;3017 whiterightpointingsmalltriangle;25B9 whiterightpointingtriangle;25B7 whitesmallsquare;25AB whitesmilingface;263A whitesquare;25A1 whitestar;2606 whitetelephone;260F whitetortoiseshellbracketleft;3018 whitetortoiseshellbracketright;3019 whiteuppointingsmalltriangle;25B5 whiteuppointingtriangle;25B3 wihiragana;3090 wikatakana;30F0 wikorean;315F wmonospace;FF57 wohiragana;3092 wokatakana;30F2 wokatakanahalfwidth;FF66 won;20A9 wonmonospace;FFE6 wowaenthai;0E27 wparen;24B2 wring;1E98 wsuperior;02B7 wturned;028D wynn;01BF x;0078 xabovecmb;033D xbopomofo;3112 xcircle;24E7 xdieresis;1E8D xdotaccent;1E8B xeharmenian;056D xi;03BE xmonospace;FF58 xparen;24B3 xsuperior;02E3 y;0079 yaadosquare;334E yabengali;09AF yacute;00FD yadeva;092F yaekorean;3152 yagujarati;0AAF yagurmukhi;0A2F yahiragana;3084 yakatakana;30E4 yakatakanahalfwidth;FF94 yakorean;3151 yamakkanthai;0E4E yasmallhiragana;3083 yasmallkatakana;30E3 yasmallkatakanahalfwidth;FF6C yatcyrillic;0463 ycircle;24E8 ycircumflex;0177 ydieresis;00FF ydotaccent;1E8F ydotbelow;1EF5 yeharabic;064A yehbarreearabic;06D2 yehbarreefinalarabic;FBAF yehfinalarabic;FEF2 yehhamzaabovearabic;0626 yehhamzaabovefinalarabic;FE8A yehhamzaaboveinitialarabic;FE8B yehhamzaabovemedialarabic;FE8C yehinitialarabic;FEF3 yehmedialarabic;FEF4 yehmeeminitialarabic;FCDD yehmeemisolatedarabic;FC58 yehnoonfinalarabic;FC94 yehthreedotsbelowarabic;06D1 yekorean;3156 yen;00A5 yenmonospace;FFE5 yeokorean;3155 yeorinhieuhkorean;3186 yerahbenyomohebrew;05AA yerahbenyomolefthebrew;05AA yericyrillic;044B yerudieresiscyrillic;04F9 yesieungkorean;3181 yesieungpansioskorean;3183 yesieungsioskorean;3182 yetivhebrew;059A ygrave;1EF3 yhook;01B4 yhookabove;1EF7 yiarmenian;0575 yicyrillic;0457 yikorean;3162 yinyang;262F yiwnarmenian;0582 ymonospace;FF59 yod;05D9 yoddagesh;FB39 yoddageshhebrew;FB39 yodhebrew;05D9 yodyodhebrew;05F2 yodyodpatahhebrew;FB1F yohiragana;3088 yoikorean;3189 yokatakana;30E8 yokatakanahalfwidth;FF96 yokorean;315B yosmallhiragana;3087 yosmallkatakana;30E7 yosmallkatakanahalfwidth;FF6E yotgreek;03F3 yoyaekorean;3188 yoyakorean;3187 yoyakthai;0E22 yoyingthai;0E0D yparen;24B4 ypogegrammeni;037A ypogegrammenigreekcmb;0345 yr;01A6 yring;1E99 ysuperior;02B8 ytilde;1EF9 yturned;028E yuhiragana;3086 yuikorean;318C yukatakana;30E6 yukatakanahalfwidth;FF95 yukorean;3160 yusbigcyrillic;046B yusbigiotifiedcyrillic;046D yuslittlecyrillic;0467 yuslittleiotifiedcyrillic;0469 yusmallhiragana;3085 yusmallkatakana;30E5 yusmallkatakanahalfwidth;FF6D yuyekorean;318B yuyeokorean;318A yyabengali;09DF yyadeva;095F z;007A zaarmenian;0566 zacute;017A zadeva;095B zagurmukhi;0A5B zaharabic;0638 zahfinalarabic;FEC6 zahinitialarabic;FEC7 zahiragana;3056 zahmedialarabic;FEC8 zainarabic;0632 zainfinalarabic;FEB0 zakatakana;30B6 zaqefgadolhebrew;0595 zaqefqatanhebrew;0594 zarqahebrew;0598 zayin;05D6 zayindagesh;FB36 zayindageshhebrew;FB36 zayinhebrew;05D6 zbopomofo;3117 zcaron;017E zcircle;24E9 zcircumflex;1E91 zcurl;0291 zdot;017C zdotaccent;017C zdotbelow;1E93 zecyrillic;0437 zedescendercyrillic;0499 zedieresiscyrillic;04DF zehiragana;305C zekatakana;30BC zero;0030 zeroarabic;0660 zerobengali;09E6 zerodeva;0966 zerogujarati;0AE6 zerogurmukhi;0A66 zerohackarabic;0660 zeroinferior;2080 zeromonospace;FF10 zerooldstyle;F730 zeropersian;06F0 zerosuperior;2070 zerothai;0E50 zerowidthjoiner;FEFF zerowidthnonjoiner;200C zerowidthspace;200B zeta;03B6 zhbopomofo;3113 zhearmenian;056A zhebrevecyrillic;04C2 zhecyrillic;0436 zhedescendercyrillic;0497 zhedieresiscyrillic;04DD zihiragana;3058 zikatakana;30B8 zinorhebrew;05AE zlinebelow;1E95 zmonospace;FF5A zohiragana;305E zokatakana;30BE zparen;24B5 zretroflexhook;0290 zstroke;01B6 zuhiragana;305A zukatakana;30BA a100;275E a101;2761 a102;2762 a103;2763 a104;2764 a105;2710 a106;2765 a107;2766 a108;2767 a109;2660 a10;2721 a110;2665 a111;2666 a112;2663 a117;2709 a118;2708 a119;2707 a11;261B a120;2460 a121;2461 a122;2462 a123;2463 a124;2464 a125;2465 a126;2466 a127;2467 a128;2468 a129;2469 a12;261E a130;2776 a131;2777 a132;2778 a133;2779 a134;277A a135;277B a136;277C a137;277D a138;277E a139;277F a13;270C a140;2780 a141;2781 a142;2782 a143;2783 a144;2784 a145;2785 a146;2786 a147;2787 a148;2788 a149;2789 a14;270D a150;278A a151;278B a152;278C a153;278D a154;278E a155;278F a156;2790 a157;2791 a158;2792 a159;2793 a15;270E a160;2794 a161;2192 a162;27A3 a163;2194 a164;2195 a165;2799 a166;279B a167;279C a168;279D a169;279E a16;270F a170;279F a171;27A0 a172;27A1 a173;27A2 a174;27A4 a175;27A5 a176;27A6 a177;27A7 a178;27A8 a179;27A9 a17;2711 a180;27AB a181;27AD a182;27AF a183;27B2 a184;27B3 a185;27B5 a186;27B8 a187;27BA a188;27BB a189;27BC a18;2712 a190;27BD a191;27BE a192;279A a193;27AA a194;27B6 a195;27B9 a196;2798 a197;27B4 a198;27B7 a199;27AC a19;2713 a1;2701 a200;27AE a201;27B1 a202;2703 a203;2750 a204;2752 a205;276E a206;2770 a20;2714 a21;2715 a22;2716 a23;2717 a24;2718 a25;2719 a26;271A a27;271B a28;271C a29;2722 a2;2702 a30;2723 a31;2724 a32;2725 a33;2726 a34;2727 a35;2605 a36;2729 a37;272A a38;272B a39;272C a3;2704 a40;272D a41;272E a42;272F a43;2730 a44;2731 a45;2732 a46;2733 a47;2734 a48;2735 a49;2736 a4;260E a50;2737 a51;2738 a52;2739 a53;273A a54;273B a55;273C a56;273D a57;273E a58;273F a59;2740 a5;2706 a60;2741 a61;2742 a62;2743 a63;2744 a64;2745 a65;2746 a66;2747 a67;2748 a68;2749 a69;274A a6;271D a70;274B a71;25CF a72;274D a73;25A0 a74;274F a75;2751 a76;25B2 a77;25BC a78;25C6 a79;2756 a7;271E a81;25D7 a82;2758 a83;2759 a84;275A a85;276F a86;2771 a87;2772 a88;2773 a89;2768 a8;271F a90;2769 a91;276C a92;276D a93;276A a94;276B a95;2774 a96;2775 a97;275B a98;275C a99;275D a9;2720 """ # string table management # class StringTable: def __init__( self, name_list, master_table_name ): self.names = name_list self.master_table = master_table_name self.indices = {} index = 0 for name in name_list: self.indices[name] = index index += len( name ) + 1 self.total = index def dump( self, file ): write = file.write write( " static const char " + self.master_table + "[" + repr( self.total ) + "] =\n" ) write( " {\n" ) line = "" for name in self.names: line += " '" line += string.join( ( re.findall( ".", name ) ), "','" ) line += "', 0,\n" write( line + " };\n\n\n" ) def dump_sublist( self, file, table_name, macro_name, sublist ): write = file.write write( "#define " + macro_name + " " + repr( len( sublist ) ) + "\n\n" ) write( " /* Values are offsets into the `" + self.master_table + "' table */\n\n" ) write( " static const short " + table_name + "[" + macro_name + "] =\n" ) write( " {\n" ) line = " " comma = "" col = 0 for name in sublist: line += comma line += "%4d" % self.indices[name] col += 1 comma = "," if col == 14: col = 0 comma = ",\n " write( line + "\n };\n\n\n" ) # We now store the Adobe Glyph List in compressed form. The list is put # into a data structure called `trie' (because it has a tree-like # appearance). Consider, for example, that you want to store the # following name mapping: # # A => 1 # Aacute => 6 # Abalon => 2 # Abstract => 4 # # It is possible to store the entries as follows. # # A => 1 # | # +-acute => 6 # | # +-b # | # +-alon => 2 # | # +-stract => 4 # # We see that each node in the trie has: # # - one or more `letters' # - an optional value # - zero or more child nodes # # The first step is to call # # root = StringNode( "", 0 ) # for word in map.values(): # root.add( word, map[word] ) # # which creates a large trie where each node has only one children. # # Executing # # root = root.optimize() # # optimizes the trie by merging the letters of successive nodes whenever # possible. # # Each node of the trie is stored as follows. # # - First the node's letter, according to the following scheme. We # use the fact that in the AGL no name contains character codes > 127. # # name bitsize description # ---------------------------------------------------------------- # notlast 1 Set to 1 if this is not the last letter # in the word. # ascii 7 The letter's ASCII value. # # - The letter is followed by a children count and the value of the # current key (if any). Again we can do some optimization because all # AGL entries are from the BMP; this means that 16 bits are sufficient # to store its Unicode values. Additionally, no node has more than # 127 children. # # name bitsize description # ----------------------------------------- # hasvalue 1 Set to 1 if a 16-bit Unicode value follows. # num_children 7 Number of children. Can be 0 only if # `hasvalue' is set to 1. # value 16 Optional Unicode value. # # - A node is finished by a list of 16bit absolute offsets to the # children, which must be sorted in increasing order of their first # letter. # # For simplicity, all 16bit quantities are stored in big-endian order. # # The root node has first letter = 0, and no value. # class StringNode: def __init__( self, letter, value ): self.letter = letter self.value = value self.children = {} def __cmp__( self, other ): return ord( self.letter[0] ) - ord( other.letter[0] ) def add( self, word, value ): if len( word ) == 0: self.value = value return letter = word[0] word = word[1:] if self.children.has_key( letter ): child = self.children[letter] else: child = StringNode( letter, 0 ) self.children[letter] = child child.add( word, value ) def optimize( self ): # optimize all children first children = self.children.values() self.children = {} for child in children: self.children[child.letter[0]] = child.optimize() # don't optimize if there's a value, # if we don't have any child or if we # have more than one child if ( self.value != 0 ) or ( not children ) or len( children ) > 1: return self child = children[0] self.letter += child.letter self.value = child.value self.children = child.children return self def dump_debug( self, write, margin ): # this is used during debugging line = margin + "+-" if len( self.letter ) == 0: line += "<NOLETTER>" else: line += self.letter if self.value: line += " => " + repr( self.value ) write( line + "\n" ) if self.children: margin += "| " for child in self.children.values(): child.dump_debug( write, margin ) def locate( self, index ): self.index = index if len( self.letter ) > 0: index += len( self.letter ) + 1 else: index += 2 if self.value != 0: index += 2 children = self.children.values() children.sort() index += 2 * len( children ) for child in children: index = child.locate( index ) return index def store( self, storage ): # write the letters l = len( self.letter ) if l == 0: storage += struct.pack( "B", 0 ) else: for n in range( l ): val = ord( self.letter[n] ) if n < l - 1: val += 128 storage += struct.pack( "B", val ) # write the count children = self.children.values() children.sort() count = len( children ) if self.value != 0: storage += struct.pack( "!BH", count + 128, self.value ) else: storage += struct.pack( "B", count ) for child in children: storage += struct.pack( "!H", child.index ) for child in children: storage = child.store( storage ) return storage def adobe_glyph_values(): """return the list of glyph names and their unicode values""" lines = string.split( adobe_glyph_list, '\n' ) glyphs = [] values = [] for line in lines: if line: fields = string.split( line, ';' ) # print fields[1] + ' - ' + fields[0] subfields = string.split( fields[1], ' ' ) if len( subfields ) == 1: glyphs.append( fields[0] ) values.append( fields[1] ) return glyphs, values def filter_glyph_names( alist, filter ): """filter `alist' by taking _out_ all glyph names that are in `filter'""" count = 0 extras = [] for name in alist: try: filtered_index = filter.index( name ) except: extras.append( name ) return extras def dump_encoding( file, encoding_name, encoding_list ): """dump a given encoding""" write = file.write write( " /* the following are indices into the SID name table */\n" ) write( " static const unsigned short " + encoding_name + "[" + repr( len( encoding_list ) ) + "] =\n" ) write( " {\n" ) line = " " comma = "" col = 0 for value in encoding_list: line += comma line += "%3d" % value comma = "," col += 1 if col == 16: col = 0 comma = ",\n " write( line + "\n };\n\n\n" ) def dump_array( the_array, write, array_name ): """dumps a given encoding""" write( " static const unsigned char " + array_name + "[" + repr( len( the_array ) ) + "L] =\n" ) write( " {\n" ) line = "" comma = " " col = 0 for value in the_array: line += comma line += "%3d" % ord( value ) comma = "," col += 1 if col == 16: col = 0 comma = ",\n " if len( line ) > 1024: write( line ) line = "" write( line + "\n };\n\n\n" ) def main(): """main program body""" if len( sys.argv ) != 2: print __doc__ % sys.argv[0] sys.exit( 1 ) file = open( sys.argv[1], "w\n" ) write = file.write count_sid = len( sid_standard_names ) # `mac_extras' contains the list of glyph names in the Macintosh standard # encoding which are not in the SID Standard Names. # mac_extras = filter_glyph_names( mac_standard_names, sid_standard_names ) # `base_list' contains the names of our final glyph names table. # It consists of the `mac_extras' glyph names, followed by the SID # standard names. # mac_extras_count = len( mac_extras ) base_list = mac_extras + sid_standard_names write( "/***************************************************************************/\n" ) write( "/* */\n" ) write( "/* %-71s*/\n" % os.path.basename( sys.argv[1] ) ) write( "/* */\n" ) write( "/* PostScript glyph names. */\n" ) write( "/* */\n" ) write( "/* Copyright 2005, 2008, 2011 by */\n" ) write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" ) write( "/* */\n" ) write( "/* This file is part of the FreeType project, and may only be used, */\n" ) write( "/* modified, and distributed under the terms of the FreeType project */\n" ) write( "/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\n" ) write( "/* this file you indicate that you have read the license and */\n" ) write( "/* understand and accept it fully. */\n" ) write( "/* */\n" ) write( "/***************************************************************************/\n" ) write( "\n" ) write( "\n" ) write( " /* This file has been generated automatically -- do not edit! */\n" ) write( "\n" ) write( "\n" ) # dump final glyph list (mac extras + sid standard names) # st = StringTable( base_list, "ft_standard_glyph_names" ) st.dump( file ) st.dump_sublist( file, "ft_mac_names", "FT_NUM_MAC_NAMES", mac_standard_names ) st.dump_sublist( file, "ft_sid_names", "FT_NUM_SID_NAMES", sid_standard_names ) dump_encoding( file, "t1_standard_encoding", t1_standard_encoding ) dump_encoding( file, "t1_expert_encoding", t1_expert_encoding ) # dump the AGL in its compressed form # agl_glyphs, agl_values = adobe_glyph_values() dict = StringNode( "", 0 ) for g in range( len( agl_glyphs ) ): dict.add( agl_glyphs[g], eval( "0x" + agl_values[g] ) ) dict = dict.optimize() dict_len = dict.locate( 0 ) dict_array = dict.store( "" ) write( """\ /* * This table is a compressed version of the Adobe Glyph List (AGL), * optimized for efficient searching. It has been generated by the * `glnames.py' python script located in the `src/tools' directory. * * The lookup function to get the Unicode value for a given string * is defined below the table. */ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST """ ) dump_array( dict_array, write, "ft_adobe_glyph_list" ) # write the lookup routine now # write( """\ /* * This function searches the compressed table efficiently. */ static unsigned long ft_get_adobe_glyph_index( const char* name, const char* limit ) { int c = 0; int count, min, max; const unsigned char* p = ft_adobe_glyph_list; if ( name == 0 || name >= limit ) goto NotFound; c = *name++; count = p[1]; p += 2; min = 0; max = count; while ( min < max ) { int mid = ( min + max ) >> 1; const unsigned char* q = p + mid * 2; int c2; q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] ); c2 = q[0] & 127; if ( c2 == c ) { p = q; goto Found; } if ( c2 < c ) min = mid + 1; else max = mid; } goto NotFound; Found: for (;;) { /* assert (*p & 127) == c */ if ( name >= limit ) { if ( (p[0] & 128) == 0 && (p[1] & 128) != 0 ) return (unsigned long)( ( (int)p[2] << 8 ) | p[3] ); goto NotFound; } c = *name++; if ( p[0] & 128 ) { p++; if ( c != (p[0] & 127) ) goto NotFound; continue; } p++; count = p[0] & 127; if ( p[0] & 128 ) p += 2; p++; for ( ; count > 0; count--, p += 2 ) { int offset = ( (int)p[0] << 8 ) | p[1]; const unsigned char* q = ft_adobe_glyph_list + offset; if ( c == ( q[0] & 127 ) ) { p = q; goto NextIter; } } goto NotFound; NextIter: ; } NotFound: return 0; } #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ """ ) if 0: # generate unit test, or don't # # now write the unit test to check that everything works OK # write( "#ifdef TEST\n\n" ) write( "static const char* const the_names[] = {\n" ) for name in agl_glyphs: write( ' "' + name + '",\n' ) write( " 0\n};\n" ) write( "static const unsigned long the_values[] = {\n" ) for val in agl_values: write( ' 0x' + val + ',\n' ) write( " 0\n};\n" ) write( """ #include <stdlib.h> #include <stdio.h> int main( void ) { int result = 0; const char* const* names = the_names; const unsigned long* values = the_values; for ( ; *names; names++, values++ ) { const char* name = *names; unsigned long reference = *values; unsigned long value; value = ft_get_adobe_glyph_index( name, name + strlen( name ) ); if ( value != reference ) { result = 1; fprintf( stderr, "name '%s' => %04x instead of %04x\\n", name, value, reference ); } } return result; } """ ) write( "#endif /* TEST */\n" ) write("\n/* END */\n") # Now run the main routine # main() # END
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 199, 3, 199, 3, 2868, 804, 499, 14165, 536, 6545, 199, 3, 421, 199, 3, 1898, 31347, 13, 8269, 12, 13004, 12, 11811, 12, 10219, 12, 9079, 12, 7760, 701, 199, 3, 20232, 16147, 281, 12, 6848, 12504, 644, 382, 72, 21226, 12, 436, 644, 281, 1372, 7005, 976, 71, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 2868, 804, 2199, 12, 436, 1443, 1454, 506, 1202, 12, 6042, 12, 199, 3, 436, 1854, 1334, 314, 2895, 402, 314, 2868, 804, 2199, 4190, 12, 199, 3, 5113, 14, 17715, 14, 221, 4885, 32620, 370, 675, 12, 2811, 12, 503, 11207, 642, 570, 1265, 199, 3, 6623, 626, 1265, 1172, 1586, 314, 4190, 436, 20647, 436, 4729, 652, 199, 3, 9999, 14, 421, 199, 19659, 199, 199, 3807, 26, 450, 83, 665, 1199, 13, 493, 30, 819, 961, 2366, 2884, 12821, 314, 14165, 1561, 6716, 3247, 315, 314, 523, 658, 1190, 1247, 7, 859, 14, 819, 22940, 2849, 1423, 365, 314, 536, 402, 314, 1406, 570, 370, 506, 2737, 14, 199, 624, 421, 199, 646, 984, 12, 1059, 12, 2702, 12, 295, 12, 747, 14, 515, 421, 199, 3, 961, 1817, 5548, 314, 24222, 7182, 370, 314, 10444, 9924, 609, 8929, 14, 199, 3, 2779, 365, 1202, 701, 314, 715, 804, 7711, 1579, 1561, 1817, 14, 199, 3, 199, 3, 1666, 199, 3, 199, 3, 257, 1455, 921, 19864, 14, 12820, 14, 957, 15, 1481, 2891, 2395, 15, 11026, 1690, 15, 1049, 439, 22, 1932, 14, 1360, 199, 3, 199, 3, 367, 314, 25410, 769, 14, 199, 3, 199, 3088, 63, 6807, 63, 1247, 275, 971, 199, 59, 523, 327, 378, 523, 3680, 1397, 318, 401, 3680, 2307, 401, 298, 2865, 1657, 316, 1107, 401, 298, 2638, 401, 298, 2804, 17984, 401, 523, 298, 9888, 3345, 401, 298, 1955, 1037, 401, 298, 68, 25317, 401, 298, 7045, 401, 298, 5282, 1192, 460, 401, 819, 327, 1616, 523, 298, 14005, 2361, 401, 298, 9575, 3039, 401, 298, 9575, 1019, 401, 298, 305, 6236, 1339, 401, 298, 6666, 401, 523, 298, 13184, 401, 298, 30215, 401, 298, 5191, 401, 298, 7001, 401, 298, 4262, 401, 819, 327, 3388, 523, 298, 368, 401, 298, 5601, 401, 298, 10480, 401, 298, 13672, 401, 298, 23702, 401, 523, 298, 4174, 401, 298, 27346, 401, 298, 32579, 401, 298, 30126, 401, 298, 12167, 401, 819, 327, 4233, 523, 298, 19290, 12167, 401, 298, 2003, 401, 298, 1452, 401, 298, 13154, 401, 298, 4790, 401, 523, 298, 292, 401, 298, 33, 401, 298, 34, 401, 298, 35, 401, 298, 36, 401, 819, 327, 6335, 523, 298, 37, 401, 298, 38, 401, 298, 39, 401, 298, 40, 401, 298, 41, 401, 523, 298, 42, 401, 298, 43, 401, 298, 44, 401, 298, 45, 401, 298, 46, 401, 819, 327, 5238, 523, 298, 47, 401, 298, 48, 401, 298, 49, 401, 298, 50, 401, 298, 51, 401, 523, 298, 52, 401, 298, 53, 401, 298, 54, 401, 298, 55, 401, 298, 56, 401, 819, 327, 5212, 523, 298, 57, 401, 298, 58, 401, 298, 14594, 3039, 401, 298, 21509, 401, 298, 14594, 1019, 401, 523, 298, 305, 559, 530, 5958, 453, 401, 298, 21831, 401, 298, 19612, 401, 298, 65, 401, 298, 66, 401, 819, 327, 10045, 523, 298, 67, 401, 298, 68, 401, 298, 69, 401, 298, 70, 401, 298, 71, 401, 523, 298, 72, 401, 298, 73, 401, 298, 74, 401, 298, 75, 401, 298, 76, 401, 819, 327, 5939, 523, 298, 77, 401, 298, 78, 401, 298, 79, 401, 298, 80, 401, 298, 81, 401, 523, 298, 82, 401, 298, 83, 401, 298, 84, 401, 298, 85, 401, 298, 86, 401, 819, 327, 9137, 523, 298, 87, 401, 298, 88, 401, 298, 89, 401, 298, 90, 401, 298, 22359, 3039, 401, 523, 298, 1700, 401, 298, 7828, 2247, 1070, 401, 298, 4371, 16488, 401, 298, 33, 30956, 401, 298, 1596, 316, 401, 819, 327, 2948, 523, 298, 35, 27916, 416, 401, 298, 37, 14696, 401, 298, 46, 16488, 401, 298, 47, 30956, 401, 298, 53, 30956, 401, 523, 298, 65, 14696, 401, 298, 643, 345, 432, 401, 298, 65, 24235, 401, 298, 65, 30956, 401, 298, 2159, 76, 271, 401, 819, 327, 16814, 523, 298, 9332, 401, 298, 67, 27916, 416, 401, 298, 69, 14696, 401, 298, 69, 19612, 401, 298, 69, 24235, 401, 523, 298, 6297, 69, 22163, 401, 298, 73, 14696, 401, 298, 528, 345, 432, 401, 298, 530, 5958, 20977, 401, 298, 9897, 69, 22163, 401, 819, 327, 13960, 523, 298, 78, 16488, 401, 298, 79, 14696, 401, 298, 79, 19612, 401, 298, 3095, 1195, 20977, 401, 298, 79, 30956, 401, 523, 298, 79, 16488, 401, 298, 8243, 938, 401, 298, 85, 19612, 401, 298, 85, 24235, 401, 298, 14525, 69, 22163, 401, 819, 327, 21334, 523, 298, 7406, 836, 401, 298, 10956, 401, 298, 2946, 401, 298, 11652, 2983, 401, 298, 2792, 401, 523, 298, 20520, 401, 298, 12400, 401, 298, 836, 10333, 66, 478, 401, 298, 11616, 401, 298, 7307, 401, 819, 327, 22796, 523, 298, 21697, 1657, 401, 298, 14696, 401, 298, 30956, 401, 298, 4610, 537, 401, 298, 12500, 401, 523, 298, 47, 7001, 401, 298, 262, 9693, 401, 298, 6666, 13084, 401, 298, 2978, 261, 537, 401, 298, 71, 622, 264, 537, 401, 819, 327, 14711, 523, 298, 28695, 401, 298, 6553, 401, 298, 6672, 3028, 401, 298, 1838, 1615, 401, 298, 2558, 401, 523, 298, 1038, 401, 298, 24705, 401, 298, 2181, 771, 827, 1132, 401, 298, 2181, 5892, 3119, 1132, 401, 298, 47, 29073, 401, 819, 327, 21235, 523, 298, 3624, 401, 298, 736, 22376, 401, 298, 4790, 2110, 401, 298, 2804, 416, 1064, 944, 401, 298, 7954, 1397, 401, 523, 298, 12841, 915, 401, 298, 2327, 269, 262, 401, 298, 16815, 1452, 401, 298, 13411, 401, 298, 6051, 382, 3701, 357, 3039, 401, 819, 327, 27209, 523, 298, 6051, 382, 3701, 357, 1019, 401, 298, 16514, 2316, 401, 298, 2865, 4785, 780, 1142, 401, 298, 33, 19612, 401, 298, 33, 16488, 401, 523, 298, 47, 16488, 401, 298, 27588, 401, 298, 13361, 401, 298, 500, 1119, 401 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 199, 3, 199, 3, 2868, 804, 499, 14165, 536, 6545, 199, 3, 421, 199, 3, 1898, 31347, 13, 8269, 12, 13004, 12, 11811, 12, 10219, 12, 9079, 12, 7760, 701, 199, 3, 20232, 16147, 281, 12, 6848, 12504, 644, 382, 72, 21226, 12, 436, 644, 281, 1372, 7005, 976, 71, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 2868, 804, 2199, 12, 436, 1443, 1454, 506, 1202, 12, 6042, 12, 199, 3, 436, 1854, 1334, 314, 2895, 402, 314, 2868, 804, 2199, 4190, 12, 199, 3, 5113, 14, 17715, 14, 221, 4885, 32620, 370, 675, 12, 2811, 12, 503, 11207, 642, 570, 1265, 199, 3, 6623, 626, 1265, 1172, 1586, 314, 4190, 436, 20647, 436, 4729, 652, 199, 3, 9999, 14, 421, 199, 19659, 199, 199, 3807, 26, 450, 83, 665, 1199, 13, 493, 30, 819, 961, 2366, 2884, 12821, 314, 14165, 1561, 6716, 3247, 315, 314, 523, 658, 1190, 1247, 7, 859, 14, 819, 22940, 2849, 1423, 365, 314, 536, 402, 314, 1406, 570, 370, 506, 2737, 14, 199, 624, 421, 199, 646, 984, 12, 1059, 12, 2702, 12, 295, 12, 747, 14, 515, 421, 199, 3, 961, 1817, 5548, 314, 24222, 7182, 370, 314, 10444, 9924, 609, 8929, 14, 199, 3, 2779, 365, 1202, 701, 314, 715, 804, 7711, 1579, 1561, 1817, 14, 199, 3, 199, 3, 1666, 199, 3, 199, 3, 257, 1455, 921, 19864, 14, 12820, 14, 957, 15, 1481, 2891, 2395, 15, 11026, 1690, 15, 1049, 439, 22, 1932, 14, 1360, 199, 3, 199, 3, 367, 314, 25410, 769, 14, 199, 3, 199, 3088, 63, 6807, 63, 1247, 275, 971, 199, 59, 523, 327, 378, 523, 3680, 1397, 318, 401, 3680, 2307, 401, 298, 2865, 1657, 316, 1107, 401, 298, 2638, 401, 298, 2804, 17984, 401, 523, 298, 9888, 3345, 401, 298, 1955, 1037, 401, 298, 68, 25317, 401, 298, 7045, 401, 298, 5282, 1192, 460, 401, 819, 327, 1616, 523, 298, 14005, 2361, 401, 298, 9575, 3039, 401, 298, 9575, 1019, 401, 298, 305, 6236, 1339, 401, 298, 6666, 401, 523, 298, 13184, 401, 298, 30215, 401, 298, 5191, 401, 298, 7001, 401, 298, 4262, 401, 819, 327, 3388, 523, 298, 368, 401, 298, 5601, 401, 298, 10480, 401, 298, 13672, 401, 298, 23702, 401, 523, 298, 4174, 401, 298, 27346, 401, 298, 32579, 401, 298, 30126, 401, 298, 12167, 401, 819, 327, 4233, 523, 298, 19290, 12167, 401, 298, 2003, 401, 298, 1452, 401, 298, 13154, 401, 298, 4790, 401, 523, 298, 292, 401, 298, 33, 401, 298, 34, 401, 298, 35, 401, 298, 36, 401, 819, 327, 6335, 523, 298, 37, 401, 298, 38, 401, 298, 39, 401, 298, 40, 401, 298, 41, 401, 523, 298, 42, 401, 298, 43, 401, 298, 44, 401, 298, 45, 401, 298, 46, 401, 819, 327, 5238, 523, 298, 47, 401, 298, 48, 401, 298, 49, 401, 298, 50, 401, 298, 51, 401, 523, 298, 52, 401, 298, 53, 401, 298, 54, 401, 298, 55, 401, 298, 56, 401, 819, 327, 5212, 523, 298, 57, 401, 298, 58, 401, 298, 14594, 3039, 401, 298, 21509, 401, 298, 14594, 1019, 401, 523, 298, 305, 559, 530, 5958, 453, 401, 298, 21831, 401, 298, 19612, 401, 298, 65, 401, 298, 66, 401, 819, 327, 10045, 523, 298, 67, 401, 298, 68, 401, 298, 69, 401, 298, 70, 401, 298, 71, 401, 523, 298, 72, 401, 298, 73, 401, 298, 74, 401, 298, 75, 401, 298, 76, 401, 819, 327, 5939, 523, 298, 77, 401, 298, 78, 401, 298, 79, 401, 298, 80, 401, 298, 81, 401, 523, 298, 82, 401, 298, 83, 401, 298, 84, 401, 298, 85, 401, 298, 86, 401, 819, 327, 9137, 523, 298, 87, 401, 298, 88, 401, 298, 89, 401, 298, 90, 401, 298, 22359, 3039, 401, 523, 298, 1700, 401, 298, 7828, 2247, 1070, 401, 298, 4371, 16488, 401, 298, 33, 30956, 401, 298, 1596, 316, 401, 819, 327, 2948, 523, 298, 35, 27916, 416, 401, 298, 37, 14696, 401, 298, 46, 16488, 401, 298, 47, 30956, 401, 298, 53, 30956, 401, 523, 298, 65, 14696, 401, 298, 643, 345, 432, 401, 298, 65, 24235, 401, 298, 65, 30956, 401, 298, 2159, 76, 271, 401, 819, 327, 16814, 523, 298, 9332, 401, 298, 67, 27916, 416, 401, 298, 69, 14696, 401, 298, 69, 19612, 401, 298, 69, 24235, 401, 523, 298, 6297, 69, 22163, 401, 298, 73, 14696, 401, 298, 528, 345, 432, 401, 298, 530, 5958, 20977, 401, 298, 9897, 69, 22163, 401, 819, 327, 13960, 523, 298, 78, 16488, 401, 298, 79, 14696, 401, 298, 79, 19612, 401, 298, 3095, 1195, 20977, 401, 298, 79, 30956, 401, 523, 298, 79, 16488, 401, 298, 8243, 938, 401, 298, 85, 19612, 401, 298, 85, 24235, 401, 298, 14525, 69, 22163, 401, 819, 327, 21334, 523, 298, 7406, 836, 401, 298, 10956, 401, 298, 2946, 401, 298, 11652, 2983, 401, 298, 2792, 401, 523, 298, 20520, 401, 298, 12400, 401, 298, 836, 10333, 66, 478, 401, 298, 11616, 401, 298, 7307, 401, 819, 327, 22796, 523, 298, 21697, 1657, 401, 298, 14696, 401, 298, 30956, 401, 298, 4610, 537, 401, 298, 12500, 401, 523, 298, 47, 7001, 401, 298, 262, 9693, 401, 298, 6666, 13084, 401, 298, 2978, 261, 537, 401, 298, 71, 622, 264, 537, 401, 819, 327, 14711, 523, 298, 28695, 401, 298, 6553, 401, 298, 6672, 3028, 401, 298, 1838, 1615, 401, 298, 2558, 401, 523, 298, 1038, 401, 298, 24705, 401, 298, 2181, 771, 827, 1132, 401, 298, 2181, 5892, 3119, 1132, 401, 298, 47, 29073, 401, 819, 327, 21235, 523, 298, 3624, 401, 298, 736, 22376, 401, 298, 4790, 2110, 401, 298, 2804, 416, 1064, 944, 401, 298, 7954, 1397, 401, 523, 298, 12841, 915, 401, 298, 2327, 269, 262, 401, 298, 16815, 1452, 401, 298, 13411, 401, 298, 6051, 382, 3701, 357, 3039, 401, 819, 327, 27209, 523, 298, 6051, 382, 3701, 357, 1019, 401, 298, 16514, 2316, 401, 298, 2865, 4785, 780, 1142, 401, 298, 33, 19612, 401, 298, 33, 16488, 401, 523, 298, 47, 16488, 401, 298, 27588, 401, 298, 13361, 401, 298, 500, 1119, 401, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Lyleo/nupic
nupic/regions/ImageSensorExplorers/BaseExplorer.py
18
10420
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2013, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- import random class BaseExplorer(object): """ BaseExplorer is the base class for all ImageSensor explorers. An explorer is a plugin to ImageSensor that defines how the sensor moves through the "input space" of images, filtered images, and positions of the sensor "window" on the image. The basic job of the explorer is to take the current sensor position (image number, filtered version, (x,y) offset) and move to the next position. For example, the ExhaustiveSweep filter with default parameters shifts the offset one pixel to the right on each iteration, and then moves the offset down and back to the left side of the image when it falls off the edge of the bounding box. When it is done sweeping left-to-right, it sweeps top-to-bottom, and then moves on to the next image. The RandomSweep explorer works similarly, but after completely one sweep across the image, it randomly chooses a new image and a place to start the sweep. The Flash explorer is the simplest explorer; it just shows each image once and then moves to the next one. Explorers do a lot of ImageSensor's work. They maintain the sensor's position and increment it. They know how to seek to a certain image, iteration, and filtered version. They decide when to send a reset signal (end of a temporal sequence). Some of them can report how many iterations are necessary to explore all the inputs (though some cannot, like RandomSweep). All other ImageSensor explorers should subclass BaseExplorer and implement at least next(), and probably __init__(), first(), and seek() as well. Deterministic explorers that can calculate a total number of iterations should override the getNumIterations() method. """ def __init__(self, getOriginalImage, getFilteredImages, getImageInfo, seed=None, holdFor=1): """ getOriginalImage -- ImageSensor method to get an original image. getFilteredImages -- ImageSensor method to get filtered images. getImageInfo -- ImageSensor method to get imageInfo. seed -- Seed for the random number generator. A specific random number generator instance is always created for each explorer, so that they do not affect each other. holdFor -- how many iterations to hold each output image for. Default is 1. The sensor will take care of dealing with this - nothing special needs to be done by the explorer. """ self.getOriginalImage = getOriginalImage self.getFilteredImages = getFilteredImages self.getImageInfo = getImageInfo self.position = None self.holdFor = holdFor self.random = random.Random() if seed is not None: self.random.seed(seed) self.initialRandomState = self.random.getstate() def first(self, center=True): """ Set up the position. BaseExplorer picks image 0, offset (0,0), etc., but explorers that wish to set a different first position should extend this method. Such explorers may wish to call BaseExplorer.first(center=False), which initializes the position tuple but does not call centerImage() (which could cause unnecessary filtering to occur). """ self.position = { 'image': 0, 'filters': [0] * self.numFilters, 'offset': [0,0], 'reset': False } if self.numImages and center: self.centerImage() def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ pass def seek(self, iteration=None, position=None): """ Seek to the specified position or iteration. iteration -- Target iteration number (or None). position -- Target position (or None). ImageSensor checks validity of inputs, checks that one (but not both) of position and iteration are None, and checks that if position is not None, at least one of its values is not None. Updates value of position. """ if iteration is not None: self.restoreRandomState() self.first() if iteration > 0: for i in xrange(iteration-1): self.next(seeking=True) self.next() else: if position['image'] is not None: self.position['image'] = position['image'] if position['filters'] is not None: self.position['filters'] = position['filters'] if position['offset'] is not None: self.position['offset'] = position['offset'] if position['reset'] is not None: self.position['reset'] = position['reset'] def update(self, **kwargs): """ Update state with new parameters from ImageSensor and call first(). """ for key in kwargs: if kwargs[key] is not None: setattr(self, key, kwargs[key]) self.first() def getNumIterations(self, image): """ Get the number of iterations required to completely explore the input space. Explorers that do not wish to support this method should not override it. image -- If None, returns the sum of the iterations for all the loaded images. Otherwise, image should be an integer specifying the image for which to calculate iterations. ImageSensor takes care of the input validation. """ return -1 def restoreRandomState(self): """ Restore the initial random state of the explorer. """ self.random.setstate(self.initialRandomState) def isBlank(self, fallOffObject, position=None): """ Return True if the enabled region of the image specified by the current position is blank. fallOffObject -- If True, the image is considered blank only if the mask is entirely black. Otherwise, it is considered blank if any of mask is black. position -- Position to use. Uses current position if not specified. """ if not position: position = self.position x1, y1 = position['offset'] x2 = x1 + self.enabledWidth y2 = y1 + self.enabledHeight mask = self.getFilteredImages(position)[0].split()[1] extrema = mask.crop((max(x1, 0), max(y1, 0), min(x2, mask.size[0]), min(y2, mask.size[1]))).getextrema() if (fallOffObject and extrema[1] == 0) \ or (not fallOffObject and extrema[0] == 0): if not fallOffObject: # The non-fallOffObject case is tricky - devious masks can make it hang # Test 1: If the window contains the entire mask, it's not a blank bbox = mask.getbbox() if bbox[0] >= x1 and bbox[1] >= y1 and bbox[2] <= x2 and bbox[3] <= y2: return False # Need to add more tests return True else: return False def isValid(self, position=None): """ Return True if the current position and enabled size contains at least some of the region specified by the bounding box. position -- Position to use. Uses current position if not specified. """ if not position: position = self.position x, y = position['offset'] bbox = self.getFilteredImages(position)[0].split()[1].getbbox() if (bbox[0] - self.enabledWidth >= x) or \ (bbox[1] - self.enabledHeight >= y) or \ (bbox[2] + self.enabledWidth <= x) or \ (bbox[3] + self.enabledHeight <= y): return False return True def getAllFilteredVersionsOfImage(self, image=None): """ Get all the filtered versions of the image, as a flat list. Each item in the list is a list of images, containing an image for each simultaneous response. image -- Image index to use. Uses current position if not specified. """ if not image: image = self.position['image'] filteredImages = [] filterPosition = [0] * self.numFilters position = {'image': image, 'filters': filterPosition} while True: filteredImages.append(self.getFilteredImages(position)) for i in xrange(self.numFilters-1, -1, -1): filterPosition[i] += 1 if filterPosition[i] == self.numFilterOutputs[i]: filterPosition[i] = 0 else: break if filterPosition == [0] * self.numFilters: break return filteredImages def pickRandomImage(self, random): """ Pick a random image from a uniform distribution. random -- Instance of random.Random. """ return random.randint(0, self.numImages - 1) def pickRandomFilters(self, random): """ Pick a random position for each filter from uniform distributions. random -- Instance of random.Random. """ return [random.randint(0, self.numFilterOutputs[i] - 1) for i in xrange(self.numFilters)] def centerImage(self): """ Update the offset to center the current image. """ image = self.getFilteredImages()[0] self.position['offset'] = [(image.size[0] - self.enabledWidth) / 2, (image.size[1] - self.enabledHeight) / 2] def _getNumFilteredVersionsPerImage(self): """ Get the number of filtered versions for each original image. """ numFilteredVersions = 1 for i in xrange(self.numFilters): numFilteredVersions *= self.numFilterOutputs[i] return numFilteredVersions numFilteredVersionsPerImage = property(_getNumFilteredVersionsPerImage)
gpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 2196, 421, 199, 533, 3523, 4527, 22732, 8, 785, 304, 819, 408, 523, 3523, 4527, 22732, 365, 314, 1300, 1021, 367, 1006, 6047, 10160, 15868, 21105, 14, 1626, 15868, 3859, 365, 523, 282, 3589, 370, 6047, 10160, 626, 7890, 4212, 314, 8778, 14569, 4012, 314, 298, 1210, 523, 4601, 2, 402, 5935, 12, 9806, 5935, 12, 436, 12266, 402, 314, 8778, 298, 3806, 2, 641, 523, 314, 1834, 14, 819, 710, 5678, 3906, 402, 314, 15868, 3859, 365, 370, 5452, 314, 1453, 8778, 3421, 334, 1569, 523, 1329, 12, 9806, 1015, 12, 334, 88, 12, 89, 9, 3268, 9, 436, 4057, 370, 314, 2163, 3421, 14, 2104, 523, 2893, 12, 314, 1316, 2411, 833, 1912, 10941, 7840, 2457, 543, 849, 2633, 20863, 1086, 314, 523, 3268, 1373, 7148, 370, 314, 2451, 641, 1924, 8494, 12, 436, 2066, 14569, 314, 3268, 523, 3224, 436, 1771, 370, 314, 3602, 5366, 402, 314, 1834, 1380, 652, 26945, 2331, 314, 6275, 402, 314, 523, 16842, 5689, 14, 3979, 652, 365, 4224, 5584, 1024, 4073, 3602, 13, 475, 13, 1019, 12, 652, 5584, 1024, 1190, 523, 2746, 13, 475, 13, 8305, 12, 436, 2066, 14569, 641, 370, 314, 2163, 1834, 14, 710, 9571, 10941, 7840, 15868, 3859, 523, 5419, 8545, 590, 12, 1325, 2410, 14793, 1373, 5584, 7840, 9371, 314, 1834, 12, 652, 19311, 523, 2468, 32128, 282, 892, 1834, 436, 282, 4192, 370, 1343, 314, 5584, 7840, 14, 710, 11040, 1119, 15868, 3859, 365, 314, 523, 3486, 270, 15868, 3859, 27, 652, 2951, 13703, 1924, 1834, 5403, 436, 2066, 14569, 370, 314, 2163, 523, 1373, 14, 819, 7910, 320, 21105, 886, 282, 13918, 402, 6047, 10160, 1159, 1736, 14, 9322, 11075, 314, 8778, 1159, 3421, 523, 436, 11609, 652, 14, 9322, 5715, 4212, 370, 12005, 370, 282, 9842, 1834, 12, 8494, 12, 436, 523, 9806, 1015, 14, 9322, 19822, 1380, 370, 3222, 282, 5305, 4673, 334, 500, 402, 282, 16457, 279, 523, 3414, 680, 6601, 402, 3062, 883, 3622, 4212, 5002, 10615, 787, 5784, 370, 523, 15868, 264, 1006, 314, 4153, 334, 15401, 2005, 3913, 12, 2839, 9571, 10941, 7840, 680, 819, 2900, 1163, 6047, 10160, 15868, 21105, 1077, 5516, 3523, 4527, 22732, 436, 5669, 523, 737, 5210, 2163, 1062, 436, 8646, 636, 826, 29709, 1642, 1062, 436, 12005, 342, 465, 5521, 14, 523, 1487, 2704, 6937, 15868, 21105, 626, 883, 8671, 282, 3141, 1329, 402, 10615, 523, 1077, 4278, 314, 664, 5667, 26292, 342, 1083, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 664, 17286, 3491, 12, 664, 13079, 3014, 18882, 12, 664, 3491, 2354, 12, 2049, 6347, 29, 403, 12, 10266, 1858, 29, 17, 304, 272, 408, 272, 664, 17286, 3491, 1553, 6047, 10160, 1083, 370, 664, 376, 3379, 1834, 14, 272, 664, 13079, 3014, 18882, 1553, 6047, 10160, 1083, 370, 664, 9806, 5935, 14, 272, 664, 3491, 2354, 1553, 6047, 10160, 1083, 370, 664, 1834, 2354, 14, 272, 6347, 1553, 3240, 379, 367, 314, 2196, 1329, 4306, 14, 437, 2488, 2196, 1329, 489, 4306, 1256, 365, 3544, 2737, 367, 1924, 15868, 3859, 12, 880, 626, 2985, 886, 489, 440, 12787, 1924, 1163, 14, 272, 10266, 1858, 1553, 4212, 5002, 10615, 370, 10266, 1924, 1072, 1834, 367, 14, 3758, 365, 413, 14, 489, 710, 8778, 911, 5452, 10296, 402, 23654, 543, 642, 446, 6548, 4539, 4839, 370, 506, 489, 4224, 701, 314, 15868, 3859, 14, 272, 408, 339, 291, 14, 362, 17286, 3491, 275, 664, 17286, 3491, 272, 291, 14, 362, 13079, 3014, 18882, 275, 664, 13079, 3014, 18882, 272, 291, 14, 362, 3491, 2354, 275, 664, 3491, 2354, 272, 291, 14, 3124, 275, 488, 272, 291, 14, 12239, 1858, 275, 10266, 1858, 339, 291, 14, 2355, 275, 2196, 14, 3883, 342, 272, 340, 6347, 365, 440, 488, 26, 489, 291, 14, 2355, 14, 5176, 8, 5176, 9, 272, 291, 14, 2747, 15726, 275, 291, 14, 2355, 14, 16011, 342, 819, 347, 1642, 8, 277, 12, 8126, 29, 549, 304, 272, 408, 272, 2494, 1536, 314, 3421, 14, 339, 3523, 4527, 22732, 31055, 1834, 378, 12, 3268, 334, 16, 12, 16, 395, 5423, 2020, 1325, 15868, 21105, 626, 13809, 272, 370, 663, 282, 3365, 1642, 3421, 1077, 12247, 642, 1083, 14, 32753, 15868, 21105, 272, 1443, 13809, 370, 1240, 3523, 4527, 22732, 14, 2246, 8, 4218, 29, 797, 395, 1314, 2536, 6491, 314, 272, 3421, 2008, 1325, 1630, 440, 1240, 8126, 3491, 342, 334, 6777, 4293, 7675, 272, 23361, 14545, 370, 4781, 680, 272, 408, 339, 291, 14, 3124, 275, 469, 489, 283, 1569, 356, 378, 12, 489, 283, 4273, 356, 359, 16, 61, 627, 291, 14, 1507, 18053, 12, 489, 283, 2743, 356, 359, 16, 12, 16, 467, 489, 283, 3958, 356, 756, 272, 789, 272, 340, 291, 14, 1507, 18882, 436, 8126, 26, 489, 291, 14, 4218, 3491, 342, 819, 347, 2163, 8, 277, 12, 12005, 316, 29, 797, 304, 272, 408, 272, 3971, 370, 314, 2163, 3421, 334, 2184, 8494, 680, 339, 12005 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 2196, 421, 199, 533, 3523, 4527, 22732, 8, 785, 304, 819, 408, 523, 3523, 4527, 22732, 365, 314, 1300, 1021, 367, 1006, 6047, 10160, 15868, 21105, 14, 1626, 15868, 3859, 365, 523, 282, 3589, 370, 6047, 10160, 626, 7890, 4212, 314, 8778, 14569, 4012, 314, 298, 1210, 523, 4601, 2, 402, 5935, 12, 9806, 5935, 12, 436, 12266, 402, 314, 8778, 298, 3806, 2, 641, 523, 314, 1834, 14, 819, 710, 5678, 3906, 402, 314, 15868, 3859, 365, 370, 5452, 314, 1453, 8778, 3421, 334, 1569, 523, 1329, 12, 9806, 1015, 12, 334, 88, 12, 89, 9, 3268, 9, 436, 4057, 370, 314, 2163, 3421, 14, 2104, 523, 2893, 12, 314, 1316, 2411, 833, 1912, 10941, 7840, 2457, 543, 849, 2633, 20863, 1086, 314, 523, 3268, 1373, 7148, 370, 314, 2451, 641, 1924, 8494, 12, 436, 2066, 14569, 314, 3268, 523, 3224, 436, 1771, 370, 314, 3602, 5366, 402, 314, 1834, 1380, 652, 26945, 2331, 314, 6275, 402, 314, 523, 16842, 5689, 14, 3979, 652, 365, 4224, 5584, 1024, 4073, 3602, 13, 475, 13, 1019, 12, 652, 5584, 1024, 1190, 523, 2746, 13, 475, 13, 8305, 12, 436, 2066, 14569, 641, 370, 314, 2163, 1834, 14, 710, 9571, 10941, 7840, 15868, 3859, 523, 5419, 8545, 590, 12, 1325, 2410, 14793, 1373, 5584, 7840, 9371, 314, 1834, 12, 652, 19311, 523, 2468, 32128, 282, 892, 1834, 436, 282, 4192, 370, 1343, 314, 5584, 7840, 14, 710, 11040, 1119, 15868, 3859, 365, 314, 523, 3486, 270, 15868, 3859, 27, 652, 2951, 13703, 1924, 1834, 5403, 436, 2066, 14569, 370, 314, 2163, 523, 1373, 14, 819, 7910, 320, 21105, 886, 282, 13918, 402, 6047, 10160, 1159, 1736, 14, 9322, 11075, 314, 8778, 1159, 3421, 523, 436, 11609, 652, 14, 9322, 5715, 4212, 370, 12005, 370, 282, 9842, 1834, 12, 8494, 12, 436, 523, 9806, 1015, 14, 9322, 19822, 1380, 370, 3222, 282, 5305, 4673, 334, 500, 402, 282, 16457, 279, 523, 3414, 680, 6601, 402, 3062, 883, 3622, 4212, 5002, 10615, 787, 5784, 370, 523, 15868, 264, 1006, 314, 4153, 334, 15401, 2005, 3913, 12, 2839, 9571, 10941, 7840, 680, 819, 2900, 1163, 6047, 10160, 15868, 21105, 1077, 5516, 3523, 4527, 22732, 436, 5669, 523, 737, 5210, 2163, 1062, 436, 8646, 636, 826, 29709, 1642, 1062, 436, 12005, 342, 465, 5521, 14, 523, 1487, 2704, 6937, 15868, 21105, 626, 883, 8671, 282, 3141, 1329, 402, 10615, 523, 1077, 4278, 314, 664, 5667, 26292, 342, 1083, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 664, 17286, 3491, 12, 664, 13079, 3014, 18882, 12, 664, 3491, 2354, 12, 2049, 6347, 29, 403, 12, 10266, 1858, 29, 17, 304, 272, 408, 272, 664, 17286, 3491, 1553, 6047, 10160, 1083, 370, 664, 376, 3379, 1834, 14, 272, 664, 13079, 3014, 18882, 1553, 6047, 10160, 1083, 370, 664, 9806, 5935, 14, 272, 664, 3491, 2354, 1553, 6047, 10160, 1083, 370, 664, 1834, 2354, 14, 272, 6347, 1553, 3240, 379, 367, 314, 2196, 1329, 4306, 14, 437, 2488, 2196, 1329, 489, 4306, 1256, 365, 3544, 2737, 367, 1924, 15868, 3859, 12, 880, 626, 2985, 886, 489, 440, 12787, 1924, 1163, 14, 272, 10266, 1858, 1553, 4212, 5002, 10615, 370, 10266, 1924, 1072, 1834, 367, 14, 3758, 365, 413, 14, 489, 710, 8778, 911, 5452, 10296, 402, 23654, 543, 642, 446, 6548, 4539, 4839, 370, 506, 489, 4224, 701, 314, 15868, 3859, 14, 272, 408, 339, 291, 14, 362, 17286, 3491, 275, 664, 17286, 3491, 272, 291, 14, 362, 13079, 3014, 18882, 275, 664, 13079, 3014, 18882, 272, 291, 14, 362, 3491, 2354, 275, 664, 3491, 2354, 272, 291, 14, 3124, 275, 488, 272, 291, 14, 12239, 1858, 275, 10266, 1858, 339, 291, 14, 2355, 275, 2196, 14, 3883, 342, 272, 340, 6347, 365, 440, 488, 26, 489, 291, 14, 2355, 14, 5176, 8, 5176, 9, 272, 291, 14, 2747, 15726, 275, 291, 14, 2355, 14, 16011, 342, 819, 347, 1642, 8, 277, 12, 8126, 29, 549, 304, 272, 408, 272, 2494, 1536, 314, 3421, 14, 339, 3523, 4527, 22732, 31055, 1834, 378, 12, 3268, 334, 16, 12, 16, 395, 5423, 2020, 1325, 15868, 21105, 626, 13809, 272, 370, 663, 282, 3365, 1642, 3421, 1077, 12247, 642, 1083, 14, 32753, 15868, 21105, 272, 1443, 13809, 370, 1240, 3523, 4527, 22732, 14, 2246, 8, 4218, 29, 797, 395, 1314, 2536, 6491, 314, 272, 3421, 2008, 1325, 1630, 440, 1240, 8126, 3491, 342, 334, 6777, 4293, 7675, 272, 23361, 14545, 370, 4781, 680, 272, 408, 339, 291, 14, 3124, 275, 469, 489, 283, 1569, 356, 378, 12, 489, 283, 4273, 356, 359, 16, 61, 627, 291, 14, 1507, 18053, 12, 489, 283, 2743, 356, 359, 16, 12, 16, 467, 489, 283, 3958, 356, 756, 272, 789, 272, 340, 291, 14, 1507, 18882, 436, 8126, 26, 489, 291, 14, 4218, 3491, 342, 819, 347, 2163, 8, 277, 12, 12005, 316, 29, 797, 304, 272, 408, 272, 3971, 370, 314, 2163, 3421, 334, 2184, 8494, 680, 339, 12005, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jaharkes/home-assistant
homeassistant/components/sensor/rfxtrx.py
4
4743
""" Support for RFXtrx sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.rfxtrx/ """ import logging import voluptuous as vol import homeassistant.components.rfxtrx as rfxtrx import homeassistant.helpers.config_validation as cv from homeassistant.const import CONF_PLATFORM from homeassistant.helpers.entity import Entity from homeassistant.util import slugify from homeassistant.components.rfxtrx import ( ATTR_AUTOMATIC_ADD, ATTR_NAME, ATTR_FIREEVENT, CONF_DEVICES, ATTR_DATA_TYPE, DATA_TYPES, ATTR_ENTITY_ID) DEPENDENCIES = ['rfxtrx'] _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = vol.Schema({ vol.Required(CONF_PLATFORM): rfxtrx.DOMAIN, vol.Optional(CONF_DEVICES, default={}): vol.All(dict, rfxtrx.valid_sensor), vol.Optional(ATTR_AUTOMATIC_ADD, default=False): cv.boolean, }, extra=vol.ALLOW_EXTRA) def setup_platform(hass, config, add_devices_callback, discovery_info=None): """Setup the RFXtrx platform.""" from RFXtrx import SensorEvent sensors = [] for packet_id, entity_info in config[CONF_DEVICES].items(): event = rfxtrx.get_rfx_object(packet_id) device_id = "sensor_" + slugify(event.device.id_string.lower()) if device_id in rfxtrx.RFX_DEVICES: continue _LOGGER.info("Add %s rfxtrx.sensor", entity_info[ATTR_NAME]) sub_sensors = {} data_types = entity_info[ATTR_DATA_TYPE] if len(data_types) == 0: data_types = [''] for data_type in DATA_TYPES: if data_type in event.values: data_types = [data_type] break for _data_type in data_types: new_sensor = RfxtrxSensor(None, entity_info[ATTR_NAME], _data_type, entity_info[ATTR_FIREEVENT]) sensors.append(new_sensor) sub_sensors[_data_type] = new_sensor rfxtrx.RFX_DEVICES[device_id] = sub_sensors add_devices_callback(sensors) def sensor_update(event): """Callback for sensor updates from the RFXtrx gateway.""" if not isinstance(event, SensorEvent): return device_id = "sensor_" + slugify(event.device.id_string.lower()) if device_id in rfxtrx.RFX_DEVICES: sensors = rfxtrx.RFX_DEVICES[device_id] for key in sensors: sensor = sensors[key] sensor.event = event # Fire event if sensors[key].should_fire_event: sensor.hass.bus.fire( "signal_received", { ATTR_ENTITY_ID: sensors[key].entity_id, } ) return # Add entity if not exist and the automatic_add is True if not config[ATTR_AUTOMATIC_ADD]: return pkt_id = "".join("{0:02x}".format(x) for x in event.data) _LOGGER.info("Automatic add rfxtrx.sensor: %s", pkt_id) data_type = '' for _data_type in DATA_TYPES: if _data_type in event.values: data_type = _data_type break new_sensor = RfxtrxSensor(event, pkt_id, data_type) sub_sensors = {} sub_sensors[new_sensor.data_type] = new_sensor rfxtrx.RFX_DEVICES[device_id] = sub_sensors add_devices_callback([new_sensor]) if sensor_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS: rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(sensor_update) class RfxtrxSensor(Entity): """Representation of a RFXtrx sensor.""" def __init__(self, event, name, data_type, should_fire_event=False): """Initialize the sensor.""" self.event = event self._name = name self.should_fire_event = should_fire_event self.data_type = data_type self._unit_of_measurement = DATA_TYPES.get(data_type, '') def __str__(self): """Return the name of the sensor.""" return self._name @property def state(self): """Return the state of the sensor.""" if not self.event: return None return self.event.values.get(self.data_type) @property def name(self): """Get the name of the sensor.""" return self._name @property def device_state_attributes(self): """Return the state attributes.""" if not self.event: return None return self.event.values @property def unit_of_measurement(self): """Return the unit this state is expressed in.""" return self._unit_of_measurement
mit
[ 624, 199, 11532, 367, 820, 22322, 454, 88, 19678, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 3941, 400, 6872, 15, 199, 624, 199, 646, 2050, 199, 646, 30291, 465, 5236, 199, 199, 646, 8846, 14, 4608, 14, 3941, 400, 6872, 465, 17781, 400, 6872, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 1297, 492, 6392, 63, 17805, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 504, 8846, 14, 1974, 492, 29864, 199, 504, 8846, 14, 4608, 14, 3941, 400, 6872, 492, 334, 272, 10762, 63, 10774, 7474, 619, 948, 63, 9732, 12, 10762, 63, 2339, 12, 10762, 63, 1976, 5271, 4554, 12, 272, 6392, 63, 1093, 8670, 12, 10762, 63, 3998, 63, 2711, 12, 7126, 63, 7893, 12, 10762, 63, 13630, 63, 998, 9, 199, 199, 25743, 9415, 2563, 275, 788, 3941, 400, 6872, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 17805, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 17805, 304, 17781, 400, 6872, 14, 7378, 12, 272, 5236, 14, 7012, 8, 3103, 63, 1093, 8670, 12, 849, 16420, 5236, 14, 2422, 8, 807, 12, 17781, 400, 6872, 14, 1078, 63, 8956, 395, 272, 5236, 14, 7012, 8, 5280, 63, 10774, 7474, 619, 948, 63, 9732, 12, 849, 29, 797, 304, 221, 6277, 14, 4871, 12, 199, 1386, 2402, 29, 5650, 14, 12231, 63, 18555, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 63, 3058, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 820, 22322, 454, 88, 4298, 1041, 272, 687, 820, 22322, 454, 88, 492, 18474, 2390, 272, 19678, 275, 942, 272, 367, 3644, 63, 344, 12, 4642, 63, 815, 315, 1101, 59, 3103, 63, 1093, 8670, 1055, 1744, 837, 267, 1566, 275, 17781, 400, 6872, 14, 362, 63, 3941, 88, 63, 785, 8, 6253, 63, 344, 9, 267, 2243, 63, 344, 275, 298, 8956, 12172, 435, 29864, 8, 1430, 14, 1782, 14, 344, 63, 875, 14, 2325, 1012, 267, 340, 2243, 63, 344, 315, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 26, 288, 1980, 267, 485, 10186, 14, 815, 480, 1123, 450, 83, 17781, 400, 6872, 14, 8956, 401, 4642, 63, 815, 59, 5280, 63, 2339, 566, 398, 1007, 63, 22675, 275, 1052, 267, 666, 63, 1313, 275, 4642, 63, 815, 59, 5280, 63, 3998, 63, 2711, 61, 267, 340, 822, 8, 576, 63, 1313, 9, 508, 378, 26, 288, 666, 63, 1313, 275, 24506, 288, 367, 666, 63, 466, 315, 7126, 63, 7893, 26, 355, 340, 666, 63, 466, 315, 1566, 14, 1459, 26, 490, 666, 63, 1313, 275, 359, 576, 63, 466, 61, 490, 2059, 267, 367, 485, 576, 63, 466, 315, 666, 63, 1313, 26, 288, 892, 63, 8956, 275, 820, 70, 400, 6872, 10160, 8, 403, 12, 4642, 63, 815, 59, 5280, 63, 2339, 467, 4228, 485, 576, 63, 466, 12, 4642, 63, 815, 59, 5280, 63, 1976, 5271, 4554, 566, 288, 19678, 14, 740, 8, 1222, 63, 8956, 9, 288, 1007, 63, 22675, 13040, 576, 63, 466, 61, 275, 892, 63, 8956, 267, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 275, 1007, 63, 22675, 272, 1050, 63, 6410, 63, 3058, 8, 22675, 9, 339, 347, 8778, 63, 873, 8, 1430, 304, 267, 408, 2806, 367, 8778, 7029, 687, 314, 820, 22322, 454, 88, 10391, 1041, 267, 340, 440, 1228, 8, 1430, 12, 18474, 2390, 304, 288, 372, 398, 2243, 63, 344, 275, 298, 8956, 12172, 435, 29864, 8, 1430, 14, 1782, 14, 344, 63, 875, 14, 2325, 1012, 398, 340, 2243, 63, 344, 315, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 26, 288, 19678, 275, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 288, 367, 790, 315, 19678, 26, 355, 8778, 275, 19678, 59, 498, 61, 355, 8778, 14, 1430, 275, 1566, 355, 327, 15967, 1566, 355, 340, 19678, 59, 498, 1055, 5626, 63, 8935, 63, 1430, 26, 490, 8778, 14, 5387, 14, 5610, 14, 8935, 8, 717, 298, 4653, 63, 9226, 401, 469, 1169, 10762, 63, 13630, 63, 998, 26, 1816, 19678, 59, 498, 1055, 4502, 63, 344, 12, 717, 789, 490, 776, 288, 372, 398, 327, 2654, 4642, 340, 440, 2187, 436, 314, 4834, 63, 525, 365, 715, 267, 340, 440, 1101, 59, 5280, 63, 10774, 7474, 619, 948, 63, 9732, 2189, 288, 372, 398, 19927, 63, 344, 275, 10587, 904, 13076, 16, 26, 996, 88, 5469, 908, 8, 88, 9, 367, 671, 315, 1566, 14, 576, 9, 267, 485, 10186, 14, 815, 480, 3358, 3889, 1050, 17781, 400, 6872, 14, 8956, 26, 450, 83, 401, 2151, 19927, 63, 344, 9, 398, 666, 63, 466, 275, 2125, 267, 367, 485, 576, 63, 466, 315, 7126, 63, 7893, 26, 288, 340, 485, 576, 63, 466, 315, 1566, 14, 1459, 26, 355, 666, 63, 466, 275, 485, 576, 63, 466, 355, 2059, 267, 892, 63, 8956, 275, 820, 70, 400, 6872, 10160, 8, 1430, 12, 19927, 63, 344, 12, 666, 63, 466, 9, 267, 1007, 63, 22675, 275, 1052, 267, 1007, 63, 22675, 59, 1222, 63, 8956, 14, 576, 63, 466, 61, 275, 892, 63, 8956, 267, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 275, 1007, 63, 22675, 267, 1050, 63, 6410, 63, 3058, 779, 1222, 63, 8956, 566, 339, 340, 8778, 63, 873, 440, 315, 17781, 400, 6872, 14, 28467, 30487, 63, 12093, 63, 6348, 51, 27448, 3960, 26, 267, 17781, 400, 6872, 14, 28467, 30487, 63, 12093, 63, 6348, 51, 27448, 3960, 14, 740, 8, 8956, 63, 873, 9, 421, 199, 533, 820, 70, 400, 6872, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 820, 22322, 454, 88, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 1566, 12, 536, 12, 666, 63, 466, 12, 1077, 63, 8935, 63, 1430, 29, 797, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 14, 1430, 275, 1566 ]
[ 199, 11532, 367, 820, 22322, 454, 88, 19678, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 3941, 400, 6872, 15, 199, 624, 199, 646, 2050, 199, 646, 30291, 465, 5236, 199, 199, 646, 8846, 14, 4608, 14, 3941, 400, 6872, 465, 17781, 400, 6872, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 1297, 492, 6392, 63, 17805, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 504, 8846, 14, 1974, 492, 29864, 199, 504, 8846, 14, 4608, 14, 3941, 400, 6872, 492, 334, 272, 10762, 63, 10774, 7474, 619, 948, 63, 9732, 12, 10762, 63, 2339, 12, 10762, 63, 1976, 5271, 4554, 12, 272, 6392, 63, 1093, 8670, 12, 10762, 63, 3998, 63, 2711, 12, 7126, 63, 7893, 12, 10762, 63, 13630, 63, 998, 9, 199, 199, 25743, 9415, 2563, 275, 788, 3941, 400, 6872, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 17805, 63, 10926, 275, 5236, 14, 6700, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 17805, 304, 17781, 400, 6872, 14, 7378, 12, 272, 5236, 14, 7012, 8, 3103, 63, 1093, 8670, 12, 849, 16420, 5236, 14, 2422, 8, 807, 12, 17781, 400, 6872, 14, 1078, 63, 8956, 395, 272, 5236, 14, 7012, 8, 5280, 63, 10774, 7474, 619, 948, 63, 9732, 12, 849, 29, 797, 304, 221, 6277, 14, 4871, 12, 199, 1386, 2402, 29, 5650, 14, 12231, 63, 18555, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 63, 3058, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 820, 22322, 454, 88, 4298, 1041, 272, 687, 820, 22322, 454, 88, 492, 18474, 2390, 272, 19678, 275, 942, 272, 367, 3644, 63, 344, 12, 4642, 63, 815, 315, 1101, 59, 3103, 63, 1093, 8670, 1055, 1744, 837, 267, 1566, 275, 17781, 400, 6872, 14, 362, 63, 3941, 88, 63, 785, 8, 6253, 63, 344, 9, 267, 2243, 63, 344, 275, 298, 8956, 12172, 435, 29864, 8, 1430, 14, 1782, 14, 344, 63, 875, 14, 2325, 1012, 267, 340, 2243, 63, 344, 315, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 26, 288, 1980, 267, 485, 10186, 14, 815, 480, 1123, 450, 83, 17781, 400, 6872, 14, 8956, 401, 4642, 63, 815, 59, 5280, 63, 2339, 566, 398, 1007, 63, 22675, 275, 1052, 267, 666, 63, 1313, 275, 4642, 63, 815, 59, 5280, 63, 3998, 63, 2711, 61, 267, 340, 822, 8, 576, 63, 1313, 9, 508, 378, 26, 288, 666, 63, 1313, 275, 24506, 288, 367, 666, 63, 466, 315, 7126, 63, 7893, 26, 355, 340, 666, 63, 466, 315, 1566, 14, 1459, 26, 490, 666, 63, 1313, 275, 359, 576, 63, 466, 61, 490, 2059, 267, 367, 485, 576, 63, 466, 315, 666, 63, 1313, 26, 288, 892, 63, 8956, 275, 820, 70, 400, 6872, 10160, 8, 403, 12, 4642, 63, 815, 59, 5280, 63, 2339, 467, 4228, 485, 576, 63, 466, 12, 4642, 63, 815, 59, 5280, 63, 1976, 5271, 4554, 566, 288, 19678, 14, 740, 8, 1222, 63, 8956, 9, 288, 1007, 63, 22675, 13040, 576, 63, 466, 61, 275, 892, 63, 8956, 267, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 275, 1007, 63, 22675, 272, 1050, 63, 6410, 63, 3058, 8, 22675, 9, 339, 347, 8778, 63, 873, 8, 1430, 304, 267, 408, 2806, 367, 8778, 7029, 687, 314, 820, 22322, 454, 88, 10391, 1041, 267, 340, 440, 1228, 8, 1430, 12, 18474, 2390, 304, 288, 372, 398, 2243, 63, 344, 275, 298, 8956, 12172, 435, 29864, 8, 1430, 14, 1782, 14, 344, 63, 875, 14, 2325, 1012, 398, 340, 2243, 63, 344, 315, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 26, 288, 19678, 275, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 288, 367, 790, 315, 19678, 26, 355, 8778, 275, 19678, 59, 498, 61, 355, 8778, 14, 1430, 275, 1566, 355, 327, 15967, 1566, 355, 340, 19678, 59, 498, 1055, 5626, 63, 8935, 63, 1430, 26, 490, 8778, 14, 5387, 14, 5610, 14, 8935, 8, 717, 298, 4653, 63, 9226, 401, 469, 1169, 10762, 63, 13630, 63, 998, 26, 1816, 19678, 59, 498, 1055, 4502, 63, 344, 12, 717, 789, 490, 776, 288, 372, 398, 327, 2654, 4642, 340, 440, 2187, 436, 314, 4834, 63, 525, 365, 715, 267, 340, 440, 1101, 59, 5280, 63, 10774, 7474, 619, 948, 63, 9732, 2189, 288, 372, 398, 19927, 63, 344, 275, 10587, 904, 13076, 16, 26, 996, 88, 5469, 908, 8, 88, 9, 367, 671, 315, 1566, 14, 576, 9, 267, 485, 10186, 14, 815, 480, 3358, 3889, 1050, 17781, 400, 6872, 14, 8956, 26, 450, 83, 401, 2151, 19927, 63, 344, 9, 398, 666, 63, 466, 275, 2125, 267, 367, 485, 576, 63, 466, 315, 7126, 63, 7893, 26, 288, 340, 485, 576, 63, 466, 315, 1566, 14, 1459, 26, 355, 666, 63, 466, 275, 485, 576, 63, 466, 355, 2059, 267, 892, 63, 8956, 275, 820, 70, 400, 6872, 10160, 8, 1430, 12, 19927, 63, 344, 12, 666, 63, 466, 9, 267, 1007, 63, 22675, 275, 1052, 267, 1007, 63, 22675, 59, 1222, 63, 8956, 14, 576, 63, 466, 61, 275, 892, 63, 8956, 267, 17781, 400, 6872, 14, 11778, 56, 63, 1093, 8670, 59, 1782, 63, 344, 61, 275, 1007, 63, 22675, 267, 1050, 63, 6410, 63, 3058, 779, 1222, 63, 8956, 566, 339, 340, 8778, 63, 873, 440, 315, 17781, 400, 6872, 14, 28467, 30487, 63, 12093, 63, 6348, 51, 27448, 3960, 26, 267, 17781, 400, 6872, 14, 28467, 30487, 63, 12093, 63, 6348, 51, 27448, 3960, 14, 740, 8, 8956, 63, 873, 9, 421, 199, 533, 820, 70, 400, 6872, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 820, 22322, 454, 88, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 1566, 12, 536, 12, 666, 63, 466, 12, 1077, 63, 8935, 63, 1430, 29, 797, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 14, 1430, 275, 1566, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
quentinsf/ansible
test/units/plugins/cache/test_cache.py
98
3150
# (c) 2012-2015, Michael DeHaan <michael.dehaan@gmail.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/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.compat.tests import unittest from ansible.plugins.cache.base import BaseCacheModule from ansible.plugins.cache.memory import CacheModule as MemoryCache HAVE_MEMCACHED = True try: import memcached except ImportError: HAVE_MEMCACHED = False else: # Use an else so that the only reason we skip this is for lack of # memcached, not errors importing the plugin from ansible.plugins.cache.memcached import CacheModule as MemcachedCache HAVE_REDIS = True try: import redis except ImportError: HAVE_REDIS = False else: from ansible.plugins.cache.redis import CacheModule as RedisCache class TestAbstractClass(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_subclass_error(self): class CacheModule1(BaseCacheModule): pass with self.assertRaises(TypeError): CacheModule1() class CacheModule2(BaseCacheModule): def get(self, key): super(CacheModule2, self).get(key) with self.assertRaises(TypeError): CacheModule2() def test_subclass_success(self): class CacheModule3(BaseCacheModule): def get(self, key): super(CacheModule3, self).get(key) def set(self, key, value): super(CacheModule3, self).set(key, value) def keys(self): super(CacheModule3, self).keys() def contains(self, key): super(CacheModule3, self).contains(key) def delete(self, key): super(CacheModule3, self).delete(key) def flush(self): super(CacheModule3, self).flush() def copy(self): super(CacheModule3, self).copy() self.assertIsInstance(CacheModule3(), CacheModule3) @unittest.skipUnless(HAVE_MEMCACHED, 'python-memcached module not installed') def test_memcached_cachemodule(self): self.assertIsInstance(MemcachedCache(), MemcachedCache) def test_memory_cachemodule(self): self.assertIsInstance(MemoryCache(), MemoryCache) @unittest.skipUnless(HAVE_REDIS, 'Redis pyhton module not installed') def test_redis_cachemodule(self): self.assertIsInstance(RedisCache(), RedisCache)
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7806, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 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, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5265, 14, 1637, 14, 1095, 492, 3523, 4437, 2377, 199, 504, 3242, 14, 5265, 14, 1637, 14, 4844, 492, 11977, 2377, 465, 15825, 4437, 199, 199, 10767, 63, 10293, 3263, 22492, 275, 715, 199, 893, 26, 272, 492, 7573, 5245, 199, 2590, 3545, 26, 272, 25227, 63, 10293, 3263, 22492, 275, 756, 199, 2836, 26, 272, 327, 3645, 376, 587, 880, 626, 314, 1454, 4499, 781, 3372, 642, 365, 367, 29098, 402, 272, 327, 7573, 5245, 12, 440, 2552, 16306, 314, 3589, 272, 687, 3242, 14, 5265, 14, 1637, 14, 32567, 492, 11977, 2377, 465, 30465, 5245, 4437, 199, 199, 10767, 63, 907, 6178, 275, 715, 199, 893, 26, 272, 492, 16967, 199, 2590, 3545, 26, 272, 25227, 63, 907, 6178, 275, 756, 199, 2836, 26, 272, 687, 3242, 14, 5265, 14, 1637, 14, 15369, 492, 11977, 2377, 465, 25496, 4437, 421, 199, 533, 1379, 8458, 2543, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 6083, 63, 705, 8, 277, 304, 267, 1021, 11977, 2377, 17, 8, 1563, 4437, 2377, 304, 355, 986, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 11977, 2377, 17, 342, 398, 1021, 11977, 2377, 18, 8, 1563, 4437, 2377, 304, 288, 347, 664, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 18, 12, 291, 680, 362, 8, 498, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 11977, 2377, 18, 342, 339, 347, 511, 63, 6083, 63, 3742, 8, 277, 304, 267, 1021, 11977, 2377, 19, 8, 1563, 4437, 2377, 304, 288, 347, 664, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 362, 8, 498, 9, 953, 347, 663, 8, 277, 12, 790, 12, 574, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 409, 8, 498, 12, 574, 9, 953, 347, 2883, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1612, 342, 953, 347, 3509, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 6134, 8, 498, 9, 953, 347, 3145, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1807, 8, 498, 9, 953, 347, 8976, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 4939, 342, 953, 347, 1331, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1574, 342, 398, 291, 14, 6926, 8, 4437, 2377, 19, 1062, 11977, 2377, 19, 9, 339, 768, 2796, 14, 11278, 8, 10767, 63, 10293, 3263, 22492, 12, 283, 1548, 13, 32567, 859, 440, 4903, 358, 272, 347, 511, 63, 32567, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 14169, 5245, 4437, 1062, 30465, 5245, 4437, 9, 339, 347, 511, 63, 4844, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 8628, 4437, 1062, 15825, 4437, 9, 339, 768, 2796, 14, 11278, 8, 10767, 63, 907, 6178, 12, 283, 29605, 1134, 517, 265, 859, 440, 4903, 358, 272, 347, 511, 63, 15369, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 29605, 4437, 1062, 25496, 4437, 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 ]
[ 334, 67, 9, 6029, 13, 7806, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 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, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5265, 14, 1637, 14, 1095, 492, 3523, 4437, 2377, 199, 504, 3242, 14, 5265, 14, 1637, 14, 4844, 492, 11977, 2377, 465, 15825, 4437, 199, 199, 10767, 63, 10293, 3263, 22492, 275, 715, 199, 893, 26, 272, 492, 7573, 5245, 199, 2590, 3545, 26, 272, 25227, 63, 10293, 3263, 22492, 275, 756, 199, 2836, 26, 272, 327, 3645, 376, 587, 880, 626, 314, 1454, 4499, 781, 3372, 642, 365, 367, 29098, 402, 272, 327, 7573, 5245, 12, 440, 2552, 16306, 314, 3589, 272, 687, 3242, 14, 5265, 14, 1637, 14, 32567, 492, 11977, 2377, 465, 30465, 5245, 4437, 199, 199, 10767, 63, 907, 6178, 275, 715, 199, 893, 26, 272, 492, 16967, 199, 2590, 3545, 26, 272, 25227, 63, 907, 6178, 275, 756, 199, 2836, 26, 272, 687, 3242, 14, 5265, 14, 1637, 14, 15369, 492, 11977, 2377, 465, 25496, 4437, 421, 199, 533, 1379, 8458, 2543, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 6083, 63, 705, 8, 277, 304, 267, 1021, 11977, 2377, 17, 8, 1563, 4437, 2377, 304, 355, 986, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 11977, 2377, 17, 342, 398, 1021, 11977, 2377, 18, 8, 1563, 4437, 2377, 304, 288, 347, 664, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 18, 12, 291, 680, 362, 8, 498, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 11977, 2377, 18, 342, 339, 347, 511, 63, 6083, 63, 3742, 8, 277, 304, 267, 1021, 11977, 2377, 19, 8, 1563, 4437, 2377, 304, 288, 347, 664, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 362, 8, 498, 9, 953, 347, 663, 8, 277, 12, 790, 12, 574, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 409, 8, 498, 12, 574, 9, 953, 347, 2883, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1612, 342, 953, 347, 3509, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 6134, 8, 498, 9, 953, 347, 3145, 8, 277, 12, 790, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1807, 8, 498, 9, 953, 347, 8976, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 4939, 342, 953, 347, 1331, 8, 277, 304, 355, 1613, 8, 4437, 2377, 19, 12, 291, 680, 1574, 342, 398, 291, 14, 6926, 8, 4437, 2377, 19, 1062, 11977, 2377, 19, 9, 339, 768, 2796, 14, 11278, 8, 10767, 63, 10293, 3263, 22492, 12, 283, 1548, 13, 32567, 859, 440, 4903, 358, 272, 347, 511, 63, 32567, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 14169, 5245, 4437, 1062, 30465, 5245, 4437, 9, 339, 347, 511, 63, 4844, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 8628, 4437, 1062, 15825, 4437, 9, 339, 768, 2796, 14, 11278, 8, 10767, 63, 907, 6178, 12, 283, 29605, 1134, 517, 265, 859, 440, 4903, 358, 272, 347, 511, 63, 15369, 63, 1637, 578, 8, 277, 304, 267, 291, 14, 6926, 8, 29605, 4437, 1062, 25496, 4437, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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db helper commands and functions for Linux kernel debugging # # list tools # # Copyright (c) Thiebaud Weksteen, 2015 # # Authors: # Thiebaud Weksteen <thiebaud@weksteen.fr> # # This work is licensed under the terms of the GNU GPL version 2. # import gdb from linux import utils list_head = utils.CachedType("struct list_head") def list_check(head): nb = 0 if (head.type == list_head.get_type().pointer()): head = head.dereference() elif (head.type != list_head.get_type()): raise gdb.GdbError('argument must be of type (struct list_head [*])') c = head try: gdb.write("Starting with: {}\n".format(c)) except gdb.MemoryError: gdb.write('head is not accessible\n') return while True: p = c['prev'].dereference() n = c['next'].dereference() try: if p['next'] != c.address: gdb.write('prev.next != current: ' 'current@{current_addr}={current} ' 'prev@{p_addr}={p}\n'.format( current_addr=c.address, current=c, p_addr=p.address, p=p, )) return except gdb.MemoryError: gdb.write('prev is not accessible: ' 'current@{current_addr}={current}\n'.format( current_addr=c.address, current=c )) return try: if n['prev'] != c.address: gdb.write('next.prev != current: ' 'current@{current_addr}={current} ' 'next@{n_addr}={n}\n'.format( current_addr=c.address, current=c, n_addr=n.address, n=n, )) return except gdb.MemoryError: gdb.write('next is not accessible: ' 'current@{current_addr}={current}\n'.format( current_addr=c.address, current=c )) return c = n nb += 1 if c == head: gdb.write("list is consistent: {} node(s)\n".format(nb)) return class LxListChk(gdb.Command): """Verify a list consistency""" def __init__(self): super(LxListChk, self).__init__("lx-list-check", gdb.COMMAND_DATA, gdb.COMPLETE_EXPRESSION) def invoke(self, arg, from_tty): argv = gdb.string_to_argv(arg) if len(argv) != 1: raise gdb.GdbError("lx-list-check takes one argument") list_check(gdb.parse_and_eval(argv[0])) LxListChk()
gpl-2.0
[ 3, 199, 3, 12124, 5922, 3718, 436, 3423, 367, 10130, 5114, 10201, 199, 3, 199, 3, 221, 769, 7249, 199, 3, 199, 3, 1898, 334, 67, 9, 3868, 1873, 2470, 1181, 2136, 75, 1597, 287, 12, 6900, 199, 3, 199, 3, 6642, 26, 199, 3, 221, 3868, 1873, 2470, 1181, 2136, 75, 1597, 287, 665, 273, 1873, 2470, 1181, 32, 1129, 75, 1597, 287, 14, 4391, 30, 199, 3, 199, 3, 961, 1736, 365, 18233, 1334, 314, 2895, 402, 314, 1664, 14629, 1015, 499, 14, 199, 3, 199, 199, 646, 12124, 199, 199, 504, 18369, 492, 3778, 199, 199, 513, 63, 2993, 275, 3778, 14, 16138, 804, 480, 1820, 769, 63, 2993, 531, 421, 199, 318, 769, 63, 1074, 8, 2993, 304, 272, 8526, 275, 378, 272, 340, 334, 2993, 14, 466, 508, 769, 63, 2993, 14, 362, 63, 466, 1252, 3929, 5109, 267, 4854, 275, 4854, 14, 27915, 342, 272, 916, 334, 2993, 14, 466, 1137, 769, 63, 2993, 14, 362, 63, 466, 5109, 267, 746, 12124, 14, 39, 697, 547, 360, 2094, 1471, 506, 402, 730, 334, 1820, 769, 63, 2993, 359, 10, 566, 358, 272, 286, 275, 4854, 272, 862, 26, 267, 12124, 14, 952, 480, 14139, 543, 26, 22902, 78, 1674, 908, 8, 67, 430, 272, 871, 12124, 14, 8628, 547, 26, 267, 12124, 14, 952, 360, 2993, 365, 440, 17909, 60, 78, 358, 267, 372, 272, 1830, 715, 26, 267, 299, 275, 286, 459, 5701, 2278, 27915, 342, 267, 302, 275, 286, 459, 2184, 2278, 27915, 342, 267, 862, 26, 288, 340, 299, 459, 2184, 418, 1137, 286, 14, 1562, 26, 355, 12124, 14, 952, 360, 5701, 14, 2184, 1137, 1453, 26, 283, 2079, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 93, 283, 2079, 283, 5701, 32, 91, 80, 63, 2697, 93, 3126, 80, 4988, 78, 1370, 908, 8, 2892, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2892, 1453, 29, 67, 12, 2892, 299, 63, 2697, 29, 80, 14, 1562, 12, 2892, 299, 29, 80, 12, 2079, 5082, 355, 372, 267, 871, 12124, 14, 8628, 547, 26, 288, 12124, 14, 952, 360, 5701, 365, 440, 17909, 26, 283, 1993, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 4988, 78, 1370, 908, 8, 2079, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2079, 1453, 29, 67, 1993, 5082, 288, 372, 267, 862, 26, 288, 340, 302, 459, 5701, 418, 1137, 286, 14, 1562, 26, 355, 12124, 14, 952, 360, 2184, 14, 5701, 1137, 1453, 26, 283, 2079, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 93, 283, 2079, 283, 2184, 32, 91, 78, 63, 2697, 93, 3126, 78, 4988, 78, 1370, 908, 8, 2892, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2892, 1453, 29, 67, 12, 2892, 302, 63, 2697, 29, 78, 14, 1562, 12, 2892, 302, 29, 78, 12, 2079, 5082, 355, 372, 267, 871, 12124, 14, 8628, 547, 26, 288, 12124, 14, 952, 360, 2184, 365, 440, 17909, 26, 283, 1993, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 4988, 78, 1370, 908, 8, 2079, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2079, 1453, 29, 67, 1993, 5082, 288, 372, 267, 286, 275, 302, 267, 8526, 847, 413, 267, 340, 286, 508, 4854, 26, 288, 12124, 14, 952, 480, 513, 365, 12137, 26, 1052, 1031, 8, 83, 2862, 78, 1674, 908, 8, 4994, 430, 288, 372, 421, 199, 533, 491, 88, 1296, 1049, 75, 8, 17119, 14, 3110, 304, 272, 408, 7496, 282, 769, 17754, 624, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 44, 88, 1296, 1049, 75, 12, 291, 2843, 826, 29093, 23605, 13, 513, 13, 1074, 401, 12124, 14, 10761, 63, 3998, 12, 3147, 12124, 14, 15558, 63, 1438, 5786, 1075, 9, 339, 347, 12677, 8, 277, 12, 1680, 12, 687, 63, 4707, 304, 267, 9238, 275, 12124, 14, 875, 63, 475, 63, 3020, 8, 1273, 9, 267, 340, 822, 8, 3020, 9, 1137, 413, 26, 288, 746, 12124, 14, 39, 697, 547, 480, 23605, 13, 513, 13, 1074, 6181, 1373, 1423, 531, 267, 769, 63, 1074, 8, 17119, 14, 1122, 63, 460, 63, 2579, 8, 3020, 59, 16, 2459, 199, 199, 44, 88, 1296, 1049, 75, 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 ]
[ 199, 3, 12124, 5922, 3718, 436, 3423, 367, 10130, 5114, 10201, 199, 3, 199, 3, 221, 769, 7249, 199, 3, 199, 3, 1898, 334, 67, 9, 3868, 1873, 2470, 1181, 2136, 75, 1597, 287, 12, 6900, 199, 3, 199, 3, 6642, 26, 199, 3, 221, 3868, 1873, 2470, 1181, 2136, 75, 1597, 287, 665, 273, 1873, 2470, 1181, 32, 1129, 75, 1597, 287, 14, 4391, 30, 199, 3, 199, 3, 961, 1736, 365, 18233, 1334, 314, 2895, 402, 314, 1664, 14629, 1015, 499, 14, 199, 3, 199, 199, 646, 12124, 199, 199, 504, 18369, 492, 3778, 199, 199, 513, 63, 2993, 275, 3778, 14, 16138, 804, 480, 1820, 769, 63, 2993, 531, 421, 199, 318, 769, 63, 1074, 8, 2993, 304, 272, 8526, 275, 378, 272, 340, 334, 2993, 14, 466, 508, 769, 63, 2993, 14, 362, 63, 466, 1252, 3929, 5109, 267, 4854, 275, 4854, 14, 27915, 342, 272, 916, 334, 2993, 14, 466, 1137, 769, 63, 2993, 14, 362, 63, 466, 5109, 267, 746, 12124, 14, 39, 697, 547, 360, 2094, 1471, 506, 402, 730, 334, 1820, 769, 63, 2993, 359, 10, 566, 358, 272, 286, 275, 4854, 272, 862, 26, 267, 12124, 14, 952, 480, 14139, 543, 26, 22902, 78, 1674, 908, 8, 67, 430, 272, 871, 12124, 14, 8628, 547, 26, 267, 12124, 14, 952, 360, 2993, 365, 440, 17909, 60, 78, 358, 267, 372, 272, 1830, 715, 26, 267, 299, 275, 286, 459, 5701, 2278, 27915, 342, 267, 302, 275, 286, 459, 2184, 2278, 27915, 342, 267, 862, 26, 288, 340, 299, 459, 2184, 418, 1137, 286, 14, 1562, 26, 355, 12124, 14, 952, 360, 5701, 14, 2184, 1137, 1453, 26, 283, 2079, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 93, 283, 2079, 283, 5701, 32, 91, 80, 63, 2697, 93, 3126, 80, 4988, 78, 1370, 908, 8, 2892, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2892, 1453, 29, 67, 12, 2892, 299, 63, 2697, 29, 80, 14, 1562, 12, 2892, 299, 29, 80, 12, 2079, 5082, 355, 372, 267, 871, 12124, 14, 8628, 547, 26, 288, 12124, 14, 952, 360, 5701, 365, 440, 17909, 26, 283, 1993, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 4988, 78, 1370, 908, 8, 2079, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2079, 1453, 29, 67, 1993, 5082, 288, 372, 267, 862, 26, 288, 340, 302, 459, 5701, 418, 1137, 286, 14, 1562, 26, 355, 12124, 14, 952, 360, 2184, 14, 5701, 1137, 1453, 26, 283, 2079, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 93, 283, 2079, 283, 2184, 32, 91, 78, 63, 2697, 93, 3126, 78, 4988, 78, 1370, 908, 8, 2892, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2892, 1453, 29, 67, 12, 2892, 302, 63, 2697, 29, 78, 14, 1562, 12, 2892, 302, 29, 78, 12, 2079, 5082, 355, 372, 267, 871, 12124, 14, 8628, 547, 26, 288, 12124, 14, 952, 360, 2184, 365, 440, 17909, 26, 283, 1993, 283, 1818, 32, 91, 1818, 63, 2697, 93, 3126, 1818, 4988, 78, 1370, 908, 8, 2079, 1453, 63, 2697, 29, 67, 14, 1562, 12, 2079, 1453, 29, 67, 1993, 5082, 288, 372, 267, 286, 275, 302, 267, 8526, 847, 413, 267, 340, 286, 508, 4854, 26, 288, 12124, 14, 952, 480, 513, 365, 12137, 26, 1052, 1031, 8, 83, 2862, 78, 1674, 908, 8, 4994, 430, 288, 372, 421, 199, 533, 491, 88, 1296, 1049, 75, 8, 17119, 14, 3110, 304, 272, 408, 7496, 282, 769, 17754, 624, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 44, 88, 1296, 1049, 75, 12, 291, 2843, 826, 29093, 23605, 13, 513, 13, 1074, 401, 12124, 14, 10761, 63, 3998, 12, 3147, 12124, 14, 15558, 63, 1438, 5786, 1075, 9, 339, 347, 12677, 8, 277, 12, 1680, 12, 687, 63, 4707, 304, 267, 9238, 275, 12124, 14, 875, 63, 475, 63, 3020, 8, 1273, 9, 267, 340, 822, 8, 3020, 9, 1137, 413, 26, 288, 746, 12124, 14, 39, 697, 547, 480, 23605, 13, 513, 13, 1074, 6181, 1373, 1423, 531, 267, 769, 63, 1074, 8, 17119, 14, 1122, 63, 460, 63, 2579, 8, 3020, 59, 16, 2459, 199, 199, 44, 88, 1296, 1049, 75, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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iko is free software; you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation; either version 2.1 of the License, or (at your option) # any later version. # # Paramiko 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 Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. """ Some unit tests for SSHClient. """ from __future__ import with_statement import socket from tempfile import mkstemp import threading import unittest import weakref import warnings import os import time from tests.util import test_path import paramiko from paramiko.common import PY2, b from paramiko.ssh_exception import SSHException FINGERPRINTS = { 'ssh-dss': b'\x44\x78\xf0\xb9\xa2\x3c\xc5\x18\x20\x09\xff\x75\x5b\xc1\xd2\x6c', 'ssh-rsa': b'\x60\x73\x38\x44\xcb\x51\x86\x65\x7f\xde\xda\xa2\x2b\x5a\x57\xd5', 'ecdsa-sha2-nistp256': b'\x25\x19\xeb\x55\xe6\xa1\x47\xff\x4f\x38\xd2\x75\x6f\xa5\xd5\x60', } class NullServer (paramiko.ServerInterface): def __init__(self, *args, **kwargs): # Allow tests to enable/disable specific key types self.__allowed_keys = kwargs.pop('allowed_keys', []) super(NullServer, self).__init__(*args, **kwargs) def get_allowed_auths(self, username): if username == 'slowdive': return 'publickey,password' return 'publickey' def check_auth_password(self, username, password): if (username == 'slowdive') and (password == 'pygmalion'): return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_FAILED def check_auth_publickey(self, username, key): try: expected = FINGERPRINTS[key.get_name()] except KeyError: return paramiko.AUTH_FAILED if ( key.get_name() in self.__allowed_keys and key.get_fingerprint() == expected ): return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_FAILED def check_channel_request(self, kind, chanid): return paramiko.OPEN_SUCCEEDED def check_channel_exec_request(self, channel, command): if command != 'yes': return False return True class SSHClientTest (unittest.TestCase): def setUp(self): self.sockl = socket.socket() self.sockl.bind(('localhost', 0)) self.sockl.listen(1) self.addr, self.port = self.sockl.getsockname() self.event = threading.Event() def tearDown(self): for attr in "tc ts socks sockl".split(): if hasattr(self, attr): getattr(self, attr).close() def _run(self, allowed_keys=None, delay=0): if allowed_keys is None: allowed_keys = FINGERPRINTS.keys() self.socks, addr = self.sockl.accept() self.ts = paramiko.Transport(self.socks) host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) self.ts.add_server_key(host_key) server = NullServer(allowed_keys=allowed_keys) if delay: time.sleep(delay) self.ts.start_server(self.event, server) def _test_connection(self, **kwargs): """ (Most) kwargs get passed directly into SSHClient.connect(). The exception is ``allowed_keys`` which is stripped and handed to the ``NullServer`` used for testing. """ run_kwargs = {'allowed_keys': kwargs.pop('allowed_keys', None)} # Server setup threading.Thread(target=self._run, kwargs=run_kwargs).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) # Client setup self.tc = paramiko.SSHClient() self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key) # Actual connection self.tc.connect(self.addr, self.port, username='slowdive', **kwargs) # Authentication successful? self.event.wait(1.0) self.assertTrue(self.event.is_set()) self.assertTrue(self.ts.is_active()) self.assertEqual('slowdive', self.ts.get_username()) self.assertEqual(True, self.ts.is_authenticated()) # Command execution functions? stdin, stdout, stderr = self.tc.exec_command('yes') schan = self.ts.accept(1.0) schan.send('Hello there.\n') schan.send_stderr('This is on stderr.\n') schan.close() self.assertEqual('Hello there.\n', stdout.readline()) self.assertEqual('', stdout.readline()) self.assertEqual('This is on stderr.\n', stderr.readline()) self.assertEqual('', stderr.readline()) # Cleanup stdin.close() stdout.close() stderr.close() def test_1_client(self): """ verify that the SSHClient stuff works too. """ self._test_connection(password='pygmalion') def test_2_client_dsa(self): """ verify that SSHClient works with a DSA key. """ self._test_connection(key_filename=test_path('test_dss.key')) def test_client_rsa(self): """ verify that SSHClient works with an RSA key. """ self._test_connection(key_filename=test_path('test_rsa.key')) def test_2_5_client_ecdsa(self): """ verify that SSHClient works with an ECDSA key. """ self._test_connection(key_filename=test_path('test_ecdsa.key')) def test_3_multiple_key_files(self): """ verify that SSHClient accepts and tries multiple key files. """ # This is dumb :( types_ = { 'rsa': 'ssh-rsa', 'dss': 'ssh-dss', 'ecdsa': 'ecdsa-sha2-nistp256', } # Various combos of attempted & valid keys # TODO: try every possible combo using itertools functions for attempt, accept in ( (['rsa', 'dss'], ['dss']), # Original test #3 (['dss', 'rsa'], ['dss']), # Ordering matters sometimes, sadly (['dss', 'rsa', 'ecdsa'], ['dss']), # Try ECDSA but fail (['rsa', 'ecdsa'], ['ecdsa']), # ECDSA success ): self._test_connection( key_filename=[ test_path('test_{0}.key'.format(x)) for x in attempt ], allowed_keys=[types_[x] for x in accept], ) def test_multiple_key_files_failure(self): """ Expect failure when multiple keys in play and none are accepted """ # Until #387 is fixed we have to catch a high-up exception since # various platforms trigger different errors here >_< self.assertRaises(SSHException, self._test_connection, key_filename=[test_path('test_rsa.key')], allowed_keys=['ecdsa-sha2-nistp256'], ) def test_4_auto_add_policy(self): """ verify that SSHClient's AutoAddPolicy works. """ threading.Thread(target=self._run).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) self.tc = paramiko.SSHClient() self.tc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.assertEqual(0, len(self.tc.get_host_keys())) self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion') self.event.wait(1.0) self.assertTrue(self.event.is_set()) self.assertTrue(self.ts.is_active()) self.assertEqual('slowdive', self.ts.get_username()) self.assertEqual(True, self.ts.is_authenticated()) self.assertEqual(1, len(self.tc.get_host_keys())) self.assertEqual(public_host_key, self.tc.get_host_keys()['[%s]:%d' % (self.addr, self.port)]['ssh-rsa']) def test_5_save_host_keys(self): """ verify that SSHClient correctly saves a known_hosts file. """ warnings.filterwarnings('ignore', 'tempnam.*') host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) fd, localname = mkstemp() os.close(fd) client = paramiko.SSHClient() self.assertEquals(0, len(client.get_host_keys())) host_id = '[%s]:%d' % (self.addr, self.port) client.get_host_keys().add(host_id, 'ssh-rsa', public_host_key) self.assertEquals(1, len(client.get_host_keys())) self.assertEquals(public_host_key, client.get_host_keys()[host_id]['ssh-rsa']) client.save_host_keys(localname) with open(localname) as fd: assert host_id in fd.read() os.unlink(localname) def test_6_cleanup(self): """ verify that when an SSHClient is collected, its transport (and the transport's packetizer) is closed. """ # Unclear why this is borked on Py3, but it is, and does not seem worth # pursuing at the moment. # XXX: It's the release of the references to e.g packetizer that fails # in py3... if not PY2: return threading.Thread(target=self._run).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) self.tc = paramiko.SSHClient() self.tc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.assertEqual(0, len(self.tc.get_host_keys())) self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion') self.event.wait(1.0) self.assertTrue(self.event.is_set()) self.assertTrue(self.ts.is_active()) p = weakref.ref(self.tc._transport.packetizer) self.assertTrue(p() is not None) self.tc.close() del self.tc # hrm, sometimes p isn't cleared right away. why is that? #st = time.time() #while (time.time() - st < 5.0) and (p() is not None): # time.sleep(0.1) # instead of dumbly waiting for the GC to collect, force a collection # to see whether the SSHClient object is deallocated correctly import gc gc.collect() self.assertTrue(p() is None) def test_client_can_be_used_as_context_manager(self): """ verify that an SSHClient can be used a context manager """ threading.Thread(target=self._run).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) with paramiko.SSHClient() as tc: self.tc = tc self.tc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.assertEquals(0, len(self.tc.get_host_keys())) self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion') self.event.wait(1.0) self.assertTrue(self.event.is_set()) self.assertTrue(self.ts.is_active()) self.assertTrue(self.tc._transport is not None) self.assertTrue(self.tc._transport is None) def test_7_banner_timeout(self): """ verify that the SSHClient has a configurable banner timeout. """ # Start the thread with a 1 second wait. threading.Thread(target=self._run, kwargs={'delay': 1}).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) self.tc = paramiko.SSHClient() self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key) # Connect with a half second banner timeout. self.assertRaises( paramiko.SSHException, self.tc.connect, self.addr, self.port, username='slowdive', password='pygmalion', banner_timeout=0.5 )
lgpl-2.1
[ 3, 1898, 334, 35, 9, 13004, 13, 8664, 221, 6848, 32236, 28833, 665, 293, 32236, 3929, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 26162, 14, 199, 3, 199, 3, 12608, 16625, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 199, 3, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12608, 16625, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 199, 3, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 199, 3, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 12608, 16625, 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, 221, 15673, 13, 13421, 221, 8217, 14, 199, 199, 624, 199, 7700, 4137, 2295, 367, 12027, 3041, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 2838, 199, 504, 5549, 492, 333, 6080, 808, 199, 646, 5796, 199, 646, 2882, 199, 646, 13852, 199, 646, 3598, 199, 646, 747, 199, 646, 900, 199, 504, 2295, 14, 1974, 492, 511, 63, 515, 199, 646, 26162, 199, 504, 26162, 14, 2330, 492, 7843, 18, 12, 330, 199, 504, 26162, 14, 5510, 63, 1971, 492, 12027, 1726, 421, 199, 38, 1206, 540, 21754, 51, 275, 469, 272, 283, 5510, 13, 68, 385, 356, 330, 1154, 88, 1602, 60, 88, 2277, 60, 1949, 16, 60, 1774, 25, 60, 1800, 18, 60, 88, 19, 67, 60, 1812, 21, 60, 88, 1085, 60, 88, 1165, 60, 88, 1643, 60, 3581, 60, 88, 2194, 60, 88, 21, 66, 60, 1812, 17, 60, 2207, 18, 60, 88, 22, 67, 297, 272, 283, 5510, 13, 13487, 356, 330, 1154, 88, 2259, 60, 88, 2898, 60, 88, 1703, 60, 88, 1602, 60, 10351, 60, 88, 2869, 60, 88, 1184, 60, 88, 2182, 60, 88, 23, 70, 60, 10745, 60, 11078, 60, 1800, 18, 60, 88, 18, 66, 60, 88, 21, 65, 60, 88, 1641, 60, 2207, 21, 297, 272, 283, 825, 24760, 13, 4835, 18, 13, 78, 631, 80, 3912, 356, 330, 1154, 88, 821, 60, 88, 1167, 60, 10145, 60, 88, 1229, 60, 1845, 22, 60, 1800, 17, 60, 88, 2417, 60, 3581, 60, 88, 20, 70, 60, 88, 1703, 60, 2207, 18, 60, 88, 2194, 60, 88, 22, 70, 60, 1800, 21, 60, 2207, 21, 60, 88, 2259, 297, 199, 93, 421, 199, 533, 12119, 3120, 334, 635, 16625, 14, 3120, 4267, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 9812, 2295, 370, 4756, 15, 5993, 2488, 790, 2943, 267, 291, 855, 6541, 63, 1612, 275, 2074, 14, 1935, 360, 6541, 63, 1612, 297, 3073, 267, 1613, 8, 8849, 3120, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 6541, 63, 1178, 83, 8, 277, 12, 3434, 304, 267, 340, 3434, 508, 283, 14362, 28021, 356, 288, 372, 283, 5645, 8442, 14655, 12, 2060, 7, 267, 372, 283, 5645, 8442, 14655, 7, 339, 347, 1104, 63, 1178, 63, 2060, 8, 277, 12, 3434, 12, 2505, 304, 267, 340, 334, 2473, 508, 283, 14362, 28021, 358, 436, 334, 2060, 508, 283, 647, 71, 2174, 1636, 735, 288, 372, 26162, 14, 5580, 63, 12779, 38, 1293, 267, 372, 26162, 14, 5580, 63, 12299, 339, 347, 1104, 63, 1178, 63, 5645, 8442, 14655, 8, 277, 12, 3434, 12, 790, 304, 267, 862, 26, 288, 1420, 275, 481, 1206, 540, 21754, 51, 59, 498, 14, 362, 63, 354, 5106, 267, 871, 4067, 26, 288, 372, 26162, 14, 5580, 63, 12299, 267, 340, 334, 288, 790, 14, 362, 63, 354, 342, 315, 291, 855, 6541, 63, 1612, 436, 288, 790, 14, 362, 63, 15077, 342, 508, 1420, 267, 3461, 288, 372, 26162, 14, 5580, 63, 12779, 38, 1293, 267, 372, 26162, 14, 5580, 63, 12299, 339, 347, 1104, 63, 2775, 63, 1069, 8, 277, 12, 4928, 12, 15985, 344, 304, 267, 372, 26162, 14, 9935, 63, 6195, 8601, 25953, 339, 347, 1104, 63, 2775, 63, 1628, 63, 1069, 8, 277, 12, 3623, 12, 1414, 304, 267, 340, 1414, 1137, 283, 5066, 356, 288, 372, 756, 267, 372, 715, 421, 199, 533, 12027, 3041, 774, 334, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5096, 76, 275, 2838, 14, 3450, 342, 267, 291, 14, 5096, 76, 14, 3409, 4725, 5967, 297, 378, 430, 267, 291, 14, 5096, 76, 14, 5859, 8, 17, 9, 267, 291, 14, 2697, 12, 291, 14, 719, 275, 291, 14, 5096, 76, 14, 27886, 342, 267, 291, 14, 1430, 275, 5796, 14, 2390, 342, 339, 347, 6766, 8, 277, 304, 267, 367, 1921, 315, 298, 3641, 6714, 6771, 83, 6771, 76, 1674, 1294, 837, 288, 340, 2688, 8, 277, 12, 1921, 304, 355, 2519, 8, 277, 12, 1921, 680, 1600, 342, 339, 347, 485, 1065, 8, 277, 12, 4370, 63, 1612, 29, 403, 12, 7339, 29, 16, 304, 267, 340, 4370, 63, 1612, 365, 488, 26, 288, 4370, 63, 1612, 275, 481, 1206, 540, 21754, 51, 14, 1612, 342, 267, 291, 14, 21234, 12, 5552, 275, 291, 14, 5096, 76, 14, 5694, 342, 267, 291, 14, 1086, 275, 26162, 14, 7836, 8, 277, 14, 21234, 9, 267, 1591, 63, 498, 275, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 8, 396, 63, 515, 360, 396, 63, 13487, 14, 498, 1333, 267, 291, 14, 1086, 14, 525, 63, 1000, 63, 498, 8, 1102, 63, 498, 9, 267, 1654, 275, 12119, 3120, 8, 6541, 63, 1612, 29, 6541, 63, 1612, 9, 267, 340, 7339, 26, 288, 900, 14, 4532, 8, 5814, 9, 267, 291, 14, 1086, 14, 928, 63, 1000, 8 ]
[ 1898, 334, 35, 9, 13004, 13, 8664, 221, 6848, 32236, 28833, 665, 293, 32236, 3929, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 26162, 14, 199, 3, 199, 3, 12608, 16625, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 199, 3, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 27, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12608, 16625, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 199, 3, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 199, 3, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 12608, 16625, 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, 221, 15673, 13, 13421, 221, 8217, 14, 199, 199, 624, 199, 7700, 4137, 2295, 367, 12027, 3041, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 2838, 199, 504, 5549, 492, 333, 6080, 808, 199, 646, 5796, 199, 646, 2882, 199, 646, 13852, 199, 646, 3598, 199, 646, 747, 199, 646, 900, 199, 504, 2295, 14, 1974, 492, 511, 63, 515, 199, 646, 26162, 199, 504, 26162, 14, 2330, 492, 7843, 18, 12, 330, 199, 504, 26162, 14, 5510, 63, 1971, 492, 12027, 1726, 421, 199, 38, 1206, 540, 21754, 51, 275, 469, 272, 283, 5510, 13, 68, 385, 356, 330, 1154, 88, 1602, 60, 88, 2277, 60, 1949, 16, 60, 1774, 25, 60, 1800, 18, 60, 88, 19, 67, 60, 1812, 21, 60, 88, 1085, 60, 88, 1165, 60, 88, 1643, 60, 3581, 60, 88, 2194, 60, 88, 21, 66, 60, 1812, 17, 60, 2207, 18, 60, 88, 22, 67, 297, 272, 283, 5510, 13, 13487, 356, 330, 1154, 88, 2259, 60, 88, 2898, 60, 88, 1703, 60, 88, 1602, 60, 10351, 60, 88, 2869, 60, 88, 1184, 60, 88, 2182, 60, 88, 23, 70, 60, 10745, 60, 11078, 60, 1800, 18, 60, 88, 18, 66, 60, 88, 21, 65, 60, 88, 1641, 60, 2207, 21, 297, 272, 283, 825, 24760, 13, 4835, 18, 13, 78, 631, 80, 3912, 356, 330, 1154, 88, 821, 60, 88, 1167, 60, 10145, 60, 88, 1229, 60, 1845, 22, 60, 1800, 17, 60, 88, 2417, 60, 3581, 60, 88, 20, 70, 60, 88, 1703, 60, 2207, 18, 60, 88, 2194, 60, 88, 22, 70, 60, 1800, 21, 60, 2207, 21, 60, 88, 2259, 297, 199, 93, 421, 199, 533, 12119, 3120, 334, 635, 16625, 14, 3120, 4267, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 9812, 2295, 370, 4756, 15, 5993, 2488, 790, 2943, 267, 291, 855, 6541, 63, 1612, 275, 2074, 14, 1935, 360, 6541, 63, 1612, 297, 3073, 267, 1613, 8, 8849, 3120, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 6541, 63, 1178, 83, 8, 277, 12, 3434, 304, 267, 340, 3434, 508, 283, 14362, 28021, 356, 288, 372, 283, 5645, 8442, 14655, 12, 2060, 7, 267, 372, 283, 5645, 8442, 14655, 7, 339, 347, 1104, 63, 1178, 63, 2060, 8, 277, 12, 3434, 12, 2505, 304, 267, 340, 334, 2473, 508, 283, 14362, 28021, 358, 436, 334, 2060, 508, 283, 647, 71, 2174, 1636, 735, 288, 372, 26162, 14, 5580, 63, 12779, 38, 1293, 267, 372, 26162, 14, 5580, 63, 12299, 339, 347, 1104, 63, 1178, 63, 5645, 8442, 14655, 8, 277, 12, 3434, 12, 790, 304, 267, 862, 26, 288, 1420, 275, 481, 1206, 540, 21754, 51, 59, 498, 14, 362, 63, 354, 5106, 267, 871, 4067, 26, 288, 372, 26162, 14, 5580, 63, 12299, 267, 340, 334, 288, 790, 14, 362, 63, 354, 342, 315, 291, 855, 6541, 63, 1612, 436, 288, 790, 14, 362, 63, 15077, 342, 508, 1420, 267, 3461, 288, 372, 26162, 14, 5580, 63, 12779, 38, 1293, 267, 372, 26162, 14, 5580, 63, 12299, 339, 347, 1104, 63, 2775, 63, 1069, 8, 277, 12, 4928, 12, 15985, 344, 304, 267, 372, 26162, 14, 9935, 63, 6195, 8601, 25953, 339, 347, 1104, 63, 2775, 63, 1628, 63, 1069, 8, 277, 12, 3623, 12, 1414, 304, 267, 340, 1414, 1137, 283, 5066, 356, 288, 372, 756, 267, 372, 715, 421, 199, 533, 12027, 3041, 774, 334, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5096, 76, 275, 2838, 14, 3450, 342, 267, 291, 14, 5096, 76, 14, 3409, 4725, 5967, 297, 378, 430, 267, 291, 14, 5096, 76, 14, 5859, 8, 17, 9, 267, 291, 14, 2697, 12, 291, 14, 719, 275, 291, 14, 5096, 76, 14, 27886, 342, 267, 291, 14, 1430, 275, 5796, 14, 2390, 342, 339, 347, 6766, 8, 277, 304, 267, 367, 1921, 315, 298, 3641, 6714, 6771, 83, 6771, 76, 1674, 1294, 837, 288, 340, 2688, 8, 277, 12, 1921, 304, 355, 2519, 8, 277, 12, 1921, 680, 1600, 342, 339, 347, 485, 1065, 8, 277, 12, 4370, 63, 1612, 29, 403, 12, 7339, 29, 16, 304, 267, 340, 4370, 63, 1612, 365, 488, 26, 288, 4370, 63, 1612, 275, 481, 1206, 540, 21754, 51, 14, 1612, 342, 267, 291, 14, 21234, 12, 5552, 275, 291, 14, 5096, 76, 14, 5694, 342, 267, 291, 14, 1086, 275, 26162, 14, 7836, 8, 277, 14, 21234, 9, 267, 1591, 63, 498, 275, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 8, 396, 63, 515, 360, 396, 63, 13487, 14, 498, 1333, 267, 291, 14, 1086, 14, 525, 63, 1000, 63, 498, 8, 1102, 63, 498, 9, 267, 1654, 275, 12119, 3120, 8, 6541, 63, 1612, 29, 6541, 63, 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 ]
ayesandarmoe/microblog_flask_tutorial
flask/lib/python2.7/site-packages/pytz/lazy.py
514
5263
from threading import RLock try: from UserDict import DictMixin except ImportError: from collections import Mapping as DictMixin # With lazy loading, we might end up with multiple threads triggering # it at the same time. We need a lock. _fill_lock = RLock() class LazyDict(DictMixin): """Dictionary populated on first use.""" data = None def __getitem__(self, key): if self.data is None: _fill_lock.acquire() try: if self.data is None: self._fill() finally: _fill_lock.release() return self.data[key.upper()] def __contains__(self, key): if self.data is None: _fill_lock.acquire() try: if self.data is None: self._fill() finally: _fill_lock.release() return key in self.data def __iter__(self): if self.data is None: _fill_lock.acquire() try: if self.data is None: self._fill() finally: _fill_lock.release() return iter(self.data) def __len__(self): if self.data is None: _fill_lock.acquire() try: if self.data is None: self._fill() finally: _fill_lock.release() return len(self.data) def keys(self): if self.data is None: _fill_lock.acquire() try: if self.data is None: self._fill() finally: _fill_lock.release() return self.data.keys() class LazyList(list): """List populated on first use.""" _props = [ '__str__', '__repr__', '__unicode__', '__hash__', '__sizeof__', '__cmp__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', 'append', 'count', 'index', 'extend', 'insert', 'pop', 'remove', 'reverse', 'sort', '__add__', '__radd__', '__iadd__', '__mul__', '__rmul__', '__imul__', '__contains__', '__len__', '__nonzero__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__reversed__', '__getslice__', '__setslice__', '__delslice__'] def __new__(cls, fill_iter=None): if fill_iter is None: return list() # We need a new class as we will be dynamically messing with its # methods. class LazyList(list): pass fill_iter = [fill_iter] def lazy(name): def _lazy(self, *args, **kw): _fill_lock.acquire() try: if len(fill_iter) > 0: list.extend(self, fill_iter.pop()) for method_name in cls._props: delattr(LazyList, method_name) finally: _fill_lock.release() return getattr(list, name)(self, *args, **kw) return _lazy for name in cls._props: setattr(LazyList, name, lazy(name)) new_list = LazyList() return new_list # Not all versions of Python declare the same magic methods. # Filter out properties that don't exist in this version of Python # from the list. LazyList._props = [prop for prop in LazyList._props if hasattr(list, prop)] class LazySet(set): """Set populated on first use.""" _props = ( '__str__', '__repr__', '__unicode__', '__hash__', '__sizeof__', '__cmp__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__contains__', '__len__', '__nonzero__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__sub__', '__and__', '__xor__', '__or__', '__rsub__', '__rand__', '__rxor__', '__ror__', '__isub__', '__iand__', '__ixor__', '__ior__', 'add', 'clear', 'copy', 'difference', 'difference_update', 'discard', 'intersection', 'intersection_update', 'isdisjoint', 'issubset', 'issuperset', 'pop', 'remove', 'symmetric_difference', 'symmetric_difference_update', 'union', 'update') def __new__(cls, fill_iter=None): if fill_iter is None: return set() class LazySet(set): pass fill_iter = [fill_iter] def lazy(name): def _lazy(self, *args, **kw): _fill_lock.acquire() try: if len(fill_iter) > 0: for i in fill_iter.pop(): set.add(self, i) for method_name in cls._props: delattr(LazySet, method_name) finally: _fill_lock.release() return getattr(set, name)(self, *args, **kw) return _lazy for name in cls._props: setattr(LazySet, name, lazy(name)) new_set = LazySet() return new_set # Not all versions of Python declare the same magic methods. # Filter out properties that don't exist in this version of Python # from the list. LazySet._props = [prop for prop in LazySet._props if hasattr(set, prop)]
gpl-2.0
[ 504, 5796, 492, 820, 6432, 199, 893, 26, 272, 687, 32241, 492, 7448, 4256, 199, 2590, 3545, 26, 272, 687, 5055, 492, 12340, 465, 7448, 4256, 421, 199, 3, 8777, 9617, 8697, 12, 781, 5594, 1284, 1536, 543, 3663, 7183, 6804, 316, 199, 3, 652, 737, 314, 2011, 900, 14, 2136, 1929, 282, 4650, 14, 199, 63, 4498, 63, 831, 275, 820, 6432, 342, 421, 199, 533, 22373, 2141, 8, 2141, 4256, 304, 272, 408, 11728, 16460, 641, 1642, 675, 1041, 272, 666, 275, 488, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 291, 14, 576, 59, 498, 14, 4142, 5106, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 790, 315, 291, 14, 576, 339, 347, 636, 1661, 721, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 2740, 8, 277, 14, 576, 9, 339, 347, 636, 552, 721, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 822, 8, 277, 14, 576, 9, 339, 347, 2883, 8, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 291, 14, 576, 14, 1612, 342, 421, 199, 533, 22373, 1296, 8, 513, 304, 272, 408, 1296, 16460, 641, 1642, 675, 1041, 339, 485, 6750, 275, 359, 267, 2560, 495, 7500, 2560, 2722, 7500, 2560, 2975, 7500, 267, 2560, 2227, 7500, 2560, 12590, 7500, 2560, 5730, 7500, 267, 2560, 4116, 7500, 2560, 274, 7500, 2560, 4077, 7500, 2560, 685, 7500, 2560, 3308, 7500, 2560, 303, 7500, 267, 283, 740, 297, 283, 835, 297, 283, 1080, 297, 283, 2880, 297, 283, 3176, 297, 283, 1935, 297, 283, 2168, 297, 267, 283, 4471, 297, 283, 3191, 297, 2560, 525, 7500, 2560, 22958, 7500, 2560, 28788, 7500, 2560, 3703, 7500, 267, 2560, 27968, 7500, 2560, 1017, 348, 7500, 2560, 6134, 7500, 2560, 552, 7500, 2560, 10262, 7500, 267, 2560, 6095, 7500, 2560, 8617, 7500, 2560, 13228, 7500, 2560, 1661, 7500, 267, 2560, 13501, 7500, 2560, 32131, 7500, 2560, 2193, 3037, 7500, 2560, 271, 478, 3037, 17501, 339, 347, 636, 1222, 721, 1886, 12, 5554, 63, 1661, 29, 403, 304, 398, 340, 5554, 63, 1661, 365, 488, 26, 288, 372, 769, 342, 398, 327, 2136, 1929, 282, 892, 1021, 465, 781, 911, 506, 18774, 15634, 316, 543, 2399, 267, 327, 3102, 14, 267, 1021, 22373, 1296, 8, 513, 304, 288, 986, 398, 5554, 63, 1661, 275, 359, 4498, 63, 1661, 61, 398, 347, 9617, 8, 354, 304, 288, 347, 485, 6395, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 355, 485, 4498, 63, 831, 14, 8174, 342, 355, 862, 26, 490, 340, 822, 8, 4498, 63, 1661, 9, 690, 378, 26, 717, 769, 14, 2880, 8, 277, 12, 5554, 63, 1661, 14, 1935, 1012, 717, 367, 1083, 63, 354, 315, 843, 423, 6750, 26, 1169, 24358, 8, 14269, 1296, 12, 1083, 63, 354, 9, 355, 3753, 26, 490, 485, 4498, 63, 831, 14, 3221, 342, 355, 372, 2519, 8, 513, 12, 536, 5130, 277, 12, 627, 589, 12, 1011, 829, 9, 288, 372, 485, 6395, 398, 367, 536, 315, 843, 423, 6750, 26, 288, 5371, 8, 14269, 1296, 12, 536, 12, 9617, 8, 354, 430, 398, 892, 63, 513, 275, 22373, 1296, 342, 267, 372, 892, 63, 513, 199, 199, 3, 2832, 1006, 5459, 402, 2018, 20771, 314, 2011, 10628, 3102, 14, 199, 3, 9388, 734, 4382, 626, 2793, 1133, 2187, 315, 642, 1015, 402, 2018, 199, 3, 687, 314, 769, 14, 199, 14269, 1296, 423, 6750, 275, 359, 4469, 367, 5931, 315, 22373, 1296, 423, 6750, 340, 2688, 8, 513, 12, 5931, 1874, 421, 199, 533, 22373, 1084, 8, 409, 304, 272, 408, 1084, 16460, 641, 1642, 675, 1041, 339, 485, 6750, 275, 334, 267, 2560, 495, 7500, 2560, 2722, 7500, 2560, 2975, 7500, 267, 2560, 2227, 7500, 2560, 12590, 7500, 2560, 5730, 7500, 267, 2560, 4116, 7500, 2560, 274, 7500, 2560, 4077, 7500, 2560, 685, 7500, 2560, 3308, 7500, 2560, 303, 7500, 267, 2560, 6134, 7500, 2560, 552, 7500, 2560, 10262, 7500, 267, 2560, 6095, 7500, 2560, 8617, 7500, 2560, 13228, 7500, 2560, 1661, 7500, 267, 2560, 954, 7500, 2560, 460, 7500, 2560, 15721, 7500, 2560, 269, 7500, 267, 2560, 82, 954, 7500, 2560, 3759, 7500, 2560, 6872, 269, 7500, 2560, 451, 7500, 267, 2560, 374, 456, 7500, 2560, 73, 460, 7500, 2560, 1148, 269, 7500, 2560, 15499, 7500, 267, 283, 525, 297, 283, 3584, 297, 283, 1574, 297, 283, 9196, 297, 283, 9196, 63, 873, 297, 267, 283, 14394, 297, 283, 12569, 297, 283, 12569, 63, 873, 297, 283, 374, 31880, 297, 267, 283, 374, 9401, 297, 283, 374, 32299, 297, 283, 1935, 297, 283, 2168, 297, 267, 283, 18422, 63, 9196, 297, 283, 18422, 63, 9196, 63, 873, 297, 267, 283, 8888, 297, 283, 873, 358, 339, 347, 636, 1222, 721, 1886, 12, 5554, 63, 1661, 29, 403, 304, 398, 340, 5554, 63, 1661, 365, 488, 26, 288, 372, 663, 342, 398, 1021, 22373, 1084, 8, 409, 304, 288, 986, 398, 5554, 63, 1661, 275, 359, 4498, 63, 1661, 61 ]
[ 5796, 492, 820, 6432, 199, 893, 26, 272, 687, 32241, 492, 7448, 4256, 199, 2590, 3545, 26, 272, 687, 5055, 492, 12340, 465, 7448, 4256, 421, 199, 3, 8777, 9617, 8697, 12, 781, 5594, 1284, 1536, 543, 3663, 7183, 6804, 316, 199, 3, 652, 737, 314, 2011, 900, 14, 2136, 1929, 282, 4650, 14, 199, 63, 4498, 63, 831, 275, 820, 6432, 342, 421, 199, 533, 22373, 2141, 8, 2141, 4256, 304, 272, 408, 11728, 16460, 641, 1642, 675, 1041, 272, 666, 275, 488, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 291, 14, 576, 59, 498, 14, 4142, 5106, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 790, 315, 291, 14, 576, 339, 347, 636, 1661, 721, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 2740, 8, 277, 14, 576, 9, 339, 347, 636, 552, 721, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 822, 8, 277, 14, 576, 9, 339, 347, 2883, 8, 277, 304, 267, 340, 291, 14, 576, 365, 488, 26, 288, 485, 4498, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 340, 291, 14, 576, 365, 488, 26, 490, 291, 423, 4498, 342, 288, 3753, 26, 355, 485, 4498, 63, 831, 14, 3221, 342, 267, 372, 291, 14, 576, 14, 1612, 342, 421, 199, 533, 22373, 1296, 8, 513, 304, 272, 408, 1296, 16460, 641, 1642, 675, 1041, 339, 485, 6750, 275, 359, 267, 2560, 495, 7500, 2560, 2722, 7500, 2560, 2975, 7500, 267, 2560, 2227, 7500, 2560, 12590, 7500, 2560, 5730, 7500, 267, 2560, 4116, 7500, 2560, 274, 7500, 2560, 4077, 7500, 2560, 685, 7500, 2560, 3308, 7500, 2560, 303, 7500, 267, 283, 740, 297, 283, 835, 297, 283, 1080, 297, 283, 2880, 297, 283, 3176, 297, 283, 1935, 297, 283, 2168, 297, 267, 283, 4471, 297, 283, 3191, 297, 2560, 525, 7500, 2560, 22958, 7500, 2560, 28788, 7500, 2560, 3703, 7500, 267, 2560, 27968, 7500, 2560, 1017, 348, 7500, 2560, 6134, 7500, 2560, 552, 7500, 2560, 10262, 7500, 267, 2560, 6095, 7500, 2560, 8617, 7500, 2560, 13228, 7500, 2560, 1661, 7500, 267, 2560, 13501, 7500, 2560, 32131, 7500, 2560, 2193, 3037, 7500, 2560, 271, 478, 3037, 17501, 339, 347, 636, 1222, 721, 1886, 12, 5554, 63, 1661, 29, 403, 304, 398, 340, 5554, 63, 1661, 365, 488, 26, 288, 372, 769, 342, 398, 327, 2136, 1929, 282, 892, 1021, 465, 781, 911, 506, 18774, 15634, 316, 543, 2399, 267, 327, 3102, 14, 267, 1021, 22373, 1296, 8, 513, 304, 288, 986, 398, 5554, 63, 1661, 275, 359, 4498, 63, 1661, 61, 398, 347, 9617, 8, 354, 304, 288, 347, 485, 6395, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 355, 485, 4498, 63, 831, 14, 8174, 342, 355, 862, 26, 490, 340, 822, 8, 4498, 63, 1661, 9, 690, 378, 26, 717, 769, 14, 2880, 8, 277, 12, 5554, 63, 1661, 14, 1935, 1012, 717, 367, 1083, 63, 354, 315, 843, 423, 6750, 26, 1169, 24358, 8, 14269, 1296, 12, 1083, 63, 354, 9, 355, 3753, 26, 490, 485, 4498, 63, 831, 14, 3221, 342, 355, 372, 2519, 8, 513, 12, 536, 5130, 277, 12, 627, 589, 12, 1011, 829, 9, 288, 372, 485, 6395, 398, 367, 536, 315, 843, 423, 6750, 26, 288, 5371, 8, 14269, 1296, 12, 536, 12, 9617, 8, 354, 430, 398, 892, 63, 513, 275, 22373, 1296, 342, 267, 372, 892, 63, 513, 199, 199, 3, 2832, 1006, 5459, 402, 2018, 20771, 314, 2011, 10628, 3102, 14, 199, 3, 9388, 734, 4382, 626, 2793, 1133, 2187, 315, 642, 1015, 402, 2018, 199, 3, 687, 314, 769, 14, 199, 14269, 1296, 423, 6750, 275, 359, 4469, 367, 5931, 315, 22373, 1296, 423, 6750, 340, 2688, 8, 513, 12, 5931, 1874, 421, 199, 533, 22373, 1084, 8, 409, 304, 272, 408, 1084, 16460, 641, 1642, 675, 1041, 339, 485, 6750, 275, 334, 267, 2560, 495, 7500, 2560, 2722, 7500, 2560, 2975, 7500, 267, 2560, 2227, 7500, 2560, 12590, 7500, 2560, 5730, 7500, 267, 2560, 4116, 7500, 2560, 274, 7500, 2560, 4077, 7500, 2560, 685, 7500, 2560, 3308, 7500, 2560, 303, 7500, 267, 2560, 6134, 7500, 2560, 552, 7500, 2560, 10262, 7500, 267, 2560, 6095, 7500, 2560, 8617, 7500, 2560, 13228, 7500, 2560, 1661, 7500, 267, 2560, 954, 7500, 2560, 460, 7500, 2560, 15721, 7500, 2560, 269, 7500, 267, 2560, 82, 954, 7500, 2560, 3759, 7500, 2560, 6872, 269, 7500, 2560, 451, 7500, 267, 2560, 374, 456, 7500, 2560, 73, 460, 7500, 2560, 1148, 269, 7500, 2560, 15499, 7500, 267, 283, 525, 297, 283, 3584, 297, 283, 1574, 297, 283, 9196, 297, 283, 9196, 63, 873, 297, 267, 283, 14394, 297, 283, 12569, 297, 283, 12569, 63, 873, 297, 283, 374, 31880, 297, 267, 283, 374, 9401, 297, 283, 374, 32299, 297, 283, 1935, 297, 283, 2168, 297, 267, 283, 18422, 63, 9196, 297, 283, 18422, 63, 9196, 63, 873, 297, 267, 283, 8888, 297, 283, 873, 358, 339, 347, 636, 1222, 721, 1886, 12, 5554, 63, 1661, 29, 403, 304, 398, 340, 5554, 63, 1661, 365, 488, 26, 288, 372, 663, 342, 398, 1021, 22373, 1084, 8, 409, 304, 288, 986, 398, 5554, 63, 1661, 275, 359, 4498, 63, 1661, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cactusbin/nyt
matplotlib/examples/user_interfaces/embedding_in_tk.py
9
1419
#!/usr/bin/env python import matplotlib matplotlib.use('TkAgg') from numpy import arange, sin, pi from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg # implement the default mpl key bindings from matplotlib.backend_bases import key_press_handler from matplotlib.figure import Figure import sys if sys.version_info[0] < 3: import Tkinter as Tk else: import tkinter as Tk root = Tk.Tk() root.wm_title("Embedding in TK") f = Figure(figsize=(5,4), dpi=100) a = f.add_subplot(111) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) a.plot(t,s) # a tk.DrawingArea canvas = FigureCanvasTkAgg(f, master=root) canvas.show() canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) toolbar = NavigationToolbar2TkAgg( canvas, root ) toolbar.update() canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) def on_key_event(event): print('you pressed %s'%event.key) key_press_handler(event, canvas, toolbar) canvas.mpl_connect('key_press_event', on_key_event) def _quit(): root.quit() # stops mainloop root.destroy() # this is necessary on Windows to prevent # Fatal Python Error: PyEval_RestoreThread: NULL tstate button = Tk.Button(master=root, text='Quit', command=_quit) button.pack(side=Tk.BOTTOM) Tk.mainloop() # If you put root.destroy() here, it will cause an error if # the window is closed with the window manager.
unlicense
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 199, 199, 504, 2680, 492, 20461, 12, 9829, 12, 6682, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 16266, 15174, 15189, 7248, 12, 20721, 5360, 29630, 18, 15189, 7248, 199, 3, 5669, 314, 849, 22513, 790, 17792, 199, 504, 8027, 14, 4620, 63, 12087, 492, 790, 63, 2915, 63, 2232, 421, 199, 504, 8027, 14, 8941, 492, 16266, 199, 199, 646, 984, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 492, 16826, 465, 12435, 199, 2836, 26, 272, 492, 22171, 465, 12435, 199, 199, 1231, 275, 12435, 14, 15189, 342, 199, 1231, 14, 16240, 63, 1213, 480, 27907, 315, 377, 43, 531, 421, 199, 70, 275, 16266, 8, 23899, 2687, 21, 12, 20, 395, 26910, 29, 1960, 9, 199, 65, 275, 289, 14, 525, 63, 13334, 8, 6673, 9, 199, 84, 275, 20461, 8, 16, 14, 16, 12, 19, 14, 16, 12, 16, 14, 614, 9, 199, 83, 275, 9829, 8, 18, 10, 1038, 10, 84, 9, 199, 199, 65, 14, 2798, 8, 84, 12, 83, 9, 421, 199, 3, 282, 10157, 14, 9654, 316, 11043, 199, 7682, 275, 16266, 15174, 15189, 7248, 8, 70, 12, 5288, 29, 1231, 9, 199, 7682, 14, 2384, 342, 199, 7682, 14, 362, 63, 2663, 63, 3440, 1252, 1389, 8, 2441, 29, 15189, 14, 11422, 12, 5554, 29, 15189, 14, 28784, 12, 6544, 29, 17, 9, 199, 199, 13951, 275, 20721, 5360, 29630, 18, 15189, 7248, 8, 10218, 12, 1738, 776, 199, 13951, 14, 873, 342, 199, 7682, 423, 2663, 7682, 14, 1389, 8, 2441, 29, 15189, 14, 11422, 12, 5554, 29, 15189, 14, 28784, 12, 6544, 29, 17, 9, 199, 199, 318, 641, 63, 498, 63, 1430, 8, 1430, 304, 272, 870, 360, 13297, 25167, 450, 83, 5956, 1430, 14, 498, 9, 272, 790, 63, 2915, 63, 2232, 8, 1430, 12, 10218, 12, 22483, 9, 199, 199, 7682, 14, 2421, 63, 2242, 360, 498, 63, 2915, 63, 1430, 297, 641, 63, 498, 63, 1430, 9, 199, 199, 318, 485, 10589, 837, 272, 1738, 14, 10589, 342, 258, 327, 20922, 2446, 3813, 272, 1738, 14, 7237, 342, 221, 327, 642, 365, 5784, 641, 5417, 370, 7981, 490, 327, 481, 7539, 2018, 4520, 26, 1611, 10006, 63, 21012, 4436, 26, 5962, 307, 929, 199, 199, 3887, 275, 12435, 14, 4259, 8, 4133, 29, 1231, 12, 1318, 534, 24145, 297, 1414, 3699, 10589, 9, 199, 3887, 14, 1389, 8, 2441, 29, 15189, 14, 27838, 9, 199, 199, 15189, 14, 22644, 342, 199, 3, 982, 1265, 5324, 1738, 14, 7237, 342, 2348, 12, 652, 911, 7675, 376, 1125, 340, 199, 3, 314, 4353, 365, 6876, 543, 314, 4353, 5256, 14, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 199, 199, 504, 2680, 492, 20461, 12, 9829, 12, 6682, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 16266, 15174, 15189, 7248, 12, 20721, 5360, 29630, 18, 15189, 7248, 199, 3, 5669, 314, 849, 22513, 790, 17792, 199, 504, 8027, 14, 4620, 63, 12087, 492, 790, 63, 2915, 63, 2232, 421, 199, 504, 8027, 14, 8941, 492, 16266, 199, 199, 646, 984, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 492, 16826, 465, 12435, 199, 2836, 26, 272, 492, 22171, 465, 12435, 199, 199, 1231, 275, 12435, 14, 15189, 342, 199, 1231, 14, 16240, 63, 1213, 480, 27907, 315, 377, 43, 531, 421, 199, 70, 275, 16266, 8, 23899, 2687, 21, 12, 20, 395, 26910, 29, 1960, 9, 199, 65, 275, 289, 14, 525, 63, 13334, 8, 6673, 9, 199, 84, 275, 20461, 8, 16, 14, 16, 12, 19, 14, 16, 12, 16, 14, 614, 9, 199, 83, 275, 9829, 8, 18, 10, 1038, 10, 84, 9, 199, 199, 65, 14, 2798, 8, 84, 12, 83, 9, 421, 199, 3, 282, 10157, 14, 9654, 316, 11043, 199, 7682, 275, 16266, 15174, 15189, 7248, 8, 70, 12, 5288, 29, 1231, 9, 199, 7682, 14, 2384, 342, 199, 7682, 14, 362, 63, 2663, 63, 3440, 1252, 1389, 8, 2441, 29, 15189, 14, 11422, 12, 5554, 29, 15189, 14, 28784, 12, 6544, 29, 17, 9, 199, 199, 13951, 275, 20721, 5360, 29630, 18, 15189, 7248, 8, 10218, 12, 1738, 776, 199, 13951, 14, 873, 342, 199, 7682, 423, 2663, 7682, 14, 1389, 8, 2441, 29, 15189, 14, 11422, 12, 5554, 29, 15189, 14, 28784, 12, 6544, 29, 17, 9, 199, 199, 318, 641, 63, 498, 63, 1430, 8, 1430, 304, 272, 870, 360, 13297, 25167, 450, 83, 5956, 1430, 14, 498, 9, 272, 790, 63, 2915, 63, 2232, 8, 1430, 12, 10218, 12, 22483, 9, 199, 199, 7682, 14, 2421, 63, 2242, 360, 498, 63, 2915, 63, 1430, 297, 641, 63, 498, 63, 1430, 9, 199, 199, 318, 485, 10589, 837, 272, 1738, 14, 10589, 342, 258, 327, 20922, 2446, 3813, 272, 1738, 14, 7237, 342, 221, 327, 642, 365, 5784, 641, 5417, 370, 7981, 490, 327, 481, 7539, 2018, 4520, 26, 1611, 10006, 63, 21012, 4436, 26, 5962, 307, 929, 199, 199, 3887, 275, 12435, 14, 4259, 8, 4133, 29, 1231, 12, 1318, 534, 24145, 297, 1414, 3699, 10589, 9, 199, 3887, 14, 1389, 8, 2441, 29, 15189, 14, 27838, 9, 199, 199, 15189, 14, 22644, 342, 199, 3, 982, 1265, 5324, 1738, 14, 7237, 342, 2348, 12, 652, 911, 7675, 376, 1125, 340, 199, 3, 314, 4353, 365, 6876, 543, 314, 4353, 5256, 14, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lehmannro/pootle
pootle/scripts/hooks.py
5
1422
#!/usr/bin/python import sys import os import os.path import subprocess import logging def hook(project, hooktype, file, *args, **kwargs): """ project should be the projectcode of any project. hooktype should be precommit, postcommit, preupdate or postupdate. file should be the absolute path of the file. Other arguments depend on the hooktype: precommit should have "author" and "message" as arguments. postcommit should have "success" as arguments. preupdate and postupdate have no additional arguments. Return value depends on the hooktype: precommit returns an array of strings indicating what files to commit. preupdate returns an array of strings indicating what files to update. postcommit and postupdate return unit. """ logger = logging.getLogger('pootle.scripts.hooks') try: activehook = __import__(project, globals(), locals(), []) if hasattr(activehook, hooktype) and callable(getattr(activehook, hooktype)): logger.debug("Executing hook %s for project %s on file %s", hooktype, project, file) return getattr(activehook, hooktype)(file, *args, **kwargs) else: return [] except ImportError, e: raise ImportError(e) except Exception, e: logger.error("Exception in project (%s) hook (%s) for file (%s): %s" % (project, hooktype, file, e))
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 646, 984, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 199, 646, 2050, 199, 199, 318, 5759, 8, 1715, 12, 5759, 466, 12, 570, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 272, 2199, 1077, 506, 314, 2199, 600, 402, 1263, 2199, 14, 272, 5759, 466, 1077, 506, 876, 3543, 12, 2963, 3543, 12, 876, 873, 503, 2963, 873, 14, 272, 570, 1077, 506, 314, 3679, 931, 402, 314, 570, 14, 339, 5439, 2368, 11687, 641, 314, 5759, 466, 26, 267, 876, 3543, 1077, 1172, 298, 2502, 2, 436, 298, 1188, 2, 465, 2368, 14, 267, 2963, 3543, 1077, 1172, 298, 3742, 2, 465, 2368, 14, 267, 876, 873, 436, 2963, 873, 1172, 949, 4722, 2368, 14, 339, 1432, 574, 8350, 641, 314, 5759, 466, 26, 267, 876, 3543, 2529, 376, 1625, 402, 3326, 9297, 4052, 1584, 370, 5532, 14, 267, 876, 873, 2529, 376, 1625, 402, 3326, 9297, 4052, 1584, 370, 1678, 14, 267, 2963, 3543, 436, 2963, 873, 372, 4137, 14, 339, 408, 272, 2512, 275, 2050, 14, 5572, 360, 555, 24629, 14, 6429, 14, 7922, 358, 272, 862, 26, 267, 4702, 3664, 275, 636, 646, 721, 1715, 12, 7992, 1062, 9480, 1062, 3073, 267, 340, 2688, 8, 2682, 3664, 12, 5759, 466, 9, 436, 4550, 8, 5675, 8, 2682, 3664, 12, 5759, 466, 2298, 288, 2512, 14, 1757, 480, 4858, 4655, 5759, 450, 83, 367, 2199, 450, 83, 641, 570, 450, 83, 401, 5759, 466, 12, 2199, 12, 570, 9, 288, 372, 2519, 8, 2682, 3664, 12, 5759, 466, 5130, 493, 12, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 372, 942, 272, 871, 3545, 12, 325, 26, 267, 746, 3545, 8, 69, 9, 272, 871, 2186, 12, 325, 26, 267, 2512, 14, 705, 480, 1726, 315, 2199, 4366, 83, 9, 5759, 4366, 83, 9, 367, 570, 4366, 83, 304, 450, 83, 2, 450, 334, 1715, 12, 5759, 466, 12, 570, 12, 325, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 984, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 3873, 199, 199, 646, 2050, 199, 199, 318, 5759, 8, 1715, 12, 5759, 466, 12, 570, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 272, 2199, 1077, 506, 314, 2199, 600, 402, 1263, 2199, 14, 272, 5759, 466, 1077, 506, 876, 3543, 12, 2963, 3543, 12, 876, 873, 503, 2963, 873, 14, 272, 570, 1077, 506, 314, 3679, 931, 402, 314, 570, 14, 339, 5439, 2368, 11687, 641, 314, 5759, 466, 26, 267, 876, 3543, 1077, 1172, 298, 2502, 2, 436, 298, 1188, 2, 465, 2368, 14, 267, 2963, 3543, 1077, 1172, 298, 3742, 2, 465, 2368, 14, 267, 876, 873, 436, 2963, 873, 1172, 949, 4722, 2368, 14, 339, 1432, 574, 8350, 641, 314, 5759, 466, 26, 267, 876, 3543, 2529, 376, 1625, 402, 3326, 9297, 4052, 1584, 370, 5532, 14, 267, 876, 873, 2529, 376, 1625, 402, 3326, 9297, 4052, 1584, 370, 1678, 14, 267, 2963, 3543, 436, 2963, 873, 372, 4137, 14, 339, 408, 272, 2512, 275, 2050, 14, 5572, 360, 555, 24629, 14, 6429, 14, 7922, 358, 272, 862, 26, 267, 4702, 3664, 275, 636, 646, 721, 1715, 12, 7992, 1062, 9480, 1062, 3073, 267, 340, 2688, 8, 2682, 3664, 12, 5759, 466, 9, 436, 4550, 8, 5675, 8, 2682, 3664, 12, 5759, 466, 2298, 288, 2512, 14, 1757, 480, 4858, 4655, 5759, 450, 83, 367, 2199, 450, 83, 641, 570, 450, 83, 401, 5759, 466, 12, 2199, 12, 570, 9, 288, 372, 2519, 8, 2682, 3664, 12, 5759, 466, 5130, 493, 12, 627, 589, 12, 1011, 958, 9, 267, 587, 26, 288, 372, 942, 272, 871, 3545, 12, 325, 26, 267, 746, 3545, 8, 69, 9, 272, 871, 2186, 12, 325, 26, 267, 2512, 14, 705, 480, 1726, 315, 2199, 4366, 83, 9, 5759, 4366, 83, 9, 367, 570, 4366, 83, 304, 450, 83, 2, 450, 334, 1715, 12, 5759, 466, 12, 570, 12, 325, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
XXMrHyde/android_external_chromium_org
third_party/pymock/mock.py
424
75527
# mock.py # Test tools for mocking and patching. # Copyright (C) 2007-2012 Michael Foord & the mock team # E-mail: fuzzyman AT voidspace DOT org DOT uk # mock 1.0 # http://www.voidspace.org.uk/python/mock/ # Released subject to the BSD License # Please see http://www.voidspace.org.uk/python/license.shtml # Scripts maintained at http://www.voidspace.org.uk/python/index.shtml # Comments, suggestions and bug reports welcome. __all__ = ( 'Mock', 'MagicMock', 'patch', 'sentinel', 'DEFAULT', 'ANY', 'call', 'create_autospec', 'FILTER_DIR', 'NonCallableMock', 'NonCallableMagicMock', 'mock_open', 'PropertyMock', ) __version__ = '1.0.1' import pprint import sys try: import inspect except ImportError: # for alternative platforms that # may not have inspect inspect = None try: from functools import wraps as original_wraps except ImportError: # Python 2.4 compatibility def wraps(original): def inner(f): f.__name__ = original.__name__ f.__doc__ = original.__doc__ f.__module__ = original.__module__ f.__wrapped__ = original return f return inner else: if sys.version_info[:2] >= (3, 3): wraps = original_wraps else: def wraps(func): def inner(f): f = original_wraps(func)(f) f.__wrapped__ = func return f return inner try: unicode except NameError: # Python 3 basestring = unicode = str try: long except NameError: # Python 3 long = int try: BaseException except NameError: # Python 2.4 compatibility BaseException = Exception try: next except NameError: def next(obj): return obj.next() BaseExceptions = (BaseException,) if 'java' in sys.platform: # jython import java BaseExceptions = (BaseException, java.lang.Throwable) try: _isidentifier = str.isidentifier except AttributeError: # Python 2.X import keyword import re regex = re.compile(r'^[a-z_][a-z0-9_]*$', re.I) def _isidentifier(string): if string in keyword.kwlist: return False return regex.match(string) inPy3k = sys.version_info[0] == 3 # Needed to work around Python 3 bug where use of "super" interferes with # defining __class__ as a descriptor _super = super self = 'im_self' builtin = '__builtin__' if inPy3k: self = '__self__' builtin = 'builtins' FILTER_DIR = True def _is_instance_mock(obj): # can't use isinstance on Mock objects because they override __class__ # The base class for all mocks is NonCallableMock return issubclass(type(obj), NonCallableMock) def _is_exception(obj): return ( isinstance(obj, BaseExceptions) or isinstance(obj, ClassTypes) and issubclass(obj, BaseExceptions) ) class _slotted(object): __slots__ = ['a'] DescriptorTypes = ( type(_slotted.a), property, ) def _getsignature(func, skipfirst, instance=False): if inspect is None: raise ImportError('inspect module not available') if isinstance(func, ClassTypes) and not instance: try: func = func.__init__ except AttributeError: return skipfirst = True elif not isinstance(func, FunctionTypes): # for classes where instance is True we end up here too try: func = func.__call__ except AttributeError: return if inPy3k: try: argspec = inspect.getfullargspec(func) except TypeError: # C function / method, possibly inherited object().__init__ return regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann = argspec else: try: regargs, varargs, varkwargs, defaults = inspect.getargspec(func) except TypeError: # C function / method, possibly inherited object().__init__ return # instance methods and classmethods need to lose the self argument if getattr(func, self, None) is not None: regargs = regargs[1:] if skipfirst: # this condition and the above one are never both True - why? regargs = regargs[1:] if inPy3k: signature = inspect.formatargspec( regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann, formatvalue=lambda value: "") else: signature = inspect.formatargspec( regargs, varargs, varkwargs, defaults, formatvalue=lambda value: "") return signature[1:-1], func def _check_signature(func, mock, skipfirst, instance=False): if not _callable(func): return result = _getsignature(func, skipfirst, instance) if result is None: return signature, func = result # can't use self because "self" is common as an argument name # unfortunately even not in the first place src = "lambda _mock_self, %s: None" % signature checksig = eval(src, {}) _copy_func_details(func, checksig) type(mock)._mock_check_sig = checksig def _copy_func_details(func, funcopy): funcopy.__name__ = func.__name__ funcopy.__doc__ = func.__doc__ #funcopy.__dict__.update(func.__dict__) funcopy.__module__ = func.__module__ if not inPy3k: funcopy.func_defaults = func.func_defaults return funcopy.__defaults__ = func.__defaults__ funcopy.__kwdefaults__ = func.__kwdefaults__ def _callable(obj): if isinstance(obj, ClassTypes): return True if getattr(obj, '__call__', None) is not None: return True return False def _is_list(obj): # checks for list or tuples # XXXX badly named! return type(obj) in (list, tuple) def _instance_callable(obj): """Given an object, return True if the object is callable. For classes, return True if instances would be callable.""" if not isinstance(obj, ClassTypes): # already an instance return getattr(obj, '__call__', None) is not None klass = obj # uses __bases__ instead of __mro__ so that we work with old style classes if klass.__dict__.get('__call__') is not None: return True for base in klass.__bases__: if _instance_callable(base): return True return False def _set_signature(mock, original, instance=False): # creates a function with signature (*args, **kwargs) that delegates to a # mock. It still does signature checking by calling a lambda with the same # signature as the original. if not _callable(original): return skipfirst = isinstance(original, ClassTypes) result = _getsignature(original, skipfirst, instance) if result is None: # was a C function (e.g. object().__init__ ) that can't be mocked return signature, func = result src = "lambda %s: None" % signature checksig = eval(src, {}) _copy_func_details(func, checksig) name = original.__name__ if not _isidentifier(name): name = 'funcopy' context = {'_checksig_': checksig, 'mock': mock} src = """def %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs)""" % name exec (src, context) funcopy = context[name] _setup_func(funcopy, mock) return funcopy def _setup_func(funcopy, mock): funcopy.mock = mock # can't use isinstance with mocks if not _is_instance_mock(mock): return def assert_called_with(*args, **kwargs): return mock.assert_called_with(*args, **kwargs) def assert_called_once_with(*args, **kwargs): return mock.assert_called_once_with(*args, **kwargs) def assert_has_calls(*args, **kwargs): return mock.assert_has_calls(*args, **kwargs) def assert_any_call(*args, **kwargs): return mock.assert_any_call(*args, **kwargs) def reset_mock(): funcopy.method_calls = _CallList() funcopy.mock_calls = _CallList() mock.reset_mock() ret = funcopy.return_value if _is_instance_mock(ret) and not ret is mock: ret.reset_mock() funcopy.called = False funcopy.call_count = 0 funcopy.call_args = None funcopy.call_args_list = _CallList() funcopy.method_calls = _CallList() funcopy.mock_calls = _CallList() funcopy.return_value = mock.return_value funcopy.side_effect = mock.side_effect funcopy._mock_children = mock._mock_children funcopy.assert_called_with = assert_called_with funcopy.assert_called_once_with = assert_called_once_with funcopy.assert_has_calls = assert_has_calls funcopy.assert_any_call = assert_any_call funcopy.reset_mock = reset_mock mock._mock_delegate = funcopy def _is_magic(name): return '__%s__' % name[2:-2] == name class _SentinelObject(object): "A unique, named, sentinel object." def __init__(self, name): self.name = name def __repr__(self): return 'sentinel.%s' % self.name class _Sentinel(object): """Access attributes to return a named object, usable as a sentinel.""" def __init__(self): self._sentinels = {} def __getattr__(self, name): if name == '__bases__': # Without this help(mock) raises an exception raise AttributeError return self._sentinels.setdefault(name, _SentinelObject(name)) sentinel = _Sentinel() DEFAULT = sentinel.DEFAULT _missing = sentinel.MISSING _deleted = sentinel.DELETED class OldStyleClass: pass ClassType = type(OldStyleClass) def _copy(value): if type(value) in (dict, list, tuple, set): return type(value)(value) return value ClassTypes = (type,) if not inPy3k: ClassTypes = (type, ClassType) _allowed_names = set( [ 'return_value', '_mock_return_value', 'side_effect', '_mock_side_effect', '_mock_parent', '_mock_new_parent', '_mock_name', '_mock_new_name' ] ) def _delegating_property(name): _allowed_names.add(name) _the_name = '_mock_' + name def _get(self, name=name, _the_name=_the_name): sig = self._mock_delegate if sig is None: return getattr(self, _the_name) return getattr(sig, name) def _set(self, value, name=name, _the_name=_the_name): sig = self._mock_delegate if sig is None: self.__dict__[_the_name] = value else: setattr(sig, name, value) return property(_get, _set) class _CallList(list): def __contains__(self, value): if not isinstance(value, list): return list.__contains__(self, value) len_value = len(value) len_self = len(self) if len_value > len_self: return False for i in range(0, len_self - len_value + 1): sub_list = self[i:i+len_value] if sub_list == value: return True return False def __repr__(self): return pprint.pformat(list(self)) def _check_and_set_parent(parent, value, name, new_name): if not _is_instance_mock(value): return False if ((value._mock_name or value._mock_new_name) or (value._mock_parent is not None) or (value._mock_new_parent is not None)): return False _parent = parent while _parent is not None: # setting a mock (value) as a child or return value of itself # should not modify the mock if _parent is value: return False _parent = _parent._mock_new_parent if new_name: value._mock_new_parent = parent value._mock_new_name = new_name if name: value._mock_parent = parent value._mock_name = name return True class Base(object): _mock_return_value = DEFAULT _mock_side_effect = None def __init__(self, *args, **kwargs): pass class NonCallableMock(Base): """A non-callable version of `Mock`""" def __new__(cls, *args, **kw): # every instance has its own class # so we can create magic methods on the # class without stomping on other mocks new = type(cls.__name__, (cls,), {'__doc__': cls.__doc__}) instance = object.__new__(new) return instance def __init__( self, spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs ): if _new_parent is None: _new_parent = parent __dict__ = self.__dict__ __dict__['_mock_parent'] = parent __dict__['_mock_name'] = name __dict__['_mock_new_name'] = _new_name __dict__['_mock_new_parent'] = _new_parent if spec_set is not None: spec = spec_set spec_set = True self._mock_add_spec(spec, spec_set) __dict__['_mock_children'] = {} __dict__['_mock_wraps'] = wraps __dict__['_mock_delegate'] = None __dict__['_mock_called'] = False __dict__['_mock_call_args'] = None __dict__['_mock_call_count'] = 0 __dict__['_mock_call_args_list'] = _CallList() __dict__['_mock_mock_calls'] = _CallList() __dict__['method_calls'] = _CallList() if kwargs: self.configure_mock(**kwargs) _super(NonCallableMock, self).__init__( spec, wraps, name, spec_set, parent, _spec_state ) def attach_mock(self, mock, attribute): """ Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the `method_calls` and `mock_calls` attributes of this one.""" mock._mock_parent = None mock._mock_new_parent = None mock._mock_name = '' mock._mock_new_name = None setattr(self, attribute, mock) def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) def _mock_add_spec(self, spec, spec_set): _spec_class = None if spec is not None and not _is_list(spec): if isinstance(spec, ClassTypes): _spec_class = spec else: _spec_class = _get_class(spec) spec = dir(spec) __dict__ = self.__dict__ __dict__['_spec_class'] = _spec_class __dict__['_spec_set'] = spec_set __dict__['_mock_methods'] = spec def __get_return_value(self): ret = self._mock_return_value if self._mock_delegate is not None: ret = self._mock_delegate.return_value if ret is DEFAULT: ret = self._get_child_mock( _new_parent=self, _new_name='()' ) self.return_value = ret return ret def __set_return_value(self, value): if self._mock_delegate is not None: self._mock_delegate.return_value = value else: self._mock_return_value = value _check_and_set_parent(self, value, None, '()') __return_value_doc = "The value to be returned when the mock is called." return_value = property(__get_return_value, __set_return_value, __return_value_doc) @property def __class__(self): if self._spec_class is None: return type(self) return self._spec_class called = _delegating_property('called') call_count = _delegating_property('call_count') call_args = _delegating_property('call_args') call_args_list = _delegating_property('call_args_list') mock_calls = _delegating_property('mock_calls') def __get_side_effect(self): sig = self._mock_delegate if sig is None: return self._mock_side_effect return sig.side_effect def __set_side_effect(self, value): value = _try_iter(value) sig = self._mock_delegate if sig is None: self._mock_side_effect = value else: sig.side_effect = value side_effect = property(__get_side_effect, __set_side_effect) def reset_mock(self): "Restore the mock object to its initial state." self.called = False self.call_args = None self.call_count = 0 self.mock_calls = _CallList() self.call_args_list = _CallList() self.method_calls = _CallList() for child in self._mock_children.values(): if isinstance(child, _SpecState): continue child.reset_mock() ret = self._mock_return_value if _is_instance_mock(ret) and ret is not self: ret.reset_mock() def configure_mock(self, **kwargs): """Set attributes on the mock through keyword arguments. Attributes plus return values and side effects can be set on child mocks using standard dot notation and unpacking a dictionary in the method call: >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError} >>> mock.configure_mock(**attrs)""" for arg, val in sorted(kwargs.items(), # we sort on the number of dots so that # attributes are set before we set attributes on # attributes key=lambda entry: entry[0].count('.')): args = arg.split('.') final = args.pop() obj = self for entry in args: obj = getattr(obj, entry) setattr(obj, final, val) def __getattr__(self, name): if name == '_mock_methods': raise AttributeError(name) elif self._mock_methods is not None: if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name): raise AttributeError(name) result = self._mock_children.get(name) if result is _deleted: raise AttributeError(name) elif result is None: wraps = None if self._mock_wraps is not None: # XXXX should we get the attribute without triggering code # execution? wraps = getattr(self._mock_wraps, name) result = self._get_child_mock( parent=self, name=name, wraps=wraps, _new_name=name, _new_parent=self ) self._mock_children[name] = result elif isinstance(result, _SpecState): result = create_autospec( result.spec, result.spec_set, result.instance, result.parent, result.name ) self._mock_children[name] = result return result def __repr__(self): _name_list = [self._mock_new_name] _parent = self._mock_new_parent last = self dot = '.' if _name_list == ['()']: dot = '' seen = set() while _parent is not None: last = _parent _name_list.append(_parent._mock_new_name + dot) dot = '.' if _parent._mock_new_name == '()': dot = '' _parent = _parent._mock_new_parent # use ids here so as not to call __hash__ on the mocks if id(_parent) in seen: break seen.add(id(_parent)) _name_list = list(reversed(_name_list)) _first = last._mock_name or 'mock' if len(_name_list) > 1: if _name_list[1] not in ('()', '().'): _first += '.' _name_list[0] = _first name = ''.join(_name_list) name_string = '' if name not in ('mock', 'mock.'): name_string = ' name=%r' % name spec_string = '' if self._spec_class is not None: spec_string = ' spec=%r' if self._spec_set: spec_string = ' spec_set=%r' spec_string = spec_string % self._spec_class.__name__ return "<%s%s%s id='%s'>" % ( type(self).__name__, name_string, spec_string, id(self) ) def __dir__(self): """Filter the output of `dir(mock)` to only useful members. XXXX """ extras = self._mock_methods or [] from_type = dir(type(self)) from_dict = list(self.__dict__) if FILTER_DIR: from_type = [e for e in from_type if not e.startswith('_')] from_dict = [e for e in from_dict if not e.startswith('_') or _is_magic(e)] return sorted(set(extras + from_type + from_dict + list(self._mock_children))) def __setattr__(self, name, value): if name in _allowed_names: # property setters go through here return object.__setattr__(self, name, value) elif (self._spec_set and self._mock_methods is not None and name not in self._mock_methods and name not in self.__dict__): raise AttributeError("Mock object has no attribute '%s'" % name) elif name in _unsupported_magics: msg = 'Attempting to set unsupported magic method %r.' % name raise AttributeError(msg) elif name in _all_magics: if self._mock_methods is not None and name not in self._mock_methods: raise AttributeError("Mock object has no attribute '%s'" % name) if not _is_instance_mock(value): setattr(type(self), name, _get_method(name, value)) original = value value = lambda *args, **kw: original(self, *args, **kw) else: # only set _new_name and not name so that mock_calls is tracked # but not method calls _check_and_set_parent(self, value, None, name) setattr(type(self), name, value) self._mock_children[name] = value elif name == '__class__': self._spec_class = value return else: if _check_and_set_parent(self, value, name, name): self._mock_children[name] = value return object.__setattr__(self, name, value) def __delattr__(self, name): if name in _all_magics and name in type(self).__dict__: delattr(type(self), name) if name not in self.__dict__: # for magic methods that are still MagicProxy objects and # not set on the instance itself return if name in self.__dict__: object.__delattr__(self, name) obj = self._mock_children.get(name, _missing) if obj is _deleted: raise AttributeError(name) if obj is not _missing: del self._mock_children[name] self._mock_children[name] = _deleted def _format_mock_call_signature(self, args, kwargs): name = self._mock_name or 'mock' return _format_call_signature(name, args, kwargs) def _format_mock_failure_message(self, args, kwargs): message = 'Expected call: %s\nActual call: %s' expected_string = self._format_mock_call_signature(args, kwargs) call_args = self.call_args if len(call_args) == 3: call_args = call_args[1:] actual_string = self._format_mock_call_signature(*call_args) return message % (expected_string, actual_string) def assert_called_with(_mock_self, *args, **kwargs): """assert that the mock was called with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.""" self = _mock_self if self.call_args is None: expected = self._format_mock_call_signature(args, kwargs) raise AssertionError('Expected call: %s\nNot called' % (expected,)) if self.call_args != (args, kwargs): msg = self._format_mock_failure_message(args, kwargs) raise AssertionError(msg) def assert_called_once_with(_mock_self, *args, **kwargs): """assert that the mock was called exactly once and with the specified arguments.""" self = _mock_self if not self.call_count == 1: msg = ("Expected to be called once. Called %s times." % self.call_count) raise AssertionError(msg) return self.assert_called_with(*args, **kwargs) def assert_has_calls(self, calls, any_order=False): """assert the mock has been called with the specified calls. The `mock_calls` list is checked for the calls. If `any_order` is False (the default) then the calls must be sequential. There can be extra calls before or after the specified calls. If `any_order` is True then the calls can be in any order, but they must all appear in `mock_calls`.""" if not any_order: if calls not in self.mock_calls: raise AssertionError( 'Calls not found.\nExpected: %r\n' 'Actual: %r' % (calls, self.mock_calls) ) return all_calls = list(self.mock_calls) not_found = [] for kall in calls: try: all_calls.remove(kall) except ValueError: not_found.append(kall) if not_found: raise AssertionError( '%r not all found in call list' % (tuple(not_found),) ) def assert_any_call(self, *args, **kwargs): """assert the mock has been called with the specified arguments. The assert passes if the mock has *ever* been called, unlike `assert_called_with` and `assert_called_once_with` that only pass if the call is the most recent one.""" kall = call(*args, **kwargs) if kall not in self.call_args_list: expected_string = self._format_mock_call_signature(args, kwargs) raise AssertionError( '%s call not found' % expected_string ) def _get_child_mock(self, **kw): """Create the child mocks for attributes and return value. By default child mocks will be the same type as the parent. Subclasses of Mock may want to override this to customize the way child mocks are made. For non-callable mocks the callable variant will be used (rather than any custom subclass).""" _type = type(self) if not issubclass(_type, CallableMixin): if issubclass(_type, NonCallableMagicMock): klass = MagicMock elif issubclass(_type, NonCallableMock) : klass = Mock else: klass = _type.__mro__[1] return klass(**kw) def _try_iter(obj): if obj is None: return obj if _is_exception(obj): return obj if _callable(obj): return obj try: return iter(obj) except TypeError: # XXXX backwards compatibility # but this will blow up on first call - so maybe we should fail early? return obj class CallableMixin(Base): def __init__(self, spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs): self.__dict__['_mock_return_value'] = return_value _super(CallableMixin, self).__init__( spec, wraps, name, spec_set, parent, _spec_state, _new_name, _new_parent, **kwargs ) self.side_effect = side_effect def _mock_check_sig(self, *args, **kwargs): # stub method that can be replaced with one with a specific signature pass def __call__(_mock_self, *args, **kwargs): # can't use self in-case a function / method we are mocking uses self # in the signature _mock_self._mock_check_sig(*args, **kwargs) return _mock_self._mock_call(*args, **kwargs) def _mock_call(_mock_self, *args, **kwargs): self = _mock_self self.called = True self.call_count += 1 self.call_args = _Call((args, kwargs), two=True) self.call_args_list.append(_Call((args, kwargs), two=True)) _new_name = self._mock_new_name _new_parent = self._mock_new_parent self.mock_calls.append(_Call(('', args, kwargs))) seen = set() skip_next_dot = _new_name == '()' do_method_calls = self._mock_parent is not None name = self._mock_name while _new_parent is not None: this_mock_call = _Call((_new_name, args, kwargs)) if _new_parent._mock_new_name: dot = '.' if skip_next_dot: dot = '' skip_next_dot = False if _new_parent._mock_new_name == '()': skip_next_dot = True _new_name = _new_parent._mock_new_name + dot + _new_name if do_method_calls: if _new_name == name: this_method_call = this_mock_call else: this_method_call = _Call((name, args, kwargs)) _new_parent.method_calls.append(this_method_call) do_method_calls = _new_parent._mock_parent is not None if do_method_calls: name = _new_parent._mock_name + '.' + name _new_parent.mock_calls.append(this_mock_call) _new_parent = _new_parent._mock_new_parent # use ids here so as not to call __hash__ on the mocks _new_parent_id = id(_new_parent) if _new_parent_id in seen: break seen.add(_new_parent_id) ret_val = DEFAULT effect = self.side_effect if effect is not None: if _is_exception(effect): raise effect if not _callable(effect): result = next(effect) if _is_exception(result): raise result return result ret_val = effect(*args, **kwargs) if ret_val is DEFAULT: ret_val = self.return_value if (self._mock_wraps is not None and self._mock_return_value is DEFAULT): return self._mock_wraps(*args, **kwargs) if ret_val is DEFAULT: ret_val = self.return_value return ret_val class Mock(CallableMixin, NonCallableMock): """ Create a new `Mock` object. `Mock` takes several optional arguments that specify the behaviour of the Mock object: * `spec`: This can be either a list of strings or an existing object (a class or instance) that acts as the specification for the mock object. If you pass in an object then a list of strings is formed by calling dir on the object (excluding unsupported magic attributes and methods). Accessing any attribute not in this list will raise an `AttributeError`. If `spec` is an object (rather than a list of strings) then `mock.__class__` returns the class of the spec object. This allows mocks to pass `isinstance` tests. * `spec_set`: A stricter variant of `spec`. If used, attempting to *set* or get an attribute on the mock that isn't on the object passed as `spec_set` will raise an `AttributeError`. * `side_effect`: A function to be called whenever the Mock is called. See the `side_effect` attribute. Useful for raising exceptions or dynamically changing return values. The function is called with the same arguments as the mock, and unless it returns `DEFAULT`, the return value of this function is used as the return value. Alternatively `side_effect` can be an exception class or instance. In this case the exception will be raised when the mock is called. If `side_effect` is an iterable then each call to the mock will return the next value from the iterable. If any of the members of the iterable are exceptions they will be raised instead of returned. * `return_value`: The value returned when the mock is called. By default this is a new Mock (created on first access). See the `return_value` attribute. * `wraps`: Item for the mock object to wrap. If `wraps` is not None then calling the Mock will pass the call through to the wrapped object (returning the real result). Attribute access on the mock will return a Mock object that wraps the corresponding attribute of the wrapped object (so attempting to access an attribute that doesn't exist will raise an `AttributeError`). If the mock has an explicit `return_value` set then calls are not passed to the wrapped object and the `return_value` is returned instead. * `name`: If the mock has a name then it will be used in the repr of the mock. This can be useful for debugging. The name is propagated to child mocks. Mocks can also be called with arbitrary keyword arguments. These will be used to set attributes on the mock after it is created. """ def _dot_lookup(thing, comp, import_path): try: return getattr(thing, comp) except AttributeError: __import__(import_path) return getattr(thing, comp) def _importer(target): components = target.split('.') import_path = components.pop(0) thing = __import__(import_path) for comp in components: import_path += ".%s" % comp thing = _dot_lookup(thing, comp, import_path) return thing def _is_started(patcher): # XXXX horrible return hasattr(patcher, 'is_local') class _patch(object): attribute_name = None _active_patches = set() def __init__( self, getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ): if new_callable is not None: if new is not DEFAULT: raise ValueError( "Cannot use 'new' and 'new_callable' together" ) if autospec is not None: raise ValueError( "Cannot use 'autospec' and 'new_callable' together" ) self.getter = getter self.attribute = attribute self.new = new self.new_callable = new_callable self.spec = spec self.create = create self.has_local = False self.spec_set = spec_set self.autospec = autospec self.kwargs = kwargs self.additional_patchers = [] def copy(self): patcher = _patch( self.getter, self.attribute, self.new, self.spec, self.create, self.spec_set, self.autospec, self.new_callable, self.kwargs ) patcher.attribute_name = self.attribute_name patcher.additional_patchers = [ p.copy() for p in self.additional_patchers ] return patcher def __call__(self, func): if isinstance(func, ClassTypes): return self.decorate_class(func) return self.decorate_callable(func) def decorate_class(self, klass): for attr in dir(klass): if not attr.startswith(patch.TEST_PREFIX): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): continue patcher = self.copy() setattr(klass, attr, patcher(attr_value)) return klass def decorate_callable(self, func): if hasattr(func, 'patchings'): func.patchings.append(self) return func @wraps(func) def patched(*args, **keywargs): # don't use a with here (backwards compatability with Python 2.4) extra_args = [] entered_patchers = [] # can't use try...except...finally because of Python 2.4 # compatibility exc_info = tuple() try: try: for patching in patched.patchings: arg = patching.__enter__() entered_patchers.append(patching) if patching.attribute_name is not None: keywargs.update(arg) elif patching.new is DEFAULT: extra_args.append(arg) args += tuple(extra_args) return func(*args, **keywargs) except: if (patching not in entered_patchers and _is_started(patching)): # the patcher may have been started, but an exception # raised whilst entering one of its additional_patchers entered_patchers.append(patching) # Pass the exception to __exit__ exc_info = sys.exc_info() # re-raise the exception raise finally: for patching in reversed(entered_patchers): patching.__exit__(*exc_info) patched.patchings = [self] if hasattr(func, 'func_code'): # not in Python 3 patched.compat_co_firstlineno = getattr( func, "compat_co_firstlineno", func.func_code.co_firstlineno ) return patched def get_original(self): target = self.getter() name = self.attribute original = DEFAULT local = False try: original = target.__dict__[name] except (AttributeError, KeyError): original = getattr(target, name, DEFAULT) else: local = True if not self.create and original is DEFAULT: raise AttributeError( "%s does not have the attribute %r" % (target, name) ) return original, local def __enter__(self): """Perform the patch.""" new, spec, spec_set = self.new, self.spec, self.spec_set autospec, kwargs = self.autospec, self.kwargs new_callable = self.new_callable self.target = self.getter() # normalise False to None if spec is False: spec = None if spec_set is False: spec_set = None if autospec is False: autospec = None if spec is not None and autospec is not None: raise TypeError("Can't specify spec and autospec") if ((spec is not None or autospec is not None) and spec_set not in (True, None)): raise TypeError("Can't provide explicit spec_set *and* spec or autospec") original, local = self.get_original() if new is DEFAULT and autospec is None: inherit = False if spec is True: # set spec to the object we are replacing spec = original if spec_set is True: spec_set = original spec = None elif spec is not None: if spec_set is True: spec_set = spec spec = None elif spec_set is True: spec_set = original if spec is not None or spec_set is not None: if original is DEFAULT: raise TypeError("Can't use 'spec' with create=True") if isinstance(original, ClassTypes): # If we're patching out a class and there is a spec inherit = True Klass = MagicMock _kwargs = {} if new_callable is not None: Klass = new_callable elif spec is not None or spec_set is not None: this_spec = spec if spec_set is not None: this_spec = spec_set if _is_list(this_spec): not_callable = '__call__' not in this_spec else: not_callable = not _callable(this_spec) if not_callable: Klass = NonCallableMagicMock if spec is not None: _kwargs['spec'] = spec if spec_set is not None: _kwargs['spec_set'] = spec_set # add a name to mocks if (isinstance(Klass, type) and issubclass(Klass, NonCallableMock) and self.attribute): _kwargs['name'] = self.attribute _kwargs.update(kwargs) new = Klass(**_kwargs) if inherit and _is_instance_mock(new): # we can only tell if the instance should be callable if the # spec is not a list this_spec = spec if spec_set is not None: this_spec = spec_set if (not _is_list(this_spec) and not _instance_callable(this_spec)): Klass = NonCallableMagicMock _kwargs.pop('name') new.return_value = Klass(_new_parent=new, _new_name='()', **_kwargs) elif autospec is not None: # spec is ignored, new *must* be default, spec_set is treated # as a boolean. Should we check spec is not None and that spec_set # is a bool? if new is not DEFAULT: raise TypeError( "autospec creates the mock for you. Can't specify " "autospec and new." ) if original is DEFAULT: raise TypeError("Can't use 'autospec' with create=True") spec_set = bool(spec_set) if autospec is True: autospec = original new = create_autospec(autospec, spec_set=spec_set, _name=self.attribute, **kwargs) elif kwargs: # can't set keyword args when we aren't creating the mock # XXXX If new is a Mock we could call new.configure_mock(**kwargs) raise TypeError("Can't pass kwargs to a mock we aren't creating") new_attr = new self.temp_original = original self.is_local = local setattr(self.target, self.attribute, new_attr) if self.attribute_name is not None: extra_args = {} if self.new is DEFAULT: extra_args[self.attribute_name] = new for patching in self.additional_patchers: arg = patching.__enter__() if patching.new is DEFAULT: extra_args.update(arg) return extra_args return new def __exit__(self, *exc_info): """Undo the patch.""" if not _is_started(self): raise RuntimeError('stop called on unstarted patcher') if self.is_local and self.temp_original is not DEFAULT: setattr(self.target, self.attribute, self.temp_original) else: delattr(self.target, self.attribute) if not self.create and not hasattr(self.target, self.attribute): # needed for proxy objects like django settings setattr(self.target, self.attribute, self.temp_original) del self.temp_original del self.is_local del self.target for patcher in reversed(self.additional_patchers): if _is_started(patcher): patcher.__exit__(*exc_info) def start(self): """Activate a patch, returning any created mock.""" result = self.__enter__() self._active_patches.add(self) return result def stop(self): """Stop an active patch.""" self._active_patches.discard(self) return self.__exit__() def _get_target(target): try: target, attribute = target.rsplit('.', 1) except (TypeError, ValueError): raise TypeError("Need a valid target to patch. You supplied: %r" % (target,)) getter = lambda: _importer(target) return getter, attribute def _patch_object( target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs ): """ patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs) patch the named member (`attribute`) on an object (`target`) with a mock object. `patch.object` can be used as a decorator, class decorator or a context manager. Arguments `new`, `spec`, `create`, `spec_set`, `autospec` and `new_callable` have the same meaning as for `patch`. Like `patch`, `patch.object` takes arbitrary keyword arguments for configuring the mock object it creates. When used as a class decorator `patch.object` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ getter = lambda: target return _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ) def _patch_multiple(target, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs): """Perform multiple patches in a single call. It takes the object to be patched (either as an object or a string to fetch the object by importing) and keyword arguments for the patches:: with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'): ... Use `DEFAULT` as the value if you want `patch.multiple` to create mocks for you. In this case the created mocks are passed into a decorated function by keyword, and a dictionary is returned when `patch.multiple` is used as a context manager. `patch.multiple` can be used as a decorator, class decorator or a context manager. The arguments `spec`, `spec_set`, `create`, `autospec` and `new_callable` have the same meaning as for `patch`. These arguments will be applied to *all* patches done by `patch.multiple`. When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ if type(target) in (unicode, str): getter = lambda: _importer(target) else: getter = lambda: target if not kwargs: raise ValueError( 'Must supply at least one keyword argument with patch.multiple' ) # need to wrap in a list for python 3, where items is a view items = list(kwargs.items()) attribute, new = items[0] patcher = _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, {} ) patcher.attribute_name = attribute for attribute, new in items[1:]: this_patcher = _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, {} ) this_patcher.attribute_name = attribute patcher.additional_patchers.append(this_patcher) return patcher def patch( target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs ): """ `patch` acts as a function decorator, class decorator or a context manager. Inside the body of the function or with statement, the `target` is patched with a `new` object. When the function/with statement exits the patch is undone. If `new` is omitted, then the target is replaced with a `MagicMock`. If `patch` is used as a decorator and `new` is omitted, the created mock is passed in as an extra argument to the decorated function. If `patch` is used as a context manager the created mock is returned by the context manager. `target` should be a string in the form `'package.module.ClassName'`. The `target` is imported and the specified object replaced with the `new` object, so the `target` must be importable from the environment you are calling `patch` from. The target is imported when the decorated function is executed, not at decoration time. The `spec` and `spec_set` keyword arguments are passed to the `MagicMock` if patch is creating one for you. In addition you can pass `spec=True` or `spec_set=True`, which causes patch to pass in the object being mocked as the spec/spec_set object. `new_callable` allows you to specify a different class, or callable object, that will be called to create the `new` object. By default `MagicMock` is used. A more powerful form of `spec` is `autospec`. If you set `autospec=True` then the mock with be created with a spec from the object being replaced. All attributes of the mock will also have the spec of the corresponding attribute of the object being replaced. Methods and functions being mocked will have their arguments checked and will raise a `TypeError` if they are called with the wrong signature. For mocks replacing a class, their return value (the 'instance') will have the same spec as the class. Instead of `autospec=True` you can pass `autospec=some_object` to use an arbitrary object as the spec instead of the one being replaced. By default `patch` will fail to replace attributes that don't exist. If you pass in `create=True`, and the attribute doesn't exist, patch will create the attribute for you when the patched function is called, and delete it again afterwards. This is useful for writing tests against attributes that your production code creates at runtime. It is off by by default because it can be dangerous. With it switched on you can write passing tests against APIs that don't actually exist! Patch can be used as a `TestCase` class decorator. It works by decorating each test method in the class. This reduces the boilerplate code when your test methods share a common patchings set. `patch` finds tests by looking for method names that start with `patch.TEST_PREFIX`. By default this is `test`, which matches the way `unittest` finds tests. You can specify an alternative prefix by setting `patch.TEST_PREFIX`. Patch can be used as a context manager, with the with statement. Here the patching applies to the indented block after the with statement. If you use "as" then the patched object will be bound to the name after the "as"; very useful if `patch` is creating a mock object for you. `patch` takes arbitrary keyword arguments. These will be passed to the `Mock` (or `new_callable`) on construction. `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are available for alternate use-cases. """ getter, attribute = _get_target(target) return _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ) class _patch_dict(object): """ Patch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test. `in_dict` can be a dictionary or a mapping like container. If it is a mapping then it must at least support getting, setting and deleting items plus iterating over keys. `in_dict` can also be a string specifying the name of the dictionary, which will then be fetched by importing it. `values` can be a dictionary of values to set in the dictionary. `values` can also be an iterable of `(key, value)` pairs. If `clear` is True then the dictionary will be cleared before the new values are set. `patch.dict` can also be called with arbitrary keyword arguments to set values in the dictionary:: with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()): ... `patch.dict` can be used as a context manager, decorator or class decorator. When used as a class decorator `patch.dict` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ def __init__(self, in_dict, values=(), clear=False, **kwargs): if isinstance(in_dict, basestring): in_dict = _importer(in_dict) self.in_dict = in_dict # support any argument supported by dict(...) constructor self.values = dict(values) self.values.update(kwargs) self.clear = clear self._original = None def __call__(self, f): if isinstance(f, ClassTypes): return self.decorate_class(f) @wraps(f) def _inner(*args, **kw): self._patch_dict() try: return f(*args, **kw) finally: self._unpatch_dict() return _inner def decorate_class(self, klass): for attr in dir(klass): attr_value = getattr(klass, attr) if (attr.startswith(patch.TEST_PREFIX) and hasattr(attr_value, "__call__")): decorator = _patch_dict(self.in_dict, self.values, self.clear) decorated = decorator(attr_value) setattr(klass, attr, decorated) return klass def __enter__(self): """Patch the dict.""" self._patch_dict() def _patch_dict(self): values = self.values in_dict = self.in_dict clear = self.clear try: original = in_dict.copy() except AttributeError: # dict like object with no copy method # must support iteration over keys original = {} for key in in_dict: original[key] = in_dict[key] self._original = original if clear: _clear_dict(in_dict) try: in_dict.update(values) except AttributeError: # dict like object with no update method for key in values: in_dict[key] = values[key] def _unpatch_dict(self): in_dict = self.in_dict original = self._original _clear_dict(in_dict) try: in_dict.update(original) except AttributeError: for key in original: in_dict[key] = original[key] def __exit__(self, *args): """Unpatch the dict.""" self._unpatch_dict() return False start = __enter__ stop = __exit__ def _clear_dict(in_dict): try: in_dict.clear() except AttributeError: keys = list(in_dict) for key in keys: del in_dict[key] def _patch_stopall(): """Stop all active patches.""" for patch in list(_patch._active_patches): patch.stop() patch.object = _patch_object patch.dict = _patch_dict patch.multiple = _patch_multiple patch.stopall = _patch_stopall patch.TEST_PREFIX = 'test' magic_methods = ( "lt le gt ge eq ne " "getitem setitem delitem " "len contains iter " "hash str sizeof " "enter exit " "divmod neg pos abs invert " "complex int float index " "trunc floor ceil " ) numerics = "add sub mul div floordiv mod lshift rshift and xor or pow " inplace = ' '.join('i%s' % n for n in numerics.split()) right = ' '.join('r%s' % n for n in numerics.split()) extra = '' if inPy3k: extra = 'bool next ' else: extra = 'unicode long nonzero oct hex truediv rtruediv ' # not including __prepare__, __instancecheck__, __subclasscheck__ # (as they are metaclass methods) # __del__ is not supported at all as it causes problems if it exists _non_defaults = set('__%s__' % method for method in [ 'cmp', 'getslice', 'setslice', 'coerce', 'subclasses', 'format', 'get', 'set', 'delete', 'reversed', 'missing', 'reduce', 'reduce_ex', 'getinitargs', 'getnewargs', 'getstate', 'setstate', 'getformat', 'setformat', 'repr', 'dir' ]) def _get_method(name, func): "Turns a callable object (like a mock) into a real function" def method(self, *args, **kw): return func(self, *args, **kw) method.__name__ = name return method _magics = set( '__%s__' % method for method in ' '.join([magic_methods, numerics, inplace, right, extra]).split() ) _all_magics = _magics | _non_defaults _unsupported_magics = set([ '__getattr__', '__setattr__', '__init__', '__new__', '__prepare__' '__instancecheck__', '__subclasscheck__', '__del__' ]) _calculate_return_value = { '__hash__': lambda self: object.__hash__(self), '__str__': lambda self: object.__str__(self), '__sizeof__': lambda self: object.__sizeof__(self), '__unicode__': lambda self: unicode(object.__str__(self)), } _return_values = { '__lt__': NotImplemented, '__gt__': NotImplemented, '__le__': NotImplemented, '__ge__': NotImplemented, '__int__': 1, '__contains__': False, '__len__': 0, '__exit__': False, '__complex__': 1j, '__float__': 1.0, '__bool__': True, '__nonzero__': True, '__oct__': '1', '__hex__': '0x1', '__long__': long(1), '__index__': 1, } def _get_eq(self): def __eq__(other): ret_val = self.__eq__._mock_return_value if ret_val is not DEFAULT: return ret_val return self is other return __eq__ def _get_ne(self): def __ne__(other): if self.__ne__._mock_return_value is not DEFAULT: return DEFAULT return self is not other return __ne__ def _get_iter(self): def __iter__(): ret_val = self.__iter__._mock_return_value if ret_val is DEFAULT: return iter([]) # if ret_val was already an iterator, then calling iter on it should # return the iterator unchanged return iter(ret_val) return __iter__ _side_effect_methods = { '__eq__': _get_eq, '__ne__': _get_ne, '__iter__': _get_iter, } def _set_return_value(mock, method, name): fixed = _return_values.get(name, DEFAULT) if fixed is not DEFAULT: method.return_value = fixed return return_calulator = _calculate_return_value.get(name) if return_calulator is not None: try: return_value = return_calulator(mock) except AttributeError: # XXXX why do we return AttributeError here? # set it as a side_effect instead? return_value = AttributeError(name) method.return_value = return_value return side_effector = _side_effect_methods.get(name) if side_effector is not None: method.side_effect = side_effector(mock) class MagicMixin(object): def __init__(self, *args, **kw): _super(MagicMixin, self).__init__(*args, **kw) self._mock_set_magics() def _mock_set_magics(self): these_magics = _magics if self._mock_methods is not None: these_magics = _magics.intersection(self._mock_methods) remove_magics = set() remove_magics = _magics - these_magics for entry in remove_magics: if entry in type(self).__dict__: # remove unneeded magic methods delattr(self, entry) # don't overwrite existing attributes if called a second time these_magics = these_magics - set(type(self).__dict__) _type = type(self) for entry in these_magics: setattr(_type, entry, MagicProxy(entry, self)) class NonCallableMagicMock(MagicMixin, NonCallableMock): """A version of `MagicMock` that isn't callable.""" def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) self._mock_set_magics() class MagicMock(MagicMixin, Mock): """ MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself. If you use the `spec` or `spec_set` arguments then *only* magic methods that exist in the spec will be created. Attributes and the return value of a `MagicMock` will also be `MagicMocks`. """ def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) self._mock_set_magics() class MagicProxy(object): def __init__(self, name, parent): self.name = name self.parent = parent def __call__(self, *args, **kwargs): m = self.create_mock() return m(*args, **kwargs) def create_mock(self): entry = self.name parent = self.parent m = parent._get_child_mock(name=entry, _new_name=entry, _new_parent=parent) setattr(parent, entry, m) _set_return_value(parent, m, entry) return m def __get__(self, obj, _type=None): return self.create_mock() class _ANY(object): "A helper object that compares equal to everything." def __eq__(self, other): return True def __ne__(self, other): return False def __repr__(self): return '<ANY>' ANY = _ANY() def _format_call_signature(name, args, kwargs): message = '%s(%%s)' % name formatted_args = '' args_string = ', '.join([repr(arg) for arg in args]) kwargs_string = ', '.join([ '%s=%r' % (key, value) for key, value in kwargs.items() ]) if args_string: formatted_args = args_string if kwargs_string: if formatted_args: formatted_args += ', ' formatted_args += kwargs_string return message % formatted_args class _Call(tuple): """ A tuple for holding the results of a call to a mock, either in the form `(args, kwargs)` or `(name, args, kwargs)`. If args or kwargs are empty then a call tuple will compare equal to a tuple without those values. This makes comparisons less verbose:: _Call(('name', (), {})) == ('name',) _Call(('name', (1,), {})) == ('name', (1,)) _Call(((), {'a': 'b'})) == ({'a': 'b'},) The `_Call` object provides a useful shortcut for comparing with call:: _Call(((1, 2), {'a': 3})) == call(1, 2, a=3) _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3) If the _Call has no name then it will match any name. """ def __new__(cls, value=(), name=None, parent=None, two=False, from_kall=True): name = '' args = () kwargs = {} _len = len(value) if _len == 3: name, args, kwargs = value elif _len == 2: first, second = value if isinstance(first, basestring): name = first if isinstance(second, tuple): args = second else: kwargs = second else: args, kwargs = first, second elif _len == 1: value, = value if isinstance(value, basestring): name = value elif isinstance(value, tuple): args = value else: kwargs = value if two: return tuple.__new__(cls, (args, kwargs)) return tuple.__new__(cls, (name, args, kwargs)) def __init__(self, value=(), name=None, parent=None, two=False, from_kall=True): self.name = name self.parent = parent self.from_kall = from_kall def __eq__(self, other): if other is ANY: return True try: len_other = len(other) except TypeError: return False self_name = '' if len(self) == 2: self_args, self_kwargs = self else: self_name, self_args, self_kwargs = self other_name = '' if len_other == 0: other_args, other_kwargs = (), {} elif len_other == 3: other_name, other_args, other_kwargs = other elif len_other == 1: value, = other if isinstance(value, tuple): other_args = value other_kwargs = {} elif isinstance(value, basestring): other_name = value other_args, other_kwargs = (), {} else: other_args = () other_kwargs = value else: # len 2 # could be (name, args) or (name, kwargs) or (args, kwargs) first, second = other if isinstance(first, basestring): other_name = first if isinstance(second, tuple): other_args, other_kwargs = second, {} else: other_args, other_kwargs = (), second else: other_args, other_kwargs = first, second if self_name and other_name != self_name: return False # this order is important for ANY to work! return (other_args, other_kwargs) == (self_args, self_kwargs) def __ne__(self, other): return not self.__eq__(other) def __call__(self, *args, **kwargs): if self.name is None: return _Call(('', args, kwargs), name='()') name = self.name + '()' return _Call((self.name, args, kwargs), name=name, parent=self) def __getattr__(self, attr): if self.name is None: return _Call(name=attr, from_kall=False) name = '%s.%s' % (self.name, attr) return _Call(name=name, parent=self, from_kall=False) def __repr__(self): if not self.from_kall: name = self.name or 'call' if name.startswith('()'): name = 'call%s' % name return name if len(self) == 2: name = 'call' args, kwargs = self else: name, args, kwargs = self if not name: name = 'call' elif not name.startswith('()'): name = 'call.%s' % name else: name = 'call%s' % name return _format_call_signature(name, args, kwargs) def call_list(self): """For a call object that represents multiple calls, `call_list` returns a list of all the intermediate calls as well as the final call.""" vals = [] thing = self while thing is not None: if thing.from_kall: vals.append(thing) thing = thing.parent return _CallList(reversed(vals)) call = _Call(from_kall=False) def create_autospec(spec, spec_set=False, instance=False, _parent=None, _name=None, **kwargs): """Create a mock object using another object as a spec. Attributes on the mock will use the corresponding attribute on the `spec` object as their spec. Functions or methods being mocked will have their arguments checked to check that they are called with the correct signature. If `spec_set` is True then attempting to set attributes that don't exist on the spec object will raise an `AttributeError`. If a class is used as a spec then the return value of the mock (the instance of the class) will have the same spec. You can use a class as the spec for an instance object by passing `instance=True`. The returned mock will only be callable if instances of the mock are callable. `create_autospec` also takes arbitrary keyword arguments that are passed to the constructor of the created mock.""" if _is_list(spec): # can't pass a list instance to the mock constructor as it will be # interpreted as a list of strings spec = type(spec) is_type = isinstance(spec, ClassTypes) _kwargs = {'spec': spec} if spec_set: _kwargs = {'spec_set': spec} elif spec is None: # None we mock with a normal mock without a spec _kwargs = {} _kwargs.update(kwargs) Klass = MagicMock if type(spec) in DescriptorTypes: # descriptors don't have a spec # because we don't know what type they return _kwargs = {} elif not _callable(spec): Klass = NonCallableMagicMock elif is_type and instance and not _instance_callable(spec): Klass = NonCallableMagicMock _new_name = _name if _parent is None: # for a top level object no _new_name should be set _new_name = '' mock = Klass(parent=_parent, _new_parent=_parent, _new_name=_new_name, name=_name, **_kwargs) if isinstance(spec, FunctionTypes): # should only happen at the top level because we don't # recurse for functions mock = _set_signature(mock, spec) else: _check_signature(spec, mock, is_type, instance) if _parent is not None and not instance: _parent._mock_children[_name] = mock if is_type and not instance and 'return_value' not in kwargs: mock.return_value = create_autospec(spec, spec_set, instance=True, _name='()', _parent=mock) for entry in dir(spec): if _is_magic(entry): # MagicMock already does the useful magic methods for us continue if isinstance(spec, FunctionTypes) and entry in FunctionAttributes: # allow a mock to actually be a function continue # XXXX do we need a better way of getting attributes without # triggering code execution (?) Probably not - we need the actual # object to mock it so we would rather trigger a property than mock # the property descriptor. Likewise we want to mock out dynamically # provided attributes. # XXXX what about attributes that raise exceptions other than # AttributeError on being fetched? # we could be resilient against it, or catch and propagate the # exception when the attribute is fetched from the mock try: original = getattr(spec, entry) except AttributeError: continue kwargs = {'spec': original} if spec_set: kwargs = {'spec_set': original} if not isinstance(original, FunctionTypes): new = _SpecState(original, spec_set, mock, entry, instance) mock._mock_children[entry] = new else: parent = mock if isinstance(spec, FunctionTypes): parent = mock.mock new = MagicMock(parent=parent, name=entry, _new_name=entry, _new_parent=parent, **kwargs) mock._mock_children[entry] = new skipfirst = _must_skip(spec, entry, is_type) _check_signature(original, new, skipfirst=skipfirst) # so functions created with _set_signature become instance attributes, # *plus* their underlying mock exists in _mock_children of the parent # mock. Adding to _mock_children may be unnecessary where we are also # setting as an instance attribute? if isinstance(new, FunctionTypes): setattr(mock, entry, new) return mock def _must_skip(spec, entry, is_type): if not isinstance(spec, ClassTypes): if entry in getattr(spec, '__dict__', {}): # instance attribute - shouldn't skip return False spec = spec.__class__ if not hasattr(spec, '__mro__'): # old style class: can't have descriptors anyway return is_type for klass in spec.__mro__: result = klass.__dict__.get(entry, DEFAULT) if result is DEFAULT: continue if isinstance(result, (staticmethod, classmethod)): return False return is_type # shouldn't get here unless function is a dynamically provided attribute # XXXX untested behaviour return is_type def _get_class(obj): try: return obj.__class__ except AttributeError: # in Python 2, _sre.SRE_Pattern objects have no __class__ return type(obj) class _SpecState(object): def __init__(self, spec, spec_set=False, parent=None, name=None, ids=None, instance=False): self.spec = spec self.ids = ids self.spec_set = spec_set self.parent = parent self.instance = instance self.name = name FunctionTypes = ( # python function type(create_autospec), # instance method type(ANY.__eq__), # unbound method type(_ANY.__eq__), ) FunctionAttributes = set([ 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name', ]) file_spec = None def mock_open(mock=None, read_data=''): """ A helper function to create a mock to replace the use of `open`. It works for `open` called directly or used as a context manager. The `mock` argument is the mock object to configure. If `None` (the default) then a `MagicMock` will be created for you, with the API limited to methods or attributes available on standard file handles. `read_data` is a string for the `read` method of the file handle to return. This is an empty string by default. """ global file_spec if file_spec is None: # set on first use if inPy3k: import _io file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) else: file_spec = file if mock is None: mock = MagicMock(name='open', spec=open) handle = MagicMock(spec=file_spec) handle.write.return_value = None handle.__enter__.return_value = handle handle.read.return_value = read_data mock.return_value = handle return mock class PropertyMock(Mock): """ A mock intended to be used as a property, or other descriptor, on a class. `PropertyMock` provides `__get__` and `__set__` methods so you can specify a return value when it is fetched. Fetching a `PropertyMock` instance from an object calls the mock, with no args. Setting it calls the mock with the value being set. """ def _get_child_mock(self, **kwargs): return MagicMock(**kwargs) def __get__(self, obj, obj_type): return self() def __set__(self, obj, val): self(val)
bsd-3-clause
[ 3, 1683, 14, 647, 199, 3, 1379, 7249, 367, 1683, 316, 436, 3371, 316, 14, 199, 3, 1898, 334, 35, 9, 10219, 13, 7409, 16922, 481, 79, 2181, 1253, 314, 1683, 8099, 199, 3, 662, 13, 1198, 26, 24101, 1237, 15059, 2309, 2638, 15854, 5981, 15854, 399, 75, 199, 199, 3, 1683, 413, 14, 16, 199, 3, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 199, 199, 3, 17646, 68, 5420, 370, 314, 6289, 844, 199, 3, 7754, 1937, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1682, 14, 83, 1360, 199, 199, 3, 14914, 83, 26391, 737, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1080, 14, 83, 1360, 199, 3, 5429, 1470, 12, 18453, 15293, 436, 6519, 13924, 336, 14628, 14, 421, 199, 363, 452, 363, 275, 334, 272, 283, 3346, 297, 272, 283, 11988, 297, 272, 283, 2068, 297, 272, 283, 13400, 297, 272, 283, 3472, 297, 272, 283, 8974, 297, 272, 283, 1250, 297, 272, 283, 981, 63, 22303, 297, 272, 283, 9905, 63, 3022, 297, 272, 283, 6932, 16410, 3346, 297, 272, 283, 6932, 16410, 11988, 297, 272, 283, 1805, 63, 1490, 297, 272, 283, 3697, 3346, 297, 199, 9, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 14, 17, 7, 421, 199, 646, 10933, 199, 646, 984, 199, 199, 893, 26, 272, 492, 6485, 199, 2590, 3545, 26, 272, 327, 367, 13943, 10677, 626, 272, 327, 1443, 440, 1172, 6485, 272, 6485, 275, 488, 199, 199, 893, 26, 272, 687, 9143, 492, 14018, 465, 3379, 63, 13582, 199, 2590, 3545, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 347, 14018, 8, 5043, 304, 267, 347, 6506, 8, 70, 304, 288, 289, 855, 354, 363, 275, 3379, 855, 354, 363, 288, 289, 855, 1301, 363, 275, 3379, 855, 1301, 363, 288, 289, 855, 578, 363, 275, 3379, 855, 578, 363, 288, 289, 855, 9130, 363, 275, 3379, 288, 372, 289, 267, 372, 6506, 199, 2836, 26, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 267, 14018, 275, 3379, 63, 13582, 272, 587, 26, 267, 347, 14018, 8, 1532, 304, 288, 347, 6506, 8, 70, 304, 355, 289, 275, 3379, 63, 13582, 8, 1532, 5130, 70, 9, 355, 289, 855, 9130, 363, 275, 2562, 355, 372, 289, 288, 372, 6506, 199, 199, 893, 26, 272, 2649, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 7116, 275, 2649, 275, 620, 199, 199, 893, 26, 272, 1846, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 1846, 275, 1109, 199, 199, 893, 26, 272, 25416, 199, 2590, 12746, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 25416, 275, 2186, 199, 199, 893, 26, 272, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 1113, 304, 267, 372, 1559, 14, 2184, 342, 421, 199, 1563, 16836, 275, 334, 29900, 4258, 199, 692, 283, 6138, 7, 315, 984, 14, 3246, 26, 272, 327, 1335, 11361, 272, 492, 12120, 272, 3523, 16836, 275, 334, 29900, 12, 12120, 14, 4159, 14, 2719, 1143, 461, 9, 199, 199, 893, 26, 272, 485, 29022, 2841, 275, 620, 14, 29022, 2841, 199, 2590, 4281, 26, 272, 327, 2018, 499, 14, 56, 272, 492, 4252, 272, 492, 295, 272, 5163, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 90, 17900, 65, 13, 90, 16, 13, 25, 15555, 4268, 295, 14, 41, 9, 272, 347, 485, 29022, 2841, 8, 875, 304, 267, 340, 1059, 315, 4252, 14, 829, 513, 26, 288, 372, 756, 267, 372, 5163, 14, 1431, 8, 875, 9, 421, 199, 262, 2713, 19, 75, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 3, 28196, 370, 1736, 6818, 2018, 650, 6519, 2382, 675, 402, 298, 4792, 2, 1640, 771, 470, 543, 199, 3, 12669, 636, 533, 363, 465, 282, 5872, 199, 63, 4792, 275, 1613, 199, 199, 277, 275, 283, 1017, 63, 277, 7, 199, 5351, 275, 2560, 5351, 12217, 199, 692, 315, 2713, 19, 75, 26, 272, 291, 275, 2560, 277, 12217, 272, 6762, 275, 283, 10372, 7, 199, 199, 9905, 63, 3022, 275, 715, 421, 199, 318, 485, 374, 63, 842, 63, 1805, 8, 1113, 304, 272, 327, 883, 1133, 675, 1228, 641, 4420, 2251, 2952, 2985, 4278, 636, 533, 363, 272, 327, 710, 1300, 1021, 367, 1006, 26500, 365, 10172, 16410, 3346, 272, 372, 11602, 8, 466, 8, 1113, 395, 10172, 16410, 3346, 9, 421, 199, 318, 485, 374, 63, 1971, 8, 1113, 304, 272, 372, 334, 267, 1228, 8, 1113, 12, 3523, 16836, 9, 503, 267, 1228, 8, 1113, 12, 8089, 4100, 9, 436, 11602, 8, 1113, 12, 3523, 16836, 9, 272, 776, 421, 199, 533, 485, 7998, 471, 8, 785, 304, 272, 636, 7257, 363, 275, 788, 65, 418, 421, 199, 4311, 4100, 275, 334, 272, 730, 1547, 7998, 471, 14, 65, 395, 272, 3324, 12, 199, 9, 421, 199, 318, 485, 362, 5233, 8, 1532, 12, 3372, 2246, 12, 1256, 29, 797, 304, 272, 340, 6485, 365, 488, 26, 267, 746, 3545, 360, 10955, 859, 440, 2808, 358, 339, 340, 1228, 8, 1532, 12, 8089, 4100, 9, 436, 440, 1256, 26, 267, 862, 26, 288, 2562, 275, 2562, 855, 826, 363, 267, 871, 4281, 26, 288, 372, 267, 3372, 2246, 275, 715, 272, 916, 440, 1228, 8, 1532, 12, 6801, 4100, 304, 267, 327, 367, 3992, 2382, 1256, 365, 715, 781, 1284, 1536, 2348, 4634, 267, 862, 26, 288, 2562, 275, 2562, 855, 1250, 363, 267, 871, 4281, 26, 288, 372, 339, 340, 315, 2713, 19, 75, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 362, 2861, 15644, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027, 826, 363, 288, 372, 267, 1295, 589, 12, 23377, 12, 27835, 12, 4243, 12, 32635, 12, 32635, 318, 12, 21172, 275, 26632, 272, 587, 26, 267, 862, 26, 288, 1295, 589, 12, 23377, 12, 2729, 958, 12, 4243, 275, 6485, 14, 29836, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027 ]
[ 1683, 14, 647, 199, 3, 1379, 7249, 367, 1683, 316, 436, 3371, 316, 14, 199, 3, 1898, 334, 35, 9, 10219, 13, 7409, 16922, 481, 79, 2181, 1253, 314, 1683, 8099, 199, 3, 662, 13, 1198, 26, 24101, 1237, 15059, 2309, 2638, 15854, 5981, 15854, 399, 75, 199, 199, 3, 1683, 413, 14, 16, 199, 3, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 199, 199, 3, 17646, 68, 5420, 370, 314, 6289, 844, 199, 3, 7754, 1937, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1682, 14, 83, 1360, 199, 199, 3, 14914, 83, 26391, 737, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1080, 14, 83, 1360, 199, 3, 5429, 1470, 12, 18453, 15293, 436, 6519, 13924, 336, 14628, 14, 421, 199, 363, 452, 363, 275, 334, 272, 283, 3346, 297, 272, 283, 11988, 297, 272, 283, 2068, 297, 272, 283, 13400, 297, 272, 283, 3472, 297, 272, 283, 8974, 297, 272, 283, 1250, 297, 272, 283, 981, 63, 22303, 297, 272, 283, 9905, 63, 3022, 297, 272, 283, 6932, 16410, 3346, 297, 272, 283, 6932, 16410, 11988, 297, 272, 283, 1805, 63, 1490, 297, 272, 283, 3697, 3346, 297, 199, 9, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 14, 17, 7, 421, 199, 646, 10933, 199, 646, 984, 199, 199, 893, 26, 272, 492, 6485, 199, 2590, 3545, 26, 272, 327, 367, 13943, 10677, 626, 272, 327, 1443, 440, 1172, 6485, 272, 6485, 275, 488, 199, 199, 893, 26, 272, 687, 9143, 492, 14018, 465, 3379, 63, 13582, 199, 2590, 3545, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 347, 14018, 8, 5043, 304, 267, 347, 6506, 8, 70, 304, 288, 289, 855, 354, 363, 275, 3379, 855, 354, 363, 288, 289, 855, 1301, 363, 275, 3379, 855, 1301, 363, 288, 289, 855, 578, 363, 275, 3379, 855, 578, 363, 288, 289, 855, 9130, 363, 275, 3379, 288, 372, 289, 267, 372, 6506, 199, 2836, 26, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 267, 14018, 275, 3379, 63, 13582, 272, 587, 26, 267, 347, 14018, 8, 1532, 304, 288, 347, 6506, 8, 70, 304, 355, 289, 275, 3379, 63, 13582, 8, 1532, 5130, 70, 9, 355, 289, 855, 9130, 363, 275, 2562, 355, 372, 289, 288, 372, 6506, 199, 199, 893, 26, 272, 2649, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 7116, 275, 2649, 275, 620, 199, 199, 893, 26, 272, 1846, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 1846, 275, 1109, 199, 199, 893, 26, 272, 25416, 199, 2590, 12746, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 25416, 275, 2186, 199, 199, 893, 26, 272, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 1113, 304, 267, 372, 1559, 14, 2184, 342, 421, 199, 1563, 16836, 275, 334, 29900, 4258, 199, 692, 283, 6138, 7, 315, 984, 14, 3246, 26, 272, 327, 1335, 11361, 272, 492, 12120, 272, 3523, 16836, 275, 334, 29900, 12, 12120, 14, 4159, 14, 2719, 1143, 461, 9, 199, 199, 893, 26, 272, 485, 29022, 2841, 275, 620, 14, 29022, 2841, 199, 2590, 4281, 26, 272, 327, 2018, 499, 14, 56, 272, 492, 4252, 272, 492, 295, 272, 5163, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 90, 17900, 65, 13, 90, 16, 13, 25, 15555, 4268, 295, 14, 41, 9, 272, 347, 485, 29022, 2841, 8, 875, 304, 267, 340, 1059, 315, 4252, 14, 829, 513, 26, 288, 372, 756, 267, 372, 5163, 14, 1431, 8, 875, 9, 421, 199, 262, 2713, 19, 75, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 3, 28196, 370, 1736, 6818, 2018, 650, 6519, 2382, 675, 402, 298, 4792, 2, 1640, 771, 470, 543, 199, 3, 12669, 636, 533, 363, 465, 282, 5872, 199, 63, 4792, 275, 1613, 199, 199, 277, 275, 283, 1017, 63, 277, 7, 199, 5351, 275, 2560, 5351, 12217, 199, 692, 315, 2713, 19, 75, 26, 272, 291, 275, 2560, 277, 12217, 272, 6762, 275, 283, 10372, 7, 199, 199, 9905, 63, 3022, 275, 715, 421, 199, 318, 485, 374, 63, 842, 63, 1805, 8, 1113, 304, 272, 327, 883, 1133, 675, 1228, 641, 4420, 2251, 2952, 2985, 4278, 636, 533, 363, 272, 327, 710, 1300, 1021, 367, 1006, 26500, 365, 10172, 16410, 3346, 272, 372, 11602, 8, 466, 8, 1113, 395, 10172, 16410, 3346, 9, 421, 199, 318, 485, 374, 63, 1971, 8, 1113, 304, 272, 372, 334, 267, 1228, 8, 1113, 12, 3523, 16836, 9, 503, 267, 1228, 8, 1113, 12, 8089, 4100, 9, 436, 11602, 8, 1113, 12, 3523, 16836, 9, 272, 776, 421, 199, 533, 485, 7998, 471, 8, 785, 304, 272, 636, 7257, 363, 275, 788, 65, 418, 421, 199, 4311, 4100, 275, 334, 272, 730, 1547, 7998, 471, 14, 65, 395, 272, 3324, 12, 199, 9, 421, 199, 318, 485, 362, 5233, 8, 1532, 12, 3372, 2246, 12, 1256, 29, 797, 304, 272, 340, 6485, 365, 488, 26, 267, 746, 3545, 360, 10955, 859, 440, 2808, 358, 339, 340, 1228, 8, 1532, 12, 8089, 4100, 9, 436, 440, 1256, 26, 267, 862, 26, 288, 2562, 275, 2562, 855, 826, 363, 267, 871, 4281, 26, 288, 372, 267, 3372, 2246, 275, 715, 272, 916, 440, 1228, 8, 1532, 12, 6801, 4100, 304, 267, 327, 367, 3992, 2382, 1256, 365, 715, 781, 1284, 1536, 2348, 4634, 267, 862, 26, 288, 2562, 275, 2562, 855, 1250, 363, 267, 871, 4281, 26, 288, 372, 339, 340, 315, 2713, 19, 75, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 362, 2861, 15644, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027, 826, 363, 288, 372, 267, 1295, 589, 12, 23377, 12, 27835, 12, 4243, 12, 32635, 12, 32635, 318, 12, 21172, 275, 26632, 272, 587, 26, 267, 862, 26, 288, 1295, 589, 12, 23377, 12, 2729, 958, 12, 4243, 275, 6485, 14, 29836, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Workday/OpenFrame
third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/protocol-test_wsh.py
108
1907
# Copyright (C) 2009 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import cgi from mod_pywebsocket import msgutil def web_socket_do_extra_handshake(request): r = request.ws_resource.split('?', 1) if len(r) == 1: return param = cgi.parse_qs(r[1]) if 'protocol' in param: request.ws_protocol = param['protocol'][0] def web_socket_transfer_data(request): msgutil.send_message(request, request.ws_protocol)
bsd-3-clause
[ 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 646, 16004, 199, 504, 3413, 63, 21387, 492, 1499, 1974, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 519, 275, 1056, 14, 3569, 63, 1927, 14, 1294, 360, 7044, 413, 9, 272, 340, 822, 8, 82, 9, 508, 413, 26, 267, 372, 272, 1215, 275, 16004, 14, 1122, 63, 6177, 8, 82, 59, 17, 566, 272, 340, 283, 3922, 7, 315, 1215, 26, 267, 1056, 14, 3569, 63, 3922, 275, 1215, 459, 3922, 3488, 16, 61, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1499, 1974, 14, 2254, 63, 1188, 8, 1069, 12, 1056, 14, 3569, 63, 3922, 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 ]
[ 1898, 334, 35, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 646, 16004, 199, 504, 3413, 63, 21387, 492, 1499, 1974, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 519, 275, 1056, 14, 3569, 63, 1927, 14, 1294, 360, 7044, 413, 9, 272, 340, 822, 8, 82, 9, 508, 413, 26, 267, 372, 272, 1215, 275, 16004, 14, 1122, 63, 6177, 8, 82, 59, 17, 566, 272, 340, 283, 3922, 7, 315, 1215, 26, 267, 1056, 14, 3569, 63, 3922, 275, 1215, 459, 3922, 3488, 16, 61, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 1499, 1974, 14, 2254, 63, 1188, 8, 1069, 12, 1056, 14, 3569, 63, 3922, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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__license__ = 'GPL 3' __copyright__ = '2009, John Schember <john@nachtimwald.com>' __docformat__ = 'restructuredtext en' import os, cStringIO from calibre.customize.conversion import (OutputFormatPlugin, OptionRecommendation) from calibre.ptempfile import TemporaryDirectory class PMLOutput(OutputFormatPlugin): name = 'PML Output' author = 'John Schember' file_type = 'pmlz' options = set([ OptionRecommendation(name='pml_output_encoding', recommended_value='cp1252', level=OptionRecommendation.LOW, help=_('Specify the character encoding of the output document. ' \ 'The default is cp1252.')), OptionRecommendation(name='inline_toc', recommended_value=False, level=OptionRecommendation.LOW, help=_('Add Table of Contents to beginning of the book.')), OptionRecommendation(name='full_image_depth', recommended_value=False, level=OptionRecommendation.LOW, help=_('Do not reduce the size or bit depth of images. Images ' \ 'have their size and depth reduced by default to accommodate ' \ 'applications that can not convert images on their ' \ 'own such as Dropbook.')), ]) def convert(self, oeb_book, output_path, input_plugin, opts, log): from calibre.ebooks.pml.pmlml import PMLMLizer from calibre.utils.zipfile import ZipFile with TemporaryDirectory('_pmlz_output') as tdir: pmlmlizer = PMLMLizer(log) pml = unicode(pmlmlizer.extract_content(oeb_book, opts)) with open(os.path.join(tdir, 'index.pml'), 'wb') as out: out.write(pml.encode(opts.pml_output_encoding, 'replace')) img_path = os.path.join(tdir, 'index_img') if not os.path.exists(img_path): os.makedirs(img_path) self.write_images(oeb_book.manifest, pmlmlizer.image_hrefs, img_path, opts) log.debug('Compressing output...') pmlz = ZipFile(output_path, 'w') pmlz.add_dir(tdir) def write_images(self, manifest, image_hrefs, out_dir, opts): try: from PIL import Image Image except ImportError: import Image from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES for item in manifest: if item.media_type in OEB_RASTER_IMAGES and item.href in image_hrefs.keys(): if opts.full_image_depth: im = Image.open(cStringIO.StringIO(item.data)) else: im = Image.open(cStringIO.StringIO(item.data)).convert('P') im.thumbnail((300,300), Image.ANTIALIAS) data = cStringIO.StringIO() im.save(data, 'PNG') data = data.getvalue() path = os.path.join(out_dir, image_hrefs[item.href]) with open(path, 'wb') as out: out.write(data)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 1682, 363, 275, 283, 12006, 650, 7, 199, 363, 7307, 363, 275, 283, 8664, 12, 17815, 428, 595, 976, 665, 20216, 32, 78, 1225, 2906, 20877, 68, 14, 957, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 747, 12, 15073, 199, 199, 504, 19238, 14, 26660, 14, 15083, 492, 334, 2959, 3484, 5061, 12, 267, 3207, 497, 22105, 9, 199, 504, 19238, 14, 80, 17336, 492, 21791, 6231, 199, 199, 533, 27320, 1484, 337, 524, 8, 2959, 3484, 5061, 304, 339, 536, 275, 283, 48, 1698, 7242, 7, 272, 4132, 275, 283, 12923, 428, 595, 976, 7, 272, 570, 63, 466, 275, 283, 80, 757, 90, 7, 339, 1511, 275, 663, 779, 267, 3207, 497, 22105, 8, 354, 534, 80, 757, 63, 1199, 63, 2991, 297, 14318, 63, 585, 534, 1850, 19364, 297, 288, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 17768, 314, 4528, 2644, 402, 314, 1072, 2213, 14, 283, 971, 288, 283, 1918, 849, 365, 7667, 19364, 2659, 395, 267, 3207, 497, 22105, 8, 354, 534, 6460, 63, 13255, 297, 288, 14318, 63, 585, 29, 797, 12, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 1123, 6957, 402, 6646, 83, 370, 9608, 402, 314, 6719, 2659, 395, 267, 3207, 497, 22105, 8, 354, 534, 2861, 63, 1569, 63, 4631, 297, 288, 14318, 63, 585, 29, 797, 12, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 2585, 440, 7114, 314, 1568, 503, 4546, 5818, 402, 5935, 14, 32658, 283, 971, 673, 283, 7804, 3932, 1568, 436, 5818, 14953, 701, 849, 370, 1066, 1404, 364, 323, 283, 971, 673, 283, 15853, 626, 883, 440, 3957, 5935, 641, 3932, 283, 971, 673, 283, 944, 4066, 465, 18110, 2706, 2659, 395, 272, 4794, 339, 347, 3957, 8, 277, 12, 312, 2871, 63, 2706, 12, 1072, 63, 515, 12, 1324, 63, 2718, 12, 3999, 12, 943, 304, 267, 687, 19238, 14, 69, 8858, 14, 80, 757, 14, 80, 757, 757, 492, 510, 1698, 1698, 1793, 267, 687, 19238, 14, 1208, 14, 18717, 492, 26755, 398, 543, 21791, 6231, 6412, 80, 757, 90, 63, 1199, 358, 465, 307, 694, 26, 288, 299, 757, 77, 28952, 275, 510, 1698, 1698, 1793, 8, 793, 9, 288, 299, 757, 275, 2649, 8, 80, 757, 77, 28952, 14, 5005, 63, 1317, 8, 79, 2871, 63, 2706, 12, 3999, 430, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 84, 694, 12, 283, 1080, 14, 80, 757, 659, 283, 6603, 358, 465, 734, 26, 355, 734, 14, 952, 8, 80, 757, 14, 2143, 8, 3291, 14, 80, 757, 63, 1199, 63, 2991, 12, 283, 1814, 1333, 953, 6050, 63, 515, 275, 747, 14, 515, 14, 904, 8, 84, 694, 12, 283, 1080, 63, 4060, 358, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 4060, 63, 515, 304, 355, 747, 14, 8347, 8, 4060, 63, 515, 9, 288, 291, 14, 952, 63, 4782, 8, 79, 2871, 63, 2706, 14, 6418, 12, 299, 757, 77, 28952, 14, 1569, 63, 6399, 83, 12, 6050, 63, 515, 12, 3999, 9, 953, 943, 14, 1757, 360, 2404, 753, 316, 1072, 15103, 288, 299, 757, 90, 275, 26755, 8, 1199, 63, 515, 12, 283, 87, 358, 288, 299, 757, 90, 14, 525, 63, 694, 8, 84, 694, 9, 339, 347, 2218, 63, 4782, 8, 277, 12, 7712, 12, 1834, 63, 6399, 83, 12, 734, 63, 694, 12, 3999, 304, 267, 862, 26, 288, 687, 14937, 492, 6047, 288, 6047, 267, 871, 3545, 26, 288, 492, 6047, 7318, 687, 19238, 14, 69, 8858, 14, 79, 2871, 14, 1095, 492, 593, 14138, 63, 2847, 14471, 63, 1469, 5383, 267, 367, 1242, 315, 7712, 26, 288, 340, 1242, 14, 4603, 63, 466, 315, 593, 14138, 63, 2847, 14471, 63, 1469, 5383, 436, 1242, 14, 6399, 315, 1834, 63, 6399, 83, 14, 1612, 837, 355, 340, 3999, 14, 2861, 63, 1569, 63, 4631, 26, 490, 3416, 275, 6047, 14, 1490, 8, 67, 6424, 14, 6424, 8, 1053, 14, 576, 430, 355, 587, 26, 490, 3416, 275, 6047, 14, 1490, 8, 67, 6424, 14, 6424, 8, 1053, 14, 576, 4992, 3916, 360, 48, 358, 490, 3416, 14, 8311, 1332, 5863, 12, 5863, 395, 6047, 14, 1441, 4938, 11352, 9, 2234, 666, 275, 15073, 14, 6424, 342, 355, 3416, 14, 2117, 8, 576, 12, 283, 24454, 358, 355, 666, 275, 666, 14, 7150, 342, 2234, 931, 275, 747, 14, 515, 14, 904, 8, 548, 63, 694, 12, 1834, 63, 6399, 83, 59, 1053, 14, 6399, 566, 2234, 543, 1551, 8, 515, 12, 283, 6603, 358, 465, 734, 26, 490, 734, 14, 952, 8, 576, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 1682, 363, 275, 283, 12006, 650, 7, 199, 363, 7307, 363, 275, 283, 8664, 12, 17815, 428, 595, 976, 665, 20216, 32, 78, 1225, 2906, 20877, 68, 14, 957, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 646, 747, 12, 15073, 199, 199, 504, 19238, 14, 26660, 14, 15083, 492, 334, 2959, 3484, 5061, 12, 267, 3207, 497, 22105, 9, 199, 504, 19238, 14, 80, 17336, 492, 21791, 6231, 199, 199, 533, 27320, 1484, 337, 524, 8, 2959, 3484, 5061, 304, 339, 536, 275, 283, 48, 1698, 7242, 7, 272, 4132, 275, 283, 12923, 428, 595, 976, 7, 272, 570, 63, 466, 275, 283, 80, 757, 90, 7, 339, 1511, 275, 663, 779, 267, 3207, 497, 22105, 8, 354, 534, 80, 757, 63, 1199, 63, 2991, 297, 14318, 63, 585, 534, 1850, 19364, 297, 288, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 17768, 314, 4528, 2644, 402, 314, 1072, 2213, 14, 283, 971, 288, 283, 1918, 849, 365, 7667, 19364, 2659, 395, 267, 3207, 497, 22105, 8, 354, 534, 6460, 63, 13255, 297, 288, 14318, 63, 585, 29, 797, 12, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 1123, 6957, 402, 6646, 83, 370, 9608, 402, 314, 6719, 2659, 395, 267, 3207, 497, 22105, 8, 354, 534, 2861, 63, 1569, 63, 4631, 297, 288, 14318, 63, 585, 29, 797, 12, 2166, 29, 2602, 497, 22105, 14, 5896, 12, 288, 1720, 12397, 2585, 440, 7114, 314, 1568, 503, 4546, 5818, 402, 5935, 14, 32658, 283, 971, 673, 283, 7804, 3932, 1568, 436, 5818, 14953, 701, 849, 370, 1066, 1404, 364, 323, 283, 971, 673, 283, 15853, 626, 883, 440, 3957, 5935, 641, 3932, 283, 971, 673, 283, 944, 4066, 465, 18110, 2706, 2659, 395, 272, 4794, 339, 347, 3957, 8, 277, 12, 312, 2871, 63, 2706, 12, 1072, 63, 515, 12, 1324, 63, 2718, 12, 3999, 12, 943, 304, 267, 687, 19238, 14, 69, 8858, 14, 80, 757, 14, 80, 757, 757, 492, 510, 1698, 1698, 1793, 267, 687, 19238, 14, 1208, 14, 18717, 492, 26755, 398, 543, 21791, 6231, 6412, 80, 757, 90, 63, 1199, 358, 465, 307, 694, 26, 288, 299, 757, 77, 28952, 275, 510, 1698, 1698, 1793, 8, 793, 9, 288, 299, 757, 275, 2649, 8, 80, 757, 77, 28952, 14, 5005, 63, 1317, 8, 79, 2871, 63, 2706, 12, 3999, 430, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 84, 694, 12, 283, 1080, 14, 80, 757, 659, 283, 6603, 358, 465, 734, 26, 355, 734, 14, 952, 8, 80, 757, 14, 2143, 8, 3291, 14, 80, 757, 63, 1199, 63, 2991, 12, 283, 1814, 1333, 953, 6050, 63, 515, 275, 747, 14, 515, 14, 904, 8, 84, 694, 12, 283, 1080, 63, 4060, 358, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 4060, 63, 515, 304, 355, 747, 14, 8347, 8, 4060, 63, 515, 9, 288, 291, 14, 952, 63, 4782, 8, 79, 2871, 63, 2706, 14, 6418, 12, 299, 757, 77, 28952, 14, 1569, 63, 6399, 83, 12, 6050, 63, 515, 12, 3999, 9, 953, 943, 14, 1757, 360, 2404, 753, 316, 1072, 15103, 288, 299, 757, 90, 275, 26755, 8, 1199, 63, 515, 12, 283, 87, 358, 288, 299, 757, 90, 14, 525, 63, 694, 8, 84, 694, 9, 339, 347, 2218, 63, 4782, 8, 277, 12, 7712, 12, 1834, 63, 6399, 83, 12, 734, 63, 694, 12, 3999, 304, 267, 862, 26, 288, 687, 14937, 492, 6047, 288, 6047, 267, 871, 3545, 26, 288, 492, 6047, 7318, 687, 19238, 14, 69, 8858, 14, 79, 2871, 14, 1095, 492, 593, 14138, 63, 2847, 14471, 63, 1469, 5383, 267, 367, 1242, 315, 7712, 26, 288, 340, 1242, 14, 4603, 63, 466, 315, 593, 14138, 63, 2847, 14471, 63, 1469, 5383, 436, 1242, 14, 6399, 315, 1834, 63, 6399, 83, 14, 1612, 837, 355, 340, 3999, 14, 2861, 63, 1569, 63, 4631, 26, 490, 3416, 275, 6047, 14, 1490, 8, 67, 6424, 14, 6424, 8, 1053, 14, 576, 430, 355, 587, 26, 490, 3416, 275, 6047, 14, 1490, 8, 67, 6424, 14, 6424, 8, 1053, 14, 576, 4992, 3916, 360, 48, 358, 490, 3416, 14, 8311, 1332, 5863, 12, 5863, 395, 6047, 14, 1441, 4938, 11352, 9, 2234, 666, 275, 15073, 14, 6424, 342, 355, 3416, 14, 2117, 8, 576, 12, 283, 24454, 358, 355, 666, 275, 666, 14, 7150, 342, 2234, 931, 275, 747, 14, 515, 14, 904, 8, 548, 63, 694, 12, 1834, 63, 6399, 83, 59, 1053, 14, 6399, 566, 2234, 543, 1551, 8, 515, 12, 283, 6603, 358, 465, 734, 26, 490, 734, 14, 952, 8, 576, 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, 0 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0, 0 ]
wgapl/moose
framework/contrib/nsiqcppstyle/rules/RULE_4_5_A_indent_blocks_inside_of_function.py
43
2715
""" Indent blocks inside of function. == Violation == void A() { for (;;) <== Violation { } } void K() { <== Don't care. It's not the block inside of the function. if (true) { if (KK) { AA; <== Violation } } switch(TT) { case WEWE: <== Violation WOW; } } == Good == void K() { if (true) { if (KK) { <== OK AA; <== OK } } switch(TT) { <== OK case WEWE: <== OK WOW; } } """ from nsiqcppstyle_reporter import * from nsiqcppstyle_rulemanager import * from nsiqcppstyle_rulehelper import * def RunRule(lexer, contextStack) : t = lexer.GetCurToken() if t.type == "LBRACE" and t.pp == None : column = GetIndentation(t) t2 = lexer.GetNextMatchingToken(True) if t2 != None and t.lineno != t2.lineno : nt = lexer.GetNextTokenSkipWhiteSpaceAndCommentAndPreprocess() if nt != None and nt != t2 and nt.type not in ("LBRACE", "RBRACE") and GetIndentation(nt) <= column : nsiqcppstyle_reporter.Error(nt, __name__, "Indent in the block. token(%s) seems to be located left column of previsous brace" % nt.value ) ruleManager.AddFunctionScopeRule(RunRule) ########################################################################################### # Unit Test ########################################################################################### from nsiqunittest.nsiqcppstyle_unittestbase import * class testRule(nct): def setUpRule(self): ruleManager.AddFunctionScopeRule(RunRule) def test1(self): self.Analyze("thisfile.c",""" void function() { for (;;) { } } """) assert CheckErrorContent(__name__) def test2(self): self.Analyze("thisfile.c",""" void function() { a = { } } """) assert CheckErrorContent(__name__) def test3(self): self.Analyze("thisfile.c",""" void function() { a = { } while(True) { tt { } } k = {} } """) assert CheckErrorContent(__name__) def test4(self): self.Analyze("thisfile.c",""" void function() { a = { } while(True) { } } """) assert not CheckErrorContent(__name__) def test5(self): self.Analyze("thisfile.c",""" void function() { a = { dsdsd} } """) assert not CheckErrorContent(__name__) def test6(self): self.Analyze("thisfile.c",""" #define AA(p, t) \ do {\ aa = e; } while(0) """) assert not CheckErrorContent(__name__)
lgpl-2.1
[ 624, 199, 7583, 5664, 6272, 402, 805, 14, 199, 199, 389, 6561, 10410, 508, 339, 2309, 437, 342, 469, 272, 367, 334, 15661, 9, 665, 389, 6561, 10410, 267, 469, 267, 789, 272, 789, 339, 2309, 1804, 342, 272, 469, 221, 665, 389, 7529, 1133, 10296, 14, 2779, 1159, 440, 314, 1853, 6272, 402, 314, 805, 14, 267, 340, 334, 2052, 9, 267, 469, 288, 340, 334, 27511, 9, 469, 288, 437, 33, 27, 665, 389, 6561, 10410, 288, 789, 267, 789, 398, 6258, 8, 1481, 9, 469, 267, 1930, 644, 37, 5408, 26, 665, 389, 6561, 10410, 288, 644, 19716, 27, 267, 789, 272, 789, 199, 199, 389, 22311, 508, 339, 2309, 1804, 342, 272, 469, 267, 340, 334, 2052, 9, 267, 469, 288, 340, 334, 27511, 9, 469, 665, 389, 9949, 355, 437, 33, 27, 257, 665, 389, 9949, 288, 789, 267, 789, 398, 6258, 8, 1481, 9, 469, 257, 665, 389, 9949, 288, 1930, 644, 37, 5408, 26, 665, 389, 9949, 355, 644, 19716, 27, 267, 789, 272, 789, 199, 199, 624, 199, 199, 504, 302, 338, 81, 5910, 2487, 63, 12222, 492, 627, 199, 504, 302, 338, 81, 5910, 2487, 63, 2200, 2609, 492, 627, 199, 504, 302, 338, 81, 5910, 2487, 63, 2200, 3676, 492, 627, 199, 199, 318, 3378, 5065, 8, 11729, 12, 1067, 4851, 9, 520, 272, 307, 275, 10426, 14, 1002, 3864, 3264, 342, 272, 340, 307, 14, 466, 508, 298, 44, 29246, 2, 436, 307, 14, 802, 508, 488, 520, 267, 2763, 275, 2372, 7583, 425, 8, 84, 9, 267, 307, 18, 275, 10426, 14, 20079, 14215, 3264, 8, 549, 9, 267, 340, 307, 18, 1137, 488, 436, 307, 14, 3469, 1137, 307, 18, 14, 3469, 520, 288, 13377, 275, 10426, 14, 20079, 3264, 7738, 19803, 7643, 3325, 7488, 3325, 26539, 342, 288, 340, 13377, 1137, 488, 436, 13377, 1137, 307, 18, 436, 13377, 14, 466, 440, 315, 1689, 44, 29246, 401, 298, 50, 29246, 531, 436, 2372, 7583, 425, 8, 343, 9, 2695, 2763, 520, 355, 302, 338, 81, 5910, 2487, 63, 12222, 14, 547, 8, 343, 12, 636, 354, 3108, 1993, 298, 7583, 315, 314, 1853, 14, 1526, 4042, 83, 9, 12237, 370, 506, 16180, 3602, 2763, 402, 876, 5068, 1785, 23549, 2, 450, 13377, 14, 585, 776, 199, 199, 2200, 2988, 14, 1123, 3481, 7812, 5065, 8, 2540, 5065, 9, 6905, 199, 3060, 6565, 5680, 199, 3, 12008, 1379, 199, 3060, 6565, 5680, 199, 199, 504, 302, 338, 81, 2796, 14, 78, 338, 81, 5910, 2487, 63, 2796, 1095, 492, 627, 199, 199, 533, 511, 5065, 8, 78, 319, 304, 272, 347, 3613, 5065, 8, 277, 304, 267, 2332, 2988, 14, 1123, 3481, 7812, 5065, 8, 2540, 5065, 9, 272, 347, 511, 17, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 199, 509, 334, 15661, 9, 469, 199, 93, 199, 93, 199, 6141, 267, 702, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 18, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 199, 65, 275, 469, 199, 93, 199, 93, 199, 6141, 267, 702, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 19, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 267, 789, 272, 1830, 8, 549, 9, 272, 469, 272, 13638, 469, 272, 789, 272, 789, 272, 1022, 275, 1052, 199, 93, 199, 6141, 267, 702, 221, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 20, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 267, 789, 272, 1830, 8, 549, 9, 272, 469, 272, 789, 199, 93, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 21, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 6364, 795, 68, 93, 199, 93, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 3368, 339, 347, 511, 22, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 3, 4640, 437, 33, 8, 80, 12, 307, 9, 971, 199, 1117, 9459, 199, 2158, 275, 325, 27, 199, 93, 1830, 8, 16, 9, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 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 ]
[ 199, 7583, 5664, 6272, 402, 805, 14, 199, 199, 389, 6561, 10410, 508, 339, 2309, 437, 342, 469, 272, 367, 334, 15661, 9, 665, 389, 6561, 10410, 267, 469, 267, 789, 272, 789, 339, 2309, 1804, 342, 272, 469, 221, 665, 389, 7529, 1133, 10296, 14, 2779, 1159, 440, 314, 1853, 6272, 402, 314, 805, 14, 267, 340, 334, 2052, 9, 267, 469, 288, 340, 334, 27511, 9, 469, 288, 437, 33, 27, 665, 389, 6561, 10410, 288, 789, 267, 789, 398, 6258, 8, 1481, 9, 469, 267, 1930, 644, 37, 5408, 26, 665, 389, 6561, 10410, 288, 644, 19716, 27, 267, 789, 272, 789, 199, 199, 389, 22311, 508, 339, 2309, 1804, 342, 272, 469, 267, 340, 334, 2052, 9, 267, 469, 288, 340, 334, 27511, 9, 469, 665, 389, 9949, 355, 437, 33, 27, 257, 665, 389, 9949, 288, 789, 267, 789, 398, 6258, 8, 1481, 9, 469, 257, 665, 389, 9949, 288, 1930, 644, 37, 5408, 26, 665, 389, 9949, 355, 644, 19716, 27, 267, 789, 272, 789, 199, 199, 624, 199, 199, 504, 302, 338, 81, 5910, 2487, 63, 12222, 492, 627, 199, 504, 302, 338, 81, 5910, 2487, 63, 2200, 2609, 492, 627, 199, 504, 302, 338, 81, 5910, 2487, 63, 2200, 3676, 492, 627, 199, 199, 318, 3378, 5065, 8, 11729, 12, 1067, 4851, 9, 520, 272, 307, 275, 10426, 14, 1002, 3864, 3264, 342, 272, 340, 307, 14, 466, 508, 298, 44, 29246, 2, 436, 307, 14, 802, 508, 488, 520, 267, 2763, 275, 2372, 7583, 425, 8, 84, 9, 267, 307, 18, 275, 10426, 14, 20079, 14215, 3264, 8, 549, 9, 267, 340, 307, 18, 1137, 488, 436, 307, 14, 3469, 1137, 307, 18, 14, 3469, 520, 288, 13377, 275, 10426, 14, 20079, 3264, 7738, 19803, 7643, 3325, 7488, 3325, 26539, 342, 288, 340, 13377, 1137, 488, 436, 13377, 1137, 307, 18, 436, 13377, 14, 466, 440, 315, 1689, 44, 29246, 401, 298, 50, 29246, 531, 436, 2372, 7583, 425, 8, 343, 9, 2695, 2763, 520, 355, 302, 338, 81, 5910, 2487, 63, 12222, 14, 547, 8, 343, 12, 636, 354, 3108, 1993, 298, 7583, 315, 314, 1853, 14, 1526, 4042, 83, 9, 12237, 370, 506, 16180, 3602, 2763, 402, 876, 5068, 1785, 23549, 2, 450, 13377, 14, 585, 776, 199, 199, 2200, 2988, 14, 1123, 3481, 7812, 5065, 8, 2540, 5065, 9, 6905, 199, 3060, 6565, 5680, 199, 3, 12008, 1379, 199, 3060, 6565, 5680, 199, 199, 504, 302, 338, 81, 2796, 14, 78, 338, 81, 5910, 2487, 63, 2796, 1095, 492, 627, 199, 199, 533, 511, 5065, 8, 78, 319, 304, 272, 347, 3613, 5065, 8, 277, 304, 267, 2332, 2988, 14, 1123, 3481, 7812, 5065, 8, 2540, 5065, 9, 272, 347, 511, 17, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 199, 509, 334, 15661, 9, 469, 199, 93, 199, 93, 199, 6141, 267, 702, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 18, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 199, 65, 275, 469, 199, 93, 199, 93, 199, 6141, 267, 702, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 19, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 267, 789, 272, 1830, 8, 549, 9, 272, 469, 272, 13638, 469, 272, 789, 272, 789, 272, 1022, 275, 1052, 199, 93, 199, 6141, 267, 702, 221, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 20, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 267, 789, 272, 1830, 8, 549, 9, 272, 469, 272, 789, 199, 93, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 3368, 272, 347, 511, 21, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 1647, 805, 342, 469, 272, 282, 275, 469, 6364, 795, 68, 93, 199, 93, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 3368, 339, 347, 511, 22, 8, 277, 304, 267, 291, 14, 8014, 806, 480, 3749, 493, 14, 67, 401, 624, 199, 3, 4640, 437, 33, 8, 80, 12, 307, 9, 971, 199, 1117, 9459, 199, 2158, 275, 325, 27, 199, 93, 1830, 8, 16, 9, 199, 6141, 267, 702, 440, 2670, 547, 2714, 3460, 354, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
apache/airflow
airflow/migrations/versions/a13f7613ad25_resource_based_permissions_for_default_.py
2
6614
# # 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. """Resource based permissions for default FAB views. Revision ID: a13f7613ad25 Revises: e165e7455d70 Create Date: 2021-03-20 21:23:05.793378 """ import logging from airflow.security import permissions from airflow.www.app import create_app # revision identifiers, used by Alembic. revision = 'a13f7613ad25' down_revision = 'e165e7455d70' branch_labels = None depends_on = None mapping = { ("PermissionModelView", "can_list"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_PERMISSION), ], ("PermissionViewModelView", "can_list"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_PERMISSION_VIEW), ], ("ResetMyPasswordView", "can_this_form_get"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PASSWORD), ], ("ResetMyPasswordView", "can_this_form_post"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_MY_PASSWORD), ], ("ResetPasswordView", "can_this_form_get"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_PASSWORD), ], ("ResetPasswordView", "can_this_form_post"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_PASSWORD), ], ("RoleModelView", "can_delete"): [ (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_download"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_show"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_list"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_edit"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_add"): [ (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_ROLE), ], ("RoleModelView", "can_copyrole"): [ (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_ROLE), ], ("ViewMenuModelView", "can_list"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "can_add"): [ (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "can_userinfo"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("UserDBModelView", "can_download"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "can_show"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "can_list"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "can_edit"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_VIEW_MENU), ], ("UserDBModelView", "resetmypassword"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PASSWORD), ], ("UserDBModelView", "resetpasswords"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_PASSWORD), ], ("UserDBModelView", "userinfoedit"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_MY_PROFILE), ], ("UserDBModelView", "can_delete"): [ (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_VIEW_MENU), ], ("UserInfoEditView", "can_this_form_get"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("UserInfoEditView", "can_this_form_post"): [ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_MY_PROFILE), ], ("UserStatsChartView", "can_chart"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_USER_STATS_CHART), ], ("UserLDAPModelView", "can_userinfo"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("UserOAuthModelView", "can_userinfo"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("UserOIDModelView", "can_userinfo"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("UserRemoteUserModelView", "can_userinfo"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE), ], ("DagRunModelView", "can_clear"): [ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_TASK_INSTANCE), ], } def remap_permissions(): """Apply Map Airflow permissions.""" appbuilder = create_app(config={'FAB_UPDATE_PERMS': False}).appbuilder for old, new in mapping.items(): (old_resource_name, old_action_name) = old old_permission = appbuilder.sm.get_permission(old_action_name, old_resource_name) if not old_permission: continue for new_action_name, new_resource_name in new: new_permission = appbuilder.sm.create_permission(new_action_name, new_resource_name) for role in appbuilder.sm.get_all_roles(): if appbuilder.sm.exist_permission_on_roles(old_resource_name, old_action_name, [role.id]): appbuilder.sm.add_permission_to_role(role, new_permission) appbuilder.sm.remove_permission_from_role(role, old_permission) appbuilder.sm.delete_permission(old_action_name, old_resource_name) if not appbuilder.sm.get_action(old_action_name): continue resources = appbuilder.sm.get_all_resources() if not any(appbuilder.sm.get_permission(old_action_name, resource.name) for resource in resources): appbuilder.sm.delete_action(old_action_name) def upgrade(): """Apply Resource based permissions.""" log = logging.getLogger() handlers = log.handlers[:] remap_permissions() log.handlers = handlers def downgrade(): """Unapply Resource based permissions.""" pass
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 4031, 4079, 3443, 367, 849, 481, 1217, 6858, 14, 199, 199, 12714, 2870, 26, 282, 969, 70, 2114, 969, 350, 821, 199, 497, 433, 874, 26, 325, 10355, 69, 1342, 1229, 68, 2760, 199, 2499, 6148, 26, 499, 15385, 13, 1644, 13, 1165, 7829, 26, 1789, 26, 1717, 14, 1965, 1153, 2277, 199, 199, 624, 199, 646, 2050, 199, 199, 504, 16321, 14, 4416, 492, 3443, 199, 504, 16321, 14, 1544, 14, 571, 492, 1218, 63, 571, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 65, 969, 70, 2114, 969, 350, 821, 7, 199, 2110, 63, 5792, 275, 283, 69, 10355, 69, 1342, 1229, 68, 2760, 7, 199, 4694, 63, 3512, 275, 488, 199, 8912, 63, 265, 275, 488, 421, 199, 4745, 275, 469, 272, 1689, 7980, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 4227, 22320, 395, 272, 2156, 272, 1689, 7980, 2768, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 4227, 22320, 63, 12058, 395, 272, 2156, 272, 1689, 9637, 5713, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 362, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 5713, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 1932, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 362, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 1932, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 9032, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 1807, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 7014, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 4249, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 2384, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 3773, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 525, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 1574, 3756, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 2768, 5977, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 525, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 751, 815, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 16632, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 4249, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 2384, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 3773, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 3958, 1662, 2060, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 3958, 28608, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 624, 4031, 4079, 3443, 367, 849, 481, 1217, 6858, 14, 199, 199, 12714, 2870, 26, 282, 969, 70, 2114, 969, 350, 821, 199, 497, 433, 874, 26, 325, 10355, 69, 1342, 1229, 68, 2760, 199, 2499, 6148, 26, 499, 15385, 13, 1644, 13, 1165, 7829, 26, 1789, 26, 1717, 14, 1965, 1153, 2277, 199, 199, 624, 199, 646, 2050, 199, 199, 504, 16321, 14, 4416, 492, 3443, 199, 504, 16321, 14, 1544, 14, 571, 492, 1218, 63, 571, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 65, 969, 70, 2114, 969, 350, 821, 7, 199, 2110, 63, 5792, 275, 283, 69, 10355, 69, 1342, 1229, 68, 2760, 7, 199, 4694, 63, 3512, 275, 488, 199, 8912, 63, 265, 275, 488, 421, 199, 4745, 275, 469, 272, 1689, 7980, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 4227, 22320, 395, 272, 2156, 272, 1689, 7980, 2768, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 4227, 22320, 63, 12058, 395, 272, 2156, 272, 1689, 9637, 5713, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 362, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 5713, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 1932, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 362, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 9032, 395, 272, 2156, 272, 1689, 9637, 6139, 2768, 401, 298, 2425, 63, 3749, 63, 964, 63, 1932, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 9032, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 1807, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 7014, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 4249, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 2384, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 3773, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 525, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 7422, 1685, 2768, 401, 298, 2425, 63, 1574, 3756, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 15468, 395, 272, 2156, 272, 1689, 2768, 5977, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 525, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 8366, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 751, 815, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 16632, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 4249, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 2384, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 513, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 2425, 63, 3773, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 17929, 12, 3443, 14, 14110, 63, 12058, 63, 18223, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 3958, 1662, 2060, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 63, 12339, 63, 9032, 395, 272, 2156, 272, 1689, 1899, 2846, 1685, 2768, 401, 298, 3958, 28608, 2349, 359, 267, 334, 6060, 14, 10052, 63, 18988, 63, 5670, 12, 3443, 14, 14110, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Jonathan727/javarosa
util/scripts/rmsdump.py
6
7565
# Copyright (C) 2009 JavaRosa # # 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 sys from recparse import * #parse the data stream from the dump file into a structure representing all RMSes and records, accounting for any errors in the stream #returns tuple ( # list of rms -- in order encountered in stream, # number of expected rms -- None if couldn't be read, # whether error was encountered in the stream # ) # where 'rms' is dict { # 'name': RMS name -- None if unreadable, # 'size': expected number of records -- None if unreadable, # 'records': list of records -- in order encountered in stream -- empty list if no records or could not # read any records # } # where 'record' is dict { # 'id': record ID -- None if unreadable, # 'len': expected length of data -- None if unreadable, # 'data': raw content of record as a string -- None if could not read ID or data length, partial data # if stream terminated while reading -- may be empty string, # 'status': status of record, # 'content': parsed data content of the record (if status is 'ok', unset otherwise) (still working out the details of this) # } # where 'status' is one of: # 'ok' if record is intact # None if ID not readable # 'data not read' if ID was readable but stream terminated before getting to this record's data (error # occured in a different record) # 'corrupt length <list of 'length' bytes read>' if could not read data length # 'partial data' if stream terminated before expected length of data was read # where 'content' is tuple ( # (still working out the details of this -- for now it's a Datum) # ) def extract_rms (stream): rmses = [] num_rms = None err = False try: num_rms = stream.read_int(True).val for i in range(0, num_rms): rms = {'name': None, 'size': None, 'records': []} rmses.append(rms) rmsname = stream.read_string().val rms['name'] = rmsname num_recs = stream.read_int(True).val rms['size'] = num_recs for j in range(0, num_recs): rec = {'id': None, 'len': None, 'data': None, 'status': None} rms['records'].append(rec) id = stream.read_int().val rec['id'] = id rec['status'] = 'data not read' for rec in rms['records']: try: rec['len'] = stream.read_int(True).val except Stream.EndOfStream, eos: rec['status'] = 'corrupt length %s' % eos.bytes raise except ValueError: rec['status'] = 'corrupt length' raise try: rec['data'] = stream.read(rec['len']) rec['status'] = 'ok' rec['content'] = get_record_content(rec['data'], rec['id'], rms['name']) except Stream.EndOfStream, eos: rec['status'] = 'partial data' rec['data'] = ''.join(eos.bytes) raise except (Stream.EndOfStream, ValueError): err = True return (rmses, num_rms, err) def get_unique (l, key, val, type): matches = filter(lambda x: x[key] == val, l) if not matches: print 'No %s %s' % (type, val) return None if len(matches) > 1: print 'Warning: more than one %s %s' % (type, val) return matches[0] rms_types = { 'USER': 'user', 'CASE': 'case', 'PAT_REFERRAL': 'patref', 'FORMDEF': 'formdef', 'FORMDATA': 'forminst', 'PROPERTY': 'property', 'LOG': 'logentry', 'JavaROSATransQ': 'txmsg', 'JavaROSATransQSent': 'txmsg', 'FORMS_RECD': 'cc-recd-forms-mapping' } def get_record_content (bytes, rec_id, rms_name): type = None if rms_name.endswith('_IX'): if rec_id == 1: type = 'bool' elif rec_id == 2: type = 'obj:rmsinfo' elif rec_id == 3: type = 'map(int,obj:recloc)' elif rec_id == 4: type = 'none' elif len(rms_name) > 3 and rms_name[-3] == '_': basename = rms_name[:-3] if basename in rms_types: type = 'obj:' + rms_types[basename] if type == None: return ('unknown', None) elif type == 'none': return None else: try: return ('ok', deserialize(bytes, type)) except Exception, e: return ('error', e) #ok #deserialization error #ok, but extra bytes #unexpected exception #return the raw byte data content for a given RMS record; pass in the parsed RMS structure, RMS name, and record ID def get_record (rmses, name, id): rms = get_unique(rmses, 'name', name, 'RMS') if not rms: return None rec = get_unique(rms['records'], 'id', id, 'record with ID') if not rec: return None if rec['status'] != 'ok': print 'Warning: record is corrupt' return rec['data'] def format_bytes (data, indent=4): strs = [' ' * indent] for (i, c) in enumerate(data): hx = '%02x' % ord(c) if i > 0: if i % 30 == 0: if (i + 15) % 1024 < 30: strs.append('\n') strs.append('\n' + ' ' * indent) elif i % 10 == 0: strs.append(' ') else: strs.append(' ') strs.append(hx) return ''.join(strs) def coalesce (val, fallback): return val if val != None else fallback #pretty print the contents of all RMSes def print_contents (dlen, rmses, num_rms, err): print 'Data length: %d' % dlen if num_rms != None: print '%d RMSes %s' % (num_rms, '(only %d recovered)' % len(rmses) if len(rmses) < num_rms else '') else: print '? RMSes' for rms in rmses: print '=== %s ===' % coalesce(rms['name'], '[no name]') if rms['size'] != None: print 'Records: %d %s' % (rms['size'], '(only %d recovered)' % len(rms['records']) if len(rms['records']) < rms['size'] else '') else: print 'Records: [no size]' for rec in rms['records']: print ' ID: %s' % coalesce(rec['id'], '[no id]') if rec['status']: if rec['status'] != 'ok': print ' Status: %s' % rec['status'] if rec['len'] != None: print ' Data: %d bytes %s' % (len(rec['data']), '(expected %d)' % rec['len'] if len(rec['data']) < rec['len'] else '') if rec['data']: print format_bytes(rec['data']) if rec['content'] != None: if rec['content'][0] == 'ok': print ' Content:\n' + rec['content'][1].pretty_print(2, False, True) elif rec['content'][0] == 'error': print ' Content: error deserializing: %s' % str(rec['content'][1]) elif rec['content'][0] == 'unknown': print ' Content: don\'t know record format' print else: print ' Data: [no data]' print print if err: print 'ERROR in dump' if __name__ == "__main__": data = sys.stdin.read() stream = DataStream(data) (rmses, num_rms, err) = extract_rms(stream) print_contents(len(data), rmses, num_rms, err)
apache-2.0
[ 3, 1898, 334, 35, 9, 8937, 9586, 50, 29295, 202, 199, 3, 20712, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 202, 199, 3, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 282, 1331, 402, 202, 199, 3, 314, 844, 737, 202, 199, 3, 20712, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 3, 20712, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 202, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 202, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 1334, 202, 199, 3, 314, 844, 14, 2999, 199, 646, 984, 202, 199, 504, 6488, 1122, 492, 627, 2999, 199, 3, 1122, 314, 666, 2547, 687, 314, 5461, 570, 1901, 282, 5523, 6144, 1006, 820, 3053, 397, 436, 5767, 12, 24772, 367, 1263, 2552, 315, 314, 2547, 202, 199, 3, 5808, 2008, 334, 202, 199, 3, 259, 769, 402, 32205, 1553, 315, 1865, 14556, 315, 2547, 12, 202, 199, 3, 259, 1329, 402, 1420, 32205, 1553, 488, 340, 21554, 1133, 506, 1586, 12, 202, 199, 3, 259, 3775, 1125, 1990, 14556, 315, 314, 2547, 202, 199, 3, 221, 776, 20712, 199, 3, 221, 2382, 283, 24444, 7, 365, 1211, 469, 202, 199, 3, 259, 283, 354, 356, 820, 3053, 536, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 890, 356, 1420, 1329, 402, 5767, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 6502, 356, 769, 402, 5767, 1553, 315, 1865, 14556, 315, 2547, 1553, 2701, 769, 340, 949, 5767, 503, 4293, 440, 202, 199, 3, 5185, 1586, 1263, 5767, 202, 199, 3, 221, 789, 202, 199, 3, 221, 2382, 283, 3059, 7, 365, 1211, 469, 202, 199, 3, 259, 283, 344, 356, 2777, 2870, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 552, 356, 1420, 2582, 402, 666, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 576, 356, 3066, 1564, 402, 2777, 465, 282, 1059, 1553, 488, 340, 4293, 440, 1586, 2870, 503, 666, 2582, 12, 7417, 666, 202, 199, 3, 3322, 340, 2547, 15745, 1830, 7664, 1553, 1443, 506, 2701, 1059, 12, 202, 199, 3, 259, 283, 1205, 356, 2004, 402, 2777, 12, 202, 199, 3, 259, 283, 1317, 356, 4565, 666, 1564, 402, 314, 2777, 334, 692, 2004, 365, 283, 745, 297, 15376, 4257, 9, 334, 32310, 6449, 734, 314, 2436, 402, 642, 9, 202, 199, 3, 221, 789, 202, 199, 3, 221, 2382, 283, 1205, 7, 365, 1373, 402, 26, 202, 199, 3, 259, 283, 745, 7, 340, 2777, 365, 315, 4552, 202, 199, 3, 259, 488, 340, 2870, 440, 12701, 202, 199, 3, 259, 283, 576, 440, 1586, 7, 340, 2870, 1990, 12701, 1325, 2547, 15745, 2544, 10232, 370, 642, 2777, 1159, 666, 334, 705, 202, 199, 3, 263, 28408, 315, 282, 3365, 2777, 9, 202, 199, 3, 259, 283, 989, 6987, 2582, 665, 513, 402, 283, 1267, 7, 2783, 1586, 3524, 340, 4293, 440, 1586, 666, 2582, 202, 199, 3, 259, 283, 6672, 666, 7, 340, 2547, 15745, 2544, 1420, 2582, 402, 666, 1990, 1586, 202, 199, 3, 221, 2382, 283, 1317, 7, 365, 2008, 334, 202, 199, 3, 259, 334, 32310, 6449, 734, 314, 2436, 402, 642, 1553, 367, 3063, 652, 1159, 282, 577, 5729, 9, 202, 199, 3, 221, 776, 202, 199, 318, 5536, 63, 24444, 334, 1745, 304, 10292, 14267, 874, 275, 942, 10292, 1967, 63, 24444, 275, 488, 10292, 2329, 275, 756, 25052, 862, 26, 1128, 1967, 63, 24444, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 1128, 367, 284, 315, 1425, 8, 16, 12, 1967, 63, 24444, 304, 8608, 32205, 275, 791, 354, 356, 488, 12, 283, 890, 356, 488, 12, 283, 6502, 356, 23455, 8608, 14267, 874, 14, 740, 8, 24444, 9, 2999, 489, 32205, 354, 275, 2547, 14, 739, 63, 875, 1252, 637, 8608, 32205, 459, 354, 418, 275, 32205, 354, 2999, 489, 1967, 63, 23587, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 8608, 32205, 459, 890, 418, 275, 1967, 63, 23587, 2999, 489, 367, 1335, 315, 1425, 8, 16, 12, 1967, 63, 23587, 304, 1039, 6488, 275, 791, 344, 356, 488, 12, 283, 552, 356, 488, 12, 283, 576, 356, 488, 12, 283, 1205, 356, 488, 93, 1039, 32205, 459, 6502, 2278, 740, 8, 2761, 9, 4341, 1305, 275, 2547, 14, 739, 63, 442, 1252, 637, 1039, 6488, 459, 344, 418, 275, 1305, 1039, 6488, 459, 1205, 418, 275, 283, 576, 440, 1586, 7, 2999, 489, 367, 6488, 315, 32205, 459, 6502, 2565, 1039, 862, 26, 16765, 6488, 459, 552, 418, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 1039, 871, 8271, 14, 3005, 3466, 3296, 12, 325, 736, 26, 16765, 6488, 459, 1205, 418, 275, 283, 989, 6987, 2582, 450, 83, 7, 450, 325, 736, 14, 2394, 16765, 746, 1039, 871, 1722, 26, 16765, 6488, 459, 1205, 418, 275, 283, 989, 6987, 2582, 7, 16765, 746, 4341, 862, 26, 16765, 6488, 459, 576, 418, 275, 2547, 14, 739, 8, 2761, 459, 552, 1105, 16765, 6488, 459, 1205, 418, 275, 283, 745, 7, 16765, 6488, 459, 1317, 418, 275, 664, 63, 3059, 63, 1317, 8, 2761, 459, 576, 995, 6488, 459, 344, 995, 32205, 459, 354, 1105, 1039, 871, 8271, 14, 3005, 3466, 3296, 12, 325, 736, 26, 16765, 6488, 459, 1205, 418, 275, 283, 6672, 666, 7, 16765, 6488, 459, 576, 418, 275, 6522, 904, 8, 24909, 14, 2394, 9, 16765, 746, 10292, 871, 334, 3296, 14, 3005, 3466, 3296, 12, 1722, 304, 1128, 2329, 275, 715, 25052, 372, 334, 5682, 874, 12, 1967, 63, 24444, 12, 2329, 9, 15497, 202, 199, 318, 664, 63, 3235, 334, 76, 12, 790, 12, 1139, 12, 730, 304, 10292, 4450, 275, 2457, 8, 2734, 671, 26, 671, 59, 498, 61, 508, 1139, 12, 634, 9, 10292, 340, 440, 4450, 26 ]
[ 1898, 334, 35, 9, 8937, 9586, 50, 29295, 202, 199, 3, 20712, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 202, 199, 3, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 282, 1331, 402, 202, 199, 3, 314, 844, 737, 202, 199, 3, 20712, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 202, 199, 3, 20712, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 202, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 202, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 202, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 1334, 202, 199, 3, 314, 844, 14, 2999, 199, 646, 984, 202, 199, 504, 6488, 1122, 492, 627, 2999, 199, 3, 1122, 314, 666, 2547, 687, 314, 5461, 570, 1901, 282, 5523, 6144, 1006, 820, 3053, 397, 436, 5767, 12, 24772, 367, 1263, 2552, 315, 314, 2547, 202, 199, 3, 5808, 2008, 334, 202, 199, 3, 259, 769, 402, 32205, 1553, 315, 1865, 14556, 315, 2547, 12, 202, 199, 3, 259, 1329, 402, 1420, 32205, 1553, 488, 340, 21554, 1133, 506, 1586, 12, 202, 199, 3, 259, 3775, 1125, 1990, 14556, 315, 314, 2547, 202, 199, 3, 221, 776, 20712, 199, 3, 221, 2382, 283, 24444, 7, 365, 1211, 469, 202, 199, 3, 259, 283, 354, 356, 820, 3053, 536, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 890, 356, 1420, 1329, 402, 5767, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 6502, 356, 769, 402, 5767, 1553, 315, 1865, 14556, 315, 2547, 1553, 2701, 769, 340, 949, 5767, 503, 4293, 440, 202, 199, 3, 5185, 1586, 1263, 5767, 202, 199, 3, 221, 789, 202, 199, 3, 221, 2382, 283, 3059, 7, 365, 1211, 469, 202, 199, 3, 259, 283, 344, 356, 2777, 2870, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 552, 356, 1420, 2582, 402, 666, 1553, 488, 340, 625, 11875, 12, 202, 199, 3, 259, 283, 576, 356, 3066, 1564, 402, 2777, 465, 282, 1059, 1553, 488, 340, 4293, 440, 1586, 2870, 503, 666, 2582, 12, 7417, 666, 202, 199, 3, 3322, 340, 2547, 15745, 1830, 7664, 1553, 1443, 506, 2701, 1059, 12, 202, 199, 3, 259, 283, 1205, 356, 2004, 402, 2777, 12, 202, 199, 3, 259, 283, 1317, 356, 4565, 666, 1564, 402, 314, 2777, 334, 692, 2004, 365, 283, 745, 297, 15376, 4257, 9, 334, 32310, 6449, 734, 314, 2436, 402, 642, 9, 202, 199, 3, 221, 789, 202, 199, 3, 221, 2382, 283, 1205, 7, 365, 1373, 402, 26, 202, 199, 3, 259, 283, 745, 7, 340, 2777, 365, 315, 4552, 202, 199, 3, 259, 488, 340, 2870, 440, 12701, 202, 199, 3, 259, 283, 576, 440, 1586, 7, 340, 2870, 1990, 12701, 1325, 2547, 15745, 2544, 10232, 370, 642, 2777, 1159, 666, 334, 705, 202, 199, 3, 263, 28408, 315, 282, 3365, 2777, 9, 202, 199, 3, 259, 283, 989, 6987, 2582, 665, 513, 402, 283, 1267, 7, 2783, 1586, 3524, 340, 4293, 440, 1586, 666, 2582, 202, 199, 3, 259, 283, 6672, 666, 7, 340, 2547, 15745, 2544, 1420, 2582, 402, 666, 1990, 1586, 202, 199, 3, 221, 2382, 283, 1317, 7, 365, 2008, 334, 202, 199, 3, 259, 334, 32310, 6449, 734, 314, 2436, 402, 642, 1553, 367, 3063, 652, 1159, 282, 577, 5729, 9, 202, 199, 3, 221, 776, 202, 199, 318, 5536, 63, 24444, 334, 1745, 304, 10292, 14267, 874, 275, 942, 10292, 1967, 63, 24444, 275, 488, 10292, 2329, 275, 756, 25052, 862, 26, 1128, 1967, 63, 24444, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 1128, 367, 284, 315, 1425, 8, 16, 12, 1967, 63, 24444, 304, 8608, 32205, 275, 791, 354, 356, 488, 12, 283, 890, 356, 488, 12, 283, 6502, 356, 23455, 8608, 14267, 874, 14, 740, 8, 24444, 9, 2999, 489, 32205, 354, 275, 2547, 14, 739, 63, 875, 1252, 637, 8608, 32205, 459, 354, 418, 275, 32205, 354, 2999, 489, 1967, 63, 23587, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 8608, 32205, 459, 890, 418, 275, 1967, 63, 23587, 2999, 489, 367, 1335, 315, 1425, 8, 16, 12, 1967, 63, 23587, 304, 1039, 6488, 275, 791, 344, 356, 488, 12, 283, 552, 356, 488, 12, 283, 576, 356, 488, 12, 283, 1205, 356, 488, 93, 1039, 32205, 459, 6502, 2278, 740, 8, 2761, 9, 4341, 1305, 275, 2547, 14, 739, 63, 442, 1252, 637, 1039, 6488, 459, 344, 418, 275, 1305, 1039, 6488, 459, 1205, 418, 275, 283, 576, 440, 1586, 7, 2999, 489, 367, 6488, 315, 32205, 459, 6502, 2565, 1039, 862, 26, 16765, 6488, 459, 552, 418, 275, 2547, 14, 739, 63, 442, 8, 549, 680, 637, 1039, 871, 8271, 14, 3005, 3466, 3296, 12, 325, 736, 26, 16765, 6488, 459, 1205, 418, 275, 283, 989, 6987, 2582, 450, 83, 7, 450, 325, 736, 14, 2394, 16765, 746, 1039, 871, 1722, 26, 16765, 6488, 459, 1205, 418, 275, 283, 989, 6987, 2582, 7, 16765, 746, 4341, 862, 26, 16765, 6488, 459, 576, 418, 275, 2547, 14, 739, 8, 2761, 459, 552, 1105, 16765, 6488, 459, 1205, 418, 275, 283, 745, 7, 16765, 6488, 459, 1317, 418, 275, 664, 63, 3059, 63, 1317, 8, 2761, 459, 576, 995, 6488, 459, 344, 995, 32205, 459, 354, 1105, 1039, 871, 8271, 14, 3005, 3466, 3296, 12, 325, 736, 26, 16765, 6488, 459, 1205, 418, 275, 283, 6672, 666, 7, 16765, 6488, 459, 576, 418, 275, 6522, 904, 8, 24909, 14, 2394, 9, 16765, 746, 10292, 871, 334, 3296, 14, 3005, 3466, 3296, 12, 1722, 304, 1128, 2329, 275, 715, 25052, 372, 334, 5682, 874, 12, 1967, 63, 24444, 12, 2329, 9, 15497, 202, 199, 318, 664, 63, 3235, 334, 76, 12, 790, 12, 1139, 12, 730, 304, 10292, 4450, 275, 2457, 8, 2734, 671, 26, 671, 59, 498, 61, 508, 1139, 12, 634, 9, 10292, 340, 440, 4450, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1,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serializers.py
1
1521
from rest_framework import generics, permissions from rest_framework import serializers from django.contrib.auth.models import User from .models import Post, Photo class UserSerializer(serializers.ModelSerializer): posts = serializers.HyperlinkedIdentityField('posts', view_name='userpost-list', lookup_field='username') class Meta: model = User fields = ('id', 'username', 'first_name', 'last_name', 'posts', ) class PostSerializer(serializers.ModelSerializer): # makes author readily accessible rather than requiring extra API requests. # The alternative hyperlink is listed with a comment for comparison. # The power of serializers is that you can extend them to create a derivative version, that uses hyperlinks instead of nested records (say, for the case of listing posts by a specific users' feed). author = UserSerializer(required=False) # author = serializers.HyperlinkedRelatedField(view_name='user-detail', lookup_field='username') photos = serializers.HyperlinkedIdentityField('photos', view_name='postphoto-list') def get_validation_exclusions(self, instance=None): # Need to exclude `author` since we'll add that later based off the request exclusions = super(PostSerializer, self).get_validation_exclusions(instance) return exclusions + ['author'] class Meta: model = Post class PhotoSerializer(serializers.ModelSerializer): image = serializers.Field('image.url') class Meta: model = Photo
mit
[ 504, 4618, 63, 4857, 492, 1519, 2932, 12, 3443, 199, 504, 4618, 63, 4857, 492, 12506, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1275, 992, 492, 7711, 12, 30808, 421, 199, 533, 2876, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 22238, 275, 12506, 14, 18727, 12751, 10193, 792, 360, 18084, 297, 2455, 63, 354, 534, 751, 1932, 13, 513, 297, 4237, 63, 698, 534, 2473, 358, 339, 1021, 6288, 26, 267, 1402, 275, 2876, 267, 1504, 275, 661, 344, 297, 283, 2473, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 18084, 297, 776, 421, 199, 533, 7711, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 327, 7704, 4132, 295, 65, 328, 590, 17909, 7830, 2419, 29963, 2402, 3261, 4145, 14, 272, 327, 710, 13943, 10342, 1073, 365, 10532, 543, 282, 3721, 367, 9132, 14, 272, 327, 710, 7074, 402, 12506, 365, 626, 1265, 883, 12247, 3062, 370, 1218, 282, 18883, 1015, 12, 626, 4440, 10342, 4614, 3140, 402, 6032, 5767, 334, 19787, 12, 367, 314, 1930, 402, 13778, 22238, 701, 282, 2488, 4390, 7, 4733, 680, 339, 4132, 275, 2876, 7299, 8, 2427, 29, 797, 9, 272, 327, 4132, 275, 12506, 14, 18727, 12751, 13885, 792, 8, 1345, 63, 354, 534, 751, 13, 5506, 297, 4237, 63, 698, 534, 2473, 358, 339, 3945, 17278, 275, 12506, 14, 18727, 12751, 10193, 792, 360, 25211, 297, 2455, 63, 354, 534, 1932, 13834, 13, 513, 358, 339, 347, 664, 63, 6136, 63, 476, 18540, 8, 277, 12, 1256, 29, 403, 304, 267, 327, 14012, 370, 5760, 658, 2502, 64, 3967, 781, 7171, 1050, 626, 2945, 4079, 2331, 314, 1056, 267, 24294, 275, 1613, 8, 6564, 7299, 12, 291, 680, 362, 63, 6136, 63, 476, 18540, 8, 842, 9, 267, 372, 24294, 435, 788, 2502, 418, 339, 1021, 6288, 26, 267, 1402, 275, 7711, 421, 199, 533, 30808, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 1834, 275, 12506, 14, 792, 360, 1569, 14, 633, 358, 339, 1021, 6288, 26, 267, 1402, 275, 30808, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4618, 63, 4857, 492, 1519, 2932, 12, 3443, 199, 504, 4618, 63, 4857, 492, 12506, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1275, 992, 492, 7711, 12, 30808, 421, 199, 533, 2876, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 22238, 275, 12506, 14, 18727, 12751, 10193, 792, 360, 18084, 297, 2455, 63, 354, 534, 751, 1932, 13, 513, 297, 4237, 63, 698, 534, 2473, 358, 339, 1021, 6288, 26, 267, 1402, 275, 2876, 267, 1504, 275, 661, 344, 297, 283, 2473, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 18084, 297, 776, 421, 199, 533, 7711, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 327, 7704, 4132, 295, 65, 328, 590, 17909, 7830, 2419, 29963, 2402, 3261, 4145, 14, 272, 327, 710, 13943, 10342, 1073, 365, 10532, 543, 282, 3721, 367, 9132, 14, 272, 327, 710, 7074, 402, 12506, 365, 626, 1265, 883, 12247, 3062, 370, 1218, 282, 18883, 1015, 12, 626, 4440, 10342, 4614, 3140, 402, 6032, 5767, 334, 19787, 12, 367, 314, 1930, 402, 13778, 22238, 701, 282, 2488, 4390, 7, 4733, 680, 339, 4132, 275, 2876, 7299, 8, 2427, 29, 797, 9, 272, 327, 4132, 275, 12506, 14, 18727, 12751, 13885, 792, 8, 1345, 63, 354, 534, 751, 13, 5506, 297, 4237, 63, 698, 534, 2473, 358, 339, 3945, 17278, 275, 12506, 14, 18727, 12751, 10193, 792, 360, 25211, 297, 2455, 63, 354, 534, 1932, 13834, 13, 513, 358, 339, 347, 664, 63, 6136, 63, 476, 18540, 8, 277, 12, 1256, 29, 403, 304, 267, 327, 14012, 370, 5760, 658, 2502, 64, 3967, 781, 7171, 1050, 626, 2945, 4079, 2331, 314, 1056, 267, 24294, 275, 1613, 8, 6564, 7299, 12, 291, 680, 362, 63, 6136, 63, 476, 18540, 8, 842, 9, 267, 372, 24294, 435, 788, 2502, 418, 339, 1021, 6288, 26, 267, 1402, 275, 7711, 421, 199, 533, 30808, 7299, 8, 12844, 14, 1685, 7299, 304, 272, 1834, 275, 12506, 14, 792, 360, 1569, 14, 633, 358, 339, 1021, 6288, 26, 267, 1402, 275, 30808, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
galaxy001/libtorrent
BitTornado-0.3.18/BitTornado/RawServer.py
12
6531
# Written by Bram Cohen # see LICENSE.txt for license information from bisect import insort from SocketHandler import SocketHandler, UPnP_ERROR import socket from cStringIO import StringIO from traceback import print_exc from select import error from threading import Thread, Event from time import sleep from clock import clock import sys try: True except: True = 1 False = 0 def autodetect_ipv6(): try: assert sys.version_info >= (2,3) assert socket.has_ipv6 socket.socket(socket.AF_INET6, socket.SOCK_STREAM) except: return 0 return 1 def autodetect_socket_style(): if sys.platform.find('linux') < 0: return 1 else: try: f = open('/proc/sys/net/ipv6/bindv6only','r') dual_socket_style = int(f.read()) f.close() return int(not dual_socket_style) except: return 0 READSIZE = 32768 class RawServer: def __init__(self, doneflag, timeout_check_interval, timeout, noisy = True, ipv6_enable = True, failfunc = lambda x: None, errorfunc = None, sockethandler = None, excflag = Event()): self.timeout_check_interval = timeout_check_interval self.timeout = timeout self.servers = {} self.single_sockets = {} self.dead_from_write = [] self.doneflag = doneflag self.noisy = noisy self.failfunc = failfunc self.errorfunc = errorfunc self.exccount = 0 self.funcs = [] self.externally_added = [] self.finished = Event() self.tasks_to_kill = [] self.excflag = excflag if sockethandler is None: sockethandler = SocketHandler(timeout, ipv6_enable, READSIZE) self.sockethandler = sockethandler self.add_task(self.scan_for_timeouts, timeout_check_interval) def get_exception_flag(self): return self.excflag def _add_task(self, func, delay, id = None): assert float(delay) >= 0 insort(self.funcs, (clock() + delay, func, id)) def add_task(self, func, delay = 0, id = None): assert float(delay) >= 0 self.externally_added.append((func, delay, id)) def scan_for_timeouts(self): self.add_task(self.scan_for_timeouts, self.timeout_check_interval) self.sockethandler.scan_for_timeouts() def bind(self, port, bind = '', reuse = False, ipv6_socket_style = 1, upnp = False): self.sockethandler.bind(port, bind, reuse, ipv6_socket_style, upnp) def find_and_bind(self, minport, maxport, bind = '', reuse = False, ipv6_socket_style = 1, upnp = 0, randomizer = False): return self.sockethandler.find_and_bind(minport, maxport, bind, reuse, ipv6_socket_style, upnp, randomizer) def start_connection_raw(self, dns, socktype, handler = None): return self.sockethandler.start_connection_raw(dns, socktype, handler) def start_connection(self, dns, handler = None, randomize = False): return self.sockethandler.start_connection(dns, handler, randomize) def get_stats(self): return self.sockethandler.get_stats() def pop_external(self): while self.externally_added: (a, b, c) = self.externally_added.pop(0) self._add_task(a, b, c) def listen_forever(self, handler): self.sockethandler.set_handler(handler) try: while not self.doneflag.isSet(): try: self.pop_external() self._kill_tasks() if self.funcs: period = self.funcs[0][0] + 0.001 - clock() else: period = 2 ** 30 if period < 0: period = 0 events = self.sockethandler.do_poll(period) if self.doneflag.isSet(): return while self.funcs and self.funcs[0][0] <= clock(): garbage1, func, id = self.funcs.pop(0) if id in self.tasks_to_kill: pass try: # print func.func_name func() except (SystemError, MemoryError), e: self.failfunc(str(e)) return except KeyboardInterrupt: # self.exception(True) return except: if self.noisy: self.exception() self.sockethandler.close_dead() self.sockethandler.handle_events(events) if self.doneflag.isSet(): return self.sockethandler.close_dead() except (SystemError, MemoryError), e: self.failfunc(str(e)) return except error: if self.doneflag.isSet(): return except KeyboardInterrupt: # self.exception(True) return except: self.exception() if self.exccount > 10: return finally: # self.sockethandler.shutdown() self.finished.set() def is_finished(self): return self.finished.isSet() def wait_until_finished(self): self.finished.wait() def _kill_tasks(self): if self.tasks_to_kill: new_funcs = [] for (t, func, id) in self.funcs: if id not in self.tasks_to_kill: new_funcs.append((t, func, id)) self.funcs = new_funcs self.tasks_to_kill = [] def kill_tasks(self, id): self.tasks_to_kill.append(id) def exception(self, kbint = False): if not kbint: self.excflag.set() self.exccount += 1 if self.errorfunc is None: print_exc() else: data = StringIO() print_exc(file = data) # print data.getvalue() # report exception here too if not kbint: # don't report here if it's a keyboard interrupt self.errorfunc(data.getvalue()) def shutdown(self): self.sockethandler.shutdown()
mit
[ 3, 27694, 701, 699, 5975, 1849, 16800, 199, 3, 1937, 5113, 14, 2424, 367, 4190, 2556, 199, 199, 504, 19063, 492, 315, 3191, 199, 504, 17766, 2461, 492, 17766, 2461, 12, 7215, 30035, 63, 3170, 199, 646, 2838, 199, 504, 15073, 492, 5228, 199, 504, 5190, 492, 870, 63, 2804, 199, 504, 3504, 492, 1125, 199, 504, 5796, 492, 11086, 12, 6763, 199, 504, 900, 492, 9435, 199, 504, 12516, 492, 12516, 199, 646, 984, 199, 893, 26, 272, 715, 199, 2590, 26, 272, 715, 275, 413, 272, 756, 275, 378, 421, 199, 318, 28537, 5302, 63, 4774, 22, 837, 272, 862, 26, 267, 702, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 19, 9, 267, 702, 2838, 14, 1989, 63, 4774, 22, 267, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 22, 12, 2838, 14, 9469, 63, 9484, 9, 272, 871, 26, 267, 372, 378, 272, 372, 413, 199, 199, 318, 28537, 5302, 63, 3450, 63, 2487, 837, 199, 198, 692, 984, 14, 3246, 14, 1623, 360, 5135, 358, 665, 378, 26, 507, 198, 1107, 413, 199, 198, 2836, 26, 507, 198, 893, 26, 686, 198, 70, 275, 1551, 2336, 4687, 15, 1274, 15, 846, 15, 4774, 22, 15, 3409, 86, 22, 2118, 1673, 82, 358, 686, 198, 17962, 63, 3450, 63, 2487, 275, 1109, 8, 70, 14, 739, 1012, 686, 198, 70, 14, 1600, 342, 686, 198, 1107, 1109, 8, 1397, 21164, 63, 3450, 63, 2487, 9, 507, 198, 2590, 26, 686, 198, 1107, 378, 421, 199, 5670, 4305, 275, 20939, 2333, 199, 199, 533, 13480, 3120, 26, 272, 347, 636, 826, 721, 277, 12, 4224, 4173, 12, 2653, 63, 1074, 63, 4284, 12, 2653, 12, 949, 19765, 275, 715, 12, 326, 3278, 22, 63, 4296, 275, 715, 12, 1433, 17588, 1097, 275, 2400, 671, 26, 488, 12, 1125, 1532, 275, 488, 12, 326, 6771, 12391, 1221, 275, 488, 12, 444, 2177, 1823, 275, 6763, 5109, 267, 291, 14, 2593, 63, 1074, 63, 4284, 275, 2653, 63, 1074, 63, 4284, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 5871, 275, 1052, 267, 291, 14, 4780, 63, 20517, 275, 1052, 267, 291, 14, 10957, 63, 504, 63, 952, 275, 942, 267, 291, 14, 4456, 4173, 275, 4224, 4173, 267, 291, 14, 889, 19765, 275, 949, 19765, 267, 291, 14, 667, 17588, 1097, 275, 1433, 17588, 1097, 267, 291, 14, 705, 1532, 275, 1125, 1532, 267, 291, 14, 2804, 835, 275, 378, 267, 291, 14, 9204, 275, 942, 267, 291, 14, 18587, 1183, 63, 3270, 275, 942, 267, 291, 14, 8669, 275, 6763, 342, 267, 291, 14, 5054, 63, 475, 63, 8997, 275, 942, 267, 291, 14, 476, 2177, 1823, 275, 444, 2177, 1823, 2728, 340, 6771, 12391, 1221, 365, 488, 26, 288, 6771, 12391, 1221, 275, 17766, 2461, 8, 2593, 12, 3278, 22, 63, 4296, 12, 16767, 4305, 9, 267, 291, 14, 5096, 12391, 1221, 275, 6771, 12391, 1221, 267, 291, 14, 525, 63, 1765, 8, 277, 14, 6282, 63, 509, 63, 30182, 12, 2653, 63, 1074, 63, 4284, 9, 339, 347, 664, 63, 1971, 63, 4173, 8, 277, 304, 267, 372, 291, 14, 476, 2177, 1823, 339, 347, 485, 525, 63, 1765, 8, 277, 12, 2562, 12, 7339, 12, 1305, 275, 488, 304, 267, 702, 2069, 8, 5814, 9, 2356, 378, 267, 315, 3191, 8, 277, 14, 9204, 12, 334, 9597, 342, 435, 7339, 12, 2562, 12, 1305, 430, 339, 347, 1050, 63, 1765, 8, 277, 12, 2562, 12, 7339, 275, 378, 12, 1305, 275, 488, 304, 267, 702, 2069, 8, 5814, 9, 2356, 378, 267, 291, 14, 18587, 1183, 63, 3270, 14, 740, 1332, 1532, 12, 7339, 12, 1305, 430, 339, 347, 8000, 63, 509, 63, 30182, 8, 277, 304, 267, 291, 14, 525, 63, 1765, 8, 277, 14, 6282, 63, 509, 63, 30182, 12, 291, 14, 2593, 63, 1074, 63, 4284, 9, 267, 291, 14, 5096, 12391, 1221, 14, 6282, 63, 509, 63, 30182, 342, 339, 347, 5398, 8, 277, 12, 1844, 12, 5398, 275, 3260, 12598, 275, 756, 12, 717, 3278, 22, 63, 3450, 63, 2487, 275, 413, 12, 1536, 1590, 275, 756, 304, 267, 291, 14, 5096, 12391, 1221, 14, 3409, 8, 719, 12, 5398, 12, 12598, 12, 3278, 22, 63, 3450, 63, 2487, 12, 1536, 1590, 9, 339, 347, 2342, 63, 460, 63, 3409, 8, 277, 12, 1748, 719, 12, 1390, 719, 12, 5398, 275, 3260, 12598, 275, 756, 12, 1993, 3278, 22, 63, 3450, 63, 2487, 275, 413, 12, 1536, 1590, 275, 378, 12, 2196, 1793, 275, 756, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 1623, 63, 460, 63, 3409, 8, 827, 719, 12, 1390, 719, 12, 5398, 12, 12598, 12, 639, 3278, 22, 63, 3450, 63, 2487, 12, 1536, 1590, 12, 2196, 1793, 9, 339, 347, 1343, 63, 2105, 63, 1773, 8, 277, 12, 6715, 12, 6771, 466, 12, 3016, 275, 488, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 928, 63, 2105, 63, 1773, 8, 5797, 12, 6771, 466, 12, 3016, 9, 339, 347, 1343, 63, 2105, 8, 277, 12, 6715, 12, 3016, 275, 488, 12, 2196, 794, 275, 756, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 928, 63, 2105, 8, 5797, 12, 3016, 12, 2196, 794, 9, 339, 347, 664, 63, 3200, 8, 277, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 362, 63, 3200, 342, 339, 347, 4560, 63, 5159, 8, 277, 304, 267, 1830, 291, 14, 18587, 1183, 63, 3270, 26, 288, 334, 65, 12, 330, 12, 286, 9, 275, 291, 14, 18587, 1183, 63, 3270, 14, 1935, 8, 16, 9, 288, 291, 423, 525, 63, 1765, 8, 65, 12, 330, 12, 286, 9, 2378, 347, 6938, 63, 21327, 8, 277, 12, 3016, 304, 267, 291, 14, 5096, 12391, 1221, 14, 409, 63, 2232, 8, 2232, 9, 267, 862, 26, 288, 1830, 440, 291, 14, 4456, 4173, 14, 374, 1084, 837, 355, 862, 26, 490, 291, 14, 1935, 63, 5159, 342, 490, 291, 423, 8997, 63, 5054, 342, 490, 340, 291, 14, 9204, 26, 717, 6247, 275, 291, 14, 9204, 59, 16, 1527, 16, 61, 435, 378, 14, 4587, 446, 12516, 342, 490, 587, 26, 717, 6247, 275, 499, 1011, 4233, 490 ]
[ 27694, 701, 699, 5975, 1849, 16800, 199, 3, 1937, 5113, 14, 2424, 367, 4190, 2556, 199, 199, 504, 19063, 492, 315, 3191, 199, 504, 17766, 2461, 492, 17766, 2461, 12, 7215, 30035, 63, 3170, 199, 646, 2838, 199, 504, 15073, 492, 5228, 199, 504, 5190, 492, 870, 63, 2804, 199, 504, 3504, 492, 1125, 199, 504, 5796, 492, 11086, 12, 6763, 199, 504, 900, 492, 9435, 199, 504, 12516, 492, 12516, 199, 646, 984, 199, 893, 26, 272, 715, 199, 2590, 26, 272, 715, 275, 413, 272, 756, 275, 378, 421, 199, 318, 28537, 5302, 63, 4774, 22, 837, 272, 862, 26, 267, 702, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 19, 9, 267, 702, 2838, 14, 1989, 63, 4774, 22, 267, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 22, 12, 2838, 14, 9469, 63, 9484, 9, 272, 871, 26, 267, 372, 378, 272, 372, 413, 199, 199, 318, 28537, 5302, 63, 3450, 63, 2487, 837, 199, 198, 692, 984, 14, 3246, 14, 1623, 360, 5135, 358, 665, 378, 26, 507, 198, 1107, 413, 199, 198, 2836, 26, 507, 198, 893, 26, 686, 198, 70, 275, 1551, 2336, 4687, 15, 1274, 15, 846, 15, 4774, 22, 15, 3409, 86, 22, 2118, 1673, 82, 358, 686, 198, 17962, 63, 3450, 63, 2487, 275, 1109, 8, 70, 14, 739, 1012, 686, 198, 70, 14, 1600, 342, 686, 198, 1107, 1109, 8, 1397, 21164, 63, 3450, 63, 2487, 9, 507, 198, 2590, 26, 686, 198, 1107, 378, 421, 199, 5670, 4305, 275, 20939, 2333, 199, 199, 533, 13480, 3120, 26, 272, 347, 636, 826, 721, 277, 12, 4224, 4173, 12, 2653, 63, 1074, 63, 4284, 12, 2653, 12, 949, 19765, 275, 715, 12, 326, 3278, 22, 63, 4296, 275, 715, 12, 1433, 17588, 1097, 275, 2400, 671, 26, 488, 12, 1125, 1532, 275, 488, 12, 326, 6771, 12391, 1221, 275, 488, 12, 444, 2177, 1823, 275, 6763, 5109, 267, 291, 14, 2593, 63, 1074, 63, 4284, 275, 2653, 63, 1074, 63, 4284, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 5871, 275, 1052, 267, 291, 14, 4780, 63, 20517, 275, 1052, 267, 291, 14, 10957, 63, 504, 63, 952, 275, 942, 267, 291, 14, 4456, 4173, 275, 4224, 4173, 267, 291, 14, 889, 19765, 275, 949, 19765, 267, 291, 14, 667, 17588, 1097, 275, 1433, 17588, 1097, 267, 291, 14, 705, 1532, 275, 1125, 1532, 267, 291, 14, 2804, 835, 275, 378, 267, 291, 14, 9204, 275, 942, 267, 291, 14, 18587, 1183, 63, 3270, 275, 942, 267, 291, 14, 8669, 275, 6763, 342, 267, 291, 14, 5054, 63, 475, 63, 8997, 275, 942, 267, 291, 14, 476, 2177, 1823, 275, 444, 2177, 1823, 2728, 340, 6771, 12391, 1221, 365, 488, 26, 288, 6771, 12391, 1221, 275, 17766, 2461, 8, 2593, 12, 3278, 22, 63, 4296, 12, 16767, 4305, 9, 267, 291, 14, 5096, 12391, 1221, 275, 6771, 12391, 1221, 267, 291, 14, 525, 63, 1765, 8, 277, 14, 6282, 63, 509, 63, 30182, 12, 2653, 63, 1074, 63, 4284, 9, 339, 347, 664, 63, 1971, 63, 4173, 8, 277, 304, 267, 372, 291, 14, 476, 2177, 1823, 339, 347, 485, 525, 63, 1765, 8, 277, 12, 2562, 12, 7339, 12, 1305, 275, 488, 304, 267, 702, 2069, 8, 5814, 9, 2356, 378, 267, 315, 3191, 8, 277, 14, 9204, 12, 334, 9597, 342, 435, 7339, 12, 2562, 12, 1305, 430, 339, 347, 1050, 63, 1765, 8, 277, 12, 2562, 12, 7339, 275, 378, 12, 1305, 275, 488, 304, 267, 702, 2069, 8, 5814, 9, 2356, 378, 267, 291, 14, 18587, 1183, 63, 3270, 14, 740, 1332, 1532, 12, 7339, 12, 1305, 430, 339, 347, 8000, 63, 509, 63, 30182, 8, 277, 304, 267, 291, 14, 525, 63, 1765, 8, 277, 14, 6282, 63, 509, 63, 30182, 12, 291, 14, 2593, 63, 1074, 63, 4284, 9, 267, 291, 14, 5096, 12391, 1221, 14, 6282, 63, 509, 63, 30182, 342, 339, 347, 5398, 8, 277, 12, 1844, 12, 5398, 275, 3260, 12598, 275, 756, 12, 717, 3278, 22, 63, 3450, 63, 2487, 275, 413, 12, 1536, 1590, 275, 756, 304, 267, 291, 14, 5096, 12391, 1221, 14, 3409, 8, 719, 12, 5398, 12, 12598, 12, 3278, 22, 63, 3450, 63, 2487, 12, 1536, 1590, 9, 339, 347, 2342, 63, 460, 63, 3409, 8, 277, 12, 1748, 719, 12, 1390, 719, 12, 5398, 275, 3260, 12598, 275, 756, 12, 1993, 3278, 22, 63, 3450, 63, 2487, 275, 413, 12, 1536, 1590, 275, 378, 12, 2196, 1793, 275, 756, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 1623, 63, 460, 63, 3409, 8, 827, 719, 12, 1390, 719, 12, 5398, 12, 12598, 12, 639, 3278, 22, 63, 3450, 63, 2487, 12, 1536, 1590, 12, 2196, 1793, 9, 339, 347, 1343, 63, 2105, 63, 1773, 8, 277, 12, 6715, 12, 6771, 466, 12, 3016, 275, 488, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 928, 63, 2105, 63, 1773, 8, 5797, 12, 6771, 466, 12, 3016, 9, 339, 347, 1343, 63, 2105, 8, 277, 12, 6715, 12, 3016, 275, 488, 12, 2196, 794, 275, 756, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 928, 63, 2105, 8, 5797, 12, 3016, 12, 2196, 794, 9, 339, 347, 664, 63, 3200, 8, 277, 304, 267, 372, 291, 14, 5096, 12391, 1221, 14, 362, 63, 3200, 342, 339, 347, 4560, 63, 5159, 8, 277, 304, 267, 1830, 291, 14, 18587, 1183, 63, 3270, 26, 288, 334, 65, 12, 330, 12, 286, 9, 275, 291, 14, 18587, 1183, 63, 3270, 14, 1935, 8, 16, 9, 288, 291, 423, 525, 63, 1765, 8, 65, 12, 330, 12, 286, 9, 2378, 347, 6938, 63, 21327, 8, 277, 12, 3016, 304, 267, 291, 14, 5096, 12391, 1221, 14, 409, 63, 2232, 8, 2232, 9, 267, 862, 26, 288, 1830, 440, 291, 14, 4456, 4173, 14, 374, 1084, 837, 355, 862, 26, 490, 291, 14, 1935, 63, 5159, 342, 490, 291, 423, 8997, 63, 5054, 342, 490, 340, 291, 14, 9204, 26, 717, 6247, 275, 291, 14, 9204, 59, 16, 1527, 16, 61, 435, 378, 14, 4587, 446, 12516, 342, 490, 587, 26, 717, 6247, 275, 499, 1011, 4233, 490, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Piratenfraktion-Berlin/OwnTube
videoportal/BitTornadoABC/BitTornado/BT1/btformats.py
2
3917
# Written by Bram Cohen # see LICENSE.txt for license information from types import StringType, LongType, IntType, ListType, DictType import re reg = re.compile(r'^[^/\\.~][^/\\]*$') ints = (LongType, IntType) def check_info(info): if type(info) != DictType: raise ValueError, 'bad metainfo - not a dictionary' pieces = info.get('pieces') if type(pieces) != StringType or len(pieces) % 20 != 0: raise ValueError, 'bad metainfo - bad pieces key' piecelength = info.get('piece length') if type(piecelength) not in ints or piecelength <= 0: raise ValueError, 'bad metainfo - illegal piece length' name = info.get('name') if type(name) != StringType: raise ValueError, 'bad metainfo - bad name' if not reg.match(name): raise ValueError, 'name %s disallowed for security reasons' % name if info.has_key('files') == info.has_key('length'): raise ValueError, 'single/multiple file mix' if info.has_key('length'): length = info.get('length') if type(length) not in ints or length < 0: raise ValueError, 'bad metainfo - bad length' else: files = info.get('files') if type(files) != ListType: raise ValueError for f in files: if type(f) != DictType: raise ValueError, 'bad metainfo - bad file value' length = f.get('length') if type(length) not in ints or length < 0: raise ValueError, 'bad metainfo - bad length' path = f.get('path') if type(path) != ListType or path == []: raise ValueError, 'bad metainfo - bad path' for p in path: if type(p) != StringType: raise ValueError, 'bad metainfo - bad path dir' if not reg.match(p): raise ValueError, 'path %s disallowed for security reasons' % p for i in xrange(len(files)): for j in xrange(i): if files[i]['path'] == files[j]['path']: raise ValueError, 'bad metainfo - duplicate path' def check_message(message): if type(message) != DictType: raise ValueError check_info(message.get('info')) if type(message.get('announce')) != StringType: raise ValueError def check_peers(message): if type(message) != DictType: raise ValueError if message.has_key('failure reason'): if type(message['failure reason']) != StringType: raise ValueError return peers = message.get('peers') if type(peers) == ListType: for p in peers: if type(p) != DictType: raise ValueError if type(p.get('ip')) != StringType: raise ValueError port = p.get('port') if type(port) not in ints or p <= 0: raise ValueError if p.has_key('peer id'): id = p['peer id'] if type(id) != StringType or len(id) != 20: raise ValueError elif type(peers) != StringType or len(peers) % 6 != 0: raise ValueError interval = message.get('interval', 1) if type(interval) not in ints or interval <= 0: raise ValueError minint = message.get('min interval', 1) if type(minint) not in ints or minint <= 0: raise ValueError if type(message.get('tracker id', '')) != StringType: raise ValueError npeers = message.get('num peers', 0) if type(npeers) not in ints or npeers < 0: raise ValueError dpeers = message.get('done peers', 0) if type(dpeers) not in ints or dpeers < 0: raise ValueError last = message.get('last', 0) if type(last) not in ints or last < 0: raise ValueError
bsd-2-clause
[ 3, 27694, 701, 699, 5975, 1849, 16800, 202, 199, 3, 1937, 5113, 14, 2424, 367, 4190, 2556, 2999, 199, 504, 2943, 492, 32654, 12, 19944, 804, 12, 9805, 804, 12, 3820, 804, 12, 7448, 804, 202, 199, 646, 295, 2999, 199, 1135, 275, 295, 14, 2014, 8, 82, 4289, 4735, 15, 20942, 94, 1527, 62, 15, 1103, 3672, 9988, 2999, 199, 13141, 275, 334, 9551, 804, 12, 9805, 804, 9, 2999, 199, 318, 1104, 63, 815, 8, 815, 304, 1128, 340, 730, 8, 815, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 440, 282, 2600, 7, 1128, 10338, 275, 2256, 14, 362, 360, 15655, 358, 1128, 340, 730, 8, 15655, 9, 1137, 32654, 503, 822, 8, 15655, 9, 450, 3388, 1137, 378, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 10338, 790, 7, 1128, 14854, 1267, 275, 2256, 14, 362, 360, 20082, 2582, 358, 1128, 340, 730, 8, 20082, 1267, 9, 440, 315, 14526, 503, 14854, 1267, 2695, 378, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 20282, 14854, 2582, 7, 1128, 536, 275, 2256, 14, 362, 360, 354, 358, 1128, 340, 730, 8, 354, 9, 1137, 32654, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 536, 7, 1128, 340, 440, 1295, 14, 1431, 8, 354, 304, 1039, 746, 1722, 12, 283, 354, 450, 83, 30994, 367, 6391, 14872, 7, 450, 536, 1128, 340, 2256, 14, 1989, 63, 498, 360, 1725, 358, 508, 2256, 14, 1989, 63, 498, 360, 1267, 735, 1039, 746, 1722, 12, 283, 4780, 15, 6048, 570, 13667, 7, 1128, 340, 2256, 14, 1989, 63, 498, 360, 1267, 735, 1039, 2582, 275, 2256, 14, 362, 360, 1267, 358, 1039, 340, 730, 8, 1267, 9, 440, 315, 14526, 503, 2582, 665, 378, 26, 1675, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 2582, 7, 1128, 587, 26, 1039, 1584, 275, 2256, 14, 362, 360, 1725, 358, 1039, 340, 730, 8, 1725, 9, 1137, 3820, 804, 26, 1675, 746, 1722, 1039, 367, 289, 315, 1584, 26, 1675, 340, 730, 8, 70, 9, 1137, 7448, 804, 26, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 570, 574, 7, 1675, 2582, 275, 289, 14, 362, 360, 1267, 358, 1675, 340, 730, 8, 1267, 9, 440, 315, 14526, 503, 2582, 665, 378, 26, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 2582, 7, 1675, 931, 275, 289, 14, 362, 360, 515, 358, 1675, 340, 730, 8, 515, 9, 1137, 3820, 804, 503, 931, 508, 18410, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 931, 7, 1675, 367, 299, 315, 931, 26, 2628, 340, 730, 8, 80, 9, 1137, 32654, 26, 4906, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 931, 2935, 7, 2628, 340, 440, 1295, 14, 1431, 8, 80, 304, 4906, 746, 1722, 12, 283, 515, 450, 83, 30994, 367, 6391, 14872, 7, 450, 299, 1039, 367, 284, 315, 4945, 8, 552, 8, 1725, 2298, 1675, 367, 1335, 315, 4945, 8, 73, 304, 2628, 340, 1584, 59, 73, 2733, 515, 418, 508, 1584, 59, 74, 2733, 515, 2565, 4906, 746, 1722, 12, 283, 4087, 3404, 815, 446, 9250, 931, 7, 2999, 199, 318, 1104, 63, 1188, 8, 1188, 304, 1128, 340, 730, 8, 1188, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 1128, 1104, 63, 815, 8, 1188, 14, 362, 360, 815, 1333, 1128, 340, 730, 8, 1188, 14, 362, 360, 17803, 1333, 1137, 32654, 26, 1039, 746, 1722, 2999, 199, 318, 1104, 63, 22416, 8, 1188, 304, 1128, 340, 730, 8, 1188, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 1128, 340, 1245, 14, 1989, 63, 498, 360, 5328, 4499, 735, 1039, 340, 730, 8, 1188, 459, 5328, 4499, 1105, 1137, 32654, 26, 1675, 746, 1722, 1039, 372, 1128, 28166, 275, 1245, 14, 362, 360, 22416, 358, 1128, 340, 730, 8, 22416, 9, 508, 3820, 804, 26, 1039, 367, 299, 315, 28166, 26, 1675, 340, 730, 8, 80, 9, 1137, 7448, 804, 26, 2628, 746, 1722, 1675, 340, 730, 8, 80, 14, 362, 360, 711, 1333, 1137, 32654, 26, 2628, 746, 1722, 1675, 1844, 275, 299, 14, 362, 360, 719, 358, 1675, 340, 730, 8, 719, 9, 440, 315, 14526, 503, 299, 2695, 378, 26, 2628, 746, 1722, 1675, 340, 299, 14, 1989, 63, 498, 360, 7866, 1305, 735, 2628, 1305, 275, 299, 459, 7866, 1305, 418, 2628, 340, 730, 8, 344, 9, 1137, 32654, 503, 822, 8, 344, 9, 1137, 3388, 26, 4906, 746, 1722, 1128, 916, 730, 8, 22416, 9, 1137, 32654, 503, 822, 8, 22416, 9, 450, 1227, 1137, 378, 26, 1039, 746, 1722, 1128, 6252, 275, 1245, 14, 362, 360, 4284, 297, 413, 9, 1128, 340, 730, 8, 4284, 9, 440, 315, 14526, 503, 6252, 2695, 378, 26, 1039, 746, 1722, 1128, 1748, 442, 275, 1245, 14, 362, 360, 827, 6252, 297, 413, 9, 1128, 340, 730, 8, 827, 442, 9, 440, 315, 14526, 503, 1748, 442, 2695, 378, 26, 1039, 746, 1722, 1128, 340, 730, 8, 1188, 14, 362, 360, 8877, 1305, 297, 12381, 1137, 32654, 26, 1039, 746, 1722, 1128, 302, 22416, 275, 1245, 14, 362, 360, 1507, 28166, 297, 378, 9, 1128, 340, 730, 8, 78, 22416, 9, 440, 315, 14526, 503, 302, 22416, 665, 378, 26, 1039, 746, 1722, 1128, 366, 22416, 275, 1245, 14, 362, 360, 4456, 28166, 297, 378, 9, 1128, 340, 730, 8, 68, 22416, 9, 440, 315, 14526, 503, 366, 22416, 665, 378, 26, 1039, 746, 1722, 1128, 2061, 275, 1245, 14, 362, 360, 2019, 297, 378, 9, 1128, 340, 730, 8, 2019, 9, 440, 315, 14526, 503, 2061, 665, 378, 26, 1039, 746, 1722, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 27694, 701, 699, 5975, 1849, 16800, 202, 199, 3, 1937, 5113, 14, 2424, 367, 4190, 2556, 2999, 199, 504, 2943, 492, 32654, 12, 19944, 804, 12, 9805, 804, 12, 3820, 804, 12, 7448, 804, 202, 199, 646, 295, 2999, 199, 1135, 275, 295, 14, 2014, 8, 82, 4289, 4735, 15, 20942, 94, 1527, 62, 15, 1103, 3672, 9988, 2999, 199, 13141, 275, 334, 9551, 804, 12, 9805, 804, 9, 2999, 199, 318, 1104, 63, 815, 8, 815, 304, 1128, 340, 730, 8, 815, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 440, 282, 2600, 7, 1128, 10338, 275, 2256, 14, 362, 360, 15655, 358, 1128, 340, 730, 8, 15655, 9, 1137, 32654, 503, 822, 8, 15655, 9, 450, 3388, 1137, 378, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 10338, 790, 7, 1128, 14854, 1267, 275, 2256, 14, 362, 360, 20082, 2582, 358, 1128, 340, 730, 8, 20082, 1267, 9, 440, 315, 14526, 503, 14854, 1267, 2695, 378, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 20282, 14854, 2582, 7, 1128, 536, 275, 2256, 14, 362, 360, 354, 358, 1128, 340, 730, 8, 354, 9, 1137, 32654, 26, 1039, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 536, 7, 1128, 340, 440, 1295, 14, 1431, 8, 354, 304, 1039, 746, 1722, 12, 283, 354, 450, 83, 30994, 367, 6391, 14872, 7, 450, 536, 1128, 340, 2256, 14, 1989, 63, 498, 360, 1725, 358, 508, 2256, 14, 1989, 63, 498, 360, 1267, 735, 1039, 746, 1722, 12, 283, 4780, 15, 6048, 570, 13667, 7, 1128, 340, 2256, 14, 1989, 63, 498, 360, 1267, 735, 1039, 2582, 275, 2256, 14, 362, 360, 1267, 358, 1039, 340, 730, 8, 1267, 9, 440, 315, 14526, 503, 2582, 665, 378, 26, 1675, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 2582, 7, 1128, 587, 26, 1039, 1584, 275, 2256, 14, 362, 360, 1725, 358, 1039, 340, 730, 8, 1725, 9, 1137, 3820, 804, 26, 1675, 746, 1722, 1039, 367, 289, 315, 1584, 26, 1675, 340, 730, 8, 70, 9, 1137, 7448, 804, 26, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 570, 574, 7, 1675, 2582, 275, 289, 14, 362, 360, 1267, 358, 1675, 340, 730, 8, 1267, 9, 440, 315, 14526, 503, 2582, 665, 378, 26, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 2582, 7, 1675, 931, 275, 289, 14, 362, 360, 515, 358, 1675, 340, 730, 8, 515, 9, 1137, 3820, 804, 503, 931, 508, 18410, 2628, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 931, 7, 1675, 367, 299, 315, 931, 26, 2628, 340, 730, 8, 80, 9, 1137, 32654, 26, 4906, 746, 1722, 12, 283, 4087, 3404, 815, 446, 4875, 931, 2935, 7, 2628, 340, 440, 1295, 14, 1431, 8, 80, 304, 4906, 746, 1722, 12, 283, 515, 450, 83, 30994, 367, 6391, 14872, 7, 450, 299, 1039, 367, 284, 315, 4945, 8, 552, 8, 1725, 2298, 1675, 367, 1335, 315, 4945, 8, 73, 304, 2628, 340, 1584, 59, 73, 2733, 515, 418, 508, 1584, 59, 74, 2733, 515, 2565, 4906, 746, 1722, 12, 283, 4087, 3404, 815, 446, 9250, 931, 7, 2999, 199, 318, 1104, 63, 1188, 8, 1188, 304, 1128, 340, 730, 8, 1188, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 1128, 1104, 63, 815, 8, 1188, 14, 362, 360, 815, 1333, 1128, 340, 730, 8, 1188, 14, 362, 360, 17803, 1333, 1137, 32654, 26, 1039, 746, 1722, 2999, 199, 318, 1104, 63, 22416, 8, 1188, 304, 1128, 340, 730, 8, 1188, 9, 1137, 7448, 804, 26, 1039, 746, 1722, 1128, 340, 1245, 14, 1989, 63, 498, 360, 5328, 4499, 735, 1039, 340, 730, 8, 1188, 459, 5328, 4499, 1105, 1137, 32654, 26, 1675, 746, 1722, 1039, 372, 1128, 28166, 275, 1245, 14, 362, 360, 22416, 358, 1128, 340, 730, 8, 22416, 9, 508, 3820, 804, 26, 1039, 367, 299, 315, 28166, 26, 1675, 340, 730, 8, 80, 9, 1137, 7448, 804, 26, 2628, 746, 1722, 1675, 340, 730, 8, 80, 14, 362, 360, 711, 1333, 1137, 32654, 26, 2628, 746, 1722, 1675, 1844, 275, 299, 14, 362, 360, 719, 358, 1675, 340, 730, 8, 719, 9, 440, 315, 14526, 503, 299, 2695, 378, 26, 2628, 746, 1722, 1675, 340, 299, 14, 1989, 63, 498, 360, 7866, 1305, 735, 2628, 1305, 275, 299, 459, 7866, 1305, 418, 2628, 340, 730, 8, 344, 9, 1137, 32654, 503, 822, 8, 344, 9, 1137, 3388, 26, 4906, 746, 1722, 1128, 916, 730, 8, 22416, 9, 1137, 32654, 503, 822, 8, 22416, 9, 450, 1227, 1137, 378, 26, 1039, 746, 1722, 1128, 6252, 275, 1245, 14, 362, 360, 4284, 297, 413, 9, 1128, 340, 730, 8, 4284, 9, 440, 315, 14526, 503, 6252, 2695, 378, 26, 1039, 746, 1722, 1128, 1748, 442, 275, 1245, 14, 362, 360, 827, 6252, 297, 413, 9, 1128, 340, 730, 8, 827, 442, 9, 440, 315, 14526, 503, 1748, 442, 2695, 378, 26, 1039, 746, 1722, 1128, 340, 730, 8, 1188, 14, 362, 360, 8877, 1305, 297, 12381, 1137, 32654, 26, 1039, 746, 1722, 1128, 302, 22416, 275, 1245, 14, 362, 360, 1507, 28166, 297, 378, 9, 1128, 340, 730, 8, 78, 22416, 9, 440, 315, 14526, 503, 302, 22416, 665, 378, 26, 1039, 746, 1722, 1128, 366, 22416, 275, 1245, 14, 362, 360, 4456, 28166, 297, 378, 9, 1128, 340, 730, 8, 68, 22416, 9, 440, 315, 14526, 503, 366, 22416, 665, 378, 26, 1039, 746, 1722, 1128, 2061, 275, 1245, 14, 362, 360, 2019, 297, 378, 9, 1128, 340, 730, 8, 2019, 9, 440, 315, 14526, 503, 2061, 665, 378, 26, 1039, 746, 1722, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
TobiasNils/python-seabreeze
seabreeze/backends.py
1
1377
import warnings __SEABREEZE_BACKEND = 'cseabreeze' def use(backend): if not backend in ['cseabreeze', 'pyseabreeze']: raise Exception('Choose backend from "cseabreeze", "pyseabreeze"') else: global __SEABREEZE_BACKEND __SEABREEZE_BACKEND = backend def get_backend(): global __SEABREEZE_BACKEND if __SEABREEZE_BACKEND == 'cseabreeze': b = _use_cseabreeze() if b: return b warnings.warn("Falling back to 'pyseabreeze'.") b = _use_pyseabreeze() if b: return b if __SEABREEZE_BACKEND == 'pyseabreeze': b = _use_pyseabreeze() if b: return b warnings.warn("Falling back to 'cseabreeze'.") b = _use_cseabreeze() if b: return b raise ImportError('Could not import any backends. Wanted "%s"' % __SEABREEZE_BACKEND) def _use_cseabreeze(): try: import seabreeze.cseabreeze as sbb except ImportError as err: warnings.warn("Can't load seabreeze c library wrapper, because:\n'%s'\n" % str(err) ) return None else: sbb.initialize() return sbb def _use_pyseabreeze(): try: import seabreeze.pyseabreeze as sbb except ImportError as err: warnings.warn("Can't load pyusb wrapper, because:\n'%s'\n" % str(err) ) return None else: sbb.initialize() return sbb
mit
[ 646, 3598, 199, 199, 363, 899, 1217, 5271, 3687, 63, 18145, 275, 283, 67, 261, 371, 850, 806, 7, 199, 199, 318, 675, 8, 4620, 304, 272, 340, 440, 4865, 315, 788, 67, 261, 371, 850, 806, 297, 283, 647, 261, 371, 850, 806, 2565, 267, 746, 2186, 360, 23932, 4865, 687, 298, 67, 261, 371, 850, 806, 401, 298, 647, 261, 371, 850, 806, 9008, 272, 587, 26, 267, 2288, 636, 899, 1217, 5271, 3687, 63, 18145, 267, 636, 899, 1217, 5271, 3687, 63, 18145, 275, 4865, 199, 199, 318, 664, 63, 4620, 837, 272, 2288, 636, 899, 1217, 5271, 3687, 63, 18145, 272, 340, 636, 899, 1217, 5271, 3687, 63, 18145, 508, 283, 67, 261, 371, 850, 806, 356, 267, 330, 275, 485, 1180, 63, 67, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 267, 3598, 14, 4050, 480, 38, 26039, 1771, 370, 283, 647, 261, 371, 850, 806, 29435, 267, 330, 275, 485, 1180, 63, 647, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 272, 340, 636, 899, 1217, 5271, 3687, 63, 18145, 508, 283, 647, 261, 371, 850, 806, 356, 267, 330, 275, 485, 1180, 63, 647, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 267, 3598, 14, 4050, 480, 38, 26039, 1771, 370, 283, 67, 261, 371, 850, 806, 29435, 267, 330, 275, 485, 1180, 63, 67, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 272, 746, 3545, 360, 6531, 440, 492, 1263, 14745, 14, 644, 10221, 2071, 83, 4507, 450, 636, 899, 1217, 5271, 3687, 63, 18145, 9, 199, 199, 318, 485, 1180, 63, 67, 261, 371, 850, 806, 837, 272, 862, 26, 267, 492, 542, 371, 850, 806, 14, 67, 261, 371, 850, 806, 465, 308, 2501, 272, 871, 3545, 465, 2329, 26, 267, 3598, 14, 4050, 480, 6049, 1133, 2248, 542, 371, 850, 806, 286, 3555, 4975, 12, 2952, 3427, 78, 5956, 83, 1154, 78, 2, 450, 620, 8, 1508, 9, 776, 267, 372, 488, 272, 587, 26, 267, 308, 2501, 14, 8489, 342, 267, 372, 308, 2501, 199, 199, 318, 485, 1180, 63, 647, 261, 371, 850, 806, 837, 272, 862, 26, 267, 492, 542, 371, 850, 806, 14, 647, 261, 371, 850, 806, 465, 308, 2501, 272, 871, 3545, 465, 2329, 26, 267, 3598, 14, 4050, 480, 6049, 1133, 2248, 1134, 17411, 4975, 12, 2952, 3427, 78, 5956, 83, 1154, 78, 2, 450, 620, 8, 1508, 9, 776, 267, 372, 488, 272, 587, 26, 267, 308, 2501, 14, 8489, 342, 267, 372, 308, 2501, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3598, 199, 199, 363, 899, 1217, 5271, 3687, 63, 18145, 275, 283, 67, 261, 371, 850, 806, 7, 199, 199, 318, 675, 8, 4620, 304, 272, 340, 440, 4865, 315, 788, 67, 261, 371, 850, 806, 297, 283, 647, 261, 371, 850, 806, 2565, 267, 746, 2186, 360, 23932, 4865, 687, 298, 67, 261, 371, 850, 806, 401, 298, 647, 261, 371, 850, 806, 9008, 272, 587, 26, 267, 2288, 636, 899, 1217, 5271, 3687, 63, 18145, 267, 636, 899, 1217, 5271, 3687, 63, 18145, 275, 4865, 199, 199, 318, 664, 63, 4620, 837, 272, 2288, 636, 899, 1217, 5271, 3687, 63, 18145, 272, 340, 636, 899, 1217, 5271, 3687, 63, 18145, 508, 283, 67, 261, 371, 850, 806, 356, 267, 330, 275, 485, 1180, 63, 67, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 267, 3598, 14, 4050, 480, 38, 26039, 1771, 370, 283, 647, 261, 371, 850, 806, 29435, 267, 330, 275, 485, 1180, 63, 647, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 272, 340, 636, 899, 1217, 5271, 3687, 63, 18145, 508, 283, 647, 261, 371, 850, 806, 356, 267, 330, 275, 485, 1180, 63, 647, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 267, 3598, 14, 4050, 480, 38, 26039, 1771, 370, 283, 67, 261, 371, 850, 806, 29435, 267, 330, 275, 485, 1180, 63, 67, 261, 371, 850, 806, 342, 267, 340, 330, 26, 372, 330, 272, 746, 3545, 360, 6531, 440, 492, 1263, 14745, 14, 644, 10221, 2071, 83, 4507, 450, 636, 899, 1217, 5271, 3687, 63, 18145, 9, 199, 199, 318, 485, 1180, 63, 67, 261, 371, 850, 806, 837, 272, 862, 26, 267, 492, 542, 371, 850, 806, 14, 67, 261, 371, 850, 806, 465, 308, 2501, 272, 871, 3545, 465, 2329, 26, 267, 3598, 14, 4050, 480, 6049, 1133, 2248, 542, 371, 850, 806, 286, 3555, 4975, 12, 2952, 3427, 78, 5956, 83, 1154, 78, 2, 450, 620, 8, 1508, 9, 776, 267, 372, 488, 272, 587, 26, 267, 308, 2501, 14, 8489, 342, 267, 372, 308, 2501, 199, 199, 318, 485, 1180, 63, 647, 261, 371, 850, 806, 837, 272, 862, 26, 267, 492, 542, 371, 850, 806, 14, 647, 261, 371, 850, 806, 465, 308, 2501, 272, 871, 3545, 465, 2329, 26, 267, 3598, 14, 4050, 480, 6049, 1133, 2248, 1134, 17411, 4975, 12, 2952, 3427, 78, 5956, 83, 1154, 78, 2, 450, 620, 8, 1508, 9, 776, 267, 372, 488, 272, 587, 26, 267, 308, 2501, 14, 8489, 342, 267, 372, 308, 2501, 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, 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, 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PfmNT0hGMEafbyKh7R9iV3pXDdEtfiW9ICcl5RBTi5OikJWrvbG/7EKkS" + "EXS4/91iRuVtW3jAEfaQELWTO0Rz3kPb6SeJlJCYV25BGCsRzk/5RqPCLOw6Pv2y7ah4e352cDpysLp3RpB9PapyEdIeetI7ZJE+Ws1bcBF6jtN469B6kj5PvI0AAoZa" + "1hjqccTFjVW+Z3PH5gh+EOTnydDmvLxy+O7676UCxNnpnC9Xx+XM9rAr31sKBn4R44KIQxYWHWere98nLWY6+guWQDoB8KO9lM3L37w431pBdhydbh2e9KarKLWfe6/s" + "V4L5iLs/uBC/gM9XD9ORyHkL8ChSmQhuX0gjK0y4oPDi49Lsf8YA+F9CaCJi5SEAAA==") g = base64.b64decode(_g)[1:] for i in range(ord(base64.b64decode(_g)[0])): g = zlib.decompress(g, 16+zlib.MAX_WBITS) g=list(map(ord, g)) def gr(x,y): if(x>=0 and y>=0 and x<1224 and y<833): return g[y*1224 + x]; return 0; def gw(x,y,v): if(x>=0 and y>=0 and x<1224 and y<833): g[y*1224 + x]=v; def td(a,b): return ((0)if(b==0)else(a//b)) def tm(a,b): return ((0)if(b==0)else(a%b)) s=[] def sp(): global s if (len(s) == 0): return 0 return s.pop() def sa(v): global s s.append(v) def sr(): global s if (len(s) == 0): return 0 return s[-1] def _0(): gw(1,1,1224) gw(2,1,817) gw(3,1,1000000) gw(4,2,0) sa(gr(3,1)-1) sa(gr(3,1)-1) gw(tm(gr(3,1)-1,gr(1,1)),(td(gr(3,1)-1,gr(1,1)))+4,0) return 1 def _1(): return (27)if(sp()!=0)else(2) def _2(): gw(7,0,0) sp(); sa(1) sa(1) return 3 def _3(): sa(gr(7,0)+9) gw(7,0,gr(7,0)+1) sa(0) v0=sp() v1=sp() gw(v1,v0,sp()) sa(sp()*gr(7,0)) return (26)if(gr(7,0)!=10)else(4) def _4(): gw(0,4,0) gw(tm(169,gr(1,1)),(td(169,gr(1,1)))+4,3) gw(tm(363601,gr(1,1)),(td(363601,gr(1,1)))+4,3) gw(tm(1454,gr(1,1)),(td(1454,gr(1,1)))+4,3) gw(tm(871,gr(1,1)),(td(871,gr(1,1)))+4,2) gw(tm(45361,gr(1,1)),(td(45361,gr(1,1)))+4,2) gw(tm(872,gr(1,1)),(td(872,gr(1,1)))+4,2) gw(tm(45362,gr(1,1)),(td(45362,gr(1,1)))+4,2) gw(1,2,1) sp(); sa(1) return 5 def _5(): gw(2,2,0) gw(9,2,0) gw(3,2,0) return 6 def _6(): return (7)if((gr(gr(3,2)+9,2)-gr(1,2))!=0)else(13) def _7(): sa(gr(1,2)) sa(gr(2,2)+10) gw(2,2,gr(2,2)+1) sa(2) v0=sp() v1=sp() gw(v1,v0,sp()) gw(3,2,gr(3,2)+1) sa(0) sa(gr(1,2)) return (24)if((gr(1,2))!=0)else(8) def _8(): sp(); return 9 def _9(): v0=sp() v1=sp() sa(v0) sa(v1) sa(sr()); return (23)if(sp()!=0)else(10) def _10(): sa(sp()+sp()); sa(sr()); gw(1,2,sp()) sa((1)if(sp()>gr(3,1))else(0)) return (6)if(sp()!=0)else(11) def _11(): global t0 t0=gr(tm(gr(1,2),gr(1,1)),(td(gr(1,2),gr(1,1)))+4) return (12)if((gr(tm(gr(1,2),gr(1,1)),(td(gr(1,2),gr(1,1)))+4))!=0)else(6) def _12(): global t0 t0=t0+gr(2,2) gw(2,2,t0) return 13 def _13(): return (14)if(gr(2,2)!=60)else(22) def _14(): sa(1) sa((1)if(gr(10,2)>gr(3,1))else(0)) return 15 def _15(): return (17)if(sp()!=0)else(16) def _16(): global t0 t0=gr(2,2)+1 sa(sr()); sa(sr()); sa(t0) v0=sp() v1=sp() sa(v0) sa(v1) v0=sp() sa(sp()-v0) v0=sp() v1=sp() sa(v0) sa(v1) sa(sp()+9) sa(2) v0=sp() sa(gr(sp(),v0)) sa(tm(sr(),gr(1,1))) v0=sp() v1=sp() sa(v0) sa(v1) sa(td(sp(),gr(1,1))) sa(sp()+4) v0=sp() v1=sp() gw(v1,v0,sp()) return 17 def _17(): return (21)if((sr()-gr(3,2))!=0)else(18) def _18(): sp(); return (20)if((sr()-gr(3,1))!=0)else(19) def _19(): sys.stdout.write(str(gr(4,2))+" ") sys.stdout.flush() sp(); return 28 def _20(): sa(sp()+1) sa(sr()); gw(1,2,sp()) return 5 def _21(): sa(sp()+1) sa((1)if(gr(sr()+9,2)>gr(3,1))else(0)) return 15 def _22(): gw(4,2,gr(4,2)+1) return 14 def _23(): sa(sp()+sp()); return 9 def _24(): sa(gr((sr()%10)+9,0)) v0=sp() v1=sp() sa(v0) sa(v1) sa(sp()/10); sa(sr()); return 25 def _25(): return (24)if(sp()!=0)else(8) def _26(): sa(sr()); return 3 def _27(): sa(sp()-1) sa(sr()); sa(0) v0=sp() v1=sp() sa(v0) sa(v1) sa(tm(sr(),gr(1,1))) v0=sp() v1=sp() sa(v0) sa(v1) sa(td(sp(),gr(1,1))) sa(sp()+4) v0=sp() v1=sp() gw(v1,v0,sp()) sa(sr()); return 1 m=[_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27] c=0 while c<28: c=m[c]()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 7115, 681, 1672, 543, 699, 2829, 324, 12626, 373, 17, 14, 19, 14, 16, 334, 67, 9, 9708, 199, 646, 984, 199, 646, 12472, 12, 1300, 772, 199, 63, 71, 275, 1689, 33, 72, 11, 7027, 6151, 31723, 1554, 7574, 54, 67, 20, 78, 39, 15, 12046, 69, 45, 19, 86, 85, 41, 19, 79, 41, 53, 2846, 77, 74, 5782, 15, 69, 42, 65, 44, 19, 3234, 50, 2226, 90, 8699, 16, 53, 55, 35, 25575, 25074, 74, 49, 5812, 9956, 39, 68, 16, 65, 42, 27046, 58, 12339, 758, 72, 13381, 84, 20098, 2226, 58, 70, 11, 50, 11, 24, 58, 15, 21405, 19, 271, 17, 82, 2898, 21405, 15, 85, 3172, 2392, 24, 1153, 53, 15, 17, 90, 80, 2177, 25939, 53, 2, 523, 435, 298, 71, 44, 24, 3593, 55, 5583, 45, 1427, 1003, 1774, 53, 2521, 7300, 43, 20369, 36, 19, 43, 19, 35, 11, 12990, 55, 73, 19327, 42, 75, 1892, 44, 90, 43, 14784, 18867, 17, 43, 1082, 88, 43, 345, 73, 87, 21, 69, 58, 15487, 17, 12874, 90, 21, 80, 52, 21, 89, 38, 74, 681, 23, 15156, 72, 300, 1400, 71, 11, 44, 17, 2041, 31413, 50, 24, 81, 69, 13129, 88, 10941, 56, 70, 2901, 83, 42, 68, 54, 1555, 1665, 79, 31005, 21, 40, 70, 90, 71, 24, 76, 44, 15, 10472, 2, 523, 435, 298, 79, 1184, 49, 38, 16, 81, 37, 17, 1845, 654, 66, 20, 44, 15, 22, 47, 1649, 14324, 44, 1230, 14828, 23, 1907, 6532, 53, 49, 75, 47, 57, 7872, 2894, 88, 4332, 6379, 43, 75, 38, 84, 596, 43, 77, 11, 77, 34, 75, 17, 58, 12098, 11, 79, 53, 49, 43, 7872, 71, 22, 80, 42, 2054, 15, 2037, 40, 31282, 2749, 33, 530, 45, 24, 37, 85, 433, 24, 55, 346, 46, 1812, 55, 15, 68, 4283, 4567, 31506, 25, 13100, 29211, 49, 1217, 77, 19, 42, 40, 43, 18, 18101, 1151, 2, 523, 435, 298, 75, 33, 24, 2319, 31330, 45, 11, 2191, 87, 22, 89, 49, 31005, 23, 89, 45, 2054, 57, 568, 17421, 57, 43, 74, 58, 1151, 7701, 1645, 54, 87, 36, 24, 89, 16911, 9839, 75, 16936, 1082, 6857, 5676, 42, 23, 50, 1038, 11, 88, 2010, 72, 2789, 6166, 88, 328, 43, 568, 40, 75, 44, 1254, 68, 36, 87, 3561, 89, 47, 86, 81, 3143, 72, 43, 845, 86, 20, 15, 84, 41, 88, 42, 5682, 88, 58, 13840, 41, 89, 18998, 19665, 20, 10772, 53, 57, 11, 57, 11888, 28868, 21, 1512, 2, 523, 435, 298, 74, 25, 45, 5466, 54, 1157, 2191, 76, 37, 16512, 1945, 2611, 654, 43, 58, 526, 72, 1226, 1138, 30251, 58, 319, 37, 7872, 371, 2226, 8070, 9730, 87, 18114, 33, 65, 42, 40, 337, 25, 6287, 66, 33, 2260, 30815, 16, 545, 71, 17420, 46, 20, 86, 998, 71, 1710, 25, 38, 72, 31064, 2089, 22, 5294, 25063, 50, 81, 79, 40, 5294, 50, 975, 67, 17706, 56, 54, 49, 1387, 42, 3714, 90, 38, 17, 38, 4680, 76, 17, 85, 26779, 643, 7902, 6002, 88, 2, 523, 435, 298, 775, 3448, 57, 23, 22904, 37, 24, 41, 1703, 7872, 711, 88, 47, 8980, 4361, 52, 20, 77, 48, 42, 40, 15268, 66, 1355, 85, 5617, 34, 72, 13167, 18, 11475, 19, 37, 15, 344, 23827, 58, 44, 72, 54, 74, 71, 43, 2208, 26607, 89, 31916, 25, 31064, 29021, 27764, 49, 20, 15361, 43, 75, 25, 7730, 24016, 9457, 25575, 57, 49, 72, 1518, 13026, 2709, 14272, 20, 87, 17, 49, 24, 42, 24, 56, 54, 1196, 88, 3927, 17, 23215, 32603, 7872, 20, 58, 3927, 77, 273, 2, 523, 435, 298, 17, 80, 6882, 1662, 80, 5691, 41, 86, 43, 21, 80, 3561, 47, 6603, 11, 31707, 14485, 25262, 5908, 39, 11, 18, 9741, 15, 53, 77, 57, 1766, 25620, 42, 80, 24, 11178, 758, 58, 20, 38, 19, 15, 3714, 37, 7431, 21, 20622, 18, 1447, 84, 18, 84, 13381, 11, 2182, 90, 18, 50, 22, 69, 24278, 19716, 23, 11, 8796, 50, 18, 69, 39, 14307, 22961, 33, 8835, 21867, 38, 72, 1193, 75, 17401, 52, 81, 56, 70, 58, 12206, 18, 50, 89, 44, 1831, 82, 6080, 829, 75, 40, 2, 523, 435, 298, 53, 14784, 19, 6287, 67, 1349, 7484, 1381, 57, 18759, 40, 454, 18, 87, 23320, 56, 20, 70, 12339, 3630, 3328, 29496, 16, 758, 56, 66, 52, 12098, 70, 56, 81, 1407, 48, 87, 81, 87, 22, 649, 4908, 88, 319, 16608, 22620, 38, 87, 26254, 2154, 68, 22367, 77, 42, 23571, 1214, 87, 90, 19, 47, 81, 86, 20, 55, 83, 57, 497, 23571, 53, 15, 81, 55, 7250, 20, 2772, 23, 47, 7574, 16944, 42, 2080, 82, 48, 70, 1344, 77, 36, 6495, 16, 57, 23, 3986, 68, 40, 16, 2, 523, 435, 298, 39, 80, 49, 38, 1229, 30127, 87, 11, 52, 11, 2916, 82, 2760, 84, 41, 75, 35, 21, 651, 67, 21, 74, 476, 280, 57, 11, 85, 1703, 679, 68, 25, 34, 86, 12098, 51, 802, 70, 50, 23605, 22879, 34, 78, 11, 39, 9457, 74, 20271, 18, 615, 48, 433, 72, 23, 4348, 82, 55, 17, 270, 37, 75, 31005, 8565, 2036, 15, 9648, 44, 80, 18750, 40, 19, 76, 16, 69, 49, 11548, 2260, 88, 47, 1786, 47, 20, 54, 74, 33, 16458, 31282, 26256, 3951, 85, 57, 24, 70, 16, 2051, 66, 2, 523, 435, 298, 56, 11, 3289, 19665, 47, 10134, 2466, 1257, 87, 40, 19, 68, 57, 4492, 1479, 19716, 3997, 40, 22, 80, 50, 42, 382, 48, 713, 1293, 17, 266, 17613, 4567, 998, 281, 18, 33, 16, 33, 1885, 18, 86, 52, 76, 27061, 49, 22947, 17, 26394, 45, 76, 23, 74, 2989, 14176, 46, 88, 58, 16, 1136, 42, 20, 1348, 18, 8711, 39, 15203, 383, 1534, 280, 19, 2639, 3172, 15, 8810, 58, 86, 34, 5372, 90, 39, 13655, 37, 89, 87, 19, 34, 1181, 18, 11, 87, 44, 2, 523, 435, 298, 71, 2501, 30896, 1480, 38, 24, 67, 44, 39, 2300, 85, 331, 17, 2662, 38, 42, 81, 58, 22, 49 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 7115, 681, 1672, 543, 699, 2829, 324, 12626, 373, 17, 14, 19, 14, 16, 334, 67, 9, 9708, 199, 646, 984, 199, 646, 12472, 12, 1300, 772, 199, 63, 71, 275, 1689, 33, 72, 11, 7027, 6151, 31723, 1554, 7574, 54, 67, 20, 78, 39, 15, 12046, 69, 45, 19, 86, 85, 41, 19, 79, 41, 53, 2846, 77, 74, 5782, 15, 69, 42, 65, 44, 19, 3234, 50, 2226, 90, 8699, 16, 53, 55, 35, 25575, 25074, 74, 49, 5812, 9956, 39, 68, 16, 65, 42, 27046, 58, 12339, 758, 72, 13381, 84, 20098, 2226, 58, 70, 11, 50, 11, 24, 58, 15, 21405, 19, 271, 17, 82, 2898, 21405, 15, 85, 3172, 2392, 24, 1153, 53, 15, 17, 90, 80, 2177, 25939, 53, 2, 523, 435, 298, 71, 44, 24, 3593, 55, 5583, 45, 1427, 1003, 1774, 53, 2521, 7300, 43, 20369, 36, 19, 43, 19, 35, 11, 12990, 55, 73, 19327, 42, 75, 1892, 44, 90, 43, 14784, 18867, 17, 43, 1082, 88, 43, 345, 73, 87, 21, 69, 58, 15487, 17, 12874, 90, 21, 80, 52, 21, 89, 38, 74, 681, 23, 15156, 72, 300, 1400, 71, 11, 44, 17, 2041, 31413, 50, 24, 81, 69, 13129, 88, 10941, 56, 70, 2901, 83, 42, 68, 54, 1555, 1665, 79, 31005, 21, 40, 70, 90, 71, 24, 76, 44, 15, 10472, 2, 523, 435, 298, 79, 1184, 49, 38, 16, 81, 37, 17, 1845, 654, 66, 20, 44, 15, 22, 47, 1649, 14324, 44, 1230, 14828, 23, 1907, 6532, 53, 49, 75, 47, 57, 7872, 2894, 88, 4332, 6379, 43, 75, 38, 84, 596, 43, 77, 11, 77, 34, 75, 17, 58, 12098, 11, 79, 53, 49, 43, 7872, 71, 22, 80, 42, 2054, 15, 2037, 40, 31282, 2749, 33, 530, 45, 24, 37, 85, 433, 24, 55, 346, 46, 1812, 55, 15, 68, 4283, 4567, 31506, 25, 13100, 29211, 49, 1217, 77, 19, 42, 40, 43, 18, 18101, 1151, 2, 523, 435, 298, 75, 33, 24, 2319, 31330, 45, 11, 2191, 87, 22, 89, 49, 31005, 23, 89, 45, 2054, 57, 568, 17421, 57, 43, 74, 58, 1151, 7701, 1645, 54, 87, 36, 24, 89, 16911, 9839, 75, 16936, 1082, 6857, 5676, 42, 23, 50, 1038, 11, 88, 2010, 72, 2789, 6166, 88, 328, 43, 568, 40, 75, 44, 1254, 68, 36, 87, 3561, 89, 47, 86, 81, 3143, 72, 43, 845, 86, 20, 15, 84, 41, 88, 42, 5682, 88, 58, 13840, 41, 89, 18998, 19665, 20, 10772, 53, 57, 11, 57, 11888, 28868, 21, 1512, 2, 523, 435, 298, 74, 25, 45, 5466, 54, 1157, 2191, 76, 37, 16512, 1945, 2611, 654, 43, 58, 526, 72, 1226, 1138, 30251, 58, 319, 37, 7872, 371, 2226, 8070, 9730, 87, 18114, 33, 65, 42, 40, 337, 25, 6287, 66, 33, 2260, 30815, 16, 545, 71, 17420, 46, 20, 86, 998, 71, 1710, 25, 38, 72, 31064, 2089, 22, 5294, 25063, 50, 81, 79, 40, 5294, 50, 975, 67, 17706, 56, 54, 49, 1387, 42, 3714, 90, 38, 17, 38, 4680, 76, 17, 85, 26779, 643, 7902, 6002, 88, 2, 523, 435, 298, 775, 3448, 57, 23, 22904, 37, 24, 41, 1703, 7872, 711, 88, 47, 8980, 4361, 52, 20, 77, 48, 42, 40, 15268, 66, 1355, 85, 5617, 34, 72, 13167, 18, 11475, 19, 37, 15, 344, 23827, 58, 44, 72, 54, 74, 71, 43, 2208, 26607, 89, 31916, 25, 31064, 29021, 27764, 49, 20, 15361, 43, 75, 25, 7730, 24016, 9457, 25575, 57, 49, 72, 1518, 13026, 2709, 14272, 20, 87, 17, 49, 24, 42, 24, 56, 54, 1196, 88, 3927, 17, 23215, 32603, 7872, 20, 58, 3927, 77, 273, 2, 523, 435, 298, 17, 80, 6882, 1662, 80, 5691, 41, 86, 43, 21, 80, 3561, 47, 6603, 11, 31707, 14485, 25262, 5908, 39, 11, 18, 9741, 15, 53, 77, 57, 1766, 25620, 42, 80, 24, 11178, 758, 58, 20, 38, 19, 15, 3714, 37, 7431, 21, 20622, 18, 1447, 84, 18, 84, 13381, 11, 2182, 90, 18, 50, 22, 69, 24278, 19716, 23, 11, 8796, 50, 18, 69, 39, 14307, 22961, 33, 8835, 21867, 38, 72, 1193, 75, 17401, 52, 81, 56, 70, 58, 12206, 18, 50, 89, 44, 1831, 82, 6080, 829, 75, 40, 2, 523, 435, 298, 53, 14784, 19, 6287, 67, 1349, 7484, 1381, 57, 18759, 40, 454, 18, 87, 23320, 56, 20, 70, 12339, 3630, 3328, 29496, 16, 758, 56, 66, 52, 12098, 70, 56, 81, 1407, 48, 87, 81, 87, 22, 649, 4908, 88, 319, 16608, 22620, 38, 87, 26254, 2154, 68, 22367, 77, 42, 23571, 1214, 87, 90, 19, 47, 81, 86, 20, 55, 83, 57, 497, 23571, 53, 15, 81, 55, 7250, 20, 2772, 23, 47, 7574, 16944, 42, 2080, 82, 48, 70, 1344, 77, 36, 6495, 16, 57, 23, 3986, 68, 40, 16, 2, 523, 435, 298, 39, 80, 49, 38, 1229, 30127, 87, 11, 52, 11, 2916, 82, 2760, 84, 41, 75, 35, 21, 651, 67, 21, 74, 476, 280, 57, 11, 85, 1703, 679, 68, 25, 34, 86, 12098, 51, 802, 70, 50, 23605, 22879, 34, 78, 11, 39, 9457, 74, 20271, 18, 615, 48, 433, 72, 23, 4348, 82, 55, 17, 270, 37, 75, 31005, 8565, 2036, 15, 9648, 44, 80, 18750, 40, 19, 76, 16, 69, 49, 11548, 2260, 88, 47, 1786, 47, 20, 54, 74, 33, 16458, 31282, 26256, 3951, 85, 57, 24, 70, 16, 2051, 66, 2, 523, 435, 298, 56, 11, 3289, 19665, 47, 10134, 2466, 1257, 87, 40, 19, 68, 57, 4492, 1479, 19716, 3997, 40, 22, 80, 50, 42, 382, 48, 713, 1293, 17, 266, 17613, 4567, 998, 281, 18, 33, 16, 33, 1885, 18, 86, 52, 76, 27061, 49, 22947, 17, 26394, 45, 76, 23, 74, 2989, 14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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
qwertyjune/BethSaidaBible
venv/lib/python2.7/site-packages/django/contrib/messages/tests/base.py
63
14509
from unittest import skipUnless from django import http from django.apps import apps from django.conf import global_settings from django.contrib.messages import constants, utils, get_level, set_level from django.contrib.messages.api import MessageFailure from django.contrib.messages.constants import DEFAULT_LEVELS from django.contrib.messages.storage import default_storage, base from django.contrib.messages.storage.base import Message from django.core.urlresolvers import reverse from django.test import modify_settings, override_settings from django.utils.translation import ugettext_lazy def skipUnlessAuthIsInstalled(func): return skipUnless( apps.is_installed('django.contrib.auth'), "django.contrib.auth isn't installed")(func) def add_level_messages(storage): """ Adds 6 messages from different levels (including a custom one) to a storage instance. """ storage.add(constants.INFO, 'A generic info message') storage.add(29, 'Some custom level') storage.add(constants.DEBUG, 'A debugging message', extra_tags='extra-tag') storage.add(constants.WARNING, 'A warning') storage.add(constants.ERROR, 'An error') storage.add(constants.SUCCESS, 'This was a triumph.') class override_settings_tags(override_settings): def enable(self): super(override_settings_tags, self).enable() # LEVEL_TAGS is a constant defined in the # django.contrib.messages.storage.base module, so after changing # settings.MESSAGE_TAGS, we need to update that constant too. self.old_level_tags = base.LEVEL_TAGS base.LEVEL_TAGS = utils.get_level_tags() def disable(self): super(override_settings_tags, self).disable() base.LEVEL_TAGS = self.old_level_tags class BaseTests(object): storage_class = default_storage urls = 'django.contrib.messages.tests.urls' levels = { 'debug': constants.DEBUG, 'info': constants.INFO, 'success': constants.SUCCESS, 'warning': constants.WARNING, 'error': constants.ERROR, } def setUp(self): self.settings_override = override_settings_tags( TEMPLATE_DIRS=(), TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS, MESSAGE_TAGS='', MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__, self.storage_class.__name__), SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer', ) self.settings_override.enable() def tearDown(self): self.settings_override.disable() def get_request(self): return http.HttpRequest() def get_response(self): return http.HttpResponse() def get_storage(self, data=None): """ Returns the storage backend, setting its loaded data to the ``data`` argument. This method avoids the storage ``_get`` method from getting called so that other parts of the storage backend can be tested independent of the message retrieval logic. """ storage = self.storage_class(self.get_request()) storage._loaded_data = data or [] return storage def test_add(self): storage = self.get_storage() self.assertFalse(storage.added_new) storage.add(constants.INFO, 'Test message 1') self.assertTrue(storage.added_new) storage.add(constants.INFO, 'Test message 2', extra_tags='tag') self.assertEqual(len(storage), 2) def test_add_lazy_translation(self): storage = self.get_storage() response = self.get_response() storage.add(constants.INFO, ugettext_lazy('lazy message')) storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 1) def test_no_update(self): storage = self.get_storage() response = self.get_response() storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 0) def test_add_update(self): storage = self.get_storage() response = self.get_response() storage.add(constants.INFO, 'Test message 1') storage.add(constants.INFO, 'Test message 1', extra_tags='tag') storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 2) def test_existing_add_read_update(self): storage = self.get_existing_storage() response = self.get_response() storage.add(constants.INFO, 'Test message 3') list(storage) # Simulates a read storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 0) def test_existing_read_add_update(self): storage = self.get_existing_storage() response = self.get_response() list(storage) # Simulates a read storage.add(constants.INFO, 'Test message 3') storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 1) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_full_request_response_cycle(self): """ With the message middleware enabled, tests that messages are properly stored and then retrieved across the full request/redirect/response cycle. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertTrue('messages' in response.context) messages = [Message(self.levels[level], msg) for msg in data['messages']] self.assertEqual(list(response.context['messages']), messages) for msg in data['messages']: self.assertContains(response, msg) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_with_template_response(self): data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show_template_response') for level in self.levels.keys(): add_url = reverse('django.contrib.messages.tests.urls.add_template_response', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertTrue('messages' in response.context) for msg in data['messages']: self.assertContains(response, msg) # there shouldn't be any messages on second GET request response = self.client.get(show_url) for msg in data['messages']: self.assertNotContains(response, msg) def test_context_processor_message_levels(self): show_url = reverse('django.contrib.messages.tests.urls.show_template_response') response = self.client.get(show_url) self.assertTrue('DEFAULT_MESSAGE_LEVELS' in response.context) self.assertEqual(response.context['DEFAULT_MESSAGE_LEVELS'], DEFAULT_LEVELS) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_multiple_posts(self): """ Tests that messages persist properly when multiple POSTs are made before a GET. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show') messages = [] for level in ('debug', 'info', 'success', 'warning', 'error'): messages.extend([Message(self.levels[level], msg) for msg in data['messages']]) add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) self.client.post(add_url, data) response = self.client.get(show_url) self.assertTrue('messages' in response.context) self.assertEqual(list(response.context['messages']), messages) for msg in data['messages']: self.assertContains(response, msg) @modify_settings( INSTALLED_APPS={'remove': 'django.contrib.messages'}, MIDDLEWARE_CLASSES={'remove': 'django.contrib.messages.middleware.MessageMiddleware'}, TEMPLATE_CONTEXT_PROCESSORS={'remove': 'django.contrib.messages.context_processors.messages'}, ) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_middleware_disabled(self): """ Tests that, when the middleware is disabled, an exception is raised when one attempts to store a message. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) self.assertRaises(MessageFailure, self.client.post, add_url, data, follow=True) @modify_settings( INSTALLED_APPS={'remove': 'django.contrib.messages'}, MIDDLEWARE_CLASSES={'remove': 'django.contrib.messages.middleware.MessageMiddleware'}, TEMPLATE_CONTEXT_PROCESSORS={'remove': 'django.contrib.messages.context_processors.messages'}, ) def test_middleware_disabled_fail_silently(self): """ Tests that, when the middleware is disabled, an exception is not raised if 'fail_silently' = True """ data = { 'messages': ['Test message %d' % x for x in range(5)], 'fail_silently': True, } show_url = reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertFalse('messages' in response.context) def stored_messages_count(self, storage, response): """ Returns the number of messages being stored after a ``storage.update()`` call. """ raise NotImplementedError('This method must be set by a subclass.') def test_get(self): raise NotImplementedError('This method must be set by a subclass.') def get_existing_storage(self): return self.get_storage([Message(constants.INFO, 'Test message 1'), Message(constants.INFO, 'Test message 2', extra_tags='tag')]) def test_existing_read(self): """ Tests that reading the existing storage doesn't cause the data to be lost. """ storage = self.get_existing_storage() self.assertFalse(storage.used) # After iterating the storage engine directly, the used flag is set. data = list(storage) self.assertTrue(storage.used) # The data does not disappear because it has been iterated. self.assertEqual(data, list(storage)) def test_existing_add(self): storage = self.get_existing_storage() self.assertFalse(storage.added_new) storage.add(constants.INFO, 'Test message 3') self.assertTrue(storage.added_new) def test_default_level(self): # get_level works even with no storage on the request. request = self.get_request() self.assertEqual(get_level(request), constants.INFO) # get_level returns the default level if it hasn't been set. storage = self.get_storage() request._messages = storage self.assertEqual(get_level(request), constants.INFO) # Only messages of sufficient level get recorded. add_level_messages(storage) self.assertEqual(len(storage), 5) def test_low_level(self): request = self.get_request() storage = self.storage_class(request) request._messages = storage self.assertTrue(set_level(request, 5)) self.assertEqual(get_level(request), 5) add_level_messages(storage) self.assertEqual(len(storage), 6) def test_high_level(self): request = self.get_request() storage = self.storage_class(request) request._messages = storage self.assertTrue(set_level(request, 30)) self.assertEqual(get_level(request), 30) add_level_messages(storage) self.assertEqual(len(storage), 2) @override_settings(MESSAGE_LEVEL=29) def test_settings_level(self): request = self.get_request() storage = self.storage_class(request) self.assertEqual(get_level(request), 29) add_level_messages(storage) self.assertEqual(len(storage), 3) def test_tags(self): storage = self.get_storage() storage.level = 0 add_level_messages(storage) tags = [msg.tags for msg in storage] self.assertEqual(tags, ['info', '', 'extra-tag debug', 'warning', 'error', 'success']) def test_level_tag(self): storage = self.get_storage() storage.level = 0 add_level_messages(storage) tags = [msg.level_tag for msg in storage] self.assertEqual(tags, ['info', '', 'debug', 'warning', 'error', 'success']) @override_settings_tags(MESSAGE_TAGS={ constants.INFO: 'info', constants.DEBUG: '', constants.WARNING: '', constants.ERROR: 'bad', 29: 'custom', } ) def test_custom_tags(self): storage = self.get_storage() storage.level = 0 add_level_messages(storage) tags = [msg.tags for msg in storage] self.assertEqual(tags, ['info', 'custom', 'extra-tag', '', 'bad', 'success'])
gpl-3.0
[ 504, 2882, 492, 3372, 5524, 199, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2288, 63, 1751, 199, 504, 1639, 14, 2828, 14, 3431, 492, 5262, 12, 3778, 12, 664, 63, 1896, 12, 663, 63, 1896, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 6430, 6782, 199, 504, 1639, 14, 2828, 14, 3431, 14, 5559, 492, 6186, 63, 906, 2524, 5296, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 492, 849, 63, 3494, 12, 1300, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 6430, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 2811, 63, 1751, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 421, 199, 318, 3372, 5524, 2817, 1831, 21268, 8, 1532, 304, 272, 372, 3372, 5524, 8, 267, 8686, 14, 374, 63, 7657, 360, 1176, 14, 2828, 14, 1178, 659, 267, 298, 1176, 14, 2828, 14, 1178, 5712, 1133, 4903, 25232, 1532, 9, 421, 199, 318, 1050, 63, 1896, 63, 3431, 8, 3494, 304, 272, 408, 272, 15747, 1227, 3788, 687, 3365, 11106, 334, 15768, 282, 3537, 1373, 9, 370, 282, 4887, 272, 1256, 14, 272, 408, 272, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 33, 7809, 2256, 1245, 358, 272, 4887, 14, 525, 8, 1398, 12, 283, 7700, 3537, 2166, 358, 272, 4887, 14, 525, 8, 5559, 14, 5287, 12, 283, 33, 10201, 1245, 297, 2402, 63, 2969, 534, 2911, 13, 1450, 358, 272, 4887, 14, 525, 8, 5559, 14, 9171, 12, 283, 33, 5721, 358, 272, 4887, 14, 525, 8, 5559, 14, 3170, 12, 283, 2493, 1125, 358, 272, 4887, 14, 525, 8, 5559, 14, 12779, 12, 283, 2765, 1990, 282, 3229, 1220, 72, 2659, 421, 199, 533, 4278, 63, 1751, 63, 2969, 8, 4415, 63, 1751, 304, 272, 347, 4756, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 4296, 342, 267, 327, 6124, 10429, 63, 17626, 365, 282, 4413, 3247, 315, 314, 267, 327, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 859, 12, 880, 2410, 13729, 267, 327, 2202, 14, 8272, 63, 17626, 12, 781, 1929, 370, 1678, 626, 4413, 4634, 14, 267, 291, 14, 1753, 63, 1896, 63, 2969, 275, 1300, 14, 11817, 63, 17626, 267, 1300, 14, 11817, 63, 17626, 275, 3778, 14, 362, 63, 1896, 63, 2969, 342, 339, 347, 3507, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 5993, 342, 267, 1300, 14, 11817, 63, 17626, 275, 291, 14, 1753, 63, 1896, 63, 2969, 421, 199, 533, 3523, 2925, 8, 785, 304, 272, 4887, 63, 533, 275, 849, 63, 3494, 272, 8187, 275, 283, 1176, 14, 2828, 14, 3431, 14, 2219, 14, 3603, 7, 272, 11106, 275, 469, 267, 283, 1757, 356, 5262, 14, 5287, 12, 267, 283, 815, 356, 5262, 14, 4531, 12, 267, 283, 3742, 356, 5262, 14, 12779, 12, 267, 283, 3764, 356, 5262, 14, 9171, 12, 267, 283, 705, 356, 5262, 14, 3170, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 275, 4278, 63, 1751, 63, 2969, 8, 288, 24877, 63, 14455, 16729, 288, 24877, 63, 9059, 63, 10494, 4149, 29, 2966, 63, 1751, 14, 7433, 63, 9059, 63, 10494, 4149, 12, 288, 603, 1608, 2962, 63, 17626, 4581, 288, 603, 1608, 2962, 63, 17467, 9569, 83, 4111, 83, 7, 450, 334, 277, 14, 3494, 63, 533, 855, 578, 3108, 4318, 291, 14, 3494, 63, 533, 855, 354, 10139, 288, 428, 9577, 63, 19637, 5357, 540, 534, 1176, 14, 2828, 14, 11676, 14, 12844, 14, 6243, 7299, 297, 267, 776, 267, 291, 14, 1751, 63, 4415, 14, 4296, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 14, 5993, 342, 339, 347, 664, 63, 1069, 8, 277, 304, 267, 372, 1455, 14, 10441, 342, 339, 347, 664, 63, 1310, 8, 277, 304, 267, 372, 1455, 14, 16287, 342, 339, 347, 664, 63, 3494, 8, 277, 12, 666, 29, 403, 304, 267, 408, 267, 1803, 314, 4887, 4865, 12, 4260, 2399, 6511, 666, 370, 314, 1124, 576, 1040, 267, 1423, 14, 398, 961, 1083, 23674, 314, 4887, 24507, 362, 1040, 1083, 687, 10232, 2797, 880, 267, 626, 1163, 4184, 402, 314, 4887, 4865, 883, 506, 12470, 12717, 402, 267, 314, 1245, 27157, 9661, 14, 267, 408, 267, 4887, 275, 291, 14, 3494, 63, 533, 8, 277, 14, 362, 63, 1069, 1012, 267, 4887, 423, 4591, 63, 576, 275, 666, 503, 942, 267, 372, 4887, 339, 347, 511, 63, 525, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 291, 14, 3334, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 291, 14, 1815, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 499, 297, 2402, 63, 2969, 534, 1450, 358, 267, 291, 14, 629, 8, 552, 8, 3494, 395, 499, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 6893, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 10366, 63, 6395, 360, 6395, 1245, 1333, 267, 4887, 14, 873, 8, 1310, 9, 398, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 413, 9, 339, 347, 511, 63, 889, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 267, 4887, 14, 873, 8, 1310, 9, 267, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 378, 9, 339, 347, 511, 63, 525, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283 ]
[ 2882, 492, 3372, 5524, 199, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2288, 63, 1751, 199, 504, 1639, 14, 2828, 14, 3431, 492, 5262, 12, 3778, 12, 664, 63, 1896, 12, 663, 63, 1896, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 6430, 6782, 199, 504, 1639, 14, 2828, 14, 3431, 14, 5559, 492, 6186, 63, 906, 2524, 5296, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 492, 849, 63, 3494, 12, 1300, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 6430, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 2811, 63, 1751, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 421, 199, 318, 3372, 5524, 2817, 1831, 21268, 8, 1532, 304, 272, 372, 3372, 5524, 8, 267, 8686, 14, 374, 63, 7657, 360, 1176, 14, 2828, 14, 1178, 659, 267, 298, 1176, 14, 2828, 14, 1178, 5712, 1133, 4903, 25232, 1532, 9, 421, 199, 318, 1050, 63, 1896, 63, 3431, 8, 3494, 304, 272, 408, 272, 15747, 1227, 3788, 687, 3365, 11106, 334, 15768, 282, 3537, 1373, 9, 370, 282, 4887, 272, 1256, 14, 272, 408, 272, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 33, 7809, 2256, 1245, 358, 272, 4887, 14, 525, 8, 1398, 12, 283, 7700, 3537, 2166, 358, 272, 4887, 14, 525, 8, 5559, 14, 5287, 12, 283, 33, 10201, 1245, 297, 2402, 63, 2969, 534, 2911, 13, 1450, 358, 272, 4887, 14, 525, 8, 5559, 14, 9171, 12, 283, 33, 5721, 358, 272, 4887, 14, 525, 8, 5559, 14, 3170, 12, 283, 2493, 1125, 358, 272, 4887, 14, 525, 8, 5559, 14, 12779, 12, 283, 2765, 1990, 282, 3229, 1220, 72, 2659, 421, 199, 533, 4278, 63, 1751, 63, 2969, 8, 4415, 63, 1751, 304, 272, 347, 4756, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 4296, 342, 267, 327, 6124, 10429, 63, 17626, 365, 282, 4413, 3247, 315, 314, 267, 327, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 859, 12, 880, 2410, 13729, 267, 327, 2202, 14, 8272, 63, 17626, 12, 781, 1929, 370, 1678, 626, 4413, 4634, 14, 267, 291, 14, 1753, 63, 1896, 63, 2969, 275, 1300, 14, 11817, 63, 17626, 267, 1300, 14, 11817, 63, 17626, 275, 3778, 14, 362, 63, 1896, 63, 2969, 342, 339, 347, 3507, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 5993, 342, 267, 1300, 14, 11817, 63, 17626, 275, 291, 14, 1753, 63, 1896, 63, 2969, 421, 199, 533, 3523, 2925, 8, 785, 304, 272, 4887, 63, 533, 275, 849, 63, 3494, 272, 8187, 275, 283, 1176, 14, 2828, 14, 3431, 14, 2219, 14, 3603, 7, 272, 11106, 275, 469, 267, 283, 1757, 356, 5262, 14, 5287, 12, 267, 283, 815, 356, 5262, 14, 4531, 12, 267, 283, 3742, 356, 5262, 14, 12779, 12, 267, 283, 3764, 356, 5262, 14, 9171, 12, 267, 283, 705, 356, 5262, 14, 3170, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 275, 4278, 63, 1751, 63, 2969, 8, 288, 24877, 63, 14455, 16729, 288, 24877, 63, 9059, 63, 10494, 4149, 29, 2966, 63, 1751, 14, 7433, 63, 9059, 63, 10494, 4149, 12, 288, 603, 1608, 2962, 63, 17626, 4581, 288, 603, 1608, 2962, 63, 17467, 9569, 83, 4111, 83, 7, 450, 334, 277, 14, 3494, 63, 533, 855, 578, 3108, 4318, 291, 14, 3494, 63, 533, 855, 354, 10139, 288, 428, 9577, 63, 19637, 5357, 540, 534, 1176, 14, 2828, 14, 11676, 14, 12844, 14, 6243, 7299, 297, 267, 776, 267, 291, 14, 1751, 63, 4415, 14, 4296, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 14, 5993, 342, 339, 347, 664, 63, 1069, 8, 277, 304, 267, 372, 1455, 14, 10441, 342, 339, 347, 664, 63, 1310, 8, 277, 304, 267, 372, 1455, 14, 16287, 342, 339, 347, 664, 63, 3494, 8, 277, 12, 666, 29, 403, 304, 267, 408, 267, 1803, 314, 4887, 4865, 12, 4260, 2399, 6511, 666, 370, 314, 1124, 576, 1040, 267, 1423, 14, 398, 961, 1083, 23674, 314, 4887, 24507, 362, 1040, 1083, 687, 10232, 2797, 880, 267, 626, 1163, 4184, 402, 314, 4887, 4865, 883, 506, 12470, 12717, 402, 267, 314, 1245, 27157, 9661, 14, 267, 408, 267, 4887, 275, 291, 14, 3494, 63, 533, 8, 277, 14, 362, 63, 1069, 1012, 267, 4887, 423, 4591, 63, 576, 275, 666, 503, 942, 267, 372, 4887, 339, 347, 511, 63, 525, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 291, 14, 3334, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 291, 14, 1815, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 499, 297, 2402, 63, 2969, 534, 1450, 358, 267, 291, 14, 629, 8, 552, 8, 3494, 395, 499, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 6893, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 10366, 63, 6395, 360, 6395, 1245, 1333, 267, 4887, 14, 873, 8, 1310, 9, 398, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 413, 9, 339, 347, 511, 63, 889, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 267, 4887, 14, 873, 8, 1310, 9, 267, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 378, 9, 339, 347, 511, 63, 525, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dimroc/tensorflow-mnist-tutorial
lib/python3.6/site-packages/tensorflow/contrib/layers/__init__.py
9
4048
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Ops for building neural network layers, regularizers, summaries, etc. ## Higher level ops for building neural network layers. This package provides several ops that take care of creating variables that are used internally in a consistent way and provide the building blocks for many common machine learning algorithms. @@avg_pool2d @@batch_norm @@convolution2d @@conv2d_in_plane @@convolution2d_in_plane @@conv2d_transpose @@convolution2d_transpose @@dropout @@flatten @@fully_connected @@layer_norm @@linear @@max_pool2d @@one_hot_encoding @@relu @@relu6 @@repeat @@safe_embedding_lookup_sparse @@separable_conv2d @@separable_convolution2d @@softmax @@stack @@unit_norm @@embed_sequence Aliases for fully_connected which set a default activation function are available: `relu`, `relu6` and `linear`. `stack` operation is also available. It builds a stack of layers by applying a layer repeatedly. ## Regularizers Regularization can help prevent overfitting. These have the signature `fn(weights)`. The loss is typically added to `tf.GraphKeys.REGULARIZATION_LOSSES`. @@apply_regularization @@l1_regularizer @@l2_regularizer @@sum_regularizer ## Initializers Initializers are used to initialize variables with sensible values given their size, data type, and purpose. @@xavier_initializer @@xavier_initializer_conv2d @@variance_scaling_initializer ## Optimization Optimize weights given a loss. @@optimize_loss ## Summaries Helper functions to summarize specific variables or ops. @@summarize_activation @@summarize_tensor @@summarize_tensors @@summarize_collection The layers module defines convenience functions `summarize_variables`, `summarize_weights` and `summarize_biases`, which set the `collection` argument of `summarize_collection` to `VARIABLES`, `WEIGHTS` and `BIASES`, respectively. @@summarize_activations ## Feature columns Feature columns provide a mechanism to map data to a model. @@bucketized_column @@check_feature_columns @@create_feature_spec_for_parsing @@crossed_column @@embedding_column @@scattered_embedding_column @@input_from_feature_columns @@joint_weighted_sum_from_feature_columns @@make_place_holder_tensors_for_base_features @@multi_class_target @@one_hot_column @@parse_feature_columns_from_examples @@parse_feature_columns_from_sequence_examples @@real_valued_column @@shared_embedding_columns @@sparse_column_with_hash_bucket @@sparse_column_with_integerized_feature @@sparse_column_with_keys @@weighted_sparse_column @@weighted_sum_from_feature_columns @@infer_real_valued_columns @@sequence_input_from_feature_columns """ from __future__ import absolute_import from __future__ import division from __future__ import print_function # pylint: disable=unused-import,wildcard-import from tensorflow.contrib.layers.python.layers import * # pylint: enable=unused-import,wildcard-import from tensorflow.python.util.all_util import remove_undocumented _allowed_symbols = ['bias_add', 'conv2d', 'feature_column', 'legacy_fully_connected', 'legacy_linear', 'legacy_relu', 'OPTIMIZER_CLS_NAMES', 'regression_target', 'SPARSE_FEATURE_CROSS_DEFAULT_HASH_KEY', 'summaries'] remove_undocumented(__name__, _allowed_symbols)
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 16452, 367, 10015, 1279, 4889, 2784, 9393, 12, 5578, 6315, 12, 23747, 12, 5423, 14, 199, 199, 309, 16332, 281, 2166, 4156, 367, 10015, 1279, 4889, 2784, 9393, 14, 199, 199, 2765, 2559, 6571, 9978, 4156, 626, 5452, 10296, 402, 6425, 2860, 626, 787, 199, 2972, 14448, 315, 282, 12137, 4340, 436, 5647, 314, 10015, 5664, 367, 5002, 199, 2330, 6844, 9328, 18036, 14, 199, 199, 7492, 8595, 63, 2293, 18, 68, 199, 7492, 2912, 63, 4791, 199, 7492, 27625, 18, 68, 199, 7492, 5598, 18, 68, 63, 262, 63, 15365, 199, 7492, 27625, 18, 68, 63, 262, 63, 15365, 199, 7492, 5598, 18, 68, 63, 10483, 199, 7492, 27625, 18, 68, 63, 10483, 199, 7492, 17953, 199, 7492, 8487, 199, 7492, 5836, 63, 7113, 199, 7492, 1897, 63, 4791, 199, 7492, 6676, 199, 7492, 988, 63, 2293, 18, 68, 199, 7492, 368, 63, 8885, 63, 2991, 199, 7492, 12833, 199, 7492, 12833, 22, 199, 7492, 8755, 199, 7492, 3489, 63, 14275, 63, 3892, 63, 4421, 199, 7492, 6175, 461, 63, 5598, 18, 68, 199, 7492, 6175, 461, 63, 27625, 18, 68, 199, 7492, 16395, 199, 7492, 2340, 199, 7492, 3248, 63, 4791, 199, 7492, 6427, 63, 4041, 199, 199, 6985, 3274, 367, 9999, 63, 7113, 1314, 663, 282, 849, 10361, 805, 787, 199, 4561, 26, 658, 12833, 3559, 658, 12833, 22, 64, 436, 658, 6676, 2313, 199, 199, 64, 2340, 64, 3439, 365, 2597, 2808, 14, 2779, 14723, 282, 3464, 402, 9393, 701, 18876, 199, 65, 4045, 27714, 14, 199, 199, 309, 18528, 6315, 199, 199, 16038, 2072, 883, 1720, 7981, 1806, 3269, 1337, 14, 5723, 1172, 314, 4955, 199, 64, 2324, 8, 4916, 20414, 710, 5621, 365, 13609, 3483, 370, 199, 64, 3249, 14, 19713, 14, 5616, 3038, 22800, 63, 28010, 654, 2313, 199, 199, 7492, 4998, 63, 18948, 199, 7492, 76, 17, 63, 14044, 199, 7492, 76, 18, 63, 14044, 199, 7492, 1838, 63, 14044, 199, 199, 309, 6026, 6315, 199, 199, 5733, 6315, 787, 1202, 370, 8265, 2860, 543, 27962, 1338, 1627, 3932, 199, 890, 12, 666, 730, 12, 436, 12016, 14, 199, 199, 7492, 1800, 26645, 63, 6498, 199, 7492, 1800, 26645, 63, 6498, 63, 5598, 18, 68, 199, 7492, 6221, 63, 12153, 63, 6498, 199, 199, 309, 19246, 2072, 199, 199, 30474, 4931, 1627, 282, 5621, 14, 199, 199, 7492, 13416, 63, 4358, 199, 199, 309, 12094, 13190, 199, 199, 4433, 3423, 370, 22301, 2488, 2860, 503, 4156, 14, 199, 199, 7492, 29902, 63, 12312, 199, 7492, 29902, 63, 3128, 199, 7492, 29902, 63, 10206, 199, 7492, 29902, 63, 3627, 199, 199, 1918, 9393, 859, 7890, 16777, 3423, 658, 29902, 63, 3669, 3559, 199, 64, 29902, 63, 4916, 64, 436, 658, 29902, 63, 20948, 3559, 1314, 663, 314, 658, 3627, 64, 1423, 199, 1618, 658, 29902, 63, 3627, 64, 370, 658, 21161, 3559, 658, 25100, 51, 64, 436, 658, 34, 11352, 654, 3559, 17342, 14, 199, 199, 7492, 29902, 63, 31117, 199, 199, 309, 13407, 4362, 199, 199, 5968, 4362, 5647, 282, 14729, 370, 2341, 666, 370, 282, 1402, 14, 199, 199, 7492, 464, 21531, 22927, 63, 2301, 199, 7492, 1074, 63, 4445, 63, 3406, 199, 7492, 981, 63, 4445, 63, 1650, 63, 509, 63, 11059, 199, 7492, 20363, 939, 63, 2301, 199, 7492, 14275, 63, 2301, 199, 7492, 551, 292, 3014, 63, 14275, 63, 2301, 199, 7492, 1210, 63, 504, 63, 4445, 63, 3406, 199, 7492, 10153, 63, 13522, 63, 1838, 63, 504, 63, 4445, 63, 3406, 199, 7492, 1875, 63, 2778, 63, 4302, 63, 10206, 63, 509, 63, 1095, 63, 3179, 199, 7492, 3029, 63, 533, 63, 1375, 199, 7492, 368, 63, 8885, 63, 2301, 199, 7492, 1122, 63, 4445, 63, 3406, 63, 504, 63, 8589, 199, 7492, 1122, 63, 4445, 63, 3406, 63, 504, 63, 4041, 63, 8589, 199, 7492, 3093, 63, 16611, 63, 2301, 199, 7492, 5555, 63, 14275, 63, 3406, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 2227, 63, 4623, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 4115, 1759, 63, 4445, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 1612, 199, 7492, 13522, 63, 4421, 63, 2301, 199, 7492, 13522, 63, 1838, 63, 504, 63, 4445, 63, 3406, 199, 7492, 14578, 63, 3093, 63, 16611, 63, 3406, 199, 7492, 4041, 63, 1210, 63, 504, 63, 4445, 63, 3406, 199, 199, 624, 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, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 16692, 13, 646, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 627, 199, 3, 4287, 26, 4756, 29, 8618, 13, 646, 12, 16692, 13, 646, 199, 199, 504, 3228, 14, 1548, 14, 1974, 14, 452, 63, 1974, 492, 2813, 63, 30107, 12546, 199, 199, 63, 6541, 63, 7450, 275, 788, 8160, 63, 525, 297, 490, 283, 5598, 18, 68, 297, 490, 283, 4445, 63, 2301, 297, 490, 283, 10000, 63, 5836, 63, 7113, 297, 490, 283, 10000, 63, 6676, 297, 490, 283, 10000, 63, 12833, 297, 490, 283, 5123, 1469, 5357, 540, 63, 1981, 51, 63, 14546, 297, 490, 283, 12513, 63, 1375, 297, 490, 283, 51, 23354, 63, 22884, 63, 28368, 63, 3472, 63, 14395, 63, 3078, 297, 490, 283, 19883 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 16452, 367, 10015, 1279, 4889, 2784, 9393, 12, 5578, 6315, 12, 23747, 12, 5423, 14, 199, 199, 309, 16332, 281, 2166, 4156, 367, 10015, 1279, 4889, 2784, 9393, 14, 199, 199, 2765, 2559, 6571, 9978, 4156, 626, 5452, 10296, 402, 6425, 2860, 626, 787, 199, 2972, 14448, 315, 282, 12137, 4340, 436, 5647, 314, 10015, 5664, 367, 5002, 199, 2330, 6844, 9328, 18036, 14, 199, 199, 7492, 8595, 63, 2293, 18, 68, 199, 7492, 2912, 63, 4791, 199, 7492, 27625, 18, 68, 199, 7492, 5598, 18, 68, 63, 262, 63, 15365, 199, 7492, 27625, 18, 68, 63, 262, 63, 15365, 199, 7492, 5598, 18, 68, 63, 10483, 199, 7492, 27625, 18, 68, 63, 10483, 199, 7492, 17953, 199, 7492, 8487, 199, 7492, 5836, 63, 7113, 199, 7492, 1897, 63, 4791, 199, 7492, 6676, 199, 7492, 988, 63, 2293, 18, 68, 199, 7492, 368, 63, 8885, 63, 2991, 199, 7492, 12833, 199, 7492, 12833, 22, 199, 7492, 8755, 199, 7492, 3489, 63, 14275, 63, 3892, 63, 4421, 199, 7492, 6175, 461, 63, 5598, 18, 68, 199, 7492, 6175, 461, 63, 27625, 18, 68, 199, 7492, 16395, 199, 7492, 2340, 199, 7492, 3248, 63, 4791, 199, 7492, 6427, 63, 4041, 199, 199, 6985, 3274, 367, 9999, 63, 7113, 1314, 663, 282, 849, 10361, 805, 787, 199, 4561, 26, 658, 12833, 3559, 658, 12833, 22, 64, 436, 658, 6676, 2313, 199, 199, 64, 2340, 64, 3439, 365, 2597, 2808, 14, 2779, 14723, 282, 3464, 402, 9393, 701, 18876, 199, 65, 4045, 27714, 14, 199, 199, 309, 18528, 6315, 199, 199, 16038, 2072, 883, 1720, 7981, 1806, 3269, 1337, 14, 5723, 1172, 314, 4955, 199, 64, 2324, 8, 4916, 20414, 710, 5621, 365, 13609, 3483, 370, 199, 64, 3249, 14, 19713, 14, 5616, 3038, 22800, 63, 28010, 654, 2313, 199, 199, 7492, 4998, 63, 18948, 199, 7492, 76, 17, 63, 14044, 199, 7492, 76, 18, 63, 14044, 199, 7492, 1838, 63, 14044, 199, 199, 309, 6026, 6315, 199, 199, 5733, 6315, 787, 1202, 370, 8265, 2860, 543, 27962, 1338, 1627, 3932, 199, 890, 12, 666, 730, 12, 436, 12016, 14, 199, 199, 7492, 1800, 26645, 63, 6498, 199, 7492, 1800, 26645, 63, 6498, 63, 5598, 18, 68, 199, 7492, 6221, 63, 12153, 63, 6498, 199, 199, 309, 19246, 2072, 199, 199, 30474, 4931, 1627, 282, 5621, 14, 199, 199, 7492, 13416, 63, 4358, 199, 199, 309, 12094, 13190, 199, 199, 4433, 3423, 370, 22301, 2488, 2860, 503, 4156, 14, 199, 199, 7492, 29902, 63, 12312, 199, 7492, 29902, 63, 3128, 199, 7492, 29902, 63, 10206, 199, 7492, 29902, 63, 3627, 199, 199, 1918, 9393, 859, 7890, 16777, 3423, 658, 29902, 63, 3669, 3559, 199, 64, 29902, 63, 4916, 64, 436, 658, 29902, 63, 20948, 3559, 1314, 663, 314, 658, 3627, 64, 1423, 199, 1618, 658, 29902, 63, 3627, 64, 370, 658, 21161, 3559, 658, 25100, 51, 64, 436, 658, 34, 11352, 654, 3559, 17342, 14, 199, 199, 7492, 29902, 63, 31117, 199, 199, 309, 13407, 4362, 199, 199, 5968, 4362, 5647, 282, 14729, 370, 2341, 666, 370, 282, 1402, 14, 199, 199, 7492, 464, 21531, 22927, 63, 2301, 199, 7492, 1074, 63, 4445, 63, 3406, 199, 7492, 981, 63, 4445, 63, 1650, 63, 509, 63, 11059, 199, 7492, 20363, 939, 63, 2301, 199, 7492, 14275, 63, 2301, 199, 7492, 551, 292, 3014, 63, 14275, 63, 2301, 199, 7492, 1210, 63, 504, 63, 4445, 63, 3406, 199, 7492, 10153, 63, 13522, 63, 1838, 63, 504, 63, 4445, 63, 3406, 199, 7492, 1875, 63, 2778, 63, 4302, 63, 10206, 63, 509, 63, 1095, 63, 3179, 199, 7492, 3029, 63, 533, 63, 1375, 199, 7492, 368, 63, 8885, 63, 2301, 199, 7492, 1122, 63, 4445, 63, 3406, 63, 504, 63, 8589, 199, 7492, 1122, 63, 4445, 63, 3406, 63, 504, 63, 4041, 63, 8589, 199, 7492, 3093, 63, 16611, 63, 2301, 199, 7492, 5555, 63, 14275, 63, 3406, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 2227, 63, 4623, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 4115, 1759, 63, 4445, 199, 7492, 4421, 63, 2301, 63, 1045, 63, 1612, 199, 7492, 13522, 63, 4421, 63, 2301, 199, 7492, 13522, 63, 1838, 63, 504, 63, 4445, 63, 3406, 199, 7492, 14578, 63, 3093, 63, 16611, 63, 3406, 199, 7492, 4041, 63, 1210, 63, 504, 63, 4445, 63, 3406, 199, 199, 624, 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, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 16692, 13, 646, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 627, 199, 3, 4287, 26, 4756, 29, 8618, 13, 646, 12, 16692, 13, 646, 199, 199, 504, 3228, 14, 1548, 14, 1974, 14, 452, 63, 1974, 492, 2813, 63, 30107, 12546, 199, 199, 63, 6541, 63, 7450, 275, 788, 8160, 63, 525, 297, 490, 283, 5598, 18, 68, 297, 490, 283, 4445, 63, 2301, 297, 490, 283, 10000, 63, 5836, 63, 7113, 297, 490, 283, 10000, 63, 6676, 297, 490, 283, 10000, 63, 12833, 297, 490, 283, 5123, 1469, 5357, 540, 63, 1981, 51, 63, 14546, 297, 490, 283, 12513, 63, 1375, 297, 490, 283, 51, 23354, 63, 22884, 63, 28368, 63, 3472, 63, 14395, 63, 3078, 297, 490, 283, 19883, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mogeiwang/nest
pynest/examples/brette-gerstner-fig-2c.py
6
1732
# -*- coding: utf-8 -*- # # brette-gerstner-fig-2c.py # # This file is part of NEST. # # Copyright (C) 2004 The NEST Initiative # # NEST 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. # # NEST 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 NEST. If not, see <http://www.gnu.org/licenses/>. # Test for the adapting exponential integrate and fire model according to # Brette and Gerstner (2005) J. Neurophysiology. # This script reproduces figure 2.C of the paper. # Note that Brette&Gerstner give the value for b in nA. # To be consistent with the other parameters in the equations, b must be # converted to pA (pico Ampere). import nest import nest.voltage_trace import pylab nest.ResetKernel() res=0.1 nest.SetKernelStatus({"resolution": res}) neuron=nest.Create("aeif_cond_alpha") nest.SetStatus(neuron,{"a": 4.0, "b":80.5}) dc=nest.Create("dc_generator",2) nest.SetStatus(dc,[{"amplitude":500.0, "start":0.0, "stop":200.0}, {"amplitude":800.0, "start":500.0, "stop":1000.0}]) nest.ConvergentConnect(dc,neuron) voltmeter= nest.Create("voltmeter") nest.SetStatus(voltmeter, {'interval':0.1, "withgid": True, "withtime": True}) nest.Connect(voltmeter,neuron) nest.Simulate(1000.0) nest.voltage_trace.from_device(voltmeter) pylab.axis([0,1000,-80,-20])
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 330, 3292, 266, 13, 836, 270, 1372, 13, 592, 13, 18, 67, 14, 647, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28878, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8353, 710, 28878, 21412, 1905, 199, 3, 199, 3, 28878, 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, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28878, 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, 28878, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 1379, 367, 314, 1503, 439, 1337, 23160, 21494, 436, 8344, 1402, 7182, 370, 199, 3, 699, 3292, 266, 436, 22261, 270, 1372, 334, 9397, 9, 1603, 14, 5612, 9129, 6581, 338, 7085, 14, 199, 3, 961, 2884, 295, 24658, 9658, 499, 14, 35, 402, 314, 15220, 14, 199, 3, 3390, 626, 699, 3292, 266, 6, 27866, 270, 1372, 8120, 314, 574, 367, 330, 315, 302, 33, 14, 199, 3, 4005, 506, 12137, 543, 314, 1163, 2633, 315, 314, 26426, 12, 330, 1471, 506, 199, 3, 6702, 370, 299, 33, 334, 1038, 331, 437, 311, 69, 264, 680, 199, 199, 646, 10715, 199, 646, 10715, 14, 27543, 63, 3446, 199, 646, 19199, 199, 199, 15272, 14, 9637, 14127, 342, 199, 199, 470, 29, 16, 14, 17, 199, 15272, 14, 1084, 14127, 3694, 6333, 12588, 582, 522, 1552, 199, 32054, 29, 15272, 14, 2499, 480, 3624, 692, 63, 2067, 63, 4468, 531, 199, 15272, 14, 1084, 3694, 8, 32054, 12, 6641, 65, 582, 841, 14, 16, 12, 298, 66, 582, 1257, 14, 21, 1552, 199, 3833, 29, 15272, 14, 2499, 480, 3833, 63, 4679, 401, 18, 9, 199, 199, 15272, 14, 1084, 3694, 8, 3833, 14343, 6641, 31928, 582, 5783, 14, 16, 12, 298, 928, 582, 16, 14, 16, 12, 298, 2379, 582, 1840, 14, 16, 1386, 718, 2420, 31928, 582, 6718, 14, 16, 12, 298, 928, 582, 5783, 14, 16, 12, 298, 2379, 582, 5279, 14, 16, 29810, 199, 199, 15272, 14, 7619, 12069, 8631, 8, 3833, 12, 32054, 9, 199, 199, 5650, 84, 10011, 29, 10715, 14, 2499, 480, 5650, 84, 10011, 531, 199, 15272, 14, 1084, 3694, 8, 5650, 84, 10011, 12, 791, 4284, 356, 16, 14, 17, 12, 298, 1045, 8787, 582, 715, 12, 298, 1045, 521, 582, 715, 1552, 199, 199, 15272, 14, 8631, 8, 5650, 84, 10011, 12, 32054, 9, 199, 199, 15272, 14, 7467, 5434, 8, 5279, 14, 16, 9, 199, 199, 15272, 14, 27543, 63, 3446, 14, 504, 63, 1782, 8, 5650, 84, 10011, 9, 199, 32538, 14, 3127, 779, 16, 12, 5279, 3057, 1257, 3057, 1165, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 330, 3292, 266, 13, 836, 270, 1372, 13, 592, 13, 18, 67, 14, 647, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28878, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8353, 710, 28878, 21412, 1905, 199, 3, 199, 3, 28878, 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, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28878, 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, 28878, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 1379, 367, 314, 1503, 439, 1337, 23160, 21494, 436, 8344, 1402, 7182, 370, 199, 3, 699, 3292, 266, 436, 22261, 270, 1372, 334, 9397, 9, 1603, 14, 5612, 9129, 6581, 338, 7085, 14, 199, 3, 961, 2884, 295, 24658, 9658, 499, 14, 35, 402, 314, 15220, 14, 199, 3, 3390, 626, 699, 3292, 266, 6, 27866, 270, 1372, 8120, 314, 574, 367, 330, 315, 302, 33, 14, 199, 3, 4005, 506, 12137, 543, 314, 1163, 2633, 315, 314, 26426, 12, 330, 1471, 506, 199, 3, 6702, 370, 299, 33, 334, 1038, 331, 437, 311, 69, 264, 680, 199, 199, 646, 10715, 199, 646, 10715, 14, 27543, 63, 3446, 199, 646, 19199, 199, 199, 15272, 14, 9637, 14127, 342, 199, 199, 470, 29, 16, 14, 17, 199, 15272, 14, 1084, 14127, 3694, 6333, 12588, 582, 522, 1552, 199, 32054, 29, 15272, 14, 2499, 480, 3624, 692, 63, 2067, 63, 4468, 531, 199, 15272, 14, 1084, 3694, 8, 32054, 12, 6641, 65, 582, 841, 14, 16, 12, 298, 66, 582, 1257, 14, 21, 1552, 199, 3833, 29, 15272, 14, 2499, 480, 3833, 63, 4679, 401, 18, 9, 199, 199, 15272, 14, 1084, 3694, 8, 3833, 14343, 6641, 31928, 582, 5783, 14, 16, 12, 298, 928, 582, 16, 14, 16, 12, 298, 2379, 582, 1840, 14, 16, 1386, 718, 2420, 31928, 582, 6718, 14, 16, 12, 298, 928, 582, 5783, 14, 16, 12, 298, 2379, 582, 5279, 14, 16, 29810, 199, 199, 15272, 14, 7619, 12069, 8631, 8, 3833, 12, 32054, 9, 199, 199, 5650, 84, 10011, 29, 10715, 14, 2499, 480, 5650, 84, 10011, 531, 199, 15272, 14, 1084, 3694, 8, 5650, 84, 10011, 12, 791, 4284, 356, 16, 14, 17, 12, 298, 1045, 8787, 582, 715, 12, 298, 1045, 521, 582, 715, 1552, 199, 199, 15272, 14, 8631, 8, 5650, 84, 10011, 12, 32054, 9, 199, 199, 15272, 14, 7467, 5434, 8, 5279, 14, 16, 9, 199, 199, 15272, 14, 27543, 63, 3446, 14, 504, 63, 1782, 8, 5650, 84, 10011, 9, 199, 32538, 14, 3127, 779, 16, 12, 5279, 3057, 1257, 3057, 1165, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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- # # Copyright (c) 2011 # Simen Natvig, <simen.natvig@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/ from PyQt4.QtGui import * from base.util.IconTheme import iconFromTheme import os.path lumaPlugin = True pluginName = u"template" pluginUserString = u"Templates" version = u"0.2" author = u"Simen Natvig" description = u"Used to define the templates used by the browser-plugin." def getIcon(): return iconFromTheme('luma-template-plugin', ':/icons/plugins/template') def getPluginWidget(parent, mainwin): from .gui.TemplateWidget import TemplateWidget pluginWidget = TemplateWidget() return pluginWidget def getPluginSettingsWidget(parent): return None def postprocess(): return # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 199, 3, 258, 428, 9001, 653, 292, 433, 71, 12, 665, 338, 1410, 14, 9468, 433, 71, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 504, 14084, 20, 14, 10604, 492, 627, 199, 504, 1300, 14, 1974, 14, 8954, 16849, 492, 7016, 2532, 16849, 199, 646, 747, 14, 515, 199, 199, 10836, 391, 5061, 275, 715, 199, 2718, 985, 275, 399, 2, 1160, 2, 199, 2718, 1899, 1558, 275, 399, 2, 17969, 2, 199, 1023, 275, 399, 2, 16, 14, 18, 2, 199, 2502, 275, 399, 2, 51, 9001, 653, 292, 433, 71, 2, 199, 1802, 275, 399, 2, 9167, 370, 5627, 314, 7009, 1202, 701, 314, 7042, 13, 2718, 2122, 421, 199, 318, 664, 8954, 837, 272, 372, 7016, 2532, 16849, 360, 10836, 391, 13, 1160, 13, 2718, 297, 7596, 15, 16471, 15, 5265, 15, 1160, 358, 421, 199, 318, 664, 5061, 3339, 8, 1708, 12, 2446, 2676, 304, 272, 687, 1275, 5885, 14, 4231, 3339, 492, 5458, 3339, 272, 3589, 3339, 275, 5458, 3339, 342, 272, 372, 3589, 3339, 421, 199, 318, 664, 5061, 5268, 3339, 8, 1708, 304, 272, 372, 488, 421, 199, 318, 2963, 1412, 837, 272, 372, 421, 199, 3, 6695, 26, 20849, 29, 20, 26414, 20105, 29, 20, 25966, 29, 20, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 199, 3, 258, 428, 9001, 653, 292, 433, 71, 12, 665, 338, 1410, 14, 9468, 433, 71, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 504, 14084, 20, 14, 10604, 492, 627, 199, 504, 1300, 14, 1974, 14, 8954, 16849, 492, 7016, 2532, 16849, 199, 646, 747, 14, 515, 199, 199, 10836, 391, 5061, 275, 715, 199, 2718, 985, 275, 399, 2, 1160, 2, 199, 2718, 1899, 1558, 275, 399, 2, 17969, 2, 199, 1023, 275, 399, 2, 16, 14, 18, 2, 199, 2502, 275, 399, 2, 51, 9001, 653, 292, 433, 71, 2, 199, 1802, 275, 399, 2, 9167, 370, 5627, 314, 7009, 1202, 701, 314, 7042, 13, 2718, 2122, 421, 199, 318, 664, 8954, 837, 272, 372, 7016, 2532, 16849, 360, 10836, 391, 13, 1160, 13, 2718, 297, 7596, 15, 16471, 15, 5265, 15, 1160, 358, 421, 199, 318, 664, 5061, 3339, 8, 1708, 12, 2446, 2676, 304, 272, 687, 1275, 5885, 14, 4231, 3339, 492, 5458, 3339, 272, 3589, 3339, 275, 5458, 3339, 342, 272, 372, 3589, 3339, 421, 199, 318, 664, 5061, 5268, 3339, 8, 1708, 304, 272, 372, 488, 421, 199, 318, 2963, 1412, 837, 272, 372, 421, 199, 3, 6695, 26, 20849, 29, 20, 26414, 20105, 29, 20, 25966, 29, 20, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Belgabor/django
django/db/models/sql/expressions.py
36
3255
from django.core.exceptions import FieldError from django.db.models.fields import FieldDoesNotExist from django.db.models.sql.constants import LOOKUP_SEP class SQLEvaluator(object): def __init__(self, expression, query, allow_joins=True): self.expression = expression self.opts = query.get_meta() self.cols = {} self.contains_aggregate = False self.expression.prepare(self, query, allow_joins) def prepare(self): return self def as_sql(self, qn, connection): return self.expression.evaluate(self, qn, connection) def relabel_aliases(self, change_map): for node, col in self.cols.items(): self.cols[node] = (change_map.get(col[0], col[0]), col[1]) ##################################################### # Vistor methods for initial expression preparation # ##################################################### def prepare_node(self, node, query, allow_joins): for child in node.children: if hasattr(child, 'prepare'): child.prepare(self, query, allow_joins) def prepare_leaf(self, node, query, allow_joins): if not allow_joins and LOOKUP_SEP in node.name: raise FieldError("Joined field references are not permitted in this query") field_list = node.name.split(LOOKUP_SEP) if (len(field_list) == 1 and node.name in query.aggregate_select.keys()): self.contains_aggregate = True self.cols[node] = query.aggregate_select[node.name] else: try: field, source, opts, join_list, last, _ = query.setup_joins( field_list, query.get_meta(), query.get_initial_alias(), False) col, _, join_list = query.trim_joins(source, join_list, last, False) self.cols[node] = (join_list[-1], col) except FieldDoesNotExist: raise FieldError("Cannot resolve keyword %r into field. " "Choices are: %s" % (self.name, [f.name for f in self.opts.fields])) ################################################## # Vistor methods for final expression evaluation # ################################################## def evaluate_node(self, node, qn, connection): expressions = [] expression_params = [] for child in node.children: if hasattr(child, 'evaluate'): sql, params = child.evaluate(self, qn, connection) else: sql, params = '%s', (child,) if len(getattr(child, 'children', [])) > 1: format = '(%s)' else: format = '%s' if sql: expressions.append(format % sql) expression_params.extend(params) return connection.ops.combine_expression(node.connector, expressions), expression_params def evaluate_leaf(self, node, qn, connection): col = self.cols[node] if hasattr(col, 'as_sql'): return col.as_sql(qn, connection), () else: return '%s.%s' % (qn(col[0]), qn(col[1])), ()
bsd-3-clause
[ 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 29994, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 199, 199, 533, 428, 49, 906, 637, 16530, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3965, 12, 1827, 12, 2040, 63, 20155, 29, 549, 304, 267, 291, 14, 5599, 275, 3965, 267, 291, 14, 3291, 275, 1827, 14, 362, 63, 2024, 342, 267, 291, 14, 4574, 275, 1052, 398, 291, 14, 6134, 63, 7516, 275, 756, 267, 291, 14, 5599, 14, 6726, 8, 277, 12, 1827, 12, 2040, 63, 20155, 9, 339, 347, 9275, 8, 277, 304, 267, 372, 291, 339, 347, 465, 63, 3009, 8, 277, 12, 18293, 12, 1950, 304, 267, 372, 291, 14, 5599, 14, 7383, 8, 277, 12, 18293, 12, 1950, 9, 339, 347, 295, 1302, 63, 8602, 8, 277, 12, 1570, 63, 1130, 304, 267, 367, 1031, 12, 1048, 315, 291, 14, 4574, 14, 1744, 837, 288, 291, 14, 4574, 59, 932, 61, 275, 334, 1461, 63, 1130, 14, 362, 8, 761, 59, 16, 467, 1048, 59, 16, 2522, 1048, 59, 17, 566, 339, 26915, 272, 327, 19801, 269, 3102, 367, 2536, 3965, 876, 462, 425, 327, 272, 26915, 339, 347, 9275, 63, 932, 8, 277, 12, 1031, 12, 1827, 12, 2040, 63, 20155, 304, 267, 367, 1982, 315, 1031, 14, 3223, 26, 288, 340, 2688, 8, 1739, 12, 283, 6726, 735, 355, 1982, 14, 6726, 8, 277, 12, 1827, 12, 2040, 63, 20155, 9, 339, 347, 9275, 63, 8914, 8, 277, 12, 1031, 12, 1827, 12, 2040, 63, 20155, 304, 267, 340, 440, 2040, 63, 20155, 436, 3412, 3593, 2160, 63, 20848, 315, 1031, 14, 354, 26, 288, 746, 27691, 480, 5691, 1942, 901, 6941, 787, 440, 8211, 315, 642, 1827, 531, 398, 901, 63, 513, 275, 1031, 14, 354, 14, 1294, 8, 29149, 63, 20848, 9, 267, 340, 334, 552, 8, 698, 63, 513, 9, 508, 413, 436, 288, 1031, 14, 354, 315, 1827, 14, 7516, 63, 2416, 14, 1612, 5109, 288, 291, 14, 6134, 63, 7516, 275, 715, 288, 291, 14, 4574, 59, 932, 61, 275, 1827, 14, 7516, 63, 2416, 59, 932, 14, 354, 61, 267, 587, 26, 288, 862, 26, 355, 901, 12, 1350, 12, 3999, 12, 4263, 63, 513, 12, 2061, 12, 485, 275, 1827, 14, 2758, 63, 20155, 8, 490, 901, 63, 513, 12, 1827, 14, 362, 63, 2024, 1062, 490, 1827, 14, 362, 63, 2747, 63, 3620, 1062, 756, 9, 355, 1048, 12, 5501, 4263, 63, 513, 275, 1827, 14, 12263, 63, 20155, 8, 1365, 12, 4263, 63, 513, 12, 2061, 12, 756, 9, 2234, 291, 14, 4574, 59, 932, 61, 275, 334, 904, 63, 513, 1988, 17, 467, 1048, 9, 288, 871, 29994, 26, 355, 746, 27691, 480, 6612, 7512, 4252, 450, 82, 1901, 901, 14, 298, 639, 298, 30806, 787, 26, 450, 83, 2, 450, 334, 277, 14, 354, 12, 10028, 359, 70, 14, 354, 367, 289, 315, 291, 14, 3291, 14, 955, 2459, 339, 20286, 309, 272, 327, 19801, 269, 3102, 367, 4242, 3965, 11735, 327, 272, 20286, 309, 339, 347, 9352, 63, 932, 8, 277, 12, 1031, 12, 18293, 12, 1950, 304, 267, 8455, 275, 942, 267, 3965, 63, 1162, 275, 942, 267, 367, 1982, 315, 1031, 14, 3223, 26, 288, 340, 2688, 8, 1739, 12, 283, 7383, 735, 355, 3875, 12, 1862, 275, 1982, 14, 7383, 8, 277, 12, 18293, 12, 1950, 9, 288, 587, 26, 355, 3875, 12, 1862, 275, 1543, 83, 297, 334, 1739, 4258, 953, 340, 822, 8, 5675, 8, 1739, 12, 283, 3223, 297, 15927, 690, 413, 26, 355, 1475, 275, 25676, 83, 3171, 288, 587, 26, 355, 1475, 275, 1543, 83, 7, 953, 340, 3875, 26, 355, 8455, 14, 740, 8, 908, 450, 3875, 9, 355, 3965, 63, 1162, 14, 2880, 8, 1162, 9, 398, 372, 1950, 14, 1483, 14, 13307, 63, 5599, 8, 932, 14, 11815, 12, 8455, 395, 3965, 63, 1162, 339, 347, 9352, 63, 8914, 8, 277, 12, 1031, 12, 18293, 12, 1950, 304, 267, 1048, 275, 291, 14, 4574, 59, 932, 61, 267, 340, 2688, 8, 761, 12, 283, 305, 63, 3009, 735, 288, 372, 1048, 14, 305, 63, 3009, 8, 15156, 12, 1950, 395, 6248, 267, 587, 26, 288, 372, 1543, 83, 4111, 83, 7, 450, 334, 15156, 8, 761, 59, 16, 2522, 18293, 8, 761, 59, 17, 12884, 6248, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 29994, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 199, 199, 533, 428, 49, 906, 637, 16530, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3965, 12, 1827, 12, 2040, 63, 20155, 29, 549, 304, 267, 291, 14, 5599, 275, 3965, 267, 291, 14, 3291, 275, 1827, 14, 362, 63, 2024, 342, 267, 291, 14, 4574, 275, 1052, 398, 291, 14, 6134, 63, 7516, 275, 756, 267, 291, 14, 5599, 14, 6726, 8, 277, 12, 1827, 12, 2040, 63, 20155, 9, 339, 347, 9275, 8, 277, 304, 267, 372, 291, 339, 347, 465, 63, 3009, 8, 277, 12, 18293, 12, 1950, 304, 267, 372, 291, 14, 5599, 14, 7383, 8, 277, 12, 18293, 12, 1950, 9, 339, 347, 295, 1302, 63, 8602, 8, 277, 12, 1570, 63, 1130, 304, 267, 367, 1031, 12, 1048, 315, 291, 14, 4574, 14, 1744, 837, 288, 291, 14, 4574, 59, 932, 61, 275, 334, 1461, 63, 1130, 14, 362, 8, 761, 59, 16, 467, 1048, 59, 16, 2522, 1048, 59, 17, 566, 339, 26915, 272, 327, 19801, 269, 3102, 367, 2536, 3965, 876, 462, 425, 327, 272, 26915, 339, 347, 9275, 63, 932, 8, 277, 12, 1031, 12, 1827, 12, 2040, 63, 20155, 304, 267, 367, 1982, 315, 1031, 14, 3223, 26, 288, 340, 2688, 8, 1739, 12, 283, 6726, 735, 355, 1982, 14, 6726, 8, 277, 12, 1827, 12, 2040, 63, 20155, 9, 339, 347, 9275, 63, 8914, 8, 277, 12, 1031, 12, 1827, 12, 2040, 63, 20155, 304, 267, 340, 440, 2040, 63, 20155, 436, 3412, 3593, 2160, 63, 20848, 315, 1031, 14, 354, 26, 288, 746, 27691, 480, 5691, 1942, 901, 6941, 787, 440, 8211, 315, 642, 1827, 531, 398, 901, 63, 513, 275, 1031, 14, 354, 14, 1294, 8, 29149, 63, 20848, 9, 267, 340, 334, 552, 8, 698, 63, 513, 9, 508, 413, 436, 288, 1031, 14, 354, 315, 1827, 14, 7516, 63, 2416, 14, 1612, 5109, 288, 291, 14, 6134, 63, 7516, 275, 715, 288, 291, 14, 4574, 59, 932, 61, 275, 1827, 14, 7516, 63, 2416, 59, 932, 14, 354, 61, 267, 587, 26, 288, 862, 26, 355, 901, 12, 1350, 12, 3999, 12, 4263, 63, 513, 12, 2061, 12, 485, 275, 1827, 14, 2758, 63, 20155, 8, 490, 901, 63, 513, 12, 1827, 14, 362, 63, 2024, 1062, 490, 1827, 14, 362, 63, 2747, 63, 3620, 1062, 756, 9, 355, 1048, 12, 5501, 4263, 63, 513, 275, 1827, 14, 12263, 63, 20155, 8, 1365, 12, 4263, 63, 513, 12, 2061, 12, 756, 9, 2234, 291, 14, 4574, 59, 932, 61, 275, 334, 904, 63, 513, 1988, 17, 467, 1048, 9, 288, 871, 29994, 26, 355, 746, 27691, 480, 6612, 7512, 4252, 450, 82, 1901, 901, 14, 298, 639, 298, 30806, 787, 26, 450, 83, 2, 450, 334, 277, 14, 354, 12, 10028, 359, 70, 14, 354, 367, 289, 315, 291, 14, 3291, 14, 955, 2459, 339, 20286, 309, 272, 327, 19801, 269, 3102, 367, 4242, 3965, 11735, 327, 272, 20286, 309, 339, 347, 9352, 63, 932, 8, 277, 12, 1031, 12, 18293, 12, 1950, 304, 267, 8455, 275, 942, 267, 3965, 63, 1162, 275, 942, 267, 367, 1982, 315, 1031, 14, 3223, 26, 288, 340, 2688, 8, 1739, 12, 283, 7383, 735, 355, 3875, 12, 1862, 275, 1982, 14, 7383, 8, 277, 12, 18293, 12, 1950, 9, 288, 587, 26, 355, 3875, 12, 1862, 275, 1543, 83, 297, 334, 1739, 4258, 953, 340, 822, 8, 5675, 8, 1739, 12, 283, 3223, 297, 15927, 690, 413, 26, 355, 1475, 275, 25676, 83, 3171, 288, 587, 26, 355, 1475, 275, 1543, 83, 7, 953, 340, 3875, 26, 355, 8455, 14, 740, 8, 908, 450, 3875, 9, 355, 3965, 63, 1162, 14, 2880, 8, 1162, 9, 398, 372, 1950, 14, 1483, 14, 13307, 63, 5599, 8, 932, 14, 11815, 12, 8455, 395, 3965, 63, 1162, 339, 347, 9352, 63, 8914, 8, 277, 12, 1031, 12, 18293, 12, 1950, 304, 267, 1048, 275, 291, 14, 4574, 59, 932, 61, 267, 340, 2688, 8, 761, 12, 283, 305, 63, 3009, 735, 288, 372, 1048, 14, 305, 63, 3009, 8, 15156, 12, 1950, 395, 6248, 267, 587, 26, 288, 372, 1543, 83, 4111, 83, 7, 450, 334, 15156, 8, 761, 59, 16, 2522, 18293, 8, 761, 59, 17, 12884, 6248, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
umayrh/sketchy-polytopes
python/evolvingdag/src/evolvingdag/random_dag.py
1
8463
from networkx import DiGraph from networkx.algorithms.dag import descendants class LongitudinalRandomDag: """This class represents a hierarchical time series of RandomDag objects. Each node in the hierarchy represents a time rollup. The top level is 'year', the second-lowest level 'hour', and each event is a leaf node connected to an hour node. An event may trigger an time rollup rollover: events in a new day or month create a new node. """ DAG_LABEL_KEY = "__dag" def __init__(self): self.root = "root" self.time_series = DiGraph() self.time_series.add_node(self.root) @staticmethod def __node_id(prefix, suffix): return "".join(prefix, suffix) def add_event(self, event, timestamp): """ Adds a RandomDag as an event. Each event is assumed to have a unique timestamp. Args: event (RandomDag): a RandomDag instance timestamp (datetime.datetime): a timestamo for this event TODO: for timestamps, handle microseconds and UTC offset TODO: should time rollups be connected in a linked list? TODO: is setting RandomDag as a node property ideal? It's space- efficient but are queries harmed in the process? """ if len(event.dag.nodes) == 0: return node_id = LongitudinalRandomDag.__node_id event_id = timestamp.isoformat() rollups = {"year": node_id('y', timestamp.year), "month": node_id('m', timestamp.month), "day": node_id('d', timestamp.day), "hour": node_id('h', timestamp.hour), "event": event_id} prev_time = self.root for (label, time) in rollups: if time not in self.time_series.nodes: self.time_series.add_node(time, {Node.NODE_LABEL_KEY: label}) self.time_series.add_edge(prev_time, time) prev_time = time property_label = LongitudinalRandomDag.DAG_LABEL_KEY self.time_series.nodes[event_id][property_label] = event class RandomDag: """This class represents a simple DAG with properties that might be random variable e.g. a 'runtime' property for each node with value from the uniform distribution, U(30, 50). Each node may be associated with key-value pairs of properties. The key specifies the name of the property whereas the value is a list. The first element in the list is the name of a SciPy random distribution function (https://docs.scipy.org/doc/numpy-1.14.0/reference/routines.random.html), and the rest are the arguments to that function. TODO: support layers, and random edges between layers """ def __init__(self): self.dag = DiGraph() def add_node(self, node): """Adds a node to this DAG Args: node (Node): a node to add to this DAG """ self.dag.add_node(node.name, **node.properties) def add_edge(self, from_node, to_node, properties={}, check_acyclicity=True): """Adds a directed edge to this DAG Args: from_node (Node): source node to_node (Node): target node properties (dict): a map of string keys to any values check_acyclicity (bool): check and throw if this edge adds a cycle to the DAG (default: True) """ if check_acyclicity and \ from_node.name in descendants(self.dag, to_node.name): raise Exception("This edge adds a cycle to the graph") if properties is None or properties is {}: self.dag.add_edge(from_node.name, to_node.name) else: self.dag.add_edge(from_node.name, to_node.name, **properties) @staticmethod def __update_property(data, property_name, default_weight): """ Updates a node or edge property with given name. Args: data (dict): map of node/edge properties property_name: name of a property (i.e. a key for 'data') default_weight (float): default value of the property """ if property_name in data: property_val = data[property_name] if property_val is not None and len(property_val) > 1: func_args = property_val[1:] return property_val[0](*func_args) return default_weight def sample_node_property(self, node_property, weight_key='w', default_weight=0): """Samples nodes with given property, and sets weight_key with the sampled, or default, value. Args: node_property (str): name of node property to sample weight_key (str): name of property that holds sampled value default_weight (float): default value of the weight_key property """ if node_property is None or node_property is "": raise Exception("Invalid property") for (node, data) in list(self.dag.nodes(data=True)): property_weight = RandomDag.__update_property( data, node_property, default_weight) self.dag.nodes[node][weight_key] = property_weight def sample_edge_property(self, edge_property, weight_key='w', default_weight=0): """Samples edges with given property, and sets weight_key with the sampled, or default, value. Args: edge_property (str): name of edge property to sample weight_key (str): name of property that holds sampled value default_weight (float): default value of the weight_key property """ if edge_property is None or edge_property is "": raise Exception("Invalid property") for (s, t, data) in list(self.dag.edges(data=True, default={})): property_weight = RandomDag.__update_property( data, edge_property, default_weight) self.dag[s][t][weight_key] = property_weight def node_property_to_edge(self, start_node_name="start", node_property='w', edge_property='w'): """Translates a node property to an edge property by modifying the underlying DAG to (1) add a "start" node, and to (2) add an edge weight, which is the weight of its successor node. Args: start_node_name (str): name of the node to add that will be topologically precedent to all others node_property (str): name of node property to get edge_property (str): name of edge property to set """ if len(self.dag) == 0: return # add an edge to existing start nodes start = Node(start_node_name) zero_indegree = [v for v, d in self.dag.in_degree() if d == 0] for node in zero_indegree: self.dag.add_edge(start.name, node) for (s, t) in list(self.dag.edges(data=False)): self.dag[s][t][edge_property] = self.dag.nodes[t][node_property] def second_longest_path(self, weight='w', default_weight=0): """Find the second-longest path in the underlying graph Args: weight (str): edge data key to use for weight default_weight (int): weight of edges that do not have a weight attribute """ # TODO print(["not implemented", weight, default_weight]) class Node: """Represent a node (vertex) in a DAG. Associated with a map of properties, and a set of labels. """ NODE_LABEL_KEY = "__node_labels" def __init__(self, name, properties={}, labels=None): """ Creates a node object. Args: name (str): an identifier for this node, assumed to be unique across all nodes in the graph that this node belongs to properties (dict): a map of string keys to any values labels (set): a set of string labels """ self.name = name self.properties = properties if labels is not None and len(labels) is not 0: self.properties[self.__class__.NODE_LABEL_KEY] = labels def __str__(self): ' '.join("name", self.name, "properties", str(self.properties))
gpl-3.0
[ 504, 24313, 492, 3757, 4578, 199, 504, 24313, 14, 24365, 14, 7406, 492, 26061, 421, 199, 533, 19944, 390, 1181, 1582, 3883, 27234, 26, 272, 408, 2765, 1021, 8469, 282, 24787, 900, 6779, 402, 9571, 27234, 2251, 14, 339, 7048, 1031, 315, 314, 14446, 8469, 282, 900, 11848, 384, 14, 710, 2746, 2166, 365, 272, 283, 3403, 297, 314, 3499, 13, 674, 597, 2166, 283, 5180, 297, 436, 1924, 1566, 365, 282, 11747, 1031, 272, 8539, 370, 376, 6925, 1031, 14, 1626, 1566, 1443, 6804, 376, 900, 11848, 384, 20182, 21960, 26, 272, 4474, 315, 282, 892, 5382, 503, 5794, 1218, 282, 892, 1031, 14, 272, 408, 272, 19666, 63, 13837, 63, 3078, 275, 4396, 7406, 2, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1231, 275, 298, 1231, 2, 267, 291, 14, 521, 63, 5602, 275, 3757, 4578, 342, 267, 291, 14, 521, 63, 5602, 14, 525, 63, 932, 8, 277, 14, 1231, 9, 339, 768, 4639, 272, 347, 636, 932, 63, 344, 8, 1861, 12, 4739, 304, 267, 372, 10587, 904, 8, 1861, 12, 4739, 9, 339, 347, 1050, 63, 1430, 8, 277, 12, 1566, 12, 4913, 304, 267, 408, 267, 15747, 282, 9571, 27234, 465, 376, 1566, 14, 7048, 1566, 365, 10826, 370, 1172, 282, 267, 3747, 4913, 14, 398, 3033, 26, 288, 1566, 334, 3883, 27234, 304, 282, 9571, 27234, 1256, 288, 4913, 334, 2083, 14, 2083, 304, 282, 900, 270, 4393, 367, 642, 1566, 267, 3254, 26, 367, 22496, 12, 2429, 21574, 436, 12174, 3268, 267, 3254, 26, 1077, 900, 11848, 15203, 506, 8539, 315, 282, 10632, 769, 31, 267, 3254, 26, 365, 4260, 9571, 27234, 465, 282, 1031, 3324, 28264, 31, 2779, 1159, 4601, 13, 2049, 13402, 1325, 787, 9212, 12159, 3594, 315, 314, 2112, 31, 267, 408, 267, 340, 822, 8, 1430, 14, 7406, 14, 2415, 9, 508, 378, 26, 288, 372, 398, 1031, 63, 344, 275, 19944, 390, 1181, 1582, 3883, 27234, 855, 932, 63, 344, 267, 1566, 63, 344, 275, 4913, 14, 17070, 342, 267, 11848, 15203, 275, 2420, 3403, 582, 1031, 63, 344, 360, 89, 297, 4913, 14, 3403, 395, 673, 298, 4482, 582, 1031, 63, 344, 360, 77, 297, 4913, 14, 4482, 395, 673, 298, 2977, 582, 1031, 63, 344, 360, 68, 297, 4913, 14, 2977, 395, 673, 298, 5180, 582, 1031, 63, 344, 360, 72, 297, 4913, 14, 5180, 395, 673, 298, 1430, 582, 1566, 63, 344, 93, 398, 5071, 63, 521, 275, 291, 14, 1231, 267, 367, 334, 1302, 12, 900, 9, 315, 11848, 15203, 26, 288, 340, 900, 440, 315, 291, 14, 521, 63, 5602, 14, 2415, 26, 355, 291, 14, 521, 63, 5602, 14, 525, 63, 932, 8, 521, 12, 469, 1716, 14, 8063, 63, 13837, 63, 3078, 26, 1768, 1552, 288, 291, 14, 521, 63, 5602, 14, 525, 63, 5173, 8, 5701, 63, 521, 12, 900, 9, 288, 5071, 63, 521, 275, 900, 398, 3324, 63, 1302, 275, 19944, 390, 1181, 1582, 3883, 27234, 14, 28211, 63, 13837, 63, 3078, 267, 291, 14, 521, 63, 5602, 14, 2415, 59, 1430, 63, 344, 1527, 1829, 63, 1302, 61, 275, 1566, 421, 199, 533, 9571, 27234, 26, 272, 408, 2765, 1021, 8469, 282, 3486, 19666, 543, 4382, 272, 626, 5594, 506, 2196, 1750, 325, 14, 71, 14, 282, 283, 7726, 7, 3324, 367, 1924, 1031, 272, 543, 574, 687, 314, 14818, 4084, 12, 738, 8, 1216, 12, 5238, 680, 339, 7048, 1031, 1443, 506, 4568, 543, 790, 13, 585, 6342, 402, 4382, 14, 710, 790, 272, 9314, 314, 536, 402, 314, 3324, 29781, 314, 574, 365, 282, 769, 14, 710, 1642, 272, 1819, 315, 314, 769, 365, 314, 536, 402, 282, 16578, 2713, 2196, 4084, 805, 272, 334, 2859, 921, 4757, 14, 14248, 14, 1308, 15, 1301, 15, 4714, 13, 17, 14, 1079, 14, 16, 15, 4443, 15, 12791, 3746, 14, 2355, 14, 1360, 395, 272, 436, 314, 4618, 787, 314, 2368, 370, 626, 805, 14, 339, 3254, 26, 2291, 9393, 12, 436, 2196, 8207, 3382, 9393, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7406, 275, 3757, 4578, 342, 339, 347, 1050, 63, 932, 8, 277, 12, 1031, 304, 267, 408, 14995, 282, 1031, 370, 642, 19666, 398, 3033, 26, 288, 1031, 334, 1716, 304, 282, 1031, 370, 1050, 370, 642, 19666, 267, 408, 267, 291, 14, 7406, 14, 525, 63, 932, 8, 932, 14, 354, 12, 1011, 932, 14, 3282, 9, 339, 347, 1050, 63, 5173, 8, 277, 12, 687, 63, 932, 12, 326, 370, 63, 932, 12, 326, 4382, 10324, 326, 1104, 63, 4085, 2764, 3690, 29, 549, 304, 267, 408, 14995, 282, 23667, 6275, 370, 642, 19666, 398, 3033, 26, 288, 687, 63, 932, 334, 1716, 304, 1350, 1031, 288, 370, 63, 932, 334, 1716, 304, 1347, 1031, 288, 4382, 334, 807, 304, 282, 2341, 402, 1059, 2883, 370, 1263, 1338, 288, 1104, 63, 4085, 2764, 3690, 334, 2245, 304, 1104, 436, 7978, 340, 642, 6275, 9584, 282, 2049, 8643, 370, 314, 19666, 334, 885, 26, 715, 9, 267, 408, 267, 340, 1104, 63, 4085, 2764, 3690, 436, 971, 355, 687, 63, 932, 14, 354, 315, 26061, 8, 277, 14, 7406, 12, 370, 63, 932, 14, 354, 304, 288, 746, 2186, 480, 2765, 6275, 9584, 282, 8643, 370, 314, 3343, 531, 398, 340, 4382, 365, 488, 503, 4382, 365, 24702, 288, 291, 14, 7406, 14, 525, 63, 5173, 8, 504, 63, 932, 14, 354, 12, 370, 63, 932, 14, 354, 9, 267, 587, 26, 288, 291, 14, 7406, 14, 525, 63, 5173, 8, 504, 63, 932, 14, 354, 12, 370, 63, 932, 14, 354, 12, 1011, 3282, 9, 339, 768, 4639, 272, 347, 636, 873, 63, 1829, 8, 576, 12, 3324, 63, 354, 12, 849, 63, 3463, 304, 267, 408, 24663, 282, 1031, 503, 6275, 3324, 543, 1627, 536, 14, 398, 3033, 26, 288, 666, 334, 807, 304, 2341, 402, 1031, 15, 5173, 4382, 288, 3324, 63, 354, 26, 536, 402, 282, 3324, 334, 73, 14, 69, 14, 282, 790, 367, 283, 576, 358, 288, 849, 63, 3463, 334, 1609, 304, 849, 574, 402, 314, 3324, 267, 408, 267, 340, 3324, 63, 354, 315, 666, 26, 288, 3324, 63, 637 ]
[ 24313, 492, 3757, 4578, 199, 504, 24313, 14, 24365, 14, 7406, 492, 26061, 421, 199, 533, 19944, 390, 1181, 1582, 3883, 27234, 26, 272, 408, 2765, 1021, 8469, 282, 24787, 900, 6779, 402, 9571, 27234, 2251, 14, 339, 7048, 1031, 315, 314, 14446, 8469, 282, 900, 11848, 384, 14, 710, 2746, 2166, 365, 272, 283, 3403, 297, 314, 3499, 13, 674, 597, 2166, 283, 5180, 297, 436, 1924, 1566, 365, 282, 11747, 1031, 272, 8539, 370, 376, 6925, 1031, 14, 1626, 1566, 1443, 6804, 376, 900, 11848, 384, 20182, 21960, 26, 272, 4474, 315, 282, 892, 5382, 503, 5794, 1218, 282, 892, 1031, 14, 272, 408, 272, 19666, 63, 13837, 63, 3078, 275, 4396, 7406, 2, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1231, 275, 298, 1231, 2, 267, 291, 14, 521, 63, 5602, 275, 3757, 4578, 342, 267, 291, 14, 521, 63, 5602, 14, 525, 63, 932, 8, 277, 14, 1231, 9, 339, 768, 4639, 272, 347, 636, 932, 63, 344, 8, 1861, 12, 4739, 304, 267, 372, 10587, 904, 8, 1861, 12, 4739, 9, 339, 347, 1050, 63, 1430, 8, 277, 12, 1566, 12, 4913, 304, 267, 408, 267, 15747, 282, 9571, 27234, 465, 376, 1566, 14, 7048, 1566, 365, 10826, 370, 1172, 282, 267, 3747, 4913, 14, 398, 3033, 26, 288, 1566, 334, 3883, 27234, 304, 282, 9571, 27234, 1256, 288, 4913, 334, 2083, 14, 2083, 304, 282, 900, 270, 4393, 367, 642, 1566, 267, 3254, 26, 367, 22496, 12, 2429, 21574, 436, 12174, 3268, 267, 3254, 26, 1077, 900, 11848, 15203, 506, 8539, 315, 282, 10632, 769, 31, 267, 3254, 26, 365, 4260, 9571, 27234, 465, 282, 1031, 3324, 28264, 31, 2779, 1159, 4601, 13, 2049, 13402, 1325, 787, 9212, 12159, 3594, 315, 314, 2112, 31, 267, 408, 267, 340, 822, 8, 1430, 14, 7406, 14, 2415, 9, 508, 378, 26, 288, 372, 398, 1031, 63, 344, 275, 19944, 390, 1181, 1582, 3883, 27234, 855, 932, 63, 344, 267, 1566, 63, 344, 275, 4913, 14, 17070, 342, 267, 11848, 15203, 275, 2420, 3403, 582, 1031, 63, 344, 360, 89, 297, 4913, 14, 3403, 395, 673, 298, 4482, 582, 1031, 63, 344, 360, 77, 297, 4913, 14, 4482, 395, 673, 298, 2977, 582, 1031, 63, 344, 360, 68, 297, 4913, 14, 2977, 395, 673, 298, 5180, 582, 1031, 63, 344, 360, 72, 297, 4913, 14, 5180, 395, 673, 298, 1430, 582, 1566, 63, 344, 93, 398, 5071, 63, 521, 275, 291, 14, 1231, 267, 367, 334, 1302, 12, 900, 9, 315, 11848, 15203, 26, 288, 340, 900, 440, 315, 291, 14, 521, 63, 5602, 14, 2415, 26, 355, 291, 14, 521, 63, 5602, 14, 525, 63, 932, 8, 521, 12, 469, 1716, 14, 8063, 63, 13837, 63, 3078, 26, 1768, 1552, 288, 291, 14, 521, 63, 5602, 14, 525, 63, 5173, 8, 5701, 63, 521, 12, 900, 9, 288, 5071, 63, 521, 275, 900, 398, 3324, 63, 1302, 275, 19944, 390, 1181, 1582, 3883, 27234, 14, 28211, 63, 13837, 63, 3078, 267, 291, 14, 521, 63, 5602, 14, 2415, 59, 1430, 63, 344, 1527, 1829, 63, 1302, 61, 275, 1566, 421, 199, 533, 9571, 27234, 26, 272, 408, 2765, 1021, 8469, 282, 3486, 19666, 543, 4382, 272, 626, 5594, 506, 2196, 1750, 325, 14, 71, 14, 282, 283, 7726, 7, 3324, 367, 1924, 1031, 272, 543, 574, 687, 314, 14818, 4084, 12, 738, 8, 1216, 12, 5238, 680, 339, 7048, 1031, 1443, 506, 4568, 543, 790, 13, 585, 6342, 402, 4382, 14, 710, 790, 272, 9314, 314, 536, 402, 314, 3324, 29781, 314, 574, 365, 282, 769, 14, 710, 1642, 272, 1819, 315, 314, 769, 365, 314, 536, 402, 282, 16578, 2713, 2196, 4084, 805, 272, 334, 2859, 921, 4757, 14, 14248, 14, 1308, 15, 1301, 15, 4714, 13, 17, 14, 1079, 14, 16, 15, 4443, 15, 12791, 3746, 14, 2355, 14, 1360, 395, 272, 436, 314, 4618, 787, 314, 2368, 370, 626, 805, 14, 339, 3254, 26, 2291, 9393, 12, 436, 2196, 8207, 3382, 9393, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7406, 275, 3757, 4578, 342, 339, 347, 1050, 63, 932, 8, 277, 12, 1031, 304, 267, 408, 14995, 282, 1031, 370, 642, 19666, 398, 3033, 26, 288, 1031, 334, 1716, 304, 282, 1031, 370, 1050, 370, 642, 19666, 267, 408, 267, 291, 14, 7406, 14, 525, 63, 932, 8, 932, 14, 354, 12, 1011, 932, 14, 3282, 9, 339, 347, 1050, 63, 5173, 8, 277, 12, 687, 63, 932, 12, 326, 370, 63, 932, 12, 326, 4382, 10324, 326, 1104, 63, 4085, 2764, 3690, 29, 549, 304, 267, 408, 14995, 282, 23667, 6275, 370, 642, 19666, 398, 3033, 26, 288, 687, 63, 932, 334, 1716, 304, 1350, 1031, 288, 370, 63, 932, 334, 1716, 304, 1347, 1031, 288, 4382, 334, 807, 304, 282, 2341, 402, 1059, 2883, 370, 1263, 1338, 288, 1104, 63, 4085, 2764, 3690, 334, 2245, 304, 1104, 436, 7978, 340, 642, 6275, 9584, 282, 2049, 8643, 370, 314, 19666, 334, 885, 26, 715, 9, 267, 408, 267, 340, 1104, 63, 4085, 2764, 3690, 436, 971, 355, 687, 63, 932, 14, 354, 315, 26061, 8, 277, 14, 7406, 12, 370, 63, 932, 14, 354, 304, 288, 746, 2186, 480, 2765, 6275, 9584, 282, 8643, 370, 314, 3343, 531, 398, 340, 4382, 365, 488, 503, 4382, 365, 24702, 288, 291, 14, 7406, 14, 525, 63, 5173, 8, 504, 63, 932, 14, 354, 12, 370, 63, 932, 14, 354, 9, 267, 587, 26, 288, 291, 14, 7406, 14, 525, 63, 5173, 8, 504, 63, 932, 14, 354, 12, 370, 63, 932, 14, 354, 12, 1011, 3282, 9, 339, 768, 4639, 272, 347, 636, 873, 63, 1829, 8, 576, 12, 3324, 63, 354, 12, 849, 63, 3463, 304, 267, 408, 24663, 282, 1031, 503, 6275, 3324, 543, 1627, 536, 14, 398, 3033, 26, 288, 666, 334, 807, 304, 2341, 402, 1031, 15, 5173, 4382, 288, 3324, 63, 354, 26, 536, 402, 282, 3324, 334, 73, 14, 69, 14, 282, 790, 367, 283, 576, 358, 288, 849, 63, 3463, 334, 1609, 304, 849, 574, 402, 314, 3324, 267, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sudheesh001/oh-mainline
vendor/packages/Django/django/contrib/sitemaps/tests/https.py
219
2550
from __future__ import unicode_literals from datetime import date from django.test.utils import override_settings from .base import SitemapTestsBase class HTTPSSitemapTests(SitemapTestsBase): protocol = 'https' urls = 'django.contrib.sitemaps.tests.urls.https' def test_secure_sitemap_index(self): "A secure sitemap index can be rendered" response = self.client.get('/secure/index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap><loc>%s/secure/sitemap-simple.xml</loc></sitemap> </sitemapindex> """ % self.base_url self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_secure_sitemap_section(self): "A secure sitemap section can be rendered" response = self.client.get('/secure/sitemap-simple.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> </urlset> """ % (self.base_url, date.today()) self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @override_settings(SECURE_PROXY_SSL_HEADER=False) class HTTPSDetectionSitemapTests(SitemapTestsBase): extra = {'wsgi.url_scheme': 'https'} def test_sitemap_index_with_https_request(self): "A sitemap index requested in HTTPS is rendered with HTTPS links" response = self.client.get('/simple/index.xml', **self.extra) expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap> </sitemapindex> """ % self.base_url.replace('http://', 'https://') self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_sitemap_section_with_https_request(self): "A sitemap section requested in HTTPS is rendered with HTTPS links" response = self.client.get('/simple/sitemap-simple.xml', **self.extra) expected_content = """<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> </urlset> """ % (self.base_url.replace('http://', 'https://'), date.today()) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
agpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 2197, 492, 1434, 199, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 199, 504, 1275, 1095, 492, 11666, 1130, 2925, 1563, 199, 199, 533, 3101, 2300, 1175, 1130, 2925, 8, 8972, 1130, 2925, 1563, 304, 272, 4113, 275, 283, 2859, 7, 272, 8187, 275, 283, 1176, 14, 2828, 14, 30515, 14, 2219, 14, 3603, 14, 2859, 7, 339, 347, 511, 63, 7817, 63, 17205, 63, 1080, 8, 277, 304, 267, 298, 33, 11153, 25121, 1478, 883, 506, 8018, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7817, 15, 1080, 14, 1652, 358, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 17205, 1080, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 17205, 2535, 2102, 6598, 83, 15, 7817, 15, 17205, 13, 4129, 14, 1652, 1108, 2102, 2957, 17205, 30, 199, 1108, 17205, 1080, 30, 199, 624, 450, 291, 14, 1095, 63, 633, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 339, 347, 511, 63, 7817, 63, 17205, 63, 2792, 8, 277, 304, 267, 298, 33, 11153, 25121, 3420, 883, 506, 8018, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7817, 15, 17205, 13, 4129, 14, 1652, 358, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 633, 409, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 633, 2535, 2102, 6598, 83, 15, 1985, 15, 1108, 2102, 2535, 2019, 1494, 6598, 83, 1108, 2019, 1494, 2535, 1461, 5646, 30, 18178, 1108, 1461, 5646, 2535, 6693, 30, 16, 14, 21, 1108, 6693, 2957, 633, 30, 199, 1108, 633, 409, 30, 199, 624, 450, 334, 277, 14, 1095, 63, 633, 12, 1434, 14, 8136, 1012, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 421, 199, 32, 4415, 63, 1751, 8, 20696, 63, 20026, 63, 5413, 63, 7311, 29, 797, 9, 199, 533, 14147, 31198, 8972, 1130, 2925, 8, 8972, 1130, 2925, 1563, 304, 272, 2402, 275, 791, 6508, 14, 633, 63, 5512, 356, 283, 2859, 936, 339, 347, 511, 63, 17205, 63, 1080, 63, 1045, 63, 2859, 63, 1069, 8, 277, 304, 267, 298, 33, 25121, 1478, 5839, 315, 14147, 365, 8018, 543, 14147, 6220, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 4129, 15, 1080, 14, 1652, 297, 1011, 277, 14, 2911, 9, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 17205, 1080, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 17205, 2535, 2102, 6598, 83, 15, 4129, 15, 17205, 13, 4129, 14, 1652, 1108, 2102, 2957, 17205, 30, 199, 1108, 17205, 1080, 30, 199, 624, 450, 291, 14, 1095, 63, 633, 14, 1814, 360, 1014, 921, 297, 283, 2859, 921, 358, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 339, 347, 511, 63, 17205, 63, 2792, 63, 1045, 63, 2859, 63, 1069, 8, 277, 304, 267, 298, 33, 25121, 3420, 5839, 315, 14147, 365, 8018, 543, 14147, 6220, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 4129, 15, 17205, 13, 4129, 14, 1652, 297, 1011, 277, 14, 2911, 9, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 633, 409, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 633, 2535, 2102, 6598, 83, 15, 1985, 15, 1108, 2102, 2535, 2019, 1494, 6598, 83, 1108, 2019, 1494, 2535, 1461, 5646, 30, 18178, 1108, 1461, 5646, 2535, 6693, 30, 16, 14, 21, 1108, 6693, 2957, 633, 30, 199, 1108, 633, 409, 30, 199, 624, 450, 334, 277, 14, 1095, 63, 633, 14, 1814, 360, 1014, 921, 297, 283, 2859, 921, 659, 1434, 14, 8136, 1012, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 2197, 492, 1434, 199, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 199, 504, 1275, 1095, 492, 11666, 1130, 2925, 1563, 199, 199, 533, 3101, 2300, 1175, 1130, 2925, 8, 8972, 1130, 2925, 1563, 304, 272, 4113, 275, 283, 2859, 7, 272, 8187, 275, 283, 1176, 14, 2828, 14, 30515, 14, 2219, 14, 3603, 14, 2859, 7, 339, 347, 511, 63, 7817, 63, 17205, 63, 1080, 8, 277, 304, 267, 298, 33, 11153, 25121, 1478, 883, 506, 8018, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7817, 15, 1080, 14, 1652, 358, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 17205, 1080, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 17205, 2535, 2102, 6598, 83, 15, 7817, 15, 17205, 13, 4129, 14, 1652, 1108, 2102, 2957, 17205, 30, 199, 1108, 17205, 1080, 30, 199, 624, 450, 291, 14, 1095, 63, 633, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 339, 347, 511, 63, 7817, 63, 17205, 63, 2792, 8, 277, 304, 267, 298, 33, 11153, 25121, 3420, 883, 506, 8018, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7817, 15, 17205, 13, 4129, 14, 1652, 358, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 633, 409, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 633, 2535, 2102, 6598, 83, 15, 1985, 15, 1108, 2102, 2535, 2019, 1494, 6598, 83, 1108, 2019, 1494, 2535, 1461, 5646, 30, 18178, 1108, 1461, 5646, 2535, 6693, 30, 16, 14, 21, 1108, 6693, 2957, 633, 30, 199, 1108, 633, 409, 30, 199, 624, 450, 334, 277, 14, 1095, 63, 633, 12, 1434, 14, 8136, 1012, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 421, 199, 32, 4415, 63, 1751, 8, 20696, 63, 20026, 63, 5413, 63, 7311, 29, 797, 9, 199, 533, 14147, 31198, 8972, 1130, 2925, 8, 8972, 1130, 2925, 1563, 304, 272, 2402, 275, 791, 6508, 14, 633, 63, 5512, 356, 283, 2859, 936, 339, 347, 511, 63, 17205, 63, 1080, 63, 1045, 63, 2859, 63, 1069, 8, 277, 304, 267, 298, 33, 25121, 1478, 5839, 315, 14147, 365, 8018, 543, 14147, 6220, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 4129, 15, 1080, 14, 1652, 297, 1011, 277, 14, 2911, 9, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 17205, 1080, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 17205, 2535, 2102, 6598, 83, 15, 4129, 15, 17205, 13, 4129, 14, 1652, 1108, 2102, 2957, 17205, 30, 199, 1108, 17205, 1080, 30, 199, 624, 450, 291, 14, 1095, 63, 633, 14, 1814, 360, 1014, 921, 297, 283, 2859, 921, 358, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 9, 339, 347, 511, 63, 17205, 63, 2792, 63, 1045, 63, 2859, 63, 1069, 8, 277, 304, 267, 298, 33, 25121, 3420, 5839, 315, 14147, 365, 8018, 543, 14147, 6220, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 4129, 15, 17205, 13, 4129, 14, 1652, 297, 1011, 277, 14, 2911, 9, 267, 1420, 63, 1317, 275, 31501, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 633, 409, 9604, 628, 1014, 921, 1544, 14, 30515, 14, 1308, 15, 9482, 15, 17205, 15, 16, 14, 25, 1743, 199, 28, 633, 2535, 2102, 6598, 83, 15, 1985, 15, 1108, 2102, 2535, 2019, 1494, 6598, 83, 1108, 2019, 1494, 2535, 1461, 5646, 30, 18178, 1108, 1461, 5646, 2535, 6693, 30, 16, 14, 21, 1108, 6693, 2957, 633, 30, 199, 1108, 633, 409, 30, 199, 624, 450, 334, 277, 14, 1095, 63, 633, 14, 1814, 360, 1014, 921, 297, 283, 2859, 921, 659, 1434, 14, 8136, 1012, 267, 291, 14, 479, 4317, 591, 8, 1310, 14, 1317, 14, 2708, 360, 1624, 13, 24, 659, 1420, 63, 1317, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
arcivanov/pybuilder
src/integrationtest/python/should_not_load_remote_classes_in_unittest_tests.py
3
1847
# -*- coding: utf-8 -*- # # This file is part of PyBuilder # # Copyright 2011-2020 PyBuilder Team # # 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 sys import unittest from itest_support import IntegrationTestSupport class Test(IntegrationTestSupport): def test(self): self.write_build_file(""" from pybuilder.core import use_plugin, init use_plugin("python.core") use_plugin("python.unittest") name = "unittest-integration-test" default_task = "run_unit_tests" @init def init (project): project.build_depends_on("mockito") """) self.create_directory("src/main/python") self.write_file("src/main/python/helloworld.py", r"""import sys def helloworld(out): out.write("Hello world of Python\n") """) self.create_directory("src/unittest/python") self.write_file("src/unittest/python/helloworld_tests.py", r"""from mockito import mock, verify import unittest from helloworld import helloworld class HelloWorldTest(unittest.TestCase): def test_should_issue_hello_world_message(self): out = mock() helloworld(out) verify(out).write("Hello world of Python\n") """) reactor = self.prepare_reactor() reactor.build() self.assertTrue("mockito" not in sys.modules) if __name__ == "__main__": unittest.main()
apache-2.0
[ 3, 257, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 257, 961, 570, 365, 1777, 402, 1611, 6437, 199, 3, 199, 3, 257, 1898, 7760, 13, 13934, 1611, 6437, 11682, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 2882, 199, 199, 504, 284, 396, 63, 4058, 492, 27561, 774, 11532, 421, 199, 533, 1379, 8, 20405, 774, 11532, 304, 272, 347, 511, 8, 277, 304, 267, 291, 14, 952, 63, 1506, 63, 493, 4852, 199, 504, 1134, 5649, 14, 1018, 492, 675, 63, 2718, 12, 4205, 199, 199, 1180, 63, 2718, 480, 1548, 14, 1018, 531, 199, 1180, 63, 2718, 480, 1548, 14, 2796, 531, 199, 199, 354, 275, 298, 2796, 13, 15092, 13, 396, 2, 199, 885, 63, 1765, 275, 298, 1065, 63, 3248, 63, 2219, 2, 199, 199, 32, 826, 199, 318, 4205, 334, 1715, 304, 272, 2199, 14, 1506, 63, 8912, 63, 265, 480, 1805, 24308, 531, 199, 6141, 267, 291, 14, 981, 63, 3619, 480, 2164, 15, 973, 15, 1548, 531, 267, 291, 14, 952, 63, 493, 480, 2164, 15, 973, 15, 1548, 15, 5006, 7617, 14, 647, 401, 519, 624, 646, 984, 199, 199, 318, 16509, 7617, 8, 548, 304, 272, 734, 14, 952, 480, 6257, 6701, 402, 2018, 60, 78, 531, 199, 199, 6141, 267, 291, 14, 981, 63, 3619, 480, 2164, 15, 2796, 15, 1548, 531, 267, 291, 14, 952, 63, 493, 480, 2164, 15, 2796, 15, 1548, 15, 5006, 7617, 63, 2219, 14, 647, 401, 519, 624, 504, 1683, 24308, 492, 1683, 12, 4911, 199, 646, 2882, 199, 199, 504, 16509, 7617, 492, 16509, 7617, 199, 199, 533, 23833, 15943, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 5626, 63, 5237, 63, 5006, 63, 7617, 63, 1188, 8, 277, 304, 267, 734, 275, 1683, 342, 398, 16509, 7617, 8, 548, 9, 398, 4911, 8, 548, 680, 952, 480, 6257, 6701, 402, 2018, 60, 78, 531, 199, 6141, 398, 9655, 275, 291, 14, 6726, 63, 13544, 342, 267, 9655, 14, 1506, 342, 398, 291, 14, 1815, 480, 1805, 24308, 2, 440, 315, 984, 14, 3112, 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 ]
[ 257, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 257, 961, 570, 365, 1777, 402, 1611, 6437, 199, 3, 199, 3, 257, 1898, 7760, 13, 13934, 1611, 6437, 11682, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 2882, 199, 199, 504, 284, 396, 63, 4058, 492, 27561, 774, 11532, 421, 199, 533, 1379, 8, 20405, 774, 11532, 304, 272, 347, 511, 8, 277, 304, 267, 291, 14, 952, 63, 1506, 63, 493, 4852, 199, 504, 1134, 5649, 14, 1018, 492, 675, 63, 2718, 12, 4205, 199, 199, 1180, 63, 2718, 480, 1548, 14, 1018, 531, 199, 1180, 63, 2718, 480, 1548, 14, 2796, 531, 199, 199, 354, 275, 298, 2796, 13, 15092, 13, 396, 2, 199, 885, 63, 1765, 275, 298, 1065, 63, 3248, 63, 2219, 2, 199, 199, 32, 826, 199, 318, 4205, 334, 1715, 304, 272, 2199, 14, 1506, 63, 8912, 63, 265, 480, 1805, 24308, 531, 199, 6141, 267, 291, 14, 981, 63, 3619, 480, 2164, 15, 973, 15, 1548, 531, 267, 291, 14, 952, 63, 493, 480, 2164, 15, 973, 15, 1548, 15, 5006, 7617, 14, 647, 401, 519, 624, 646, 984, 199, 199, 318, 16509, 7617, 8, 548, 304, 272, 734, 14, 952, 480, 6257, 6701, 402, 2018, 60, 78, 531, 199, 199, 6141, 267, 291, 14, 981, 63, 3619, 480, 2164, 15, 2796, 15, 1548, 531, 267, 291, 14, 952, 63, 493, 480, 2164, 15, 2796, 15, 1548, 15, 5006, 7617, 63, 2219, 14, 647, 401, 519, 624, 504, 1683, 24308, 492, 1683, 12, 4911, 199, 646, 2882, 199, 199, 504, 16509, 7617, 492, 16509, 7617, 199, 199, 533, 23833, 15943, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 5626, 63, 5237, 63, 5006, 63, 7617, 63, 1188, 8, 277, 304, 267, 734, 275, 1683, 342, 398, 16509, 7617, 8, 548, 9, 398, 4911, 8, 548, 680, 952, 480, 6257, 6701, 402, 2018, 60, 78, 531, 199, 6141, 398, 9655, 275, 291, 14, 6726, 63, 13544, 342, 267, 9655, 14, 1506, 342, 398, 291, 14, 1815, 480, 1805, 24308, 2, 440, 315, 984, 14, 3112, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
paregorios/awibmanager
awibmanager/tests/test_awibimages.py
1
1724
import unittest from awibmanager.awibimages import AI from os import remove from os.path import join TESTAWIBID = 'isawi-201102172235161' TESTPATH = 'awibmanager/tests/data/pont-du-gard-france' BADPATH = './boguspath' EMPTYPATH = 'awibmanager/tests/data/empty' BADID = 'jenny-867-5309' class AIInitCase(unittest.TestCase): """ test basic initialization behaviors of the awibimages class """ def test_path(self): ai = AI(TESTAWIBID, TESTPATH) self.assertIsInstance(ai, AI) self.assertEqual(ai.path, TESTPATH) def test_bad_path(self): try: ai = AI(TESTAWIBID, BADPATH) except IOError as e: self.assertEqual(e[0], "'./boguspath' is not a directory") def test_empty_path(self): try: ai = AI(TESTAWIBID, EMPTYPATH) except IOError as e: self.assertEqual(e[0], "'awibmanager/tests/data/empty/meta/isawi-201102172235161-meta.xml' is not a file while trying to set metadata filename") # definitely need some more tests here class AIFlickrCase(unittest.TestCase): """ test flickr-related behaviors of the awibimages class """ def setUp(self): fn = join(TESTPATH, 'flickr2', '.'.join((TESTAWIBID, 'png'))) try: remove(fn) except OSError: pass def tearDown(self): fn = join(TESTPATH, 'flickr2', '.'.join((TESTAWIBID, 'png'))) try: remove(fn) except OSError: pass def test_flickr_prep(self): ai = AI(TESTAWIBID, TESTPATH) ai.prep_for_flickr() def test_flickr_send(self): ai = AI(TESTAWIBID, TESTPATH) ai.prep_for_flickr() ai.send_to_flickr()
bsd-3-clause
[ 199, 646, 2882, 199, 504, 26936, 1892, 2609, 14, 10084, 1892, 4782, 492, 437, 41, 199, 504, 747, 492, 2813, 199, 504, 747, 14, 515, 492, 4263, 199, 199, 2864, 15088, 2100, 998, 275, 283, 374, 10084, 73, 13, 1797, 7759, 1196, 1081, 1276, 12285, 7, 199, 2864, 3243, 275, 283, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 678, 84, 13, 2033, 13, 71, 1005, 13, 4391, 554, 7, 199, 9439, 3243, 275, 21526, 18665, 515, 7, 199, 13993, 3243, 275, 283, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 1667, 7, 199, 9439, 998, 275, 283, 74, 287, 9745, 13, 14927, 13, 21, 10556, 7, 199, 199, 533, 437, 41, 9346, 1538, 8, 2796, 14, 1746, 304, 272, 408, 511, 5678, 11097, 5112, 1384, 402, 314, 26936, 1892, 4782, 1021, 408, 339, 347, 511, 63, 515, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 291, 14, 6926, 8, 5789, 12, 437, 41, 9, 267, 291, 14, 629, 8, 5789, 14, 515, 12, 7393, 3243, 9, 339, 347, 511, 63, 4087, 63, 515, 8, 277, 304, 267, 862, 26, 288, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 699, 1554, 3243, 9, 267, 871, 5925, 465, 325, 26, 288, 291, 14, 629, 8, 69, 59, 16, 467, 298, 1370, 15, 18665, 515, 7, 365, 440, 282, 2082, 531, 339, 347, 511, 63, 1667, 63, 515, 8, 277, 304, 267, 862, 26, 288, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 16589, 3243, 9, 267, 871, 5925, 465, 325, 26, 288, 291, 14, 629, 8, 69, 59, 16, 467, 3546, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 1667, 15, 2024, 15, 374, 10084, 73, 13, 1797, 7759, 1196, 1081, 1276, 12285, 13, 2024, 14, 1652, 7, 365, 440, 282, 570, 1830, 9936, 370, 663, 3341, 1788, 531, 339, 327, 28088, 590, 1929, 2005, 1655, 2295, 2348, 199, 199, 533, 437, 4656, 8442, 82, 1538, 8, 2796, 14, 1746, 304, 272, 408, 511, 289, 8442, 82, 13, 2407, 5112, 1384, 402, 314, 26936, 1892, 4782, 1021, 408, 339, 347, 3613, 8, 277, 304, 267, 4325, 275, 4263, 8, 2864, 3243, 12, 283, 70, 8442, 82, 18, 297, 15671, 904, 1332, 2864, 15088, 2100, 998, 12, 283, 4524, 7058, 267, 862, 26, 7205, 2813, 8, 2324, 9, 267, 871, 6440, 26, 288, 986, 339, 347, 6766, 8, 277, 304, 267, 4325, 275, 4263, 8, 2864, 3243, 12, 283, 70, 8442, 82, 18, 297, 15671, 904, 1332, 2864, 15088, 2100, 998, 12, 283, 4524, 7058, 267, 862, 26, 7205, 2813, 8, 2324, 9, 267, 871, 6440, 26, 288, 986, 339, 347, 511, 63, 70, 8442, 82, 63, 10837, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 15933, 14, 10837, 63, 509, 63, 70, 8442, 82, 342, 339, 347, 511, 63, 70, 8442, 82, 63, 2254, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 15933, 14, 10837, 63, 509, 63, 70, 8442, 82, 342, 267, 15933, 14, 2254, 63, 475, 63, 70, 8442, 82, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 646, 2882, 199, 504, 26936, 1892, 2609, 14, 10084, 1892, 4782, 492, 437, 41, 199, 504, 747, 492, 2813, 199, 504, 747, 14, 515, 492, 4263, 199, 199, 2864, 15088, 2100, 998, 275, 283, 374, 10084, 73, 13, 1797, 7759, 1196, 1081, 1276, 12285, 7, 199, 2864, 3243, 275, 283, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 678, 84, 13, 2033, 13, 71, 1005, 13, 4391, 554, 7, 199, 9439, 3243, 275, 21526, 18665, 515, 7, 199, 13993, 3243, 275, 283, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 1667, 7, 199, 9439, 998, 275, 283, 74, 287, 9745, 13, 14927, 13, 21, 10556, 7, 199, 199, 533, 437, 41, 9346, 1538, 8, 2796, 14, 1746, 304, 272, 408, 511, 5678, 11097, 5112, 1384, 402, 314, 26936, 1892, 4782, 1021, 408, 339, 347, 511, 63, 515, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 291, 14, 6926, 8, 5789, 12, 437, 41, 9, 267, 291, 14, 629, 8, 5789, 14, 515, 12, 7393, 3243, 9, 339, 347, 511, 63, 4087, 63, 515, 8, 277, 304, 267, 862, 26, 288, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 699, 1554, 3243, 9, 267, 871, 5925, 465, 325, 26, 288, 291, 14, 629, 8, 69, 59, 16, 467, 298, 1370, 15, 18665, 515, 7, 365, 440, 282, 2082, 531, 339, 347, 511, 63, 1667, 63, 515, 8, 277, 304, 267, 862, 26, 288, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 16589, 3243, 9, 267, 871, 5925, 465, 325, 26, 288, 291, 14, 629, 8, 69, 59, 16, 467, 3546, 10084, 1892, 2609, 15, 2219, 15, 576, 15, 1667, 15, 2024, 15, 374, 10084, 73, 13, 1797, 7759, 1196, 1081, 1276, 12285, 13, 2024, 14, 1652, 7, 365, 440, 282, 570, 1830, 9936, 370, 663, 3341, 1788, 531, 339, 327, 28088, 590, 1929, 2005, 1655, 2295, 2348, 199, 199, 533, 437, 4656, 8442, 82, 1538, 8, 2796, 14, 1746, 304, 272, 408, 511, 289, 8442, 82, 13, 2407, 5112, 1384, 402, 314, 26936, 1892, 4782, 1021, 408, 339, 347, 3613, 8, 277, 304, 267, 4325, 275, 4263, 8, 2864, 3243, 12, 283, 70, 8442, 82, 18, 297, 15671, 904, 1332, 2864, 15088, 2100, 998, 12, 283, 4524, 7058, 267, 862, 26, 7205, 2813, 8, 2324, 9, 267, 871, 6440, 26, 288, 986, 339, 347, 6766, 8, 277, 304, 267, 4325, 275, 4263, 8, 2864, 3243, 12, 283, 70, 8442, 82, 18, 297, 15671, 904, 1332, 2864, 15088, 2100, 998, 12, 283, 4524, 7058, 267, 862, 26, 7205, 2813, 8, 2324, 9, 267, 871, 6440, 26, 288, 986, 339, 347, 511, 63, 70, 8442, 82, 63, 10837, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 15933, 14, 10837, 63, 509, 63, 70, 8442, 82, 342, 339, 347, 511, 63, 70, 8442, 82, 63, 2254, 8, 277, 304, 267, 15933, 275, 437, 41, 8, 2864, 15088, 2100, 998, 12, 7393, 3243, 9, 267, 15933, 14, 10837, 63, 509, 63, 70, 8442, 82, 342, 267, 15933, 14, 2254, 63, 475, 63, 70, 8442, 82, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
jcftang/ansible
lib/ansible/modules/database/misc/mongodb_parameter.py
5
7290
#!/usr/bin/python # -*- coding: utf-8 -*- """ (c) 2016, Loic Blot <loic.blot@unix-experience.fr> Sponsored by Infopro Digital. http://www.infopro-digital.com/ Sponsored by E.T.A.I. http://www.etai.fr/ 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 = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' --- module: mongodb_parameter short_description: Change an administrative parameter on a MongoDB server. description: - Change an administrative parameter on a MongoDB server. version_added: "2.1" options: login_user: description: - The username used to authenticate with required: false default: null login_password: description: - The password used to authenticate with required: false default: null login_host: description: - The host running the database required: false default: localhost login_port: description: - The port to connect to required: false default: 27017 login_database: description: - The database where login credentials are stored required: false default: null replica_set: description: - Replica set to connect to (automatically connects to primary for writes) required: false default: null database: description: - The name of the database to add/remove the user from required: true ssl: description: - Whether to use an SSL connection when connecting to the database required: false default: false param: description: - MongoDB administrative parameter to modify required: true value: description: - MongoDB administrative parameter value to set required: true param_type: description: - Define the parameter value (str, int) required: false default: str notes: - Requires the pymongo Python package on the remote host, version 2.4.2+. This can be installed using pip or the OS package manager. @see http://api.mongodb.org/python/current/installation.html requirements: [ "pymongo" ] author: "Loic Blot (@nerzhul)" ''' EXAMPLES = ''' # Set MongoDB syncdelay to 60 (this is an int) - mongodb_parameter: param: syncdelay value: 60 param_type: int ''' RETURN = ''' before: description: value before modification returned: success type: string after: description: value after modification returned: success type: string ''' import ConfigParser try: from pymongo.errors import ConnectionFailure from pymongo.errors import OperationFailure from pymongo import version as PyMongoVersion from pymongo import MongoClient except ImportError: try: # for older PyMongo 2.2 from pymongo import Connection as MongoClient except ImportError: pymongo_found = False else: pymongo_found = True else: pymongo_found = True # ========================================= # MongoDB module specific support methods. # def load_mongocnf(): config = ConfigParser.RawConfigParser() mongocnf = os.path.expanduser('~/.mongodb.cnf') try: config.readfp(open(mongocnf)) creds = dict( user=config.get('client', 'user'), password=config.get('client', 'pass') ) except (ConfigParser.NoOptionError, IOError): return False return creds # ========================================= # Module execution. # def main(): module = AnsibleModule( argument_spec=dict( login_user=dict(default=None), login_password=dict(default=None, no_log=True), login_host=dict(default='localhost'), login_port=dict(default=27017, type='int'), login_database=dict(default=None), replica_set=dict(default=None), param=dict(default=None, required=True), value=dict(default=None, required=True), param_type=dict(default="str", choices=['str', 'int']), ssl=dict(default=False, type='bool'), ) ) if not pymongo_found: module.fail_json(msg='the python pymongo module is required') login_user = module.params['login_user'] login_password = module.params['login_password'] login_host = module.params['login_host'] login_port = module.params['login_port'] login_database = module.params['login_database'] replica_set = module.params['replica_set'] ssl = module.params['ssl'] param = module.params['param'] param_type = module.params['param_type'] value = module.params['value'] # Verify parameter is coherent with specified type try: if param_type == 'int': value = int(value) except ValueError: e = get_exception() module.fail_json(msg="value '%s' is not %s" % (value, param_type)) try: if replica_set: client = MongoClient(login_host, int(login_port), replicaset=replica_set, ssl=ssl) else: client = MongoClient(login_host, int(login_port), ssl=ssl) if login_user is None and login_password is None: mongocnf_creds = load_mongocnf() if mongocnf_creds is not False: login_user = mongocnf_creds['user'] login_password = mongocnf_creds['password'] elif login_password is None or login_user is None: module.fail_json(msg='when supplying login arguments, both login_user and login_password must be provided') if login_user is not None and login_password is not None: client.admin.authenticate(login_user, login_password, source=login_database) except ConnectionFailure: e = get_exception() module.fail_json(msg='unable to connect to database: %s' % str(e)) db = client.admin try: after_value = db.command("setParameter", **{param: value}) except OperationFailure: e = get_exception() module.fail_json(msg="unable to change parameter: %s" % str(e)) if "was" not in after_value: module.exit_json(changed=True, msg="Unable to determine old value, assume it changed.") else: module.exit_json(changed=(value != after_value["was"]), before=after_value["was"], after=value) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.pycompat24 import get_exception if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 8, 67, 9, 7800, 12, 3835, 530, 699, 1653, 665, 320, 530, 14, 66, 1653, 32, 11864, 13, 476, 24242, 14, 4391, 30, 199, 51, 678, 1152, 581, 701, 1010, 70, 11340, 29979, 14, 1455, 921, 1544, 14, 4904, 11340, 13, 25888, 14, 957, 15, 199, 51, 678, 1152, 581, 701, 662, 14, 52, 14, 33, 14, 41, 14, 1455, 921, 1544, 14, 1841, 73, 14, 4391, 15, 199, 199, 2765, 570, 365, 1777, 402, 2622, 199, 199, 10047, 365, 2867, 2032, 26, 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, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 10047, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 32315, 13152, 63, 5329, 199, 3612, 63, 1802, 26, 7743, 376, 4628, 25124, 2725, 641, 282, 28458, 1654, 14, 199, 1802, 26, 272, 446, 7743, 376, 4628, 25124, 2725, 641, 282, 28458, 1654, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 1419, 26, 272, 4676, 63, 751, 26, 267, 1369, 26, 288, 446, 710, 3434, 1202, 370, 12895, 543, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 2505, 1202, 370, 12895, 543, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 3879, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 11667, 272, 4676, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 370, 4907, 370, 267, 1415, 26, 3055, 267, 849, 26, 8087, 9570, 272, 4676, 63, 4659, 26, 267, 1369, 26, 288, 446, 710, 3050, 2382, 4676, 6235, 787, 5489, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 16234, 63, 409, 26, 267, 1369, 26, 288, 446, 16000, 7518, 663, 370, 4907, 370, 334, 2495, 17174, 4907, 83, 370, 5062, 367, 14511, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3050, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 3050, 370, 1050, 15, 2168, 314, 922, 687, 267, 1415, 26, 2549, 272, 6149, 26, 267, 1369, 26, 288, 446, 7480, 370, 675, 376, 7799, 1950, 1380, 18170, 370, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1215, 26, 267, 1369, 26, 288, 446, 28458, 4628, 25124, 2725, 370, 2811, 267, 1415, 26, 2549, 272, 574, 26, 267, 1369, 26, 288, 446, 28458, 4628, 25124, 2725, 574, 370, 663, 267, 1415, 26, 2549, 272, 1215, 63, 466, 26, 267, 1369, 26, 288, 446, 13930, 314, 2725, 574, 334, 495, 12, 1109, 9, 267, 1415, 26, 3055, 267, 849, 26, 620, 199, 199, 5983, 26, 272, 446, 15127, 314, 21878, 2018, 2559, 641, 314, 3982, 1591, 12, 1015, 499, 14, 20, 14, 18, 26240, 961, 489, 883, 506, 4903, 1808, 7305, 503, 314, 4403, 2559, 5256, 14, 768, 3239, 1455, 921, 1246, 14, 22130, 13152, 14, 1308, 15, 1548, 15, 1818, 15, 23048, 14, 1360, 199, 7538, 26, 359, 298, 29380, 2, 1622, 199, 2502, 26, 298, 2041, 530, 699, 1653, 8593, 1372, 3951, 348, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2494, 28458, 7604, 5814, 370, 5212, 334, 3749, 365, 376, 1109, 9, 199, 13, 32315, 13152, 63, 5329, 26, 272, 1215, 26, 7604, 5814, 272, 574, 26, 5212, 272, 1215, 63, 466, 26, 1109, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5182, 26, 272, 1369, 26, 574, 2544, 7100, 272, 2138, 26, 3182, 272, 730, 26, 1059, 199, 4399, 26, 272, 1369, 26, 574, 2410, 7100, 272, 2138, 26, 3182, 272, 730, 26, 1059, 199, 2344, 199, 199, 646, 14196, 199, 199, 893, 26, 272, 687, 21878, 14, 2550, 492, 8113, 6782, 272, 687, 21878, 14, 2550, 492, 17954, 6782, 272, 687, 21878, 492, 1015, 465, 1611, 20393, 3353, 272, 687, 21878, 492, 13503, 3041, 199, 2590, 3545, 26, 272, 862, 26, 221, 327, 367, 12731, 1611, 20393, 499, 14, 18, 267, 687, 21878, 492, 8113, 465, 13503, 3041, 272, 871, 3545, 26, 267, 21878, 63, 4214, 275, 756, 272, 587, 26, 267, 21878, 63, 4214, 275, 715, 199, 2836, 26, 272, 21878, 63, 4214, 275, 715, 421, 199, 3, 19469, 763, 199, 3, 28458, 859, 2488, 2291, 3102, 14, 199, 3, 199, 199, 318, 2248, 63, 22130, 679, 9914, 837, 272, 1101, 275, 14196, 14, 7963, 15218, 342, 272, 32315, 679, 9914, 275, 747, 14, 515, 14, 12131, 21114, 8083, 22130, 13152, 14, 23600, 358, 339, 862, 26, 267, 1101, 14, 739, 3997, 8, 1490, 8, 22130, 679, 9914, 430, 267, 20023, 275, 1211, 8, 288, 922, 29, 888, 14, 362, 360, 1258, 297, 283, 751, 659, 288, 2505, 29, 888, 14, 362, 360, 1258, 297, 283, 1529, 358, 267, 776, 272, 871, 334, 15218, 14, 1944, 16546, 12, 5925, 304, 267, 372, 756, 339, 372, 20023, 421, 199, 3, 19469, 763, 199, 3, 5673, 6451, 14, 199, 3, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 4676, 63, 751, 29, 807, 8, 885, 29, 403, 395, 288, 4676, 63, 2060, 29, 807, 8, 885, 29, 403, 12, 949, 63, 793, 29, 549, 395, 288, 4676, 63, 1102, 29, 807, 8, 885, 534, 5967, 659, 288, 4676, 63, 719, 29 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 8, 67, 9, 7800, 12, 3835, 530, 699, 1653, 665, 320, 530, 14, 66, 1653, 32, 11864, 13, 476, 24242, 14, 4391, 30, 199, 51, 678, 1152, 581, 701, 1010, 70, 11340, 29979, 14, 1455, 921, 1544, 14, 4904, 11340, 13, 25888, 14, 957, 15, 199, 51, 678, 1152, 581, 701, 662, 14, 52, 14, 33, 14, 41, 14, 1455, 921, 1544, 14, 1841, 73, 14, 4391, 15, 199, 199, 2765, 570, 365, 1777, 402, 2622, 199, 199, 10047, 365, 2867, 2032, 26, 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, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 10047, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 32315, 13152, 63, 5329, 199, 3612, 63, 1802, 26, 7743, 376, 4628, 25124, 2725, 641, 282, 28458, 1654, 14, 199, 1802, 26, 272, 446, 7743, 376, 4628, 25124, 2725, 641, 282, 28458, 1654, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 1419, 26, 272, 4676, 63, 751, 26, 267, 1369, 26, 288, 446, 710, 3434, 1202, 370, 12895, 543, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 2060, 26, 267, 1369, 26, 288, 446, 710, 2505, 1202, 370, 12895, 543, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4676, 63, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 3879, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 11667, 272, 4676, 63, 719, 26, 267, 1369, 26, 288, 446, 710, 1844, 370, 4907, 370, 267, 1415, 26, 3055, 267, 849, 26, 8087, 9570, 272, 4676, 63, 4659, 26, 267, 1369, 26, 288, 446, 710, 3050, 2382, 4676, 6235, 787, 5489, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 16234, 63, 409, 26, 267, 1369, 26, 288, 446, 16000, 7518, 663, 370, 4907, 370, 334, 2495, 17174, 4907, 83, 370, 5062, 367, 14511, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3050, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 3050, 370, 1050, 15, 2168, 314, 922, 687, 267, 1415, 26, 2549, 272, 6149, 26, 267, 1369, 26, 288, 446, 7480, 370, 675, 376, 7799, 1950, 1380, 18170, 370, 314, 3050, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1215, 26, 267, 1369, 26, 288, 446, 28458, 4628, 25124, 2725, 370, 2811, 267, 1415, 26, 2549, 272, 574, 26, 267, 1369, 26, 288, 446, 28458, 4628, 25124, 2725, 574, 370, 663, 267, 1415, 26, 2549, 272, 1215, 63, 466, 26, 267, 1369, 26, 288, 446, 13930, 314, 2725, 574, 334, 495, 12, 1109, 9, 267, 1415, 26, 3055, 267, 849, 26, 620, 199, 199, 5983, 26, 272, 446, 15127, 314, 21878, 2018, 2559, 641, 314, 3982, 1591, 12, 1015, 499, 14, 20, 14, 18, 26240, 961, 489, 883, 506, 4903, 1808, 7305, 503, 314, 4403, 2559, 5256, 14, 768, 3239, 1455, 921, 1246, 14, 22130, 13152, 14, 1308, 15, 1548, 15, 1818, 15, 23048, 14, 1360, 199, 7538, 26, 359, 298, 29380, 2, 1622, 199, 2502, 26, 298, 2041, 530, 699, 1653, 8593, 1372, 3951, 348, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2494, 28458, 7604, 5814, 370, 5212, 334, 3749, 365, 376, 1109, 9, 199, 13, 32315, 13152, 63, 5329, 26, 272, 1215, 26, 7604, 5814, 272, 574, 26, 5212, 272, 1215, 63, 466, 26, 1109, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5182, 26, 272, 1369, 26, 574, 2544, 7100, 272, 2138, 26, 3182, 272, 730, 26, 1059, 199, 4399, 26, 272, 1369, 26, 574, 2410, 7100, 272, 2138, 26, 3182, 272, 730, 26, 1059, 199, 2344, 199, 199, 646, 14196, 199, 199, 893, 26, 272, 687, 21878, 14, 2550, 492, 8113, 6782, 272, 687, 21878, 14, 2550, 492, 17954, 6782, 272, 687, 21878, 492, 1015, 465, 1611, 20393, 3353, 272, 687, 21878, 492, 13503, 3041, 199, 2590, 3545, 26, 272, 862, 26, 221, 327, 367, 12731, 1611, 20393, 499, 14, 18, 267, 687, 21878, 492, 8113, 465, 13503, 3041, 272, 871, 3545, 26, 267, 21878, 63, 4214, 275, 756, 272, 587, 26, 267, 21878, 63, 4214, 275, 715, 199, 2836, 26, 272, 21878, 63, 4214, 275, 715, 421, 199, 3, 19469, 763, 199, 3, 28458, 859, 2488, 2291, 3102, 14, 199, 3, 199, 199, 318, 2248, 63, 22130, 679, 9914, 837, 272, 1101, 275, 14196, 14, 7963, 15218, 342, 272, 32315, 679, 9914, 275, 747, 14, 515, 14, 12131, 21114, 8083, 22130, 13152, 14, 23600, 358, 339, 862, 26, 267, 1101, 14, 739, 3997, 8, 1490, 8, 22130, 679, 9914, 430, 267, 20023, 275, 1211, 8, 288, 922, 29, 888, 14, 362, 360, 1258, 297, 283, 751, 659, 288, 2505, 29, 888, 14, 362, 360, 1258, 297, 283, 1529, 358, 267, 776, 272, 871, 334, 15218, 14, 1944, 16546, 12, 5925, 304, 267, 372, 756, 339, 372, 20023, 421, 199, 3, 19469, 763, 199, 3, 5673, 6451, 14, 199, 3, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 4676, 63, 751, 29, 807, 8, 885, 29, 403, 395, 288, 4676, 63, 2060, 29, 807, 8, 885, 29, 403, 12, 949, 63, 793, 29, 549, 395, 288, 4676, 63, 1102, 29, 807, 8, 885, 534, 5967, 659, 288, 4676, 63, 719, 29, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
games-useaible/Useaible-machine-learning-challenge
PythonCode/Lunarlander.py
1
15973
import numpy as np import tempfile import tensorflow as tf import math import json import random import puka import pika import thread import time from simulator import LanderSimulator from mazeGame import mazeSimulator credentials = pika.PlainCredentials('test', 'test') parameters = pika.ConnectionParameters('invirmq.southeastasia.cloudapp.azure.com', 5672, '/', credentials) connection = pika.BlockingConnection(parameters) channel = connection.channel() network_solutions = {} # lander_channel = connection.channel() class neural_network: REPLAY_MEMORY_SIZE = 500000 RANDOM_ACTION_DECAY = 0.99 FINAL_RANDOM_ACTION_PROB = 0.05 INITIAL_RANDOM_ACTION_PROB = 0.9 MIN_RANDOM_ACTION_PROB = 0.1 HIDDEN1_SIZE = 200 HIDDEN2_SIZE = 200 NUM_EPISODES = 10000 MAX_STEPS = 100000 LEARNING_RATE = 0.001 MINIBATCH_SIZE = 100 DISCOUNT_FACTOR = 0.9 TARGET_UPDATE_FREQ = 300 REG_FACTOR = 0.001 OBS_LAST_STATE_INDEX, OBS_ACTION_INDEX, OBS_REWARD_INDEX, OBS_CURRENT_STATE_INDEX, OBS_TERMINAL_INDEX = range(5) LOG_DIR = '/home/useaible/project/logs' # random_action_prob = 0.9 replay_memory = [] def __init__(self): self.env = None self.input_size = None self.output_size = None def init_network(self, env): self.env = env self.input_size = self.env.inputs self.output_size = len(self.env.actions) self.random_action_prob = self.INITIAL_RANDOM_ACTION_PROB # Inference self.x = tf.placeholder(tf.float32, [None, self.input_size]) # self.score = tf.placeholder(tf.float32, shape=[], name="score") with tf.name_scope('hidden1'): W1 = tf.Variable( tf.truncated_normal([self.input_size, self.HIDDEN1_SIZE], stddev=0.01), name='W1') b1 = tf.Variable(tf.zeros(shape=[self.HIDDEN1_SIZE]), name='b1') h1 = tf.nn.tanh(tf.matmul(self.x, W1) + b1) with tf.name_scope('hidden2'): W2 = tf.Variable( tf.truncated_normal([self.HIDDEN1_SIZE, self.HIDDEN2_SIZE], stddev=0.01), name='W2') b2 = tf.Variable(tf.zeros(shape=[self.HIDDEN2_SIZE]), name='b2') h2 = tf.nn.tanh(tf.matmul(h1, W2) + b2) with tf.name_scope('output'): W3 = tf.Variable( tf.truncated_normal([self.HIDDEN2_SIZE, self.output_size], stddev=0.01), name='W3') b3 = tf.Variable(tf.zeros(shape=[self.output_size]), name='b3') self.Q = tf.matmul(h2, W3) + b3 self.weights = [W1, b1, W2, b2, W3, b3] # Loss self.targetQ = tf.placeholder(tf.float32, [None]) self.targetActionMask = tf.placeholder(tf.float32, [None, self.output_size]) # TODO: Optimize this q_values = tf.reduce_sum(tf.mul(self.Q, self.targetActionMask), reduction_indices=[1]) self.loss = tf.reduce_mean(tf.square(tf.sub(q_values, self.targetQ))) # Reguralization for w in [W1, W2, W3]: self.loss += self.REG_FACTOR * tf.reduce_sum(tf.square(w)) # Training optimizer = tf.train.AdamOptimizer(self.LEARNING_RATE) global_step = tf.Variable(0, name='global_step', trainable=False) self.train_op = optimizer.minimize(self.loss, global_step=global_step) #end init_network def train(self, num_episodes=NUM_EPISODES, mqtt=None): on_training = True stop_training = False score = 0 self.session = tf.Session() # Summary for TensorBoard tf.scalar_summary('loss', self.loss) # tf.scalar_summary('score', self.score) self.summary = tf.merge_all_summaries() self.summary_writer = tf.train.SummaryWriter(self.LOG_DIR, self.session.graph) self.session.run(tf.initialize_all_variables()) total_steps = 0 step_counts = [] target_weights = self.session.run(self.weights) # create a temporary queue # queue_promise = client.queue_declare(exclusive=True, durable=True) # queue = client.wait(queue_promise)['queue'] # #bind the queue # bind_promise = client.queue_bind(exchange='amq.topic', queue=queue, routing_key='telemetry') # client.wait(bind_promise) # # start waiting for data # data_promise = client.basic_consume(queue=queue, no_ack=True) # # create a fanout exchange # exchange_promise = client.exchange_declare( # exchange='amq.topic', type='topic', durable=True) # client.wait(exchange_promise) for episode in range(num_episodes): # move = { # 'Reset' : True, # 'Value' : '0' # } # json_str = json.dumps(move) # message = json_str # message_promise = client.basic_publish( # exchange='amq.topic', routing_key='move', body=message) # # request to start simulator # client.wait(message_promise) #delay for multi threading purposes #sleeps for .1 second time.sleep(.1); score = 0 actions = [] state = self.env.reset() steps = 0 reward = 0 done = False for step in range(self.MAX_STEPS): # Pick the next action and execute it # if episode % 10 == 0: # self.env.render() action = None if episode < self.MINIBATCH_SIZE or episode % 10 == 1 \ or random.random() < self.random_action_prob: action = random.choice(self.env.actions) else: q_values = self.session.run(self.Q, feed_dict={self.x: [state]}) action = q_values.argmax() actions.append(action) # move = { # 'Reset' : False, # 'Value' : action # } # json_str = json.dumps(move) # message = json_str # message_promise = client.basic_publish( # exchange='amq.topic', routing_key='move', body=message) # client.wait(message_promise) # # wait for the telemetry # data = client.wait(data_promise) # # print "[x] data: ", repr(data['body']) # receive_data = json.loads(data['body']) # obs = receive_data['obs'] # reward = receive_data['reward'] # if receive_data['done'] == 0: # done = False # else: # done = True obs, reward, done, _ = self.env.step(action) # Update replay memory if done: # reward = self.env.episode_reward() # reward = reward score = self.env.episode_reward() self.replay_memory.append((state, action, reward, obs, done)) if len(self.replay_memory) > self.REPLAY_MEMORY_SIZE: self.replay_memory.pop(0) state = obs total_steps += 1 steps += 1 if done: break # todo send episode actions using mqtt if num_episodes == (episode + 1): training_done = True else: training_done = False #send training session data if mqtt not None if mqtt is not None: data = { 'data': actions, "session": episode + 1, "score": score, "done": training_done } json_data = json.dumps(data) mqtt['channel'].basic_publish(exchange=mqtt['exchange'], routing_key=mqtt['train_route_key'], body=json_data) # Sample a random minibatch and fetch max Q at s' if episode > self.MINIBATCH_SIZE: minibatch = random.sample(self.replay_memory, self.MINIBATCH_SIZE) previous_states = [d[self.OBS_LAST_STATE_INDEX] for d in minibatch] actions = [d[self.OBS_ACTION_INDEX] for d in minibatch] rewards = [d[self.OBS_REWARD_INDEX] for d in minibatch] current_states = [d[self.OBS_CURRENT_STATE_INDEX] for d in minibatch] next_states = [m[3] for m in minibatch] # TODO: Optimize to skip terminal states feed_dict = {self.x: current_states} feed_dict.update(zip(self.weights, target_weights)) q_values = self.session.run(self.Q, feed_dict=feed_dict) max_q_values = q_values.max(axis=1) # Compute target Q values target_q = np.zeros(self.MINIBATCH_SIZE) target_action_mask = np.zeros((self.MINIBATCH_SIZE, self.output_size), dtype=int) for i in range(self.MINIBATCH_SIZE): _, action, reward, _, terminal = minibatch[i] # print "Action: %r, Reward: %r, Terminal: %r" % (action, reward, terminal) target_q[i] = rewards[i] if not terminal: target_q[i] += self.DISCOUNT_FACTOR * np.max(q_values[i]) target_action_mask[i][actions[i]] = 1 # Gradient descent # print "target_action_mask: ", target_action_mask # print "actions: ", actions states = [m[0] for m in minibatch] feed_dict_x = { self.x: previous_states, self.targetQ: target_q, self.targetActionMask: target_action_mask, } _, summary = self.session.run([self.train_op, self.summary], feed_dict=feed_dict_x) # Write summary for TensorBoard if episode % 10 == 0: self.summary_writer.add_summary(summary, episode) step_counts.append(steps) mean_steps = np.mean(step_counts[-100:]) # print("Training episode = {}, Score = {}, Random chance: {}, Steps: {}" # .format(episode, score, self.random_action_prob, steps)) self.update_random_action_prob() # Update target network if episode % self.TARGET_UPDATE_FREQ == 0: target_weights = self.session.run(self.weights) def update_random_action_prob(self): self.random_action_prob *= self.RANDOM_ACTION_DECAY if self.random_action_prob < self.MIN_RANDOM_ACTION_PROB: self.random_action_prob = self.MIN_RANDOM_ACTION_PROB def play(self, mqtt=None): lander_solution = [] state = self.env.reset() done = False loop_count = 0 while not done: loop_count += 1 self.env.render() q_values = self.session.run(self.Q, feed_dict={self.x: [state]}) action = q_values.argmax() print "Action: ", action lander_solution.append(action) state, _, done, _ = self.env.step(action) if loop_count == 1000: break # steps += 1 print "Done playing" if mqtt is not None: data = { 'data': lander_solution, "session": 'best solution', "score": 0, "done": True } json_data = json.dumps(data) mqtt['channel'].basic_publish(exchange=mqtt['exchange'], routing_key=mqtt['play_route_key'], body=json_data) return lander_solution # return steps # nn = None def main(): try: print "Neural network initialize" result = channel.queue_declare(exclusive=True) queue_name = result.method.queue def start_training(ch, method, properties, body): print body print ch print method print properties thread.start_new_thread(train_tensorflow, (body, ch,)) #end start_training channel.queue_bind(exchange='amq.topic', queue=queue_name, routing_key="tensorflow.train") channel.basic_consume(start_training, queue=queue_name, no_ack=True) print "Chanel ready to consume" channel.start_consuming() except KeyboardInterrupt: connection.close() # client.close() def train_tensorflow(data, channel): # global network_solutions nn = neural_network() receive_data = json.loads(data) session = receive_data['Sessions'] nn.INITIAL_RANDOM_ACTION_PROB = np.float32(receive_data['random_action_prob']) nn.RANDOM_ACTION_DECAY = np.float32(receive_data['RANDOM_ACTION_DECAY']) nn.HIDDEN1_SIZE = np.int32(receive_data['HIDDEN1_SIZE']) nn.HIDDEN2_SIZE = np.int32(receive_data['HIDDEN2_SIZE']) nn.LEARNING_RATE = np.float32(receive_data['LEARNING_RATE']) nn.MINIBATCH_SIZE = np.int32(receive_data['MINIBATCH_SIZE']) nn.DISCOUNT_FACTOR = np.float32(receive_data['DISCOUNT_FACTOR']) nn.TARGET_UPDATE_FREQ = np.int(receive_data['TARGET_UPDATE_FREQ']) # USER TOKEN user_token = receive_data['USER_TOKEN'] game = None try: game_type = receive_data['Game'] except: game_type = None print "Training started..." tf.reset_default_graph() if game_type and receive_data['Game'] == 'maze': data = receive_data['MazeInfo'] grid = data['Grid'] goal_postion = data['GoalPosition'] starting_position = data['StartingPosition'] maze_height = data['Height'] maze_width = data['Width'] perfect_game_moves = data['PerfectGameMovesCount'] game = mazeSimulator(maze_height, maze_width,grid,starting_position['X'], starting_position['Y'],goal_postion['X'], goal_postion['Y'], perfect_game_moves) else: altitude = receive_data['Altitude'] fuel = receive_data['Fuel'] game = LanderSimulator(altitude, fuel) nn.env = game user_exchange_name = 'amq.topic' #'lander.' + user_token train_route_key = 'tensorflow.actions.' + user_token play_route_key = 'tensorflow.play_lander.' + user_token mqttMetadata = { 'token': user_token, 'channel': channel, 'exchange': user_exchange_name, 'train_route_key': train_route_key, 'play_route_key': play_route_key } # todo pass the parameters from the client nn.init_network(game) nn.train(session, mqttMetadata) network_solutions[user_token] = nn.play(mqttMetadata) #end train_tensorflow() if __name__ == "__main__": main()
gpl-3.0
[ 646, 2680, 465, 980, 202, 199, 646, 5549, 202, 199, 646, 3228, 465, 2833, 202, 199, 646, 3473, 202, 199, 646, 2022, 202, 199, 646, 2196, 202, 199, 646, 299, 3210, 65, 202, 199, 646, 299, 26966, 202, 199, 646, 2462, 202, 199, 646, 900, 2999, 199, 504, 15797, 492, 491, 11438, 11397, 202, 199, 504, 610, 806, 11454, 492, 610, 806, 11397, 2999, 199, 6942, 275, 299, 26966, 14, 20711, 13428, 360, 396, 297, 283, 396, 358, 202, 199, 3214, 275, 299, 26966, 14, 3225, 5976, 360, 262, 1042, 8334, 14, 22607, 14346, 305, 4674, 14, 4091, 571, 14, 9078, 14, 957, 297, 202, 4318, 959, 20298, 12, 202, 4318, 17220, 202, 4318, 6235, 9, 2999, 199, 2105, 275, 299, 26966, 14, 27132, 3225, 8, 3214, 9, 2999, 199, 2775, 275, 1950, 14, 2775, 342, 202, 199, 1200, 63, 27313, 275, 1052, 202, 199, 3, 634, 11438, 63, 2775, 275, 1950, 14, 2775, 342, 2999, 199, 533, 1279, 4889, 63, 1200, 26, 1128, 5363, 11625, 63, 19495, 63, 4305, 275, 959, 5345, 1128, 820, 879, 10462, 63, 10052, 63, 1093, 3263, 57, 275, 378, 14, 1020, 1128, 24745, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 1717, 1128, 26105, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 25, 1128, 15861, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 17, 1128, 869, 22436, 17, 63, 4305, 275, 1926, 1128, 869, 22436, 18, 63, 4305, 275, 1926, 1128, 11576, 63, 6102, 7336, 4448, 275, 11630, 1128, 9141, 63, 840, 25711, 275, 25761, 1128, 6124, 689, 6024, 63, 16553, 275, 378, 14, 4587, 1128, 15861, 2100, 8078, 63, 4305, 275, 2948, 1128, 7587, 8760, 63, 26393, 275, 378, 14, 25, 1128, 26134, 63, 10383, 63, 38, 14583, 275, 9601, 1128, 14142, 63, 26393, 275, 378, 14, 4587, 1128, 593, 11087, 63, 16901, 63, 6689, 63, 10215, 12, 593, 11087, 63, 10052, 63, 10215, 12, 593, 11087, 63, 907, 2982, 36, 63, 10215, 12, 593, 11087, 63, 14211, 63, 6689, 63, 10215, 12, 593, 11087, 63, 28376, 748, 63, 10215, 275, 1425, 8, 21, 9, 1128, 5051, 63, 3022, 275, 1994, 4219, 15, 1180, 5789, 830, 15, 1715, 15, 7270, 7, 2958, 327, 2196, 63, 1287, 63, 6101, 275, 378, 14, 25, 1128, 24331, 63, 4844, 275, 942, 10292, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 1813, 275, 488, 1039, 291, 14, 1210, 63, 890, 275, 488, 1039, 291, 14, 1199, 63, 890, 275, 488, 8740, 2958, 347, 4205, 63, 1200, 8, 277, 12, 2589, 304, 1039, 291, 14, 1813, 275, 2589, 1039, 291, 14, 1210, 63, 890, 275, 291, 14, 1813, 14, 3711, 1039, 291, 14, 1199, 63, 890, 275, 822, 8, 277, 14, 1813, 14, 3723, 9, 1039, 291, 14, 2355, 63, 1287, 63, 6101, 275, 291, 14, 13768, 63, 27644, 10462, 63, 10052, 63, 30533, 1039, 327, 1010, 1769, 1039, 291, 14, 88, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 291, 14, 1210, 63, 890, 566, 1039, 327, 291, 14, 3397, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 2215, 6034, 536, 628, 3397, 531, 1039, 543, 2833, 14, 354, 63, 2645, 360, 5642, 17, 735, 1675, 644, 17, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 1210, 63, 890, 12, 291, 14, 40, 22436, 17, 63, 4305, 467, 221, 4906, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 17, 358, 1675, 330, 17, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 40, 22436, 17, 63, 4305, 2522, 536, 534, 66, 17, 358, 1675, 394, 17, 275, 2833, 14, 4411, 14, 21468, 8, 3249, 14, 14465, 8, 277, 14, 88, 12, 644, 17, 9, 435, 330, 17, 9, 1039, 543, 2833, 14, 354, 63, 2645, 360, 5642, 18, 735, 1675, 644, 18, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 40, 22436, 17, 63, 4305, 12, 291, 14, 40, 22436, 18, 63, 4305, 467, 221, 4906, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 18, 358, 1675, 330, 18, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 40, 22436, 18, 63, 4305, 2522, 536, 534, 66, 18, 358, 1675, 394, 18, 275, 2833, 14, 4411, 14, 21468, 8, 3249, 14, 14465, 8, 72, 17, 12, 644, 18, 9, 435, 330, 18, 9, 1039, 543, 2833, 14, 354, 63, 2645, 360, 1199, 735, 1675, 644, 19, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 40, 22436, 18, 63, 4305, 12, 291, 14, 1199, 63, 890, 467, 20712, 2151, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 19, 358, 1675, 330, 19, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 1199, 63, 890, 2522, 536, 534, 66, 19, 358, 1675, 291, 14, 49, 275, 2833, 14, 14465, 8, 72, 18, 12, 644, 19, 9, 435, 330, 19, 1039, 291, 14, 4916, 275, 359, 55, 17, 12, 330, 17, 12, 644, 18, 12, 330, 18, 12, 644, 19, 12, 330, 19, 61, 4341, 327, 3835, 385, 1039, 291, 14, 1375, 49, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 566, 1039, 291, 14, 1375, 3310, 5144, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 291, 14, 1199, 63, 890, 566, 1039, 327, 3254, 26, 19246, 794, 642, 1039, 1894, 63, 1459, 275, 2833, 14, 5270, 63, 1838, 8, 3249, 14, 3703, 8, 277, 14, 49, 12, 291, 14, 1375, 3310, 5144, 395, 221, 4906, 16773, 63, 4108, 1524, 17, 566, 1039, 291, 14, 4358, 275, 2833, 14, 5270, 63, 3670, 8, 3249, 14, 9646, 8, 3249, 14, 954, 8, 81, 63, 1459, 12, 291, 14, 1375, 49, 1724, 4341, 327, 5044, 4889, 2072, 1039, 367, 336, 315, 359, 55, 17, 12, 644, 18, 12, 644, 19, 2189, 1675, 291, 14, 4358, 847, 291, 14, 5616, 63, 26393, 627, 2833, 14, 5270, 63, 1838, 8, 3249, 14, 9646, 8, 87, 430, 4341, 327, 22859, 1039, 10736, 275, 2833, 14, 2834, 14, 32408, 13946, 8, 277, 14 ]
[ 2680, 465, 980, 202, 199, 646, 5549, 202, 199, 646, 3228, 465, 2833, 202, 199, 646, 3473, 202, 199, 646, 2022, 202, 199, 646, 2196, 202, 199, 646, 299, 3210, 65, 202, 199, 646, 299, 26966, 202, 199, 646, 2462, 202, 199, 646, 900, 2999, 199, 504, 15797, 492, 491, 11438, 11397, 202, 199, 504, 610, 806, 11454, 492, 610, 806, 11397, 2999, 199, 6942, 275, 299, 26966, 14, 20711, 13428, 360, 396, 297, 283, 396, 358, 202, 199, 3214, 275, 299, 26966, 14, 3225, 5976, 360, 262, 1042, 8334, 14, 22607, 14346, 305, 4674, 14, 4091, 571, 14, 9078, 14, 957, 297, 202, 4318, 959, 20298, 12, 202, 4318, 17220, 202, 4318, 6235, 9, 2999, 199, 2105, 275, 299, 26966, 14, 27132, 3225, 8, 3214, 9, 2999, 199, 2775, 275, 1950, 14, 2775, 342, 202, 199, 1200, 63, 27313, 275, 1052, 202, 199, 3, 634, 11438, 63, 2775, 275, 1950, 14, 2775, 342, 2999, 199, 533, 1279, 4889, 63, 1200, 26, 1128, 5363, 11625, 63, 19495, 63, 4305, 275, 959, 5345, 1128, 820, 879, 10462, 63, 10052, 63, 1093, 3263, 57, 275, 378, 14, 1020, 1128, 24745, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 1717, 1128, 26105, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 25, 1128, 15861, 63, 27644, 10462, 63, 10052, 63, 30533, 275, 378, 14, 17, 1128, 869, 22436, 17, 63, 4305, 275, 1926, 1128, 869, 22436, 18, 63, 4305, 275, 1926, 1128, 11576, 63, 6102, 7336, 4448, 275, 11630, 1128, 9141, 63, 840, 25711, 275, 25761, 1128, 6124, 689, 6024, 63, 16553, 275, 378, 14, 4587, 1128, 15861, 2100, 8078, 63, 4305, 275, 2948, 1128, 7587, 8760, 63, 26393, 275, 378, 14, 25, 1128, 26134, 63, 10383, 63, 38, 14583, 275, 9601, 1128, 14142, 63, 26393, 275, 378, 14, 4587, 1128, 593, 11087, 63, 16901, 63, 6689, 63, 10215, 12, 593, 11087, 63, 10052, 63, 10215, 12, 593, 11087, 63, 907, 2982, 36, 63, 10215, 12, 593, 11087, 63, 14211, 63, 6689, 63, 10215, 12, 593, 11087, 63, 28376, 748, 63, 10215, 275, 1425, 8, 21, 9, 1128, 5051, 63, 3022, 275, 1994, 4219, 15, 1180, 5789, 830, 15, 1715, 15, 7270, 7, 2958, 327, 2196, 63, 1287, 63, 6101, 275, 378, 14, 25, 1128, 24331, 63, 4844, 275, 942, 10292, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 1813, 275, 488, 1039, 291, 14, 1210, 63, 890, 275, 488, 1039, 291, 14, 1199, 63, 890, 275, 488, 8740, 2958, 347, 4205, 63, 1200, 8, 277, 12, 2589, 304, 1039, 291, 14, 1813, 275, 2589, 1039, 291, 14, 1210, 63, 890, 275, 291, 14, 1813, 14, 3711, 1039, 291, 14, 1199, 63, 890, 275, 822, 8, 277, 14, 1813, 14, 3723, 9, 1039, 291, 14, 2355, 63, 1287, 63, 6101, 275, 291, 14, 13768, 63, 27644, 10462, 63, 10052, 63, 30533, 1039, 327, 1010, 1769, 1039, 291, 14, 88, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 291, 14, 1210, 63, 890, 566, 1039, 327, 291, 14, 3397, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 2215, 6034, 536, 628, 3397, 531, 1039, 543, 2833, 14, 354, 63, 2645, 360, 5642, 17, 735, 1675, 644, 17, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 1210, 63, 890, 12, 291, 14, 40, 22436, 17, 63, 4305, 467, 221, 4906, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 17, 358, 1675, 330, 17, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 40, 22436, 17, 63, 4305, 2522, 536, 534, 66, 17, 358, 1675, 394, 17, 275, 2833, 14, 4411, 14, 21468, 8, 3249, 14, 14465, 8, 277, 14, 88, 12, 644, 17, 9, 435, 330, 17, 9, 1039, 543, 2833, 14, 354, 63, 2645, 360, 5642, 18, 735, 1675, 644, 18, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 40, 22436, 17, 63, 4305, 12, 291, 14, 40, 22436, 18, 63, 4305, 467, 221, 4906, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 18, 358, 1675, 330, 18, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 40, 22436, 18, 63, 4305, 2522, 536, 534, 66, 18, 358, 1675, 394, 18, 275, 2833, 14, 4411, 14, 21468, 8, 3249, 14, 14465, 8, 72, 17, 12, 644, 18, 9, 435, 330, 18, 9, 1039, 543, 2833, 14, 354, 63, 2645, 360, 1199, 735, 1675, 644, 19, 275, 2833, 14, 2773, 8, 4906, 2833, 14, 19347, 63, 3302, 779, 277, 14, 40, 22436, 18, 63, 4305, 12, 291, 14, 1199, 63, 890, 467, 20712, 2151, 28052, 29, 16, 14, 614, 395, 536, 534, 55, 19, 358, 1675, 330, 19, 275, 2833, 14, 2773, 8, 3249, 14, 4250, 8, 1392, 1524, 277, 14, 1199, 63, 890, 2522, 536, 534, 66, 19, 358, 1675, 291, 14, 49, 275, 2833, 14, 14465, 8, 72, 18, 12, 644, 19, 9, 435, 330, 19, 1039, 291, 14, 4916, 275, 359, 55, 17, 12, 330, 17, 12, 644, 18, 12, 330, 18, 12, 644, 19, 12, 330, 19, 61, 4341, 327, 3835, 385, 1039, 291, 14, 1375, 49, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 566, 1039, 291, 14, 1375, 3310, 5144, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 291, 14, 1199, 63, 890, 566, 1039, 327, 3254, 26, 19246, 794, 642, 1039, 1894, 63, 1459, 275, 2833, 14, 5270, 63, 1838, 8, 3249, 14, 3703, 8, 277, 14, 49, 12, 291, 14, 1375, 3310, 5144, 395, 221, 4906, 16773, 63, 4108, 1524, 17, 566, 1039, 291, 14, 4358, 275, 2833, 14, 5270, 63, 3670, 8, 3249, 14, 9646, 8, 3249, 14, 954, 8, 81, 63, 1459, 12, 291, 14, 1375, 49, 1724, 4341, 327, 5044, 4889, 2072, 1039, 367, 336, 315, 359, 55, 17, 12, 644, 18, 12, 644, 19, 2189, 1675, 291, 14, 4358, 847, 291, 14, 5616, 63, 26393, 627, 2833, 14, 5270, 63, 1838, 8, 3249, 14, 9646, 8, 87, 430, 4341, 327, 22859, 1039, 10736, 275, 2833, 14, 2834, 14, 32408, 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1, 1, 1, 1, 1, 1, 1 ]
artoonie/RedStatesBlueStates
redblue/viewsenators/initialization.py
1
6633
import os import requests import viewsenators.cityToFbCode as cityToFbCode import viewsenators.stateToFbCode as stateToFbCode from .models import Party, City, State, Senator, Congressmember, ContactList from .getPopulations import getCityStatePopulations def populateParties(partyModel, partyObjects): """ Takes in partyObjects instead of using the Party.objects.all() so it can get the correct Model from an in-progress migration if needed. """ numParties = len(partyObjects.all()) if len(partyObjects.all()) != 0: assert numParties == 3 return partyObjects.bulk_create([ partyModel(name="Republican", abbrev="R", adjective="Republican"), partyModel(name="Democrat", abbrev="D", adjective="Democratic"), partyModel(name="Independent", abbrev="ID", adjective="Independent") ]) def populateStates(statePopulations): """ Populate the list of states and their facebook codes """ # For now, never overwrite numStates = len(State.objects.all()) if len(State.objects.all()) != 0: assert numStates == 50 return for line in stateToFbCode.mapping: abbrev = line[0] name = line[1] facebookId = line[2] population = statePopulations[name] State.objects.create(name=name, abbrev=abbrev, facebookId=facebookId, population=population) def addPopulationToStates(statePopulations): """ For migration, most likely, though maybe to update when we get newer data? """ for state in statePopulations: if state == "District of Columbia": continue stateObj = State.objects.get(name=state) stateObj.population = statePopulations[state] stateObj.save() def populateCities(cityPopulations, fixMode=False, verboseYield = False): """ Populate the list of cities and their facebook codes. :param fixMode: Will create any new cities not in the database, and update any facebook codes and populations of existing cities. Will not delete cities, :param verboseYield: To overcome heroku timeouts, will yield progress strings. """ # For now, never overwrite numCities = len(City.objects.all()) if not fixMode and len(City.objects.all()) != 0: # sanity check to make sure it didn't crash on a previous run assert numCities > 18000 return if verboseYield: yield "Beginning download.<br>" if verboseYield: yield "Completed download. Processing.<br>" for i, line in enumerate(cityToFbCode.mapping): city = line[0] stateAbbrev = line[1] facebookId = line[2] if verboseYield and (i+1) % 100 == 0: yield "%d/%d<br>" % (i+1, len(cityToFbCode.mapping)) try: state = State.objects.get(abbrev=stateAbbrev) except State.DoesNotExist: # Puerto Rico & other territories if verboseYield: yield "Skipping non-state: " + stateAbbrev + "<br>" continue stateName = state.name assert stateName in cityPopulations if city not in cityPopulations[stateName]: try: cityObj = City.objects.get(name=city, state=state) cityObj.delete() except City.DoesNotExist: pass continue # city likely below minPopulation threshold else: population = cityPopulations[stateName][city] if fixMode: try: cityObj = City.objects.get(name=city, state=state) if cityObj.facebookId != facebookId or cityObj.population != population: cityObj.facebookId = facebookId cityObj.population = population cityObj.save() continue except City.DoesNotExist: # Continue to create pass City.objects.create(name=city, state=state, facebookId=facebookId, population=population) def updateCitiesWithCurrentData(cityPopulations): for x in populateCities(cityPopulations, fixMode=True, verboseYield=True): yield x def clearDataForNewCongress(): Party.objects.all().delete() State.objects.all().delete() Senator.objects.all().delete() Congressmember.objects.all().delete() # Note: contactlists have links to senators which are now defunct ContactList.objects.all().delete() def populateAllData(): def _populateMOCWith(data, mocType): """ Populate members of congress with a propublica dictionary. mocType should be either Senator or Congressmember """ assert(mocType == Senator or mocType == Congressmember) assert data['status'] == 'OK' results = data['results'] assert len(results) == 1 # could have multiple congresses? result = results[0] assert result['congress'] == '116' assert result['chamber'] == 'Senate' if mocType == 'Senator' else 'House' assert result['offset'] == 0 for member in result['members']: assert isinstance(member['in_office'], bool) # was once a string if member['in_office'] == False: continue state = State.objects.get(abbrev=member['state']) party = Party.objects.get(abbrev=member['party']) try: senator = mocType.objects.get(firstName= member['first_name'], lastName = member['last_name']) senator.phoneNumber = member['phone'] senator.save() except mocType.DoesNotExist: mocType.objects.create(firstName= member['first_name'], lastName = member['last_name'], phoneNumber = member['phone'], party = party, state = state) url = 'https://api.propublica.org/congress/v1/116/senate/members.json' apiKey = os.environ['PROPUBLICA_API_KEY'] headers = {'X-API-Key': apiKey} cityPopulations, statePopulations = getCityStatePopulations() populateParties(Party, Party.objects) populateStates(statePopulations) populateCities(cityPopulations) senatorDataFile = requests.get(url, headers=headers) _populateMOCWith(senatorDataFile.json(), Senator)
gpl-3.0
[ 646, 747, 199, 646, 4145, 199, 646, 2455, 2464, 2750, 14, 3690, 1378, 38, 66, 3034, 465, 14492, 1378, 38, 66, 3034, 199, 646, 2455, 2464, 2750, 14, 929, 1378, 38, 66, 3034, 465, 1174, 1378, 38, 66, 3034, 199, 504, 1275, 992, 492, 2235, 369, 12, 14753, 12, 8511, 12, 428, 287, 707, 12, 445, 951, 753, 1114, 12, 18684, 1296, 199, 504, 1275, 362, 9606, 21429, 492, 664, 17024, 2223, 9606, 21429, 199, 199, 318, 13904, 1262, 1417, 8, 7522, 1685, 12, 17135, 11188, 304, 272, 408, 17415, 315, 17135, 11188, 3140, 402, 1808, 314, 2235, 369, 14, 1462, 14, 452, 342, 880, 652, 267, 883, 664, 314, 3211, 5822, 687, 376, 315, 13, 5734, 8367, 340, 4346, 14, 408, 272, 1967, 1262, 1417, 275, 822, 8, 7522, 11188, 14, 452, 1012, 272, 340, 822, 8, 7522, 11188, 14, 452, 1012, 1137, 378, 26, 267, 702, 1967, 1262, 1417, 508, 650, 267, 372, 339, 17135, 11188, 14, 9377, 63, 981, 779, 267, 17135, 1685, 8, 354, 628, 497, 3455, 290, 401, 221, 2236, 66, 4964, 628, 50, 401, 14510, 6850, 628, 497, 3455, 290, 1288, 267, 17135, 1685, 8, 354, 628, 21493, 1556, 292, 401, 259, 2236, 66, 4964, 628, 36, 401, 14510, 6850, 628, 21493, 67, 19826, 1288, 267, 17135, 1685, 8, 354, 628, 607, 7106, 401, 2236, 66, 4964, 628, 998, 401, 14510, 6850, 628, 607, 7106, 531, 272, 4794, 199, 199, 318, 13904, 18010, 8, 929, 9606, 21429, 304, 272, 408, 31731, 314, 769, 402, 6363, 436, 3932, 8870, 2706, 9479, 408, 272, 327, 2104, 3063, 12, 7078, 8970, 272, 1967, 18010, 275, 822, 8, 2223, 14, 1462, 14, 452, 1012, 272, 340, 822, 8, 2223, 14, 1462, 14, 452, 1012, 1137, 378, 26, 267, 702, 1967, 18010, 508, 5238, 267, 372, 339, 367, 1004, 315, 1174, 1378, 38, 66, 3034, 14, 4745, 26, 267, 2236, 66, 4964, 275, 1004, 59, 16, 61, 267, 536, 275, 1004, 59, 17, 61, 267, 8870, 2706, 1304, 275, 1004, 59, 18, 61, 267, 16423, 275, 1174, 9606, 21429, 59, 354, 61, 398, 8511, 14, 1462, 14, 981, 8, 354, 29, 354, 12, 2490, 2236, 66, 4964, 29, 31349, 12, 2490, 8870, 2706, 1304, 29, 16652, 1304, 12, 2490, 16423, 29, 16003, 9, 199, 199, 318, 1050, 31824, 1378, 18010, 8, 929, 9606, 21429, 304, 272, 408, 2104, 8367, 12, 4750, 12060, 12, 10617, 11703, 370, 1678, 1380, 781, 664, 267, 15666, 666, 31, 408, 272, 367, 1174, 315, 1174, 9606, 21429, 26, 267, 340, 1174, 508, 298, 36, 5230, 319, 402, 3626, 4295, 4674, 582, 1980, 267, 1174, 5665, 275, 8511, 14, 1462, 14, 362, 8, 354, 29, 929, 9, 267, 1174, 5665, 14, 16003, 275, 1174, 9606, 21429, 59, 929, 61, 267, 1174, 5665, 14, 2117, 342, 199, 199, 318, 13904, 35, 12107, 8, 3690, 9606, 21429, 12, 5325, 1385, 29, 797, 12, 3376, 22889, 275, 756, 304, 272, 408, 31731, 314, 769, 402, 286, 12107, 436, 3932, 8870, 2706, 9479, 14, 267, 520, 635, 5325, 1385, 26, 12823, 1218, 1263, 892, 286, 12107, 440, 315, 314, 3050, 12, 288, 436, 1678, 1263, 8870, 2706, 9479, 436, 4560, 21429, 402, 3411, 286, 12107, 14, 288, 12823, 440, 3145, 286, 12107, 12, 267, 520, 635, 3376, 22889, 26, 4005, 1806, 4352, 14737, 745, 85, 25870, 12, 911, 1995, 288, 6696, 3326, 14, 339, 408, 272, 327, 2104, 3063, 12, 7078, 8970, 272, 1967, 35, 12107, 275, 822, 8, 17024, 14, 1462, 14, 452, 1012, 272, 340, 440, 5325, 1385, 436, 822, 8, 17024, 14, 1462, 14, 452, 1012, 1137, 378, 26, 267, 327, 16740, 1104, 370, 1852, 3238, 652, 9980, 1133, 12420, 641, 282, 4136, 1255, 267, 702, 1967, 35, 12107, 690, 6155, 1493, 267, 372, 339, 340, 3376, 22889, 26, 267, 1995, 298, 5595, 1835, 5235, 21455, 3289, 4335, 339, 340, 3376, 22889, 26, 267, 1995, 298, 19908, 5235, 14, 20157, 21455, 3289, 4335, 339, 367, 284, 12, 1004, 315, 3874, 8, 3690, 1378, 38, 66, 3034, 14, 4745, 304, 267, 14492, 275, 1004, 59, 16, 61, 267, 1174, 33, 2501, 4964, 275, 1004, 59, 17, 61, 267, 8870, 2706, 1304, 275, 1004, 59, 18, 61, 398, 340, 3376, 22889, 436, 334, 73, 11, 17, 9, 450, 2948, 508, 378, 26, 288, 1995, 2071, 68, 3149, 68, 28, 3289, 4335, 450, 334, 73, 11, 17, 12, 822, 8, 3690, 1378, 38, 66, 3034, 14, 4745, 430, 398, 862, 26, 288, 1174, 275, 8511, 14, 1462, 14, 362, 8, 31349, 29, 929, 33, 2501, 4964, 9, 267, 871, 8511, 14, 7400, 26, 288, 327, 510, 14262, 475, 820, 12802, 1253, 1163, 2044, 11133, 6112, 288, 340, 3376, 22889, 26, 355, 1995, 298, 18297, 2222, 13, 929, 26, 298, 435, 1174, 33, 2501, 4964, 435, 3886, 3289, 4335, 288, 1980, 398, 1174, 985, 275, 1174, 14, 354, 267, 702, 1174, 985, 315, 14492, 9606, 21429, 267, 340, 14492, 440, 315, 14492, 9606, 21429, 59, 929, 985, 2189, 288, 862, 26, 355, 14492, 5665, 275, 14753, 14, 1462, 14, 362, 8, 354, 29, 3690, 12, 1174, 29, 929, 9, 355, 14492, 5665, 14, 1807, 342, 288, 871, 14753, 14, 7400, 26, 355, 986, 288, 1980, 327, 14492, 12060, 5084, 1748, 31824, 8765, 267, 587, 26, 288, 16423, 275, 14492, 9606, 21429, 59, 929, 985, 1527, 3690, 61, 398, 340, 5325, 1385, 26, 288, 862, 26, 355, 14492, 5665, 275, 14753, 14, 1462, 14, 362, 8, 354, 29, 3690, 12, 1174, 29, 929, 9, 355, 340, 14492, 5665, 14, 16652, 1304, 1137, 8870, 2706, 1304, 503, 14492, 5665, 14, 16003, 1137, 16423, 26, 490, 14492, 5665, 14, 16652, 1304, 275, 8870, 2706, 1304, 490, 14492, 5665, 14, 16003, 275, 16423, 490, 14492, 5665, 14, 2117, 342, 355, 1980, 288, 871, 14753, 14, 7400, 26, 355, 327, 1448, 1781, 370, 1218, 355, 986, 398, 14753, 14, 1462, 14, 981, 8, 354, 29, 3690, 12, 1169, 1174, 29, 929, 12, 1169, 8870, 2706, 1304, 29, 16652, 1304, 12, 1169, 16423, 29, 16003, 9, 199, 199, 318, 1678, 35, 12107, 3007, 5639, 1451, 8, 3690, 9606, 21429, 304, 272, 367, 671, 315, 13904, 35, 12107, 8, 3690, 9606, 21429, 12, 5325, 1385, 29, 549, 12, 3376, 22889, 29 ]
[ 747, 199, 646, 4145, 199, 646, 2455, 2464, 2750, 14, 3690, 1378, 38, 66, 3034, 465, 14492, 1378, 38, 66, 3034, 199, 646, 2455, 2464, 2750, 14, 929, 1378, 38, 66, 3034, 465, 1174, 1378, 38, 66, 3034, 199, 504, 1275, 992, 492, 2235, 369, 12, 14753, 12, 8511, 12, 428, 287, 707, 12, 445, 951, 753, 1114, 12, 18684, 1296, 199, 504, 1275, 362, 9606, 21429, 492, 664, 17024, 2223, 9606, 21429, 199, 199, 318, 13904, 1262, 1417, 8, 7522, 1685, 12, 17135, 11188, 304, 272, 408, 17415, 315, 17135, 11188, 3140, 402, 1808, 314, 2235, 369, 14, 1462, 14, 452, 342, 880, 652, 267, 883, 664, 314, 3211, 5822, 687, 376, 315, 13, 5734, 8367, 340, 4346, 14, 408, 272, 1967, 1262, 1417, 275, 822, 8, 7522, 11188, 14, 452, 1012, 272, 340, 822, 8, 7522, 11188, 14, 452, 1012, 1137, 378, 26, 267, 702, 1967, 1262, 1417, 508, 650, 267, 372, 339, 17135, 11188, 14, 9377, 63, 981, 779, 267, 17135, 1685, 8, 354, 628, 497, 3455, 290, 401, 221, 2236, 66, 4964, 628, 50, 401, 14510, 6850, 628, 497, 3455, 290, 1288, 267, 17135, 1685, 8, 354, 628, 21493, 1556, 292, 401, 259, 2236, 66, 4964, 628, 36, 401, 14510, 6850, 628, 21493, 67, 19826, 1288, 267, 17135, 1685, 8, 354, 628, 607, 7106, 401, 2236, 66, 4964, 628, 998, 401, 14510, 6850, 628, 607, 7106, 531, 272, 4794, 199, 199, 318, 13904, 18010, 8, 929, 9606, 21429, 304, 272, 408, 31731, 314, 769, 402, 6363, 436, 3932, 8870, 2706, 9479, 408, 272, 327, 2104, 3063, 12, 7078, 8970, 272, 1967, 18010, 275, 822, 8, 2223, 14, 1462, 14, 452, 1012, 272, 340, 822, 8, 2223, 14, 1462, 14, 452, 1012, 1137, 378, 26, 267, 702, 1967, 18010, 508, 5238, 267, 372, 339, 367, 1004, 315, 1174, 1378, 38, 66, 3034, 14, 4745, 26, 267, 2236, 66, 4964, 275, 1004, 59, 16, 61, 267, 536, 275, 1004, 59, 17, 61, 267, 8870, 2706, 1304, 275, 1004, 59, 18, 61, 267, 16423, 275, 1174, 9606, 21429, 59, 354, 61, 398, 8511, 14, 1462, 14, 981, 8, 354, 29, 354, 12, 2490, 2236, 66, 4964, 29, 31349, 12, 2490, 8870, 2706, 1304, 29, 16652, 1304, 12, 2490, 16423, 29, 16003, 9, 199, 199, 318, 1050, 31824, 1378, 18010, 8, 929, 9606, 21429, 304, 272, 408, 2104, 8367, 12, 4750, 12060, 12, 10617, 11703, 370, 1678, 1380, 781, 664, 267, 15666, 666, 31, 408, 272, 367, 1174, 315, 1174, 9606, 21429, 26, 267, 340, 1174, 508, 298, 36, 5230, 319, 402, 3626, 4295, 4674, 582, 1980, 267, 1174, 5665, 275, 8511, 14, 1462, 14, 362, 8, 354, 29, 929, 9, 267, 1174, 5665, 14, 16003, 275, 1174, 9606, 21429, 59, 929, 61, 267, 1174, 5665, 14, 2117, 342, 199, 199, 318, 13904, 35, 12107, 8, 3690, 9606, 21429, 12, 5325, 1385, 29, 797, 12, 3376, 22889, 275, 756, 304, 272, 408, 31731, 314, 769, 402, 286, 12107, 436, 3932, 8870, 2706, 9479, 14, 267, 520, 635, 5325, 1385, 26, 12823, 1218, 1263, 892, 286, 12107, 440, 315, 314, 3050, 12, 288, 436, 1678, 1263, 8870, 2706, 9479, 436, 4560, 21429, 402, 3411, 286, 12107, 14, 288, 12823, 440, 3145, 286, 12107, 12, 267, 520, 635, 3376, 22889, 26, 4005, 1806, 4352, 14737, 745, 85, 25870, 12, 911, 1995, 288, 6696, 3326, 14, 339, 408, 272, 327, 2104, 3063, 12, 7078, 8970, 272, 1967, 35, 12107, 275, 822, 8, 17024, 14, 1462, 14, 452, 1012, 272, 340, 440, 5325, 1385, 436, 822, 8, 17024, 14, 1462, 14, 452, 1012, 1137, 378, 26, 267, 327, 16740, 1104, 370, 1852, 3238, 652, 9980, 1133, 12420, 641, 282, 4136, 1255, 267, 702, 1967, 35, 12107, 690, 6155, 1493, 267, 372, 339, 340, 3376, 22889, 26, 267, 1995, 298, 5595, 1835, 5235, 21455, 3289, 4335, 339, 340, 3376, 22889, 26, 267, 1995, 298, 19908, 5235, 14, 20157, 21455, 3289, 4335, 339, 367, 284, 12, 1004, 315, 3874, 8, 3690, 1378, 38, 66, 3034, 14, 4745, 304, 267, 14492, 275, 1004, 59, 16, 61, 267, 1174, 33, 2501, 4964, 275, 1004, 59, 17, 61, 267, 8870, 2706, 1304, 275, 1004, 59, 18, 61, 398, 340, 3376, 22889, 436, 334, 73, 11, 17, 9, 450, 2948, 508, 378, 26, 288, 1995, 2071, 68, 3149, 68, 28, 3289, 4335, 450, 334, 73, 11, 17, 12, 822, 8, 3690, 1378, 38, 66, 3034, 14, 4745, 430, 398, 862, 26, 288, 1174, 275, 8511, 14, 1462, 14, 362, 8, 31349, 29, 929, 33, 2501, 4964, 9, 267, 871, 8511, 14, 7400, 26, 288, 327, 510, 14262, 475, 820, 12802, 1253, 1163, 2044, 11133, 6112, 288, 340, 3376, 22889, 26, 355, 1995, 298, 18297, 2222, 13, 929, 26, 298, 435, 1174, 33, 2501, 4964, 435, 3886, 3289, 4335, 288, 1980, 398, 1174, 985, 275, 1174, 14, 354, 267, 702, 1174, 985, 315, 14492, 9606, 21429, 267, 340, 14492, 440, 315, 14492, 9606, 21429, 59, 929, 985, 2189, 288, 862, 26, 355, 14492, 5665, 275, 14753, 14, 1462, 14, 362, 8, 354, 29, 3690, 12, 1174, 29, 929, 9, 355, 14492, 5665, 14, 1807, 342, 288, 871, 14753, 14, 7400, 26, 355, 986, 288, 1980, 327, 14492, 12060, 5084, 1748, 31824, 8765, 267, 587, 26, 288, 16423, 275, 14492, 9606, 21429, 59, 929, 985, 1527, 3690, 61, 398, 340, 5325, 1385, 26, 288, 862, 26, 355, 14492, 5665, 275, 14753, 14, 1462, 14, 362, 8, 354, 29, 3690, 12, 1174, 29, 929, 9, 355, 340, 14492, 5665, 14, 16652, 1304, 1137, 8870, 2706, 1304, 503, 14492, 5665, 14, 16003, 1137, 16423, 26, 490, 14492, 5665, 14, 16652, 1304, 275, 8870, 2706, 1304, 490, 14492, 5665, 14, 16003, 275, 16423, 490, 14492, 5665, 14, 2117, 342, 355, 1980, 288, 871, 14753, 14, 7400, 26, 355, 327, 1448, 1781, 370, 1218, 355, 986, 398, 14753, 14, 1462, 14, 981, 8, 354, 29, 3690, 12, 1169, 1174, 29, 929, 12, 1169, 8870, 2706, 1304, 29, 16652, 1304, 12, 1169, 16423, 29, 16003, 9, 199, 199, 318, 1678, 35, 12107, 3007, 5639, 1451, 8, 3690, 9606, 21429, 304, 272, 367, 671, 315, 13904, 35, 12107, 8, 3690, 9606, 21429, 12, 5325, 1385, 29, 549, 12, 3376, 22889, 29, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chinmaygarde/mojo
sky/engine/bindings/scripts/v8_globals.py
73
1645
# Copyright (C) 2013 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Module to share global variables (includes and interfaces) across modules.""" includes = set() interfaces = {}
bsd-3-clause
[ 3, 1898, 334, 35, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2377, 370, 8663, 2288, 2860, 334, 9441, 436, 8386, 9, 9371, 4621, 1041, 199, 199, 9441, 275, 663, 342, 199, 7436, 275, 1052, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2377, 370, 8663, 2288, 2860, 334, 9441, 436, 8386, 9, 9371, 4621, 1041, 199, 199, 9441, 275, 663, 342, 199, 7436, 275, 1052, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
twz915/django
tests/cache/tests.py
1
91820
# Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. import copy import io import os import pickle import re import shutil import tempfile import threading import time import unittest import warnings from unittest import mock from django.conf import settings from django.core import management, signals from django.core.cache import ( DEFAULT_CACHE_ALIAS, CacheKeyWarning, cache, caches, ) from django.core.cache.utils import make_template_fragment_key from django.db import close_old_connections, connection, connections from django.http import ( HttpRequest, HttpResponse, HttpResponseNotModified, StreamingHttpResponse, ) from django.middleware.cache import ( CacheMiddleware, FetchFromCacheMiddleware, UpdateCacheMiddleware, ) from django.middleware.csrf import CsrfViewMiddleware from django.template import engines from django.template.context_processors import csrf from django.template.response import TemplateResponse from django.test import ( RequestFactory, SimpleTestCase, TestCase, TransactionTestCase, ignore_warnings, override_settings, ) from django.test.signals import setting_changed from django.utils import timezone, translation from django.utils.cache import ( get_cache_key, learn_cache_key, patch_cache_control, patch_response_headers, patch_vary_headers, ) from django.utils.deprecation import RemovedInDjango21Warning from django.utils.encoding import force_text from django.views.decorators.cache import cache_page from .models import Poll, expensive_calculation # functions/classes for complex data type tests def f(): return 42 class C: def m(n): return 24 class Unpicklable: def __getstate__(self): raise pickle.PickleError() @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } }) class DummyCacheTests(SimpleTestCase): # The Dummy cache backend doesn't really behave like a test backend, # so it has its own test case. def test_simple(self): "Dummy cache backend ignores cache set calls" cache.set("key", "value") self.assertIsNone(cache.get("key")) def test_add(self): "Add doesn't do anything in dummy cache backend" cache.add("addkey1", "value") result = cache.add("addkey1", "newvalue") self.assertTrue(result) self.assertIsNone(cache.get("addkey1")) def test_non_existent(self): "Non-existent keys aren't found in the dummy cache backend" self.assertIsNone(cache.get("does_not_exist")) self.assertEqual(cache.get("does_not_exist", "bang!"), "bang!") def test_get_many(self): "get_many returns nothing for the dummy cache backend" cache.set('a', 'a') cache.set('b', 'b') cache.set('c', 'c') cache.set('d', 'd') self.assertEqual(cache.get_many(['a', 'c', 'd']), {}) self.assertEqual(cache.get_many(['a', 'b', 'e']), {}) def test_delete(self): "Cache deletion is transparently ignored on the dummy cache backend" cache.set("key1", "spam") cache.set("key2", "eggs") self.assertIsNone(cache.get("key1")) cache.delete("key1") self.assertIsNone(cache.get("key1")) self.assertIsNone(cache.get("key2")) def test_has_key(self): "The has_key method doesn't ever return True for the dummy cache backend" cache.set("hello1", "goodbye1") self.assertFalse(cache.has_key("hello1")) self.assertFalse(cache.has_key("goodbye1")) def test_in(self): "The in operator doesn't ever return True for the dummy cache backend" cache.set("hello2", "goodbye2") self.assertNotIn("hello2", cache) self.assertNotIn("goodbye2", cache) def test_incr(self): "Dummy cache values can't be incremented" cache.set('answer', 42) with self.assertRaises(ValueError): cache.incr('answer') with self.assertRaises(ValueError): cache.incr('does_not_exist') def test_decr(self): "Dummy cache values can't be decremented" cache.set('answer', 42) with self.assertRaises(ValueError): cache.decr('answer') with self.assertRaises(ValueError): cache.decr('does_not_exist') def test_data_types(self): "All data types are ignored equally by the dummy cache" stuff = { 'string': 'this is a string', 'int': 42, 'list': [1, 2, 3, 4], 'tuple': (1, 2, 3, 4), 'dict': {'A': 1, 'B': 2}, 'function': f, 'class': C, } cache.set("stuff", stuff) self.assertIsNone(cache.get("stuff")) def test_expiration(self): "Expiration has no effect on the dummy cache" cache.set('expire1', 'very quickly', 1) cache.set('expire2', 'very quickly', 1) cache.set('expire3', 'very quickly', 1) time.sleep(2) self.assertIsNone(cache.get("expire1")) cache.add("expire2", "newvalue") self.assertIsNone(cache.get("expire2")) self.assertFalse(cache.has_key("expire3")) def test_unicode(self): "Unicode values are ignored by the dummy cache" stuff = { 'ascii': 'ascii_value', 'unicode_ascii': 'Iñtërnâtiônàlizætiøn1', 'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2', 'ascii2': {'x': 1} } for (key, value) in stuff.items(): cache.set(key, value) self.assertIsNone(cache.get(key)) def test_set_many(self): "set_many does nothing for the dummy cache backend" cache.set_many({'a': 1, 'b': 2}) cache.set_many({'a': 1, 'b': 2}, timeout=2, version='1') def test_delete_many(self): "delete_many does nothing for the dummy cache backend" cache.delete_many(['a', 'b']) def test_clear(self): "clear does nothing for the dummy cache backend" cache.clear() def test_incr_version(self): "Dummy cache versions can't be incremented" cache.set('answer', 42) with self.assertRaises(ValueError): cache.incr_version('answer') with self.assertRaises(ValueError): cache.incr_version('does_not_exist') def test_decr_version(self): "Dummy cache versions can't be decremented" cache.set('answer', 42) with self.assertRaises(ValueError): cache.decr_version('answer') with self.assertRaises(ValueError): cache.decr_version('does_not_exist') def test_get_or_set(self): self.assertEqual(cache.get_or_set('mykey', 'default'), 'default') self.assertEqual(cache.get_or_set('mykey', None), None) def test_get_or_set_callable(self): def my_callable(): return 'default' self.assertEqual(cache.get_or_set('mykey', my_callable), 'default') self.assertEqual(cache.get_or_set('mykey', my_callable()), 'default') def custom_key_func(key, key_prefix, version): "A customized cache key function" return 'CUSTOM-' + '-'.join([key_prefix, str(version), key]) _caches_setting_base = { 'default': {}, 'prefix': {'KEY_PREFIX': 'cacheprefix{}'.format(os.getpid())}, 'v2': {'VERSION': 2}, 'custom_key': {'KEY_FUNCTION': custom_key_func}, 'custom_key2': {'KEY_FUNCTION': 'cache.tests.custom_key_func'}, 'cull': {'OPTIONS': {'MAX_ENTRIES': 30}}, 'zero_cull': {'OPTIONS': {'CULL_FREQUENCY': 0, 'MAX_ENTRIES': 30}}, } def caches_setting_for_tests(base=None, exclude=None, **params): # `base` is used to pull in the memcached config from the original settings, # `exclude` is a set of cache names denoting which `_caches_setting_base` keys # should be omitted. # `params` are test specific overrides and `_caches_settings_base` is the # base config for the tests. # This results in the following search order: # params -> _caches_setting_base -> base base = base or {} exclude = exclude or set() setting = {k: base.copy() for k in _caches_setting_base.keys() if k not in exclude} for key, cache_params in setting.items(): cache_params.update(_caches_setting_base[key]) cache_params.update(params) return setting class BaseCacheTests: # A common set of tests to apply to all cache backends def setUp(self): self.factory = RequestFactory() def tearDown(self): cache.clear() def test_simple(self): # Simple cache set/get works cache.set("key", "value") self.assertEqual(cache.get("key"), "value") def test_add(self): # A key can be added to a cache cache.add("addkey1", "value") result = cache.add("addkey1", "newvalue") self.assertFalse(result) self.assertEqual(cache.get("addkey1"), "value") def test_prefix(self): # Test for same cache key conflicts between shared backend cache.set('somekey', 'value') # should not be set in the prefixed cache self.assertFalse(caches['prefix'].has_key('somekey')) caches['prefix'].set('somekey', 'value2') self.assertEqual(cache.get('somekey'), 'value') self.assertEqual(caches['prefix'].get('somekey'), 'value2') def test_non_existent(self): # Non-existent cache keys return as None/default # get with non-existent keys self.assertIsNone(cache.get("does_not_exist")) self.assertEqual(cache.get("does_not_exist", "bang!"), "bang!") def test_get_many(self): # Multiple cache keys can be returned using get_many cache.set('a', 'a') cache.set('b', 'b') cache.set('c', 'c') cache.set('d', 'd') self.assertDictEqual(cache.get_many(['a', 'c', 'd']), {'a': 'a', 'c': 'c', 'd': 'd'}) self.assertDictEqual(cache.get_many(['a', 'b', 'e']), {'a': 'a', 'b': 'b'}) def test_delete(self): # Cache keys can be deleted cache.set("key1", "spam") cache.set("key2", "eggs") self.assertEqual(cache.get("key1"), "spam") cache.delete("key1") self.assertIsNone(cache.get("key1")) self.assertEqual(cache.get("key2"), "eggs") def test_has_key(self): # The cache can be inspected for cache keys cache.set("hello1", "goodbye1") self.assertTrue(cache.has_key("hello1")) self.assertFalse(cache.has_key("goodbye1")) cache.set("no_expiry", "here", None) self.assertTrue(cache.has_key("no_expiry")) def test_in(self): # The in operator can be used to inspect cache contents cache.set("hello2", "goodbye2") self.assertIn("hello2", cache) self.assertNotIn("goodbye2", cache) def test_incr(self): # Cache values can be incremented cache.set('answer', 41) self.assertEqual(cache.incr('answer'), 42) self.assertEqual(cache.get('answer'), 42) self.assertEqual(cache.incr('answer', 10), 52) self.assertEqual(cache.get('answer'), 52) self.assertEqual(cache.incr('answer', -10), 42) with self.assertRaises(ValueError): cache.incr('does_not_exist') def test_decr(self): # Cache values can be decremented cache.set('answer', 43) self.assertEqual(cache.decr('answer'), 42) self.assertEqual(cache.get('answer'), 42) self.assertEqual(cache.decr('answer', 10), 32) self.assertEqual(cache.get('answer'), 32) self.assertEqual(cache.decr('answer', -10), 42) with self.assertRaises(ValueError): cache.decr('does_not_exist') def test_close(self): self.assertTrue(hasattr(cache, 'close')) cache.close() def test_data_types(self): # Many different data types can be cached stuff = { 'string': 'this is a string', 'int': 42, 'list': [1, 2, 3, 4], 'tuple': (1, 2, 3, 4), 'dict': {'A': 1, 'B': 2}, 'function': f, 'class': C, } cache.set("stuff", stuff) self.assertEqual(cache.get("stuff"), stuff) def test_cache_read_for_model_instance(self): # Don't want fields with callable as default to be called on cache read expensive_calculation.num_runs = 0 Poll.objects.all().delete() my_poll = Poll.objects.create(question="Well?") self.assertEqual(Poll.objects.count(), 1) pub_date = my_poll.pub_date cache.set('question', my_poll) cached_poll = cache.get('question') self.assertEqual(cached_poll.pub_date, pub_date) # We only want the default expensive calculation run once self.assertEqual(expensive_calculation.num_runs, 1) def test_cache_write_for_model_instance_with_deferred(self): # Don't want fields with callable as default to be called on cache write expensive_calculation.num_runs = 0 Poll.objects.all().delete() Poll.objects.create(question="What?") self.assertEqual(expensive_calculation.num_runs, 1) defer_qs = Poll.objects.all().defer('question') self.assertEqual(defer_qs.count(), 1) self.assertEqual(expensive_calculation.num_runs, 1) cache.set('deferred_queryset', defer_qs) # cache set should not re-evaluate default functions self.assertEqual(expensive_calculation.num_runs, 1) def test_cache_read_for_model_instance_with_deferred(self): # Don't want fields with callable as default to be called on cache read expensive_calculation.num_runs = 0 Poll.objects.all().delete() Poll.objects.create(question="What?") self.assertEqual(expensive_calculation.num_runs, 1) defer_qs = Poll.objects.all().defer('question') self.assertEqual(defer_qs.count(), 1) cache.set('deferred_queryset', defer_qs) self.assertEqual(expensive_calculation.num_runs, 1) runs_before_cache_read = expensive_calculation.num_runs cache.get('deferred_queryset') # We only want the default expensive calculation run on creation and set self.assertEqual(expensive_calculation.num_runs, runs_before_cache_read) def test_expiration(self): # Cache values can be set to expire cache.set('expire1', 'very quickly', 1) cache.set('expire2', 'very quickly', 1) cache.set('expire3', 'very quickly', 1) time.sleep(2) self.assertIsNone(cache.get("expire1")) cache.add("expire2", "newvalue") self.assertEqual(cache.get("expire2"), "newvalue") self.assertFalse(cache.has_key("expire3")) def test_unicode(self): # Unicode values can be cached stuff = { 'ascii': 'ascii_value', 'unicode_ascii': 'Iñtërnâtiônàlizætiøn1', 'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2', 'ascii2': {'x': 1} } # Test `set` for (key, value) in stuff.items(): cache.set(key, value) self.assertEqual(cache.get(key), value) # Test `add` for (key, value) in stuff.items(): cache.delete(key) cache.add(key, value) self.assertEqual(cache.get(key), value) # Test `set_many` for (key, value) in stuff.items(): cache.delete(key) cache.set_many(stuff) for (key, value) in stuff.items(): self.assertEqual(cache.get(key), value) def test_binary_string(self): # Binary strings should be cacheable from zlib import compress, decompress value = 'value_to_be_compressed' compressed_value = compress(value.encode()) # Test set cache.set('binary1', compressed_value) compressed_result = cache.get('binary1') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result).decode()) # Test add cache.add('binary1-add', compressed_value) compressed_result = cache.get('binary1-add') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result).decode()) # Test set_many cache.set_many({'binary1-set_many': compressed_value}) compressed_result = cache.get('binary1-set_many') self.assertEqual(compressed_value, compressed_result) self.assertEqual(value, decompress(compressed_result).decode()) def test_set_many(self): # Multiple keys can be set using set_many cache.set_many({"key1": "spam", "key2": "eggs"}) self.assertEqual(cache.get("key1"), "spam") self.assertEqual(cache.get("key2"), "eggs") def test_set_many_expiration(self): # set_many takes a second ``timeout`` parameter cache.set_many({"key1": "spam", "key2": "eggs"}, 1) time.sleep(2) self.assertIsNone(cache.get("key1")) self.assertIsNone(cache.get("key2")) def test_delete_many(self): # Multiple keys can be deleted using delete_many cache.set("key1", "spam") cache.set("key2", "eggs") cache.set("key3", "ham") cache.delete_many(["key1", "key2"]) self.assertIsNone(cache.get("key1")) self.assertIsNone(cache.get("key2")) self.assertEqual(cache.get("key3"), "ham") def test_clear(self): # The cache can be emptied using clear cache.set("key1", "spam") cache.set("key2", "eggs") cache.clear() self.assertIsNone(cache.get("key1")) self.assertIsNone(cache.get("key2")) def test_long_timeout(self): """ Followe memcached's convention where a timeout greater than 30 days is treated as an absolute expiration timestamp instead of a relative offset (#12399). """ cache.set('key1', 'eggs', 60 * 60 * 24 * 30 + 1) # 30 days + 1 second self.assertEqual(cache.get('key1'), 'eggs') cache.add('key2', 'ham', 60 * 60 * 24 * 30 + 1) self.assertEqual(cache.get('key2'), 'ham') cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 60 * 60 * 24 * 30 + 1) self.assertEqual(cache.get('key3'), 'sausage') self.assertEqual(cache.get('key4'), 'lobster bisque') def test_forever_timeout(self): """ Passing in None into timeout results in a value that is cached forever """ cache.set('key1', 'eggs', None) self.assertEqual(cache.get('key1'), 'eggs') cache.add('key2', 'ham', None) self.assertEqual(cache.get('key2'), 'ham') added = cache.add('key1', 'new eggs', None) self.assertIs(added, False) self.assertEqual(cache.get('key1'), 'eggs') cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, None) self.assertEqual(cache.get('key3'), 'sausage') self.assertEqual(cache.get('key4'), 'lobster bisque') def test_zero_timeout(self): """ Passing in zero into timeout results in a value that is not cached """ cache.set('key1', 'eggs', 0) self.assertIsNone(cache.get('key1')) cache.add('key2', 'ham', 0) self.assertIsNone(cache.get('key2')) cache.set_many({'key3': 'sausage', 'key4': 'lobster bisque'}, 0) self.assertIsNone(cache.get('key3')) self.assertIsNone(cache.get('key4')) def test_float_timeout(self): # Make sure a timeout given as a float doesn't crash anything. cache.set("key1", "spam", 100.2) self.assertEqual(cache.get("key1"), "spam") def _perform_cull_test(self, cull_cache, initial_count, final_count): # Create initial cache key entries. This will overflow the cache, # causing a cull. for i in range(1, initial_count): cull_cache.set('cull%d' % i, 'value', 1000) count = 0 # Count how many keys are left in the cache. for i in range(1, initial_count): if cull_cache.has_key('cull%d' % i): count += 1 self.assertEqual(count, final_count) def test_cull(self): self._perform_cull_test(caches['cull'], 50, 29) def test_zero_cull(self): self._perform_cull_test(caches['zero_cull'], 50, 19) def _perform_invalid_key_test(self, key, expected_warning): """ All the builtin backends (except memcached, see below) should warn on keys that would be refused by memcached. This encourages portable caching code without making it too difficult to use production backends with more liberal key rules. Refs #6447. """ # mimic custom ``make_key`` method being defined since the default will # never show the below warnings def func(key, *args): return key old_func = cache.key_func cache.key_func = func try: with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") cache.set(key, 'value') self.assertEqual(len(w), 1) self.assertIsInstance(w[0].message, CacheKeyWarning) self.assertEqual(str(w[0].message.args[0]), expected_warning) finally: cache.key_func = old_func def test_invalid_key_characters(self): # memcached doesn't allow whitespace or control characters in keys. key = 'key with spaces and 清' expected_warning = ( "Cache key contains characters that will cause errors if used " "with memcached: %r" % key ) self._perform_invalid_key_test(key, expected_warning) def test_invalid_key_length(self): # memcached limits key length to 250. key = ('a' * 250) + '清' expected_warning = ( 'Cache key will cause errors if used with memcached: ' '%r (longer than %s)' % (key, 250) ) self._perform_invalid_key_test(key, expected_warning) def test_cache_versioning_get_set(self): # set, using default version = 1 cache.set('answer1', 42) self.assertEqual(cache.get('answer1'), 42) self.assertEqual(cache.get('answer1', version=1), 42) self.assertIsNone(cache.get('answer1', version=2)) self.assertIsNone(caches['v2'].get('answer1')) self.assertEqual(caches['v2'].get('answer1', version=1), 42) self.assertIsNone(caches['v2'].get('answer1', version=2)) # set, default version = 1, but manually override version = 2 cache.set('answer2', 42, version=2) self.assertIsNone(cache.get('answer2')) self.assertIsNone(cache.get('answer2', version=1)) self.assertEqual(cache.get('answer2', version=2), 42) self.assertEqual(caches['v2'].get('answer2'), 42) self.assertIsNone(caches['v2'].get('answer2', version=1)) self.assertEqual(caches['v2'].get('answer2', version=2), 42) # v2 set, using default version = 2 caches['v2'].set('answer3', 42) self.assertIsNone(cache.get('answer3')) self.assertIsNone(cache.get('answer3', version=1)) self.assertEqual(cache.get('answer3', version=2), 42) self.assertEqual(caches['v2'].get('answer3'), 42) self.assertIsNone(caches['v2'].get('answer3', version=1)) self.assertEqual(caches['v2'].get('answer3', version=2), 42) # v2 set, default version = 2, but manually override version = 1 caches['v2'].set('answer4', 42, version=1) self.assertEqual(cache.get('answer4'), 42) self.assertEqual(cache.get('answer4', version=1), 42) self.assertIsNone(cache.get('answer4', version=2)) self.assertIsNone(caches['v2'].get('answer4')) self.assertEqual(caches['v2'].get('answer4', version=1), 42) self.assertIsNone(caches['v2'].get('answer4', version=2)) def test_cache_versioning_add(self): # add, default version = 1, but manually override version = 2 cache.add('answer1', 42, version=2) self.assertIsNone(cache.get('answer1', version=1)) self.assertEqual(cache.get('answer1', version=2), 42) cache.add('answer1', 37, version=2) self.assertIsNone(cache.get('answer1', version=1)) self.assertEqual(cache.get('answer1', version=2), 42) cache.add('answer1', 37, version=1) self.assertEqual(cache.get('answer1', version=1), 37) self.assertEqual(cache.get('answer1', version=2), 42) # v2 add, using default version = 2 caches['v2'].add('answer2', 42) self.assertIsNone(cache.get('answer2', version=1)) self.assertEqual(cache.get('answer2', version=2), 42) caches['v2'].add('answer2', 37) self.assertIsNone(cache.get('answer2', version=1)) self.assertEqual(cache.get('answer2', version=2), 42) caches['v2'].add('answer2', 37, version=1) self.assertEqual(cache.get('answer2', version=1), 37) self.assertEqual(cache.get('answer2', version=2), 42) # v2 add, default version = 2, but manually override version = 1 caches['v2'].add('answer3', 42, version=1) self.assertEqual(cache.get('answer3', version=1), 42) self.assertIsNone(cache.get('answer3', version=2)) caches['v2'].add('answer3', 37, version=1) self.assertEqual(cache.get('answer3', version=1), 42) self.assertIsNone(cache.get('answer3', version=2)) caches['v2'].add('answer3', 37) self.assertEqual(cache.get('answer3', version=1), 42) self.assertEqual(cache.get('answer3', version=2), 37) def test_cache_versioning_has_key(self): cache.set('answer1', 42) # has_key self.assertTrue(cache.has_key('answer1')) self.assertTrue(cache.has_key('answer1', version=1)) self.assertFalse(cache.has_key('answer1', version=2)) self.assertFalse(caches['v2'].has_key('answer1')) self.assertTrue(caches['v2'].has_key('answer1', version=1)) self.assertFalse(caches['v2'].has_key('answer1', version=2)) def test_cache_versioning_delete(self): cache.set('answer1', 37, version=1) cache.set('answer1', 42, version=2) cache.delete('answer1') self.assertIsNone(cache.get('answer1', version=1)) self.assertEqual(cache.get('answer1', version=2), 42) cache.set('answer2', 37, version=1) cache.set('answer2', 42, version=2) cache.delete('answer2', version=2) self.assertEqual(cache.get('answer2', version=1), 37) self.assertIsNone(cache.get('answer2', version=2)) cache.set('answer3', 37, version=1) cache.set('answer3', 42, version=2) caches['v2'].delete('answer3') self.assertEqual(cache.get('answer3', version=1), 37) self.assertIsNone(cache.get('answer3', version=2)) cache.set('answer4', 37, version=1) cache.set('answer4', 42, version=2) caches['v2'].delete('answer4', version=1) self.assertIsNone(cache.get('answer4', version=1)) self.assertEqual(cache.get('answer4', version=2), 42) def test_cache_versioning_incr_decr(self): cache.set('answer1', 37, version=1) cache.set('answer1', 42, version=2) cache.incr('answer1') self.assertEqual(cache.get('answer1', version=1), 38) self.assertEqual(cache.get('answer1', version=2), 42) cache.decr('answer1') self.assertEqual(cache.get('answer1', version=1), 37) self.assertEqual(cache.get('answer1', version=2), 42) cache.set('answer2', 37, version=1) cache.set('answer2', 42, version=2) cache.incr('answer2', version=2) self.assertEqual(cache.get('answer2', version=1), 37) self.assertEqual(cache.get('answer2', version=2), 43) cache.decr('answer2', version=2) self.assertEqual(cache.get('answer2', version=1), 37) self.assertEqual(cache.get('answer2', version=2), 42) cache.set('answer3', 37, version=1) cache.set('answer3', 42, version=2) caches['v2'].incr('answer3') self.assertEqual(cache.get('answer3', version=1), 37) self.assertEqual(cache.get('answer3', version=2), 43) caches['v2'].decr('answer3') self.assertEqual(cache.get('answer3', version=1), 37) self.assertEqual(cache.get('answer3', version=2), 42) cache.set('answer4', 37, version=1) cache.set('answer4', 42, version=2) caches['v2'].incr('answer4', version=1) self.assertEqual(cache.get('answer4', version=1), 38) self.assertEqual(cache.get('answer4', version=2), 42) caches['v2'].decr('answer4', version=1) self.assertEqual(cache.get('answer4', version=1), 37) self.assertEqual(cache.get('answer4', version=2), 42) def test_cache_versioning_get_set_many(self): # set, using default version = 1 cache.set_many({'ford1': 37, 'arthur1': 42}) self.assertDictEqual(cache.get_many(['ford1', 'arthur1']), {'ford1': 37, 'arthur1': 42}) self.assertDictEqual(cache.get_many(['ford1', 'arthur1'], version=1), {'ford1': 37, 'arthur1': 42}) self.assertDictEqual(cache.get_many(['ford1', 'arthur1'], version=2), {}) self.assertDictEqual(caches['v2'].get_many(['ford1', 'arthur1']), {}) self.assertDictEqual(caches['v2'].get_many(['ford1', 'arthur1'], version=1), {'ford1': 37, 'arthur1': 42}) self.assertDictEqual(caches['v2'].get_many(['ford1', 'arthur1'], version=2), {}) # set, default version = 1, but manually override version = 2 cache.set_many({'ford2': 37, 'arthur2': 42}, version=2) self.assertDictEqual(cache.get_many(['ford2', 'arthur2']), {}) self.assertDictEqual(cache.get_many(['ford2', 'arthur2'], version=1), {}) self.assertDictEqual(cache.get_many(['ford2', 'arthur2'], version=2), {'ford2': 37, 'arthur2': 42}) self.assertDictEqual(caches['v2'].get_many(['ford2', 'arthur2']), {'ford2': 37, 'arthur2': 42}) self.assertDictEqual(caches['v2'].get_many(['ford2', 'arthur2'], version=1), {}) self.assertDictEqual(caches['v2'].get_many(['ford2', 'arthur2'], version=2), {'ford2': 37, 'arthur2': 42}) # v2 set, using default version = 2 caches['v2'].set_many({'ford3': 37, 'arthur3': 42}) self.assertDictEqual(cache.get_many(['ford3', 'arthur3']), {}) self.assertDictEqual(cache.get_many(['ford3', 'arthur3'], version=1), {}) self.assertDictEqual(cache.get_many(['ford3', 'arthur3'], version=2), {'ford3': 37, 'arthur3': 42}) self.assertDictEqual(caches['v2'].get_many(['ford3', 'arthur3']), {'ford3': 37, 'arthur3': 42}) self.assertDictEqual(caches['v2'].get_many(['ford3', 'arthur3'], version=1), {}) self.assertDictEqual(caches['v2'].get_many(['ford3', 'arthur3'], version=2), {'ford3': 37, 'arthur3': 42}) # v2 set, default version = 2, but manually override version = 1 caches['v2'].set_many({'ford4': 37, 'arthur4': 42}, version=1) self.assertDictEqual(cache.get_many(['ford4', 'arthur4']), {'ford4': 37, 'arthur4': 42}) self.assertDictEqual(cache.get_many(['ford4', 'arthur4'], version=1), {'ford4': 37, 'arthur4': 42}) self.assertDictEqual(cache.get_many(['ford4', 'arthur4'], version=2), {}) self.assertDictEqual(caches['v2'].get_many(['ford4', 'arthur4']), {}) self.assertDictEqual(caches['v2'].get_many(['ford4', 'arthur4'], version=1), {'ford4': 37, 'arthur4': 42}) self.assertDictEqual(caches['v2'].get_many(['ford4', 'arthur4'], version=2), {}) def test_incr_version(self): cache.set('answer', 42, version=2) self.assertIsNone(cache.get('answer')) self.assertIsNone(cache.get('answer', version=1)) self.assertEqual(cache.get('answer', version=2), 42) self.assertIsNone(cache.get('answer', version=3)) self.assertEqual(cache.incr_version('answer', version=2), 3) self.assertIsNone(cache.get('answer')) self.assertIsNone(cache.get('answer', version=1)) self.assertIsNone(cache.get('answer', version=2)) self.assertEqual(cache.get('answer', version=3), 42) caches['v2'].set('answer2', 42) self.assertEqual(caches['v2'].get('answer2'), 42) self.assertIsNone(caches['v2'].get('answer2', version=1)) self.assertEqual(caches['v2'].get('answer2', version=2), 42) self.assertIsNone(caches['v2'].get('answer2', version=3)) self.assertEqual(caches['v2'].incr_version('answer2'), 3) self.assertIsNone(caches['v2'].get('answer2')) self.assertIsNone(caches['v2'].get('answer2', version=1)) self.assertIsNone(caches['v2'].get('answer2', version=2)) self.assertEqual(caches['v2'].get('answer2', version=3), 42) with self.assertRaises(ValueError): cache.incr_version('does_not_exist') def test_decr_version(self): cache.set('answer', 42, version=2) self.assertIsNone(cache.get('answer')) self.assertIsNone(cache.get('answer', version=1)) self.assertEqual(cache.get('answer', version=2), 42) self.assertEqual(cache.decr_version('answer', version=2), 1) self.assertEqual(cache.get('answer'), 42) self.assertEqual(cache.get('answer', version=1), 42) self.assertIsNone(cache.get('answer', version=2)) caches['v2'].set('answer2', 42) self.assertEqual(caches['v2'].get('answer2'), 42) self.assertIsNone(caches['v2'].get('answer2', version=1)) self.assertEqual(caches['v2'].get('answer2', version=2), 42) self.assertEqual(caches['v2'].decr_version('answer2'), 1) self.assertIsNone(caches['v2'].get('answer2')) self.assertEqual(caches['v2'].get('answer2', version=1), 42) self.assertIsNone(caches['v2'].get('answer2', version=2)) with self.assertRaises(ValueError): cache.decr_version('does_not_exist', version=2) def test_custom_key_func(self): # Two caches with different key functions aren't visible to each other cache.set('answer1', 42) self.assertEqual(cache.get('answer1'), 42) self.assertIsNone(caches['custom_key'].get('answer1')) self.assertIsNone(caches['custom_key2'].get('answer1')) caches['custom_key'].set('answer2', 42) self.assertIsNone(cache.get('answer2')) self.assertEqual(caches['custom_key'].get('answer2'), 42) self.assertEqual(caches['custom_key2'].get('answer2'), 42) def test_cache_write_unpicklable_object(self): update_middleware = UpdateCacheMiddleware() update_middleware.cache = cache fetch_middleware = FetchFromCacheMiddleware() fetch_middleware.cache = cache request = self.factory.get('/cache/test') request._cache_update_cache = True get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNone(get_cache_data) response = HttpResponse() content = 'Testing cookie serialization.' response.content = content response.set_cookie('foo', 'bar') update_middleware.process_response(request, response) get_cache_data = fetch_middleware.process_request(request) self.assertIsNotNone(get_cache_data) self.assertEqual(get_cache_data.content, content.encode('utf-8')) self.assertEqual(get_cache_data.cookies, response.cookies) update_middleware.process_response(request, get_cache_data) get_cache_data = fetch_middleware.process_request(request) self.assertIsNotNone(get_cache_data) self.assertEqual(get_cache_data.content, content.encode('utf-8')) self.assertEqual(get_cache_data.cookies, response.cookies) def test_add_fail_on_pickleerror(self): # Shouldn't fail silently if trying to cache an unpicklable type. with self.assertRaises(pickle.PickleError): cache.add('unpicklable', Unpicklable()) def test_set_fail_on_pickleerror(self): with self.assertRaises(pickle.PickleError): cache.set('unpicklable', Unpicklable()) def test_get_or_set(self): self.assertIsNone(cache.get('projector')) self.assertEqual(cache.get_or_set('projector', 42), 42) self.assertEqual(cache.get('projector'), 42) self.assertEqual(cache.get_or_set('null', None), None) def test_get_or_set_callable(self): def my_callable(): return 'value' self.assertEqual(cache.get_or_set('mykey', my_callable), 'value') self.assertEqual(cache.get_or_set('mykey', my_callable()), 'value') def test_get_or_set_version(self): msg = "get_or_set() missing 1 required positional argument: 'default'" cache.get_or_set('brian', 1979, version=2) with self.assertRaisesMessage(TypeError, msg): cache.get_or_set('brian') with self.assertRaisesMessage(TypeError, msg): cache.get_or_set('brian', version=1) self.assertIsNone(cache.get('brian', version=1)) self.assertEqual(cache.get_or_set('brian', 42, version=1), 42) self.assertEqual(cache.get_or_set('brian', 1979, version=2), 1979) self.assertIsNone(cache.get('brian', version=3)) def test_get_or_set_racing(self): with mock.patch('%s.%s' % (settings.CACHES['default']['BACKEND'], 'add')) as cache_add: # Simulate cache.add() failing to add a value. In that case, the # default value should be returned. cache_add.return_value = False self.assertEqual(cache.get_or_set('key', 'default'), 'default') @override_settings(CACHES=caches_setting_for_tests( BACKEND='django.core.cache.backends.db.DatabaseCache', # Spaces are used in the table name to ensure quoting/escaping is working LOCATION='test cache table' )) class DBCacheTests(BaseCacheTests, TransactionTestCase): available_apps = ['cache'] def setUp(self): # The super calls needs to happen first for the settings override. super(DBCacheTests, self).setUp() self.create_table() def tearDown(self): # The super call needs to happen first because it uses the database. super(DBCacheTests, self).tearDown() self.drop_table() def create_table(self): management.call_command('createcachetable', verbosity=0, interactive=False) def drop_table(self): with connection.cursor() as cursor: table_name = connection.ops.quote_name('test cache table') cursor.execute('DROP TABLE %s' % table_name) def test_zero_cull(self): self._perform_cull_test(caches['zero_cull'], 50, 18) def test_second_call_doesnt_crash(self): out = io.StringIO() management.call_command('createcachetable', stdout=out) self.assertEqual(out.getvalue(), "Cache table 'test cache table' already exists.\n" * len(settings.CACHES)) @override_settings(CACHES=caches_setting_for_tests( BACKEND='django.core.cache.backends.db.DatabaseCache', # Use another table name to avoid the 'table already exists' message. LOCATION='createcachetable_dry_run_mode' )) def test_createcachetable_dry_run_mode(self): out = io.StringIO() management.call_command('createcachetable', dry_run=True, stdout=out) output = out.getvalue() self.assertTrue(output.startswith("CREATE TABLE")) def test_createcachetable_with_table_argument(self): """ Delete and recreate cache table with legacy behavior (explicitly specifying the table name). """ self.drop_table() out = io.StringIO() management.call_command( 'createcachetable', 'test cache table', verbosity=2, stdout=out, ) self.assertEqual(out.getvalue(), "Cache table 'test cache table' created.\n") @override_settings(USE_TZ=True) class DBCacheWithTimeZoneTests(DBCacheTests): pass class DBCacheRouter: """A router that puts the cache table on the 'other' database.""" def db_for_read(self, model, **hints): if model._meta.app_label == 'django_cache': return 'other' return None def db_for_write(self, model, **hints): if model._meta.app_label == 'django_cache': return 'other' return None def allow_migrate(self, db, app_label, **hints): if app_label == 'django_cache': return db == 'other' return None @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'my_cache_table', }, }, ) class CreateCacheTableForDBCacheTests(TestCase): multi_db = True @override_settings(DATABASE_ROUTERS=[DBCacheRouter()]) def test_createcachetable_observes_database_router(self): # cache table should not be created on 'default' with self.assertNumQueries(0, using='default'): management.call_command('createcachetable', database='default', verbosity=0, interactive=False) # cache table should be created on 'other' # Queries: # 1: check table doesn't already exist # 2: create savepoint (if transactional DDL is supported) # 3: create the table # 4: create the index # 5: release savepoint (if transactional DDL is supported) num = 5 if connections['other'].features.can_rollback_ddl else 3 with self.assertNumQueries(num, using='other'): management.call_command('createcachetable', database='other', verbosity=0, interactive=False) class PicklingSideEffect: def __init__(self, cache): self.cache = cache self.locked = False def __getstate__(self): if self.cache._lock.active_writers: self.locked = True return {} @override_settings(CACHES=caches_setting_for_tests( BACKEND='django.core.cache.backends.locmem.LocMemCache', )) class LocMemCacheTests(BaseCacheTests, TestCase): def setUp(self): super(LocMemCacheTests, self).setUp() # LocMem requires a hack to make the other caches # share a data store with the 'normal' cache. caches['prefix']._cache = cache._cache caches['prefix']._expire_info = cache._expire_info caches['v2']._cache = cache._cache caches['v2']._expire_info = cache._expire_info caches['custom_key']._cache = cache._cache caches['custom_key']._expire_info = cache._expire_info caches['custom_key2']._cache = cache._cache caches['custom_key2']._expire_info = cache._expire_info @override_settings(CACHES={ 'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}, 'other': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'other' }, }) def test_multiple_caches(self): "Multiple locmem caches are isolated" cache.set('value', 42) self.assertEqual(caches['default'].get('value'), 42) self.assertIsNone(caches['other'].get('value')) def test_locking_on_pickle(self): """#20613/#18541 -- Ensures pickling is done outside of the lock.""" bad_obj = PicklingSideEffect(cache) cache.set('set', bad_obj) self.assertFalse(bad_obj.locked, "Cache was locked during pickling") cache.add('add', bad_obj) self.assertFalse(bad_obj.locked, "Cache was locked during pickling") def test_incr_decr_timeout(self): """incr/decr does not modify expiry time (matches memcached behavior)""" key = 'value' _key = cache.make_key(key) cache.set(key, 1, timeout=cache.default_timeout * 10) expire = cache._expire_info[_key] cache.incr(key) self.assertEqual(expire, cache._expire_info[_key]) cache.decr(key) self.assertEqual(expire, cache._expire_info[_key]) # memcached backend isn't guaranteed to be available. # To check the memcached backend, the test settings file will # need to contain at least one cache backend setting that points at # your memcache server. configured_caches = {} for _cache_params in settings.CACHES.values(): configured_caches[_cache_params['BACKEND']] = _cache_params MemcachedCache_params = configured_caches.get('django.core.cache.backends.memcached.MemcachedCache') PyLibMCCache_params = configured_caches.get('django.core.cache.backends.memcached.PyLibMCCache') # The memcached backends don't support cull-related options like `MAX_ENTRIES`. memcached_excluded_caches = {'cull', 'zero_cull'} class BaseMemcachedTests(BaseCacheTests): # By default it's assumed that the client doesn't clean up connections # properly, in which case the backend must do so after each request. should_disconnect_on_close = True def test_location_multiple_servers(self): locations = [ ['server1.tld', 'server2:11211'], 'server1.tld;server2:11211', 'server1.tld,server2:11211', ] for location in locations: params = {'BACKEND': self.base_params['BACKEND'], 'LOCATION': location} with self.settings(CACHES={'default': params}): self.assertEqual(cache._servers, ['server1.tld', 'server2:11211']) def test_invalid_key_characters(self): """ On memcached, we don't introduce a duplicate key validation step (for speed reasons), we just let the memcached API library raise its own exception on bad keys. Refs #6447. In order to be memcached-API-library agnostic, we only assert that a generic exception of some kind is raised. """ # memcached does not allow whitespace or control characters in keys # when using the ascii protocol. with self.assertRaises(Exception): cache.set('key with spaces', 'value') def test_invalid_key_length(self): # memcached limits key length to 250 with self.assertRaises(Exception): cache.set('a' * 251, 'value') def test_default_never_expiring_timeout(self): # Regression test for #22845 with self.settings(CACHES=caches_setting_for_tests( base=self.base_params, exclude=memcached_excluded_caches, TIMEOUT=None)): cache.set('infinite_foo', 'bar') self.assertEqual(cache.get('infinite_foo'), 'bar') def test_default_far_future_timeout(self): # Regression test for #22845 with self.settings(CACHES=caches_setting_for_tests( base=self.base_params, exclude=memcached_excluded_caches, # 60*60*24*365, 1 year TIMEOUT=31536000)): cache.set('future_foo', 'bar') self.assertEqual(cache.get('future_foo'), 'bar') def test_cull(self): # culling isn't implemented, memcached deals with it. pass def test_zero_cull(self): # culling isn't implemented, memcached deals with it. pass def test_memcached_deletes_key_on_failed_set(self): # By default memcached allows objects up to 1MB. For the cache_db session # backend to always use the current session, memcached needs to delete # the old key if it fails to set. # pylibmc doesn't seem to have SERVER_MAX_VALUE_LENGTH as far as I can # tell from a quick check of its source code. This is falling back to # the default value exposed by python-memcached on my system. max_value_length = getattr(cache._lib, 'SERVER_MAX_VALUE_LENGTH', 1048576) cache.set('small_value', 'a') self.assertEqual(cache.get('small_value'), 'a') large_value = 'a' * (max_value_length + 1) try: cache.set('small_value', large_value) except Exception: # Some clients (e.g. pylibmc) raise when the value is too large, # while others (e.g. python-memcached) intentionally return True # indicating success. This test is primarily checking that the key # was deleted, so the return/exception behavior for the set() # itself is not important. pass # small_value should be deleted, or set if configured to accept larger values value = cache.get('small_value') self.assertTrue(value is None or value == large_value) def test_close(self): # For clients that don't manage their connections properly, the # connection is closed when the request is complete. signals.request_finished.disconnect(close_old_connections) try: with mock.patch.object(cache._lib.Client, 'disconnect_all', autospec=True) as mock_disconnect: signals.request_finished.send(self.__class__) self.assertIs(mock_disconnect.called, self.should_disconnect_on_close) finally: signals.request_finished.connect(close_old_connections) @unittest.skipUnless(MemcachedCache_params, "MemcachedCache backend not configured") @override_settings(CACHES=caches_setting_for_tests( base=MemcachedCache_params, exclude=memcached_excluded_caches, )) class MemcachedCacheTests(BaseMemcachedTests, TestCase): base_params = MemcachedCache_params def test_memcached_uses_highest_pickle_version(self): # Regression test for #19810 for cache_key in settings.CACHES: self.assertEqual(caches[cache_key]._cache.pickleProtocol, pickle.HIGHEST_PROTOCOL) @override_settings(CACHES=caches_setting_for_tests( base=MemcachedCache_params, exclude=memcached_excluded_caches, OPTIONS={'server_max_value_length': 9999}, )) def test_memcached_options(self): self.assertEqual(cache._cache.server_max_value_length, 9999) @unittest.skipUnless(PyLibMCCache_params, "PyLibMCCache backend not configured") @override_settings(CACHES=caches_setting_for_tests( base=PyLibMCCache_params, exclude=memcached_excluded_caches, )) class PyLibMCCacheTests(BaseMemcachedTests, TestCase): base_params = PyLibMCCache_params # libmemcached manages its own connections. should_disconnect_on_close = False # By default, pylibmc/libmemcached don't verify keys client-side and so # this test triggers a server-side bug that causes later tests to fail # (#19914). The `verify_keys` behavior option could be set to True (which # would avoid triggering the server-side bug), however this test would # still fail due to https://github.com/lericson/pylibmc/issues/219. @unittest.skip("triggers a memcached-server bug, causing subsequent tests to fail") def test_invalid_key_characters(self): pass @override_settings(CACHES=caches_setting_for_tests( base=PyLibMCCache_params, exclude=memcached_excluded_caches, OPTIONS={ 'binary': True, 'behaviors': {'tcp_nodelay': True}, }, )) def test_pylibmc_options(self): self.assertTrue(cache._cache.binary) self.assertEqual(cache._cache.behaviors['tcp_nodelay'], int(True)) @override_settings(CACHES=caches_setting_for_tests( base=PyLibMCCache_params, exclude=memcached_excluded_caches, OPTIONS={'tcp_nodelay': True}, )) def test_pylibmc_legacy_options(self): deprecation_message = ( "Specifying pylibmc cache behaviors as a top-level property " "within `OPTIONS` is deprecated. Move `tcp_nodelay` into a dict named " "`behaviors` inside `OPTIONS` instead." ) with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") self.assertEqual(cache._cache.behaviors['tcp_nodelay'], int(True)) self.assertEqual(len(warns), 1) self.assertIsInstance(warns[0].message, RemovedInDjango21Warning) self.assertEqual(str(warns[0].message), deprecation_message) @override_settings(CACHES=caches_setting_for_tests( BACKEND='django.core.cache.backends.filebased.FileBasedCache', )) class FileBasedCacheTests(BaseCacheTests, TestCase): """ Specific test cases for the file-based cache. """ def setUp(self): super(FileBasedCacheTests, self).setUp() self.dirname = tempfile.mkdtemp() # Caches location cannot be modified through override_settings / modify_settings, # hence settings are manipulated directly here and the setting_changed signal # is triggered manually. for cache_params in settings.CACHES.values(): cache_params.update({'LOCATION': self.dirname}) setting_changed.send(self.__class__, setting='CACHES', enter=False) def tearDown(self): super(FileBasedCacheTests, self).tearDown() # Call parent first, as cache.clear() may recreate cache base directory shutil.rmtree(self.dirname) def test_ignores_non_cache_files(self): fname = os.path.join(self.dirname, 'not-a-cache-file') with open(fname, 'w'): os.utime(fname, None) cache.clear() self.assertTrue(os.path.exists(fname), 'Expected cache.clear to ignore non cache files') os.remove(fname) def test_clear_does_not_remove_cache_dir(self): cache.clear() self.assertTrue(os.path.exists(self.dirname), 'Expected cache.clear to keep the cache dir') def test_creates_cache_dir_if_nonexistent(self): os.rmdir(self.dirname) cache.set('foo', 'bar') os.path.exists(self.dirname) def test_get_ignores_enoent(self): cache.set('foo', 'bar') os.unlink(cache._key_to_file('foo')) # Returns the default instead of erroring. self.assertEqual(cache.get('foo', 'baz'), 'baz') def test_get_does_not_ignore_non_enoent_errno_values(self): with mock.patch('builtins.open', side_effect=IOError): with self.assertRaises(IOError): cache.get('foo') @override_settings(CACHES={ 'default': { 'BACKEND': 'cache.liberal_backend.CacheClass', }, }) class CustomCacheKeyValidationTests(SimpleTestCase): """ Tests for the ability to mixin a custom ``validate_key`` method to a custom cache backend that otherwise inherits from a builtin backend, and override the default key validation. Refs #6447. """ def test_custom_key_validation(self): # this key is both longer than 250 characters, and has spaces key = 'some key with spaces' * 15 val = 'a value' cache.set(key, val) self.assertEqual(cache.get(key), val) @override_settings( CACHES={ 'default': { 'BACKEND': 'cache.closeable_cache.CacheClass', } } ) class CacheClosingTests(SimpleTestCase): def test_close(self): self.assertFalse(cache.closed) signals.request_finished.send(self.__class__) self.assertTrue(cache.closed) DEFAULT_MEMORY_CACHES_SETTINGS = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', } } NEVER_EXPIRING_CACHES_SETTINGS = copy.deepcopy(DEFAULT_MEMORY_CACHES_SETTINGS) NEVER_EXPIRING_CACHES_SETTINGS['default']['TIMEOUT'] = None class DefaultNonExpiringCacheKeyTests(SimpleTestCase): """ Settings having Cache arguments with a TIMEOUT=None create Caches that will set non-expiring keys. """ def setUp(self): # The 5 minute (300 seconds) default expiration time for keys is # defined in the implementation of the initializer method of the # BaseCache type. self.DEFAULT_TIMEOUT = caches[DEFAULT_CACHE_ALIAS].default_timeout def tearDown(self): del(self.DEFAULT_TIMEOUT) def test_default_expiration_time_for_keys_is_5_minutes(self): """The default expiration time of a cache key is 5 minutes. This value is defined in django.core.cache.backends.base.BaseCache.__init__(). """ self.assertEqual(300, self.DEFAULT_TIMEOUT) def test_caches_with_unset_timeout_has_correct_default_timeout(self): """Caches that have the TIMEOUT parameter undefined in the default settings will use the default 5 minute timeout. """ cache = caches[DEFAULT_CACHE_ALIAS] self.assertEqual(self.DEFAULT_TIMEOUT, cache.default_timeout) @override_settings(CACHES=NEVER_EXPIRING_CACHES_SETTINGS) def test_caches_set_with_timeout_as_none_has_correct_default_timeout(self): """Memory caches that have the TIMEOUT parameter set to `None` in the default settings with have `None` as the default timeout. This means "no timeout". """ cache = caches[DEFAULT_CACHE_ALIAS] self.assertIsNone(cache.default_timeout) self.assertIsNone(cache.get_backend_timeout()) @override_settings(CACHES=DEFAULT_MEMORY_CACHES_SETTINGS) def test_caches_with_unset_timeout_set_expiring_key(self): """Memory caches that have the TIMEOUT parameter unset will set cache keys having the default 5 minute timeout. """ key = "my-key" value = "my-value" cache = caches[DEFAULT_CACHE_ALIAS] cache.set(key, value) cache_key = cache.make_key(key) self.assertIsNotNone(cache._expire_info[cache_key]) @override_settings(CACHES=NEVER_EXPIRING_CACHES_SETTINGS) def test_caches_set_with_timeout_as_none_set_non_expiring_key(self): """Memory caches that have the TIMEOUT parameter set to `None` will set a non expiring key by default. """ key = "another-key" value = "another-value" cache = caches[DEFAULT_CACHE_ALIAS] cache.set(key, value) cache_key = cache.make_key(key) self.assertIsNone(cache._expire_info[cache_key]) @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', CACHE_MIDDLEWARE_SECONDS=1, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, USE_I18N=False, ALLOWED_HOSTS=['.example.com'], ) class CacheUtils(SimpleTestCase): """TestCase for django.utils.cache functions.""" def setUp(self): self.host = 'www.example.com' self.path = '/cache/test/' self.factory = RequestFactory(HTTP_HOST=self.host) def tearDown(self): cache.clear() def _get_request_cache(self, method='GET', query_string=None, update_cache=None): request = self._get_request(self.host, self.path, method, query_string=query_string) request._cache_update_cache = True if not update_cache else update_cache return request def _set_cache(self, request, msg): response = HttpResponse() response.content = msg return UpdateCacheMiddleware().process_response(request, response) def test_patch_vary_headers(self): headers = ( # Initial vary, new headers, resulting vary. (None, ('Accept-Encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('accept-encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('ACCEPT-ENCODING',), 'Accept-Encoding'), ('Cookie', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), (None, ('Accept-Encoding', 'COOKIE'), 'Accept-Encoding, COOKIE'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ('Cookie , Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ) for initial_vary, newheaders, resulting_vary in headers: response = HttpResponse() if initial_vary is not None: response['Vary'] = initial_vary patch_vary_headers(response, newheaders) self.assertEqual(response['Vary'], resulting_vary) def test_get_cache_key(self): request = self.factory.get(self.path) response = HttpResponse() # Expect None if no headers have been set yet. self.assertIsNone(get_cache_key(request)) # Set headers to an empty list. learn_cache_key(request, response) self.assertEqual( get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.' '18a03f9c9649f7d684af5db3524f5c99.d41d8cd98f00b204e9800998ecf8427e' ) # A specified key_prefix is taken into account. key_prefix = 'localprefix' learn_cache_key(request, response, key_prefix=key_prefix) self.assertEqual( get_cache_key(request, key_prefix=key_prefix), 'views.decorators.cache.cache_page.localprefix.GET.' '18a03f9c9649f7d684af5db3524f5c99.d41d8cd98f00b204e9800998ecf8427e' ) def test_get_cache_key_with_query(self): request = self.factory.get(self.path, {'test': 1}) response = HttpResponse() # Expect None if no headers have been set yet. self.assertIsNone(get_cache_key(request)) # Set headers to an empty list. learn_cache_key(request, response) # The querystring is taken into account. self.assertEqual( get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.' 'beaf87a9a99ee81c673ea2d67ccbec2a.d41d8cd98f00b204e9800998ecf8427e' ) def test_cache_key_varies_by_url(self): """ get_cache_key keys differ by fully-qualified URL instead of path """ request1 = self.factory.get(self.path, HTTP_HOST='sub-1.example.com') learn_cache_key(request1, HttpResponse()) request2 = self.factory.get(self.path, HTTP_HOST='sub-2.example.com') learn_cache_key(request2, HttpResponse()) self.assertNotEqual(get_cache_key(request1), get_cache_key(request2)) def test_learn_cache_key(self): request = self.factory.head(self.path) response = HttpResponse() response['Vary'] = 'Pony' # Make sure that the Vary header is added to the key hash learn_cache_key(request, response) self.assertEqual( get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.' '18a03f9c9649f7d684af5db3524f5c99.d41d8cd98f00b204e9800998ecf8427e' ) def test_patch_cache_control(self): tests = ( # Initial Cache-Control, kwargs to patch_cache_control, expected Cache-Control parts (None, {'private': True}, {'private'}), ('', {'private': True}, {'private'}), # Test whether private/public attributes are mutually exclusive ('private', {'private': True}, {'private'}), ('private', {'public': True}, {'public'}), ('public', {'public': True}, {'public'}), ('public', {'private': True}, {'private'}), ('must-revalidate,max-age=60,private', {'public': True}, {'must-revalidate', 'max-age=60', 'public'}), ('must-revalidate,max-age=60,public', {'private': True}, {'must-revalidate', 'max-age=60', 'private'}), ('must-revalidate,max-age=60', {'public': True}, {'must-revalidate', 'max-age=60', 'public'}), ) cc_delim_re = re.compile(r'\s*,\s*') for initial_cc, newheaders, expected_cc in tests: response = HttpResponse() if initial_cc is not None: response['Cache-Control'] = initial_cc patch_cache_control(response, **newheaders) parts = set(cc_delim_re.split(response['Cache-Control'])) self.assertEqual(parts, expected_cc) @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix', }, }, ) class PrefixedCacheUtils(CacheUtils): pass @override_settings( CACHE_MIDDLEWARE_SECONDS=60, CACHE_MIDDLEWARE_KEY_PREFIX='test', CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, ) class CacheHEADTest(SimpleTestCase): def setUp(self): self.path = '/cache/test/' self.factory = RequestFactory() def tearDown(self): cache.clear() def _set_cache(self, request, msg): response = HttpResponse() response.content = msg return UpdateCacheMiddleware().process_response(request, response) def test_head_caches_correctly(self): test_content = 'test content' request = self.factory.head(self.path) request._cache_update_cache = True self._set_cache(request, test_content) request = self.factory.head(self.path) request._cache_update_cache = True get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNotNone(get_cache_data) self.assertEqual(test_content.encode(), get_cache_data.content) def test_head_with_cached_get(self): test_content = 'test content' request = self.factory.get(self.path) request._cache_update_cache = True self._set_cache(request, test_content) request = self.factory.head(self.path) get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNotNone(get_cache_data) self.assertEqual(test_content.encode(), get_cache_data.content) @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, LANGUAGES=[ ('en', 'English'), ('es', 'Spanish'), ], ) class CacheI18nTest(TestCase): def setUp(self): self.path = '/cache/test/' self.factory = RequestFactory() def tearDown(self): cache.clear() @override_settings(USE_I18N=True, USE_L10N=False, USE_TZ=False) def test_cache_key_i18n_translation(self): request = self.factory.get(self.path) lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) self.assertIn(lang, key, "Cache keys should include the language name when translation is active") key2 = get_cache_key(request) self.assertEqual(key, key2) def check_accept_language_vary(self, accept_language, vary, reference_key): request = self.factory.get(self.path) request.META['HTTP_ACCEPT_LANGUAGE'] = accept_language request.META['HTTP_ACCEPT_ENCODING'] = 'gzip;q=1.0, identity; q=0.5, *;q=0' response = HttpResponse() response['Vary'] = vary key = learn_cache_key(request, response) key2 = get_cache_key(request) self.assertEqual(key, reference_key) self.assertEqual(key2, reference_key) @override_settings(USE_I18N=True, USE_L10N=False, USE_TZ=False) def test_cache_key_i18n_translation_accept_language(self): lang = translation.get_language() self.assertEqual(lang, 'en') request = self.factory.get(self.path) request.META['HTTP_ACCEPT_ENCODING'] = 'gzip;q=1.0, identity; q=0.5, *;q=0' response = HttpResponse() response['Vary'] = 'accept-encoding' key = learn_cache_key(request, response) self.assertIn(lang, key, "Cache keys should include the language name when translation is active") self.check_accept_language_vary( 'en-us', 'cookie, accept-language, accept-encoding', key ) self.check_accept_language_vary( 'en-US', 'cookie, accept-encoding, accept-language', key ) self.check_accept_language_vary( 'en-US,en;q=0.8', 'accept-encoding, accept-language, cookie', key ) self.check_accept_language_vary( 'en-US,en;q=0.8,ko;q=0.6', 'accept-language, cookie, accept-encoding', key ) self.check_accept_language_vary( 'ko-kr,ko;q=0.8,en-us;q=0.5,en;q=0.3 ', 'accept-encoding, cookie, accept-language', key ) self.check_accept_language_vary( 'ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-language, accept-encoding, cookie', key ) self.check_accept_language_vary( 'ko;q=1.0,en;q=0.5', 'cookie, accept-language, accept-encoding', key ) self.check_accept_language_vary( 'ko, en', 'cookie, accept-encoding, accept-language', key ) self.check_accept_language_vary( 'ko-KR, en-US', 'accept-encoding, accept-language, cookie', key ) @override_settings(USE_I18N=False, USE_L10N=True, USE_TZ=False) def test_cache_key_i18n_formatting(self): request = self.factory.get(self.path) lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) self.assertIn(lang, key, "Cache keys should include the language name when formatting is active") key2 = get_cache_key(request) self.assertEqual(key, key2) @override_settings(USE_I18N=False, USE_L10N=False, USE_TZ=True) def test_cache_key_i18n_timezone(self): request = self.factory.get(self.path) # This is tightly coupled to the implementation, # but it's the most straightforward way to test the key. tz = force_text(timezone.get_current_timezone_name(), errors='ignore') tz = tz.encode('ascii', 'ignore').decode('ascii').replace(' ', '_') response = HttpResponse() key = learn_cache_key(request, response) self.assertIn(tz, key, "Cache keys should include the time zone name when time zones are active") key2 = get_cache_key(request) self.assertEqual(key, key2) @override_settings(USE_I18N=False, USE_L10N=False) def test_cache_key_no_i18n(self): request = self.factory.get(self.path) lang = translation.get_language() tz = force_text(timezone.get_current_timezone_name(), errors='ignore') tz = tz.encode('ascii', 'ignore').decode('ascii').replace(' ', '_') response = HttpResponse() key = learn_cache_key(request, response) self.assertNotIn(lang, key, "Cache keys shouldn't include the language name when i18n isn't active") self.assertNotIn(tz, key, "Cache keys shouldn't include the time zone name when i18n isn't active") @override_settings(USE_I18N=False, USE_L10N=False, USE_TZ=True) def test_cache_key_with_non_ascii_tzname(self): # Timezone-dependent cache keys should use ASCII characters only # (#17476). The implementation here is a bit odd (timezone.utc is an # instance, not a class), but it simulates the correct conditions. class CustomTzName(timezone.utc): pass request = self.factory.get(self.path) response = HttpResponse() with timezone.override(CustomTzName): CustomTzName.zone = 'Hora estándar de Argentina'.encode('UTF-8') # UTF-8 string sanitized_name = 'Hora_estndar_de_Argentina' self.assertIn( sanitized_name, learn_cache_key(request, response), "Cache keys should include the time zone name when time zones are active" ) CustomTzName.name = 'Hora estándar de Argentina' # unicode sanitized_name = 'Hora_estndar_de_Argentina' self.assertIn( sanitized_name, learn_cache_key(request, response), "Cache keys should include the time zone name when time zones are active" ) @ignore_warnings(category=RemovedInDjango21Warning) # USE_ETAGS=True @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX="test", CACHE_MIDDLEWARE_SECONDS=60, USE_ETAGS=True, USE_I18N=True, ) def test_middleware(self): def set_cache(request, lang, msg): translation.activate(lang) response = HttpResponse() response.content = msg return UpdateCacheMiddleware().process_response(request, response) # cache with non empty request.GET request = self.factory.get(self.path, {'foo': 'bar', 'other': 'true'}) request._cache_update_cache = True get_cache_data = FetchFromCacheMiddleware().process_request(request) # first access, cache must return None self.assertIsNone(get_cache_data) response = HttpResponse() content = 'Check for cache with QUERY_STRING' response.content = content UpdateCacheMiddleware().process_response(request, response) get_cache_data = FetchFromCacheMiddleware().process_request(request) # cache must return content self.assertIsNotNone(get_cache_data) self.assertEqual(get_cache_data.content, content.encode()) # different QUERY_STRING, cache must be empty request = self.factory.get(self.path, {'foo': 'bar', 'somethingelse': 'true'}) request._cache_update_cache = True get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNone(get_cache_data) # i18n tests en_message = "Hello world!" es_message = "Hola mundo!" request = self.factory.get(self.path) request._cache_update_cache = True set_cache(request, 'en', en_message) get_cache_data = FetchFromCacheMiddleware().process_request(request) # The cache can be recovered self.assertIsNotNone(get_cache_data) self.assertEqual(get_cache_data.content, en_message.encode()) # ETags are used. self.assertTrue(get_cache_data.has_header('ETag')) # ETags can be disabled. with self.settings(USE_ETAGS=False): request._cache_update_cache = True set_cache(request, 'en', en_message) get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertFalse(get_cache_data.has_header('ETag')) # change the session language and set content request = self.factory.get(self.path) request._cache_update_cache = True set_cache(request, 'es', es_message) # change again the language translation.activate('en') # retrieve the content from cache get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertEqual(get_cache_data.content, en_message.encode()) # change again the language translation.activate('es') get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertEqual(get_cache_data.content, es_message.encode()) # reset the language translation.deactivate() @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX="test", CACHE_MIDDLEWARE_SECONDS=60, USE_ETAGS=True, ) def test_middleware_doesnt_cache_streaming_response(self): request = self.factory.get(self.path) get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNone(get_cache_data) # This test passes on Python < 3.3 even without the corresponding code # in UpdateCacheMiddleware, because pickling a StreamingHttpResponse # fails (http://bugs.python.org/issue14288). LocMemCache silently # swallows the exception and doesn't store the response in cache. content = ['Check for cache with streaming content.'] response = StreamingHttpResponse(content) UpdateCacheMiddleware().process_response(request, response) get_cache_data = FetchFromCacheMiddleware().process_request(request) self.assertIsNone(get_cache_data) @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix' }, }, ) class PrefixedCacheI18nTest(CacheI18nTest): pass def hello_world_view(request, value): return HttpResponse('Hello World %s' % value) def csrf_view(request): return HttpResponse(csrf(request)['csrf_token']) @override_settings( CACHE_MIDDLEWARE_ALIAS='other', CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix', CACHE_MIDDLEWARE_SECONDS=30, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, 'other': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'other', 'TIMEOUT': '1', }, }, ) class CacheMiddlewareTest(SimpleTestCase): def setUp(self): super(CacheMiddlewareTest, self).setUp() self.factory = RequestFactory() self.default_cache = caches['default'] self.other_cache = caches['other'] def tearDown(self): self.default_cache.clear() self.other_cache.clear() super(CacheMiddlewareTest, self).tearDown() def test_constructor(self): """ Ensure the constructor is correctly distinguishing between usage of CacheMiddleware as Middleware vs. usage of CacheMiddleware as view decorator and setting attributes appropriately. """ # If no arguments are passed in construction, it's being used as middleware. middleware = CacheMiddleware() # Now test object attributes against values defined in setUp above self.assertEqual(middleware.cache_timeout, 30) self.assertEqual(middleware.key_prefix, 'middlewareprefix') self.assertEqual(middleware.cache_alias, 'other') # If arguments are being passed in construction, it's being used as a decorator. # First, test with "defaults": as_view_decorator = CacheMiddleware(cache_alias=None, key_prefix=None) self.assertEqual(as_view_decorator.cache_timeout, 30) # Timeout value for 'default' cache, i.e. 30 self.assertEqual(as_view_decorator.key_prefix, '') # Value of DEFAULT_CACHE_ALIAS from django.core.cache self.assertEqual(as_view_decorator.cache_alias, 'default') # Next, test with custom values: as_view_decorator_with_custom = CacheMiddleware(cache_timeout=60, cache_alias='other', key_prefix='foo') self.assertEqual(as_view_decorator_with_custom.cache_timeout, 60) self.assertEqual(as_view_decorator_with_custom.key_prefix, 'foo') self.assertEqual(as_view_decorator_with_custom.cache_alias, 'other') def test_middleware(self): middleware = CacheMiddleware() prefix_middleware = CacheMiddleware(key_prefix='prefix1') timeout_middleware = CacheMiddleware(cache_timeout=1) request = self.factory.get('/view/') # Put the request through the request middleware result = middleware.process_request(request) self.assertIsNone(result) response = hello_world_view(request, '1') # Now put the response through the response middleware response = middleware.process_response(request, response) # Repeating the request should result in a cache hit result = middleware.process_request(request) self.assertIsNotNone(result) self.assertEqual(result.content, b'Hello World 1') # The same request through a different middleware won't hit result = prefix_middleware.process_request(request) self.assertIsNone(result) # The same request with a timeout _will_ hit result = timeout_middleware.process_request(request) self.assertIsNotNone(result) self.assertEqual(result.content, b'Hello World 1') def test_view_decorator(self): # decorate the same view with different cache decorators default_view = cache_page(3)(hello_world_view) default_with_prefix_view = cache_page(3, key_prefix='prefix1')(hello_world_view) explicit_default_view = cache_page(3, cache='default')(hello_world_view) explicit_default_with_prefix_view = cache_page(3, cache='default', key_prefix='prefix1')(hello_world_view) other_view = cache_page(1, cache='other')(hello_world_view) other_with_prefix_view = cache_page(1, cache='other', key_prefix='prefix2')(hello_world_view) request = self.factory.get('/view/') # Request the view once response = default_view(request, '1') self.assertEqual(response.content, b'Hello World 1') # Request again -- hit the cache response = default_view(request, '2') self.assertEqual(response.content, b'Hello World 1') # Requesting the same view with the explicit cache should yield the same result response = explicit_default_view(request, '3') self.assertEqual(response.content, b'Hello World 1') # Requesting with a prefix will hit a different cache key response = explicit_default_with_prefix_view(request, '4') self.assertEqual(response.content, b'Hello World 4') # Hitting the same view again gives a cache hit response = explicit_default_with_prefix_view(request, '5') self.assertEqual(response.content, b'Hello World 4') # And going back to the implicit cache will hit the same cache response = default_with_prefix_view(request, '6') self.assertEqual(response.content, b'Hello World 4') # Requesting from an alternate cache won't hit cache response = other_view(request, '7') self.assertEqual(response.content, b'Hello World 7') # But a repeated hit will hit cache response = other_view(request, '8') self.assertEqual(response.content, b'Hello World 7') # And prefixing the alternate cache yields yet another cache entry response = other_with_prefix_view(request, '9') self.assertEqual(response.content, b'Hello World 9') # But if we wait a couple of seconds... time.sleep(2) # ... the default cache will still hit caches['default'] response = default_view(request, '11') self.assertEqual(response.content, b'Hello World 1') # ... the default cache with a prefix will still hit response = default_with_prefix_view(request, '12') self.assertEqual(response.content, b'Hello World 4') # ... the explicit default cache will still hit response = explicit_default_view(request, '13') self.assertEqual(response.content, b'Hello World 1') # ... the explicit default cache with a prefix will still hit response = explicit_default_with_prefix_view(request, '14') self.assertEqual(response.content, b'Hello World 4') # .. but a rapidly expiring cache won't hit response = other_view(request, '15') self.assertEqual(response.content, b'Hello World 15') # .. even if it has a prefix response = other_with_prefix_view(request, '16') self.assertEqual(response.content, b'Hello World 16') def test_sensitive_cookie_not_cached(self): """ Django must prevent caching of responses that set a user-specific (and maybe security sensitive) cookie in response to a cookie-less request. """ csrf_middleware = CsrfViewMiddleware() cache_middleware = CacheMiddleware() request = self.factory.get('/view/') self.assertIsNone(cache_middleware.process_request(request)) csrf_middleware.process_view(request, csrf_view, (), {}) response = csrf_view(request) response = csrf_middleware.process_response(request, response) response = cache_middleware.process_response(request, response) # Inserting a CSRF cookie in a cookie-less request prevented caching. self.assertIsNone(cache_middleware.process_request(request)) def test_304_response_has_http_caching_headers_but_not_cached(self): original_view = mock.Mock(return_value=HttpResponseNotModified()) view = cache_page(2)(original_view) request = self.factory.get('/view/') # The view shouldn't be cached on the second call. view(request).close() response = view(request) response.close() self.assertEqual(original_view.call_count, 2) self.assertIsInstance(response, HttpResponseNotModified) self.assertIn('Cache-Control', response) self.assertIn('Expires', response) @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', CACHE_MIDDLEWARE_SECONDS=1, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, USE_I18N=False, ) class TestWithTemplateResponse(SimpleTestCase): """ Tests various headers w/ TemplateResponse. Most are probably redundant since they manipulate the same object anyway but the ETag header is 'special' because it relies on the content being complete (which is not necessarily always the case with a TemplateResponse) """ def setUp(self): self.path = '/cache/test/' self.factory = RequestFactory() def tearDown(self): cache.clear() def test_patch_vary_headers(self): headers = ( # Initial vary, new headers, resulting vary. (None, ('Accept-Encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('accept-encoding',), 'Accept-Encoding'), ('Accept-Encoding', ('ACCEPT-ENCODING',), 'Accept-Encoding'), ('Cookie', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), (None, ('Accept-Encoding', 'COOKIE'), 'Accept-Encoding, COOKIE'), ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ('Cookie , Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), ) for initial_vary, newheaders, resulting_vary in headers: template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) if initial_vary is not None: response['Vary'] = initial_vary patch_vary_headers(response, newheaders) self.assertEqual(response['Vary'], resulting_vary) def test_get_cache_key(self): request = self.factory.get(self.path) template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) key_prefix = 'localprefix' # Expect None if no headers have been set yet. self.assertIsNone(get_cache_key(request)) # Set headers to an empty list. learn_cache_key(request, response) self.assertEqual( get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.' '58a0a05c8a5620f813686ff969c26853.d41d8cd98f00b204e9800998ecf8427e' ) # A specified key_prefix is taken into account. learn_cache_key(request, response, key_prefix=key_prefix) self.assertEqual( get_cache_key(request, key_prefix=key_prefix), 'views.decorators.cache.cache_page.localprefix.GET.' '58a0a05c8a5620f813686ff969c26853.d41d8cd98f00b204e9800998ecf8427e' ) def test_get_cache_key_with_query(self): request = self.factory.get(self.path, {'test': 1}) template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) # Expect None if no headers have been set yet. self.assertIsNone(get_cache_key(request)) # Set headers to an empty list. learn_cache_key(request, response) # The querystring is taken into account. self.assertEqual( get_cache_key(request), 'views.decorators.cache.cache_page.settingsprefix.GET.' '0f1c2d56633c943073c4569d9a9502fe.d41d8cd98f00b204e9800998ecf8427e' ) @override_settings(USE_ETAGS=False) def test_without_etag(self): template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) self.assertFalse(response.has_header('ETag')) patch_response_headers(response) self.assertFalse(response.has_header('ETag')) response = response.render() self.assertFalse(response.has_header('ETag')) @ignore_warnings(category=RemovedInDjango21Warning) @override_settings(USE_ETAGS=True) def test_with_etag(self): template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) self.assertFalse(response.has_header('ETag')) patch_response_headers(response) self.assertFalse(response.has_header('ETag')) response = response.render() self.assertTrue(response.has_header('ETag')) class TestMakeTemplateFragmentKey(SimpleTestCase): def test_without_vary_on(self): key = make_template_fragment_key('a.fragment') self.assertEqual(key, 'template.cache.a.fragment.d41d8cd98f00b204e9800998ecf8427e') def test_with_one_vary_on(self): key = make_template_fragment_key('foo', ['abc']) self.assertEqual(key, 'template.cache.foo.900150983cd24fb0d6963f7d28e17f72') def test_with_many_vary_on(self): key = make_template_fragment_key('bar', ['abc', 'def']) self.assertEqual(key, 'template.cache.bar.4b35f12ab03cec09beec4c21b2d2fa88') def test_proper_escaping(self): key = make_template_fragment_key('spam', ['abc:def%']) self.assertEqual(key, 'template.cache.spam.f27688177baec990cdf3fbd9d9c3f469') class CacheHandlerTest(SimpleTestCase): def test_same_instance(self): """ Attempting to retrieve the same alias should yield the same instance. """ cache1 = caches['default'] cache2 = caches['default'] self.assertIs(cache1, cache2) def test_per_thread(self): """ Requesting the same alias from separate threads should yield separate instances. """ c = [] def runner(): c.append(caches['default']) for x in range(2): t = threading.Thread(target=runner) t.start() t.join() self.assertIsNot(c[0], c[1])
bsd-3-clause
[ 3, 12008, 2295, 367, 2581, 10059, 199, 3, 14911, 15685, 2581, 4865, 365, 663, 315, 314, 511, 2202, 570, 14, 199, 646, 1331, 199, 646, 5890, 199, 646, 747, 199, 646, 5927, 199, 646, 295, 199, 646, 5145, 199, 646, 5549, 199, 646, 5796, 199, 646, 900, 199, 646, 2882, 199, 646, 3598, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 10041, 12, 10166, 199, 504, 1639, 14, 1018, 14, 1637, 492, 334, 272, 6186, 63, 8677, 63, 12644, 12, 11977, 1197, 3849, 12, 2581, 12, 18014, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 1637, 14, 1208, 492, 1852, 63, 1160, 63, 7677, 63, 498, 199, 504, 1639, 14, 697, 492, 4002, 63, 1753, 63, 7995, 12, 1950, 12, 6947, 199, 504, 1639, 14, 1014, 492, 334, 272, 20730, 12, 6183, 12, 6183, 1763, 11911, 12, 28167, 16287, 12, 199, 9, 199, 504, 1639, 14, 5754, 14, 1637, 492, 334, 272, 11977, 6608, 12, 16347, 2532, 4437, 6608, 12, 6162, 4437, 6608, 12, 199, 9, 199, 504, 1639, 14, 5754, 14, 10088, 492, 22145, 25322, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1100, 63, 10547, 492, 19213, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 396, 492, 334, 272, 18638, 12, 24424, 12, 7640, 12, 18244, 1746, 12, 272, 3686, 63, 5451, 12, 4278, 63, 1751, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 10458, 492, 4260, 63, 2489, 199, 504, 1639, 14, 1208, 492, 7137, 12, 7761, 199, 504, 1639, 14, 1208, 14, 1637, 492, 334, 272, 664, 63, 1637, 63, 498, 12, 12537, 63, 1637, 63, 498, 12, 3371, 63, 1637, 63, 2785, 12, 272, 3371, 63, 1310, 63, 2139, 12, 3371, 63, 21989, 63, 2139, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 2025, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 199, 504, 1275, 992, 492, 25306, 12, 23133, 63, 31458, 421, 199, 3, 3423, 15, 2888, 367, 6114, 666, 730, 2295, 199, 318, 289, 837, 272, 372, 5685, 421, 199, 533, 445, 26, 272, 347, 333, 8, 78, 304, 267, 372, 5504, 421, 199, 533, 1910, 4510, 76, 461, 26, 272, 347, 636, 16011, 721, 277, 304, 267, 746, 5927, 14, 12755, 547, 342, 421, 199, 32, 4415, 63, 1751, 8, 3263, 1244, 654, 3126, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 5869, 14, 11324, 4437, 297, 272, 789, 199, 1552, 199, 533, 9762, 4437, 2925, 8, 17968, 304, 272, 327, 710, 9762, 2581, 4865, 3181, 1133, 7710, 24062, 2839, 282, 511, 4865, 12, 272, 327, 880, 652, 965, 2399, 5705, 511, 1930, 14, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 298, 11324, 2581, 4865, 24010, 2581, 663, 4882, 2, 267, 2581, 14, 409, 480, 498, 401, 298, 585, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 2237, 339, 347, 511, 63, 525, 8, 277, 304, 267, 298, 1123, 3181, 1133, 886, 7003, 315, 7283, 2581, 4865, 2, 267, 2581, 14, 525, 480, 525, 498, 17, 401, 298, 585, 531, 267, 754, 275, 2581, 14, 525, 480, 525, 498, 17, 401, 298, 1222, 585, 531, 267, 291, 14, 1815, 8, 1099, 9, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 525, 498, 17, 2237, 339, 347, 511, 63, 2865, 63, 15025, 8, 277, 304, 267, 298, 6932, 13, 15025, 2883, 10621, 1133, 1911, 315, 314, 7283, 2581, 4865, 2, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 2237, 267, 291, 14, 629, 8, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 401, 298, 66, 621, 1, 1288, 298, 66, 621, 9124, 339, 347, 511, 63, 362, 63, 3479, 8, 277, 304, 267, 298, 362, 63, 3479, 2529, 6548, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 360, 65, 297, 283, 65, 358, 267, 2581, 14, 409, 360, 66, 297, 283, 66, 358, 267, 2581, 14, 409, 360, 67, 297, 283, 67, 358, 267, 2581, 14, 409, 360, 68, 297, 283, 68, 358, 267, 291, 14, 629, 8, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 67, 297, 283, 68, 3815, 5009, 267, 291, 14, 629, 8, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 66, 297, 283, 69, 3815, 5009, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 298, 4437, 14068, 365, 17265, 590, 5525, 641, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 498, 17, 401, 298, 8283, 531, 267, 2581, 14, 409, 480, 498, 18, 401, 298, 14488, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 17, 2237, 267, 2581, 14, 1807, 480, 498, 17, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 17, 2237, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 18, 2237, 339, 347, 511, 63, 1989, 63, 498, 8, 277, 304, 267, 298, 1918, 965, 63, 498, 1083, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 5006, 17, 401, 298, 8302, 16481, 17, 531, 267, 291, 14, 3334, 8, 1637, 14, 1989, 63, 498, 480, 5006, 17, 2237, 267, 291, 14, 3334, 8, 1637, 14, 1989, 63, 498, 480, 8302, 16481, 17, 2237, 339, 347, 511, 63, 262, 8, 277, 304, 267, 298, 1918, 315, 4182, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 5006, 18, 401, 298, 8302, 16481, 18, 531, 267, 291, 14, 8795, 480, 5006, 18, 401, 2581, 9, 267, 291, 14, 8795, 480, 8302, 16481, 18, 401, 2581, 9, 339, 347, 511, 63, 19362, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 10035, 2509, 2, 267, 2581, 14, 409, 360, 5934, 297, 5685, 9, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 2581, 14, 19362, 360, 5934, 358, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 2581, 14, 19362, 360, 9105, 63 ]
[ 12008, 2295, 367, 2581, 10059, 199, 3, 14911, 15685, 2581, 4865, 365, 663, 315, 314, 511, 2202, 570, 14, 199, 646, 1331, 199, 646, 5890, 199, 646, 747, 199, 646, 5927, 199, 646, 295, 199, 646, 5145, 199, 646, 5549, 199, 646, 5796, 199, 646, 900, 199, 646, 2882, 199, 646, 3598, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 10041, 12, 10166, 199, 504, 1639, 14, 1018, 14, 1637, 492, 334, 272, 6186, 63, 8677, 63, 12644, 12, 11977, 1197, 3849, 12, 2581, 12, 18014, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 1637, 14, 1208, 492, 1852, 63, 1160, 63, 7677, 63, 498, 199, 504, 1639, 14, 697, 492, 4002, 63, 1753, 63, 7995, 12, 1950, 12, 6947, 199, 504, 1639, 14, 1014, 492, 334, 272, 20730, 12, 6183, 12, 6183, 1763, 11911, 12, 28167, 16287, 12, 199, 9, 199, 504, 1639, 14, 5754, 14, 1637, 492, 334, 272, 11977, 6608, 12, 16347, 2532, 4437, 6608, 12, 6162, 4437, 6608, 12, 199, 9, 199, 504, 1639, 14, 5754, 14, 10088, 492, 22145, 25322, 199, 504, 1639, 14, 1160, 492, 28156, 199, 504, 1639, 14, 1160, 14, 1100, 63, 10547, 492, 19213, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 396, 492, 334, 272, 18638, 12, 24424, 12, 7640, 12, 18244, 1746, 12, 272, 3686, 63, 5451, 12, 4278, 63, 1751, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 10458, 492, 4260, 63, 2489, 199, 504, 1639, 14, 1208, 492, 7137, 12, 7761, 199, 504, 1639, 14, 1208, 14, 1637, 492, 334, 272, 664, 63, 1637, 63, 498, 12, 12537, 63, 1637, 63, 498, 12, 3371, 63, 1637, 63, 2785, 12, 272, 3371, 63, 1310, 63, 2139, 12, 3371, 63, 21989, 63, 2139, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 2025, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 199, 504, 1275, 992, 492, 25306, 12, 23133, 63, 31458, 421, 199, 3, 3423, 15, 2888, 367, 6114, 666, 730, 2295, 199, 318, 289, 837, 272, 372, 5685, 421, 199, 533, 445, 26, 272, 347, 333, 8, 78, 304, 267, 372, 5504, 421, 199, 533, 1910, 4510, 76, 461, 26, 272, 347, 636, 16011, 721, 277, 304, 267, 746, 5927, 14, 12755, 547, 342, 421, 199, 32, 4415, 63, 1751, 8, 3263, 1244, 654, 3126, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 5869, 14, 11324, 4437, 297, 272, 789, 199, 1552, 199, 533, 9762, 4437, 2925, 8, 17968, 304, 272, 327, 710, 9762, 2581, 4865, 3181, 1133, 7710, 24062, 2839, 282, 511, 4865, 12, 272, 327, 880, 652, 965, 2399, 5705, 511, 1930, 14, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 298, 11324, 2581, 4865, 24010, 2581, 663, 4882, 2, 267, 2581, 14, 409, 480, 498, 401, 298, 585, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 2237, 339, 347, 511, 63, 525, 8, 277, 304, 267, 298, 1123, 3181, 1133, 886, 7003, 315, 7283, 2581, 4865, 2, 267, 2581, 14, 525, 480, 525, 498, 17, 401, 298, 585, 531, 267, 754, 275, 2581, 14, 525, 480, 525, 498, 17, 401, 298, 1222, 585, 531, 267, 291, 14, 1815, 8, 1099, 9, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 525, 498, 17, 2237, 339, 347, 511, 63, 2865, 63, 15025, 8, 277, 304, 267, 298, 6932, 13, 15025, 2883, 10621, 1133, 1911, 315, 314, 7283, 2581, 4865, 2, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 2237, 267, 291, 14, 629, 8, 1637, 14, 362, 480, 9105, 63, 1397, 63, 4494, 401, 298, 66, 621, 1, 1288, 298, 66, 621, 9124, 339, 347, 511, 63, 362, 63, 3479, 8, 277, 304, 267, 298, 362, 63, 3479, 2529, 6548, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 360, 65, 297, 283, 65, 358, 267, 2581, 14, 409, 360, 66, 297, 283, 66, 358, 267, 2581, 14, 409, 360, 67, 297, 283, 67, 358, 267, 2581, 14, 409, 360, 68, 297, 283, 68, 358, 267, 291, 14, 629, 8, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 67, 297, 283, 68, 3815, 5009, 267, 291, 14, 629, 8, 1637, 14, 362, 63, 3479, 2941, 65, 297, 283, 66, 297, 283, 69, 3815, 5009, 339, 347, 511, 63, 1807, 8, 277, 304, 267, 298, 4437, 14068, 365, 17265, 590, 5525, 641, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 498, 17, 401, 298, 8283, 531, 267, 2581, 14, 409, 480, 498, 18, 401, 298, 14488, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 17, 2237, 267, 2581, 14, 1807, 480, 498, 17, 531, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 17, 2237, 267, 291, 14, 7702, 8, 1637, 14, 362, 480, 498, 18, 2237, 339, 347, 511, 63, 1989, 63, 498, 8, 277, 304, 267, 298, 1918, 965, 63, 498, 1083, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 5006, 17, 401, 298, 8302, 16481, 17, 531, 267, 291, 14, 3334, 8, 1637, 14, 1989, 63, 498, 480, 5006, 17, 2237, 267, 291, 14, 3334, 8, 1637, 14, 1989, 63, 498, 480, 8302, 16481, 17, 2237, 339, 347, 511, 63, 262, 8, 277, 304, 267, 298, 1918, 315, 4182, 3181, 1133, 14433, 372, 715, 367, 314, 7283, 2581, 4865, 2, 267, 2581, 14, 409, 480, 5006, 18, 401, 298, 8302, 16481, 18, 531, 267, 291, 14, 8795, 480, 5006, 18, 401, 2581, 9, 267, 291, 14, 8795, 480, 8302, 16481, 18, 401, 2581, 9, 339, 347, 511, 63, 19362, 8, 277, 304, 267, 298, 11324, 2581, 1338, 883, 1133, 506, 10035, 2509, 2, 267, 2581, 14, 409, 360, 5934, 297, 5685, 9, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 2581, 14, 19362, 360, 5934, 358, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 2581, 14, 19362, 360, 9105, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
hxa7241/minilight-python
spatialindex.py
1
5023
# MiniLight Python : minimal global illumination renderer # # Harrison Ainsworth / HXA7241 and Juraj Sukop : 2007-2008, 2013. # http://www.hxa.name/minilight from triangle import Triangle, TOLERANCE from vector3f import Vector3f, MAX MAX_LEVELS = 44 MAX_ITEMS = 8 class SpatialIndex(object): def __init__(self, arg, items, level=0): if type(arg) == Vector3f: items = [(item.get_bound(), item) for item in items] bound = list(arg) * 2 for item in items: for j in range(6): if (bound[j] > item[0][j]) ^ (j > 2): bound[j] = item[0][j] size = max(list(Vector3f(bound[3:6]) - Vector3f(bound[0:3]))) self.bound = bound[0:3] + list(Vector3f(bound[3:6] ).clamped(Vector3f(bound[0:3]) + Vector3f(size), MAX)) else: self.bound = arg self.is_branch = len(items) > MAX_ITEMS and level < MAX_LEVELS - 1 if self.is_branch: q1 = 0 self.vector = [None] * 8 for s in range(8): sub_bound = [] for j in range(6): m = j % 3 if (((s >> m) & 1) != 0) ^ (j > 2): sub_bound.append((self.bound[m] + self.bound[m + 3]) * 0.5) else: sub_bound.append(self.bound[j]) sub_items = [] for item in items: item_bound = item[0] if item_bound[3] >= sub_bound[0] and \ item_bound[0] < sub_bound[3] and \ item_bound[4] >= sub_bound[1] and \ item_bound[1] < sub_bound[4] and \ item_bound[5] >= sub_bound[2] and \ item_bound[2] < sub_bound[5]: sub_items.append(item) q1 += 1 if len(sub_items) == len(items) else 0 q2 = (sub_bound[3] - sub_bound[0]) < (TOLERANCE * 4.0) if len(sub_items) > 0: self.vector[s] = SpatialIndex(sub_bound, sub_items, MAX_LEVELS if q1 > 1 or q2 else level + 1) else: self.vector = [item[1] for item in items] def get_intersection(self, ray_origin, ray_direction, last_hit, start=None): start = start if start else ray_origin hit_object = hit_position = None if self.is_branch: sub_cell = 1 if start[0] >= (self.bound[0] + self.bound[3]) * 0.5 \ else 0 if start[1] >= (self.bound[1] + self.bound[4]) * 0.5: sub_cell |= 2 if start[2] >= (self.bound[2] + self.bound[5]) * 0.5: sub_cell |= 4 cell_position = start while True: if self.vector[sub_cell]: hit_object, hit_position = self.vector[sub_cell ].get_intersection(ray_origin, ray_direction, last_hit, cell_position) if hit_object: break step = float(2**1024 - 2**971) axis = 0 for i in range(3): high = (sub_cell >> i) & 1 face = self.bound[i + high * 3] if (ray_direction[i] < 0.0 ) ^ (0 != high) else (self.bound[i] + self.bound[i + 3] ) * 0.5 try: distance = (face - ray_origin[i]) / ray_direction[i] except: distance = float(1e30000) if distance <= step: step = distance axis = i if (((sub_cell >> axis) & 1) == 1) ^ (ray_direction[axis] < 0.0): break cell_position = ray_origin + ray_direction * step sub_cell = sub_cell ^ (1 << axis) else: nearest_distance = float(2**1024 - 2**971) for item in self.vector: if item != last_hit: distance = item.get_intersection(ray_origin, ray_direction) if distance and (distance < nearest_distance): hit = ray_origin + ray_direction * distance if (self.bound[0] - hit[0] <= TOLERANCE) and \ (hit[0] - self.bound[3] <= TOLERANCE) and \ (self.bound[1] - hit[1] <= TOLERANCE) and \ (hit[1] - self.bound[4] <= TOLERANCE) and \ (self.bound[2] - hit[2] <= TOLERANCE) and \ (hit[2] - self.bound[5] <= TOLERANCE): hit_object = item hit_position = hit nearest_distance = distance return hit_object, hit_position
cc0-1.0
[ 3, 221, 24954, 16393, 2018, 520, 13460, 2288, 22907, 453, 3155, 11889, 199, 3, 199, 3, 221, 25378, 322, 834, 437, 3617, 584, 273, 1182, 869, 56, 33, 23, 13571, 436, 1603, 300, 9091, 428, 3210, 411, 520, 10219, 13, 9300, 12, 6171, 14, 199, 3, 221, 1455, 921, 1544, 14, 72, 1800, 14, 354, 15, 827, 1638, 913, 421, 199, 504, 26268, 492, 12480, 4593, 12, 377, 2228, 540, 7140, 199, 504, 5477, 19, 70, 492, 11388, 19, 70, 12, 9141, 199, 199, 4283, 63, 906, 2524, 5296, 275, 10868, 199, 4283, 63, 10439, 51, 221, 275, 221, 1695, 199, 199, 533, 13423, 2681, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1680, 12, 2974, 12, 2166, 29, 16, 304, 267, 340, 730, 8, 1273, 9, 508, 11388, 19, 70, 26, 288, 2974, 275, 3842, 1053, 14, 362, 63, 3556, 1062, 1242, 9, 367, 1242, 315, 2974, 61, 288, 3914, 275, 769, 8, 1273, 9, 627, 499, 288, 367, 1242, 315, 2974, 26, 355, 367, 1335, 315, 1425, 8, 22, 304, 490, 340, 334, 3556, 59, 74, 61, 690, 1242, 59, 16, 1527, 74, 566, 7167, 334, 74, 690, 499, 304, 717, 3914, 59, 74, 61, 275, 1242, 59, 16, 1527, 74, 61, 288, 1568, 275, 1390, 8, 513, 8, 3646, 19, 70, 8, 3556, 59, 19, 26, 22, 566, 446, 11388, 19, 70, 8, 3556, 59, 16, 26, 19, 11845, 288, 291, 14, 3556, 275, 3914, 59, 16, 26, 19, 61, 435, 769, 8, 3646, 19, 70, 8, 3556, 59, 19, 26, 22, 61, 355, 7092, 3995, 311, 379, 8, 3646, 19, 70, 8, 3556, 59, 16, 26, 19, 566, 435, 11388, 19, 70, 8, 890, 395, 9141, 430, 267, 587, 26, 288, 291, 14, 3556, 275, 1680, 267, 291, 14, 374, 63, 4694, 275, 822, 8, 1744, 9, 690, 9141, 63, 10439, 51, 436, 2166, 665, 9141, 63, 906, 2524, 5296, 446, 413, 267, 340, 291, 14, 374, 63, 4694, 26, 288, 1894, 17, 275, 378, 288, 291, 14, 4106, 275, 359, 403, 61, 627, 1695, 288, 367, 308, 315, 1425, 8, 24, 304, 355, 1007, 63, 3556, 275, 942, 355, 367, 1335, 315, 1425, 8, 22, 304, 490, 333, 275, 1335, 450, 650, 490, 340, 20337, 83, 4331, 333, 9, 1253, 413, 9, 1137, 378, 9, 7167, 334, 74, 690, 499, 304, 717, 1007, 63, 3556, 14, 740, 1332, 277, 14, 3556, 59, 77, 61, 435, 291, 14, 3556, 59, 77, 435, 650, 566, 627, 1169, 378, 14, 21, 9, 490, 587, 26, 717, 1007, 63, 3556, 14, 740, 8, 277, 14, 3556, 59, 74, 566, 355, 1007, 63, 1744, 275, 942, 355, 367, 1242, 315, 2974, 26, 490, 1242, 63, 3556, 275, 1242, 59, 16, 61, 490, 340, 1242, 63, 3556, 59, 19, 61, 2356, 1007, 63, 3556, 59, 16, 61, 436, 971, 2432, 1242, 63, 3556, 59, 16, 61, 665, 1007, 63, 3556, 59, 19, 61, 436, 971, 2432, 1242, 63, 3556, 59, 20, 61, 2356, 1007, 63, 3556, 59, 17, 61, 436, 971, 2432, 1242, 63, 3556, 59, 17, 61, 665, 1007, 63, 3556, 59, 20, 61, 436, 971, 2432, 1242, 63, 3556, 59, 21, 61, 2356, 1007, 63, 3556, 59, 18, 61, 436, 971, 2432, 1242, 63, 3556, 59, 18, 61, 665, 1007, 63, 3556, 59, 21, 2189, 2574, 1007, 63, 1744, 14, 740, 8, 1053, 9, 355, 1894, 17, 847, 413, 340, 822, 8, 954, 63, 1744, 9, 508, 822, 8, 1744, 9, 587, 378, 355, 1894, 18, 275, 334, 954, 63, 3556, 59, 19, 61, 446, 1007, 63, 3556, 59, 16, 566, 665, 334, 52, 2228, 540, 7140, 627, 841, 14, 16, 9, 355, 340, 822, 8, 954, 63, 1744, 9, 690, 378, 26, 490, 291, 14, 4106, 59, 83, 61, 275, 13423, 2681, 8, 954, 63, 3556, 12, 1007, 63, 1744, 12, 717, 9141, 63, 906, 2524, 5296, 340, 1894, 17, 690, 413, 503, 1894, 18, 587, 2166, 435, 413, 9, 267, 587, 26, 288, 291, 14, 4106, 275, 359, 1053, 59, 17, 61, 367, 1242, 315, 2974, 61, 339, 347, 664, 63, 12569, 8, 277, 12, 22059, 63, 6493, 12, 22059, 63, 6874, 12, 2061, 63, 12948, 12, 1343, 29, 403, 304, 267, 1343, 275, 1343, 340, 1343, 587, 22059, 63, 6493, 267, 9793, 63, 785, 275, 9793, 63, 3124, 275, 488, 267, 340, 291, 14, 374, 63, 4694, 26, 288, 1007, 63, 3890, 275, 413, 340, 1343, 59, 16, 61, 2356, 334, 277, 14, 3556, 59, 16, 61, 435, 291, 14, 3556, 59, 19, 566, 627, 378, 14, 21, 971, 355, 587, 378, 288, 340, 1343, 59, 17, 61, 2356, 334, 277, 14, 3556, 59, 17, 61, 435, 291, 14, 3556, 59, 20, 566, 627, 378, 14, 21, 26, 355, 1007, 63, 3890, 8901, 499, 288, 340, 1343, 59, 18, 61, 2356, 334, 277, 14, 3556, 59, 18, 61, 435, 291, 14, 3556, 59, 21, 566, 627, 378, 14, 21, 26, 355, 1007, 63, 3890, 8901, 841, 288, 4917, 63, 3124, 275, 1343, 288, 1830, 715, 26, 355, 340, 291, 14, 4106, 59, 954, 63, 3890, 2189, 490, 9793, 63, 785, 12, 9793, 63, 3124, 275, 291, 14, 4106, 59, 954, 63, 3890, 717, 221, 1055, 362, 63, 12569, 8, 803, 63, 6493, 12, 22059, 63, 6874, 12, 2061, 63, 12948, 12, 717, 4917, 63, 3124, 9, 490, 340, 9793, 63, 785, 26, 717, 2059, 355, 3650, 275, 2069, 8, 18, 538, 7727, 446, 499, 538, 27622, 9, 355, 3114, 275, 378, 355, 367, 284, 315, 1425, 8, 19, 304, 490, 4721, 275, 334, 954, 63, 3890, 4331, 284, 9, 1253, 413, 490, 8870, 275, 291, 14, 3556, 59, 73, 435, 4721, 627, 650, 61, 340, 334, 803, 63, 6874, 59, 73, 61, 665, 378, 14, 16, 717, 776, 7167, 334, 16, 1137, 4721, 9, 587, 334, 277, 14, 3556, 59, 73, 61, 435, 291, 14, 3556, 59, 73, 435, 650, 61, 717, 776, 627, 378, 14, 21, 490, 862, 26, 717, 6033, 275, 334, 1409, 446, 22059, 63, 6493, 59, 73, 566, 1182, 22059, 63, 6874, 59, 73, 61, 490, 871, 26, 717, 6033, 275, 2069, 8, 17, 69, 19, 993, 9, 490, 340, 6033, 2695, 3650, 26 ]
[ 221, 24954, 16393, 2018, 520, 13460, 2288, 22907, 453, 3155, 11889, 199, 3, 199, 3, 221, 25378, 322, 834, 437, 3617, 584, 273, 1182, 869, 56, 33, 23, 13571, 436, 1603, 300, 9091, 428, 3210, 411, 520, 10219, 13, 9300, 12, 6171, 14, 199, 3, 221, 1455, 921, 1544, 14, 72, 1800, 14, 354, 15, 827, 1638, 913, 421, 199, 504, 26268, 492, 12480, 4593, 12, 377, 2228, 540, 7140, 199, 504, 5477, 19, 70, 492, 11388, 19, 70, 12, 9141, 199, 199, 4283, 63, 906, 2524, 5296, 275, 10868, 199, 4283, 63, 10439, 51, 221, 275, 221, 1695, 199, 199, 533, 13423, 2681, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1680, 12, 2974, 12, 2166, 29, 16, 304, 267, 340, 730, 8, 1273, 9, 508, 11388, 19, 70, 26, 288, 2974, 275, 3842, 1053, 14, 362, 63, 3556, 1062, 1242, 9, 367, 1242, 315, 2974, 61, 288, 3914, 275, 769, 8, 1273, 9, 627, 499, 288, 367, 1242, 315, 2974, 26, 355, 367, 1335, 315, 1425, 8, 22, 304, 490, 340, 334, 3556, 59, 74, 61, 690, 1242, 59, 16, 1527, 74, 566, 7167, 334, 74, 690, 499, 304, 717, 3914, 59, 74, 61, 275, 1242, 59, 16, 1527, 74, 61, 288, 1568, 275, 1390, 8, 513, 8, 3646, 19, 70, 8, 3556, 59, 19, 26, 22, 566, 446, 11388, 19, 70, 8, 3556, 59, 16, 26, 19, 11845, 288, 291, 14, 3556, 275, 3914, 59, 16, 26, 19, 61, 435, 769, 8, 3646, 19, 70, 8, 3556, 59, 19, 26, 22, 61, 355, 7092, 3995, 311, 379, 8, 3646, 19, 70, 8, 3556, 59, 16, 26, 19, 566, 435, 11388, 19, 70, 8, 890, 395, 9141, 430, 267, 587, 26, 288, 291, 14, 3556, 275, 1680, 267, 291, 14, 374, 63, 4694, 275, 822, 8, 1744, 9, 690, 9141, 63, 10439, 51, 436, 2166, 665, 9141, 63, 906, 2524, 5296, 446, 413, 267, 340, 291, 14, 374, 63, 4694, 26, 288, 1894, 17, 275, 378, 288, 291, 14, 4106, 275, 359, 403, 61, 627, 1695, 288, 367, 308, 315, 1425, 8, 24, 304, 355, 1007, 63, 3556, 275, 942, 355, 367, 1335, 315, 1425, 8, 22, 304, 490, 333, 275, 1335, 450, 650, 490, 340, 20337, 83, 4331, 333, 9, 1253, 413, 9, 1137, 378, 9, 7167, 334, 74, 690, 499, 304, 717, 1007, 63, 3556, 14, 740, 1332, 277, 14, 3556, 59, 77, 61, 435, 291, 14, 3556, 59, 77, 435, 650, 566, 627, 1169, 378, 14, 21, 9, 490, 587, 26, 717, 1007, 63, 3556, 14, 740, 8, 277, 14, 3556, 59, 74, 566, 355, 1007, 63, 1744, 275, 942, 355, 367, 1242, 315, 2974, 26, 490, 1242, 63, 3556, 275, 1242, 59, 16, 61, 490, 340, 1242, 63, 3556, 59, 19, 61, 2356, 1007, 63, 3556, 59, 16, 61, 436, 971, 2432, 1242, 63, 3556, 59, 16, 61, 665, 1007, 63, 3556, 59, 19, 61, 436, 971, 2432, 1242, 63, 3556, 59, 20, 61, 2356, 1007, 63, 3556, 59, 17, 61, 436, 971, 2432, 1242, 63, 3556, 59, 17, 61, 665, 1007, 63, 3556, 59, 20, 61, 436, 971, 2432, 1242, 63, 3556, 59, 21, 61, 2356, 1007, 63, 3556, 59, 18, 61, 436, 971, 2432, 1242, 63, 3556, 59, 18, 61, 665, 1007, 63, 3556, 59, 21, 2189, 2574, 1007, 63, 1744, 14, 740, 8, 1053, 9, 355, 1894, 17, 847, 413, 340, 822, 8, 954, 63, 1744, 9, 508, 822, 8, 1744, 9, 587, 378, 355, 1894, 18, 275, 334, 954, 63, 3556, 59, 19, 61, 446, 1007, 63, 3556, 59, 16, 566, 665, 334, 52, 2228, 540, 7140, 627, 841, 14, 16, 9, 355, 340, 822, 8, 954, 63, 1744, 9, 690, 378, 26, 490, 291, 14, 4106, 59, 83, 61, 275, 13423, 2681, 8, 954, 63, 3556, 12, 1007, 63, 1744, 12, 717, 9141, 63, 906, 2524, 5296, 340, 1894, 17, 690, 413, 503, 1894, 18, 587, 2166, 435, 413, 9, 267, 587, 26, 288, 291, 14, 4106, 275, 359, 1053, 59, 17, 61, 367, 1242, 315, 2974, 61, 339, 347, 664, 63, 12569, 8, 277, 12, 22059, 63, 6493, 12, 22059, 63, 6874, 12, 2061, 63, 12948, 12, 1343, 29, 403, 304, 267, 1343, 275, 1343, 340, 1343, 587, 22059, 63, 6493, 267, 9793, 63, 785, 275, 9793, 63, 3124, 275, 488, 267, 340, 291, 14, 374, 63, 4694, 26, 288, 1007, 63, 3890, 275, 413, 340, 1343, 59, 16, 61, 2356, 334, 277, 14, 3556, 59, 16, 61, 435, 291, 14, 3556, 59, 19, 566, 627, 378, 14, 21, 971, 355, 587, 378, 288, 340, 1343, 59, 17, 61, 2356, 334, 277, 14, 3556, 59, 17, 61, 435, 291, 14, 3556, 59, 20, 566, 627, 378, 14, 21, 26, 355, 1007, 63, 3890, 8901, 499, 288, 340, 1343, 59, 18, 61, 2356, 334, 277, 14, 3556, 59, 18, 61, 435, 291, 14, 3556, 59, 21, 566, 627, 378, 14, 21, 26, 355, 1007, 63, 3890, 8901, 841, 288, 4917, 63, 3124, 275, 1343, 288, 1830, 715, 26, 355, 340, 291, 14, 4106, 59, 954, 63, 3890, 2189, 490, 9793, 63, 785, 12, 9793, 63, 3124, 275, 291, 14, 4106, 59, 954, 63, 3890, 717, 221, 1055, 362, 63, 12569, 8, 803, 63, 6493, 12, 22059, 63, 6874, 12, 2061, 63, 12948, 12, 717, 4917, 63, 3124, 9, 490, 340, 9793, 63, 785, 26, 717, 2059, 355, 3650, 275, 2069, 8, 18, 538, 7727, 446, 499, 538, 27622, 9, 355, 3114, 275, 378, 355, 367, 284, 315, 1425, 8, 19, 304, 490, 4721, 275, 334, 954, 63, 3890, 4331, 284, 9, 1253, 413, 490, 8870, 275, 291, 14, 3556, 59, 73, 435, 4721, 627, 650, 61, 340, 334, 803, 63, 6874, 59, 73, 61, 665, 378, 14, 16, 717, 776, 7167, 334, 16, 1137, 4721, 9, 587, 334, 277, 14, 3556, 59, 73, 61, 435, 291, 14, 3556, 59, 73, 435, 650, 61, 717, 776, 627, 378, 14, 21, 490, 862, 26, 717, 6033, 275, 334, 1409, 446, 22059, 63, 6493, 59, 73, 566, 1182, 22059, 63, 6874, 59, 73, 61, 490, 871, 26, 717, 6033, 275, 2069, 8, 17, 69, 19, 993, 9, 490, 340, 6033, 2695, 3650, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
playm2mboy/edx-platform
openedx/core/djangoapps/content/course_overviews/migrations/0004_default_lowest_passing_grade_to_None.py
62
3157
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'CourseOverview.lowest_passing_grade' db.alter_column('course_overviews_courseoverview', 'lowest_passing_grade', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=5, decimal_places=2)) def backwards(self, orm): # Changing field 'CourseOverview.lowest_passing_grade' db.alter_column('course_overviews_courseoverview', 'lowest_passing_grade', self.gf('django.db.models.fields.DecimalField')(default=0.5, max_digits=5, decimal_places=2)) models = { 'course_overviews.courseoverview': { 'Meta': {'object_name': 'CourseOverview'}, '_location': ('xmodule_django.models.UsageKeyField', [], {'max_length': '255'}), '_pre_requisite_courses_json': ('django.db.models.fields.TextField', [], {}), 'advertised_start': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'cert_html_view_enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'cert_name_long': ('django.db.models.fields.TextField', [], {}), 'cert_name_short': ('django.db.models.fields.TextField', [], {}), 'certificates_display_behavior': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'certificates_show_before_end': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'course_image_url': ('django.db.models.fields.TextField', [], {}), 'days_early_for_beta': ('django.db.models.fields.FloatField', [], {'null': 'True'}), 'display_name': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'display_number_with_default': ('django.db.models.fields.TextField', [], {}), 'display_org_with_default': ('django.db.models.fields.TextField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'end_of_course_survey_url': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'facebook_url': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'has_any_active_web_certificate': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'primary_key': 'True', 'db_index': 'True'}), 'lowest_passing_grade': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '5', 'decimal_places': '2'}), 'mobile_available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'social_sharing_url': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'start': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'visible_to_staff_only': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['course_overviews']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 6979, 28077, 14, 674, 597, 63, 29436, 63, 4523, 7, 267, 1592, 14, 11858, 63, 2301, 360, 1972, 63, 1883, 4196, 63, 1972, 21753, 297, 283, 674, 597, 63, 29436, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 2307, 29, 549, 12, 1390, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 18, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 6979, 28077, 14, 674, 597, 63, 29436, 63, 4523, 7, 267, 1592, 14, 11858, 63, 2301, 360, 1972, 63, 1883, 4196, 63, 1972, 21753, 297, 283, 674, 597, 63, 29436, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 21, 12, 1390, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 18, 430, 339, 1709, 275, 469, 267, 283, 1972, 63, 1883, 4196, 14, 1972, 21753, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6979, 28077, 2267, 288, 2513, 1985, 356, 661, 14293, 63, 1176, 14, 992, 14, 7692, 1197, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 2513, 657, 63, 21763, 63, 11653, 63, 1001, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 24576, 939, 63, 928, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 4736, 63, 1360, 63, 1345, 63, 3827, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 4736, 63, 354, 63, 2809, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 4736, 63, 354, 63, 3612, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 16159, 63, 2918, 63, 17537, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 16159, 63, 2384, 63, 5182, 63, 500, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 1972, 63, 1569, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 4899, 63, 21423, 63, 509, 63, 5683, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 2918, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 2918, 63, 1955, 63, 1045, 63, 885, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 2918, 63, 1308, 63, 1045, 63, 885, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 500, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 500, 63, 1618, 63, 1972, 63, 10625, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 16652, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 1989, 63, 1629, 63, 2682, 63, 2520, 63, 6999, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 344, 356, 661, 14293, 63, 1176, 14, 992, 14, 18806, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 3327, 63, 498, 356, 283, 549, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 674, 597, 63, 29436, 63, 4523, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 988, 63, 7022, 356, 283, 21, 297, 283, 6355, 63, 10696, 356, 283, 18, 1604, 288, 283, 11375, 63, 4561, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 13574, 63, 29122, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 928, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 6604, 63, 475, 63, 7018, 63, 2118, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 1972, 63, 1883, 4196, 418, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 6979, 28077, 14, 674, 597, 63, 29436, 63, 4523, 7, 267, 1592, 14, 11858, 63, 2301, 360, 1972, 63, 1883, 4196, 63, 1972, 21753, 297, 283, 674, 597, 63, 29436, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 2307, 29, 549, 12, 1390, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 18, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 6979, 28077, 14, 674, 597, 63, 29436, 63, 4523, 7, 267, 1592, 14, 11858, 63, 2301, 360, 1972, 63, 1883, 4196, 63, 1972, 21753, 297, 283, 674, 597, 63, 29436, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 7533, 885, 29, 16, 14, 21, 12, 1390, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 18, 430, 339, 1709, 275, 469, 267, 283, 1972, 63, 1883, 4196, 14, 1972, 21753, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6979, 28077, 2267, 288, 2513, 1985, 356, 661, 14293, 63, 1176, 14, 992, 14, 7692, 1197, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 2513, 657, 63, 21763, 63, 11653, 63, 1001, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 24576, 939, 63, 928, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 4736, 63, 1360, 63, 1345, 63, 3827, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 4736, 63, 354, 63, 2809, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 4736, 63, 354, 63, 3612, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 16159, 63, 2918, 63, 17537, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 16159, 63, 2384, 63, 5182, 63, 500, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 1972, 63, 1569, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 4899, 63, 21423, 63, 509, 63, 5683, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 2918, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 2918, 63, 1955, 63, 1045, 63, 885, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 2918, 63, 1308, 63, 1045, 63, 885, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 8613, 288, 283, 500, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 500, 63, 1618, 63, 1972, 63, 10625, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 16652, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 1989, 63, 1629, 63, 2682, 63, 2520, 63, 6999, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 344, 356, 661, 14293, 63, 1176, 14, 992, 14, 18806, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 3327, 63, 498, 356, 283, 549, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 674, 597, 63, 29436, 63, 4523, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 15975, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 988, 63, 7022, 356, 283, 21, 297, 283, 6355, 63, 10696, 356, 283, 18, 1604, 288, 283, 11375, 63, 4561, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 13574, 63, 29122, 63, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 928, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2307, 356, 283, 549, 1604, 288, 283, 6604, 63, 475, 63, 7018, 63, 2118, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 1972, 63, 1883, 4196, 418, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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TemporaryFile, mkdtemp from shutil import rmtree from presets.presetManager import PresetException import json import os from presets.presetManager import PresetManager minimalBody = { "id": "id_test", "properties": [] } tmpDir = None def setUpModule(): global tmpDir tmpDir = mkdtemp(prefix='libreant_presets_tests') def tearDownModule(): rmtree(tmpDir) def json_tmp_file(): return NamedTemporaryFile(delete=False, dir=tmpDir, suffix=".json") def test_sigle_file(): ''' test single file loding''' file = json_tmp_file() file.write(json.dumps(minimalBody)) file.close() p = PresetManager(file.name, strict=True) assert minimalBody['id'] in p.presets def test_multiple_file(): '''test multiple file loading''' files = list() presetBodies = list() num = 5 for i in range(0, num): files.append(json_tmp_file()) presetBodies.append(minimalBody.copy()) presetBodies[i]['id'] = "id_" + str(i) files[i].write(json.dumps(presetBodies[i])) files[i].close() p = PresetManager(map(lambda x: x.name, files), strict=True) for i in range(0, num): assert presetBodies[i]['id'] in p.presets @raises(PresetException) def test_duplicate_id(): f1 = json_tmp_file() f1.write(json.dumps(minimalBody)) f1.close() f2 = json_tmp_file() f2.write(json.dumps(minimalBody)) f2.close() p = PresetManager([f1.name,f2.name], strict=True) def test_empty_path(): ''' passing empty path must not break anything ''' p = PresetManager([""]) eq_(len(p.presets), 0) @raises(PresetException) def test_not_existent(): ''' if preset file do not exists we expect an exception ''' p = PresetManager("notexistent", strict=True) def test_folders(): ''' test preset files distributed in multiple folders ''' folders = list() presetBodies = list() num = 5 for i in range(num): folders.append(mkdtemp(dir=tmpDir)) presetBodies.append(minimalBody.copy()) presetBodies[i]['id'] = "id_" + str(i) file = NamedTemporaryFile(delete=False, dir=folders[i], suffix=".json") file.write(json.dumps(presetBodies[i])) file.close() p = PresetManager(folders, strict=True) for i in range(num): assert presetBodies[i]['id'] in p.presets rmtree(folders[i], ignore_errors=True) @raises(PresetException) def test_wrong_json_format(): ''' if preset has a bad json format we expect an exception''' f = json_tmp_file() f.write("{{{{}") f.close() p = PresetManager(f.name, strict=True)
agpl-3.0
[ 2344, 199, 7768, 402, 2295, 370, 4911, 876, 409, 3792, 8697, 199, 2344, 199, 199, 504, 11354, 14, 2537, 492, 6534, 12, 3850, 63, 199, 504, 5549, 492, 31825, 12, 31781, 199, 504, 5145, 492, 20978, 199, 504, 876, 2193, 14, 25701, 2988, 492, 510, 3958, 1726, 199, 646, 2022, 199, 646, 747, 199, 504, 876, 2193, 14, 25701, 2988, 492, 510, 3958, 2988, 421, 199, 21508, 8173, 275, 469, 298, 344, 582, 298, 344, 63, 396, 401, 355, 298, 3282, 582, 942, 789, 199, 199, 2791, 3567, 275, 488, 199, 199, 318, 3613, 2377, 837, 272, 2288, 3529, 3567, 272, 3529, 3567, 275, 31781, 8, 1861, 534, 773, 264, 867, 63, 657, 2193, 63, 2219, 358, 199, 199, 318, 6766, 2377, 837, 272, 20978, 8, 2791, 3567, 9, 199, 199, 318, 2022, 63, 2791, 63, 493, 837, 272, 372, 31825, 8, 1807, 29, 797, 12, 2935, 29, 2791, 3567, 12, 4739, 25356, 1001, 531, 199, 199, 318, 511, 63, 338, 3845, 63, 493, 837, 272, 1449, 511, 2849, 570, 560, 1098, 2344, 272, 570, 275, 2022, 63, 2791, 63, 493, 342, 272, 570, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 570, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 493, 14, 354, 12, 7478, 29, 549, 9, 272, 702, 13460, 8173, 459, 344, 418, 315, 299, 14, 657, 2193, 421, 199, 318, 511, 63, 6048, 63, 493, 837, 272, 1449, 396, 3663, 570, 8697, 2344, 272, 1584, 275, 769, 342, 272, 876, 409, 2208, 18245, 275, 769, 342, 272, 1967, 275, 959, 272, 367, 284, 315, 1425, 8, 16, 12, 1967, 304, 267, 1584, 14, 740, 8, 1001, 63, 2791, 63, 493, 1012, 267, 876, 409, 2208, 18245, 14, 740, 8, 21508, 8173, 14, 1574, 1012, 267, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 275, 298, 344, 12172, 435, 620, 8, 73, 9, 267, 1584, 59, 73, 1055, 952, 8, 1001, 14, 4180, 8, 25701, 2208, 18245, 59, 73, 2459, 267, 1584, 59, 73, 1055, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 1130, 8, 2734, 671, 26, 671, 14, 354, 12, 1584, 395, 7478, 29, 549, 9, 272, 367, 284, 315, 1425, 8, 16, 12, 1967, 304, 267, 702, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 315, 299, 14, 657, 2193, 421, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 11081, 63, 344, 837, 272, 289, 17, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 17, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 289, 17, 14, 1600, 342, 272, 289, 18, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 18, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 289, 18, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 779, 70, 17, 14, 354, 12, 70, 18, 14, 354, 467, 7478, 29, 549, 9, 421, 199, 318, 511, 63, 1667, 63, 515, 837, 272, 1449, 9476, 2701, 931, 1471, 440, 2059, 7003, 1449, 272, 299, 275, 510, 3958, 2988, 779, 341, 566, 272, 3850, 2531, 552, 8, 80, 14, 657, 2193, 395, 378, 9, 421, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 1397, 63, 15025, 837, 272, 1449, 340, 876, 409, 570, 886, 440, 3495, 781, 4282, 376, 1919, 1449, 272, 299, 275, 510, 3958, 2988, 480, 889, 3858, 13298, 401, 7478, 29, 549, 9, 421, 199, 318, 511, 63, 15171, 837, 272, 1449, 511, 876, 409, 1584, 1854, 315, 3663, 16533, 1449, 272, 16533, 275, 769, 342, 272, 876, 409, 2208, 18245, 275, 769, 342, 272, 1967, 275, 959, 272, 367, 284, 315, 1425, 8, 1507, 304, 267, 16533, 14, 740, 8, 11983, 8, 694, 29, 2791, 3567, 430, 267, 876, 409, 2208, 18245, 14, 740, 8, 21508, 8173, 14, 1574, 1012, 267, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 275, 298, 344, 12172, 435, 620, 8, 73, 9, 267, 570, 275, 31825, 8, 1807, 29, 797, 12, 2935, 29, 15171, 59, 73, 467, 4739, 25356, 1001, 531, 267, 570, 14, 952, 8, 1001, 14, 4180, 8, 25701, 2208, 18245, 59, 73, 2459, 267, 570, 14, 1600, 342, 339, 299, 275, 510, 3958, 2988, 8, 15171, 12, 7478, 29, 549, 9, 272, 367, 284, 315, 1425, 8, 1507, 304, 267, 702, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 315, 299, 14, 657, 2193, 267, 20978, 8, 15171, 59, 73, 467, 3686, 63, 2550, 29, 549, 9, 199, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 10603, 63, 1001, 63, 908, 837, 272, 1449, 340, 876, 409, 965, 282, 4875, 2022, 1475, 781, 4282, 376, 1919, 2344, 272, 289, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 14, 952, 480, 3638, 91, 2440, 531, 272, 289, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 70, 14, 354, 12, 7478, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 7768, 402, 2295, 370, 4911, 876, 409, 3792, 8697, 199, 2344, 199, 199, 504, 11354, 14, 2537, 492, 6534, 12, 3850, 63, 199, 504, 5549, 492, 31825, 12, 31781, 199, 504, 5145, 492, 20978, 199, 504, 876, 2193, 14, 25701, 2988, 492, 510, 3958, 1726, 199, 646, 2022, 199, 646, 747, 199, 504, 876, 2193, 14, 25701, 2988, 492, 510, 3958, 2988, 421, 199, 21508, 8173, 275, 469, 298, 344, 582, 298, 344, 63, 396, 401, 355, 298, 3282, 582, 942, 789, 199, 199, 2791, 3567, 275, 488, 199, 199, 318, 3613, 2377, 837, 272, 2288, 3529, 3567, 272, 3529, 3567, 275, 31781, 8, 1861, 534, 773, 264, 867, 63, 657, 2193, 63, 2219, 358, 199, 199, 318, 6766, 2377, 837, 272, 20978, 8, 2791, 3567, 9, 199, 199, 318, 2022, 63, 2791, 63, 493, 837, 272, 372, 31825, 8, 1807, 29, 797, 12, 2935, 29, 2791, 3567, 12, 4739, 25356, 1001, 531, 199, 199, 318, 511, 63, 338, 3845, 63, 493, 837, 272, 1449, 511, 2849, 570, 560, 1098, 2344, 272, 570, 275, 2022, 63, 2791, 63, 493, 342, 272, 570, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 570, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 493, 14, 354, 12, 7478, 29, 549, 9, 272, 702, 13460, 8173, 459, 344, 418, 315, 299, 14, 657, 2193, 421, 199, 318, 511, 63, 6048, 63, 493, 837, 272, 1449, 396, 3663, 570, 8697, 2344, 272, 1584, 275, 769, 342, 272, 876, 409, 2208, 18245, 275, 769, 342, 272, 1967, 275, 959, 272, 367, 284, 315, 1425, 8, 16, 12, 1967, 304, 267, 1584, 14, 740, 8, 1001, 63, 2791, 63, 493, 1012, 267, 876, 409, 2208, 18245, 14, 740, 8, 21508, 8173, 14, 1574, 1012, 267, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 275, 298, 344, 12172, 435, 620, 8, 73, 9, 267, 1584, 59, 73, 1055, 952, 8, 1001, 14, 4180, 8, 25701, 2208, 18245, 59, 73, 2459, 267, 1584, 59, 73, 1055, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 1130, 8, 2734, 671, 26, 671, 14, 354, 12, 1584, 395, 7478, 29, 549, 9, 272, 367, 284, 315, 1425, 8, 16, 12, 1967, 304, 267, 702, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 315, 299, 14, 657, 2193, 421, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 11081, 63, 344, 837, 272, 289, 17, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 17, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 289, 17, 14, 1600, 342, 272, 289, 18, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 18, 14, 952, 8, 1001, 14, 4180, 8, 21508, 8173, 430, 272, 289, 18, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 779, 70, 17, 14, 354, 12, 70, 18, 14, 354, 467, 7478, 29, 549, 9, 421, 199, 318, 511, 63, 1667, 63, 515, 837, 272, 1449, 9476, 2701, 931, 1471, 440, 2059, 7003, 1449, 272, 299, 275, 510, 3958, 2988, 779, 341, 566, 272, 3850, 2531, 552, 8, 80, 14, 657, 2193, 395, 378, 9, 421, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 1397, 63, 15025, 837, 272, 1449, 340, 876, 409, 570, 886, 440, 3495, 781, 4282, 376, 1919, 1449, 272, 299, 275, 510, 3958, 2988, 480, 889, 3858, 13298, 401, 7478, 29, 549, 9, 421, 199, 318, 511, 63, 15171, 837, 272, 1449, 511, 876, 409, 1584, 1854, 315, 3663, 16533, 1449, 272, 16533, 275, 769, 342, 272, 876, 409, 2208, 18245, 275, 769, 342, 272, 1967, 275, 959, 272, 367, 284, 315, 1425, 8, 1507, 304, 267, 16533, 14, 740, 8, 11983, 8, 694, 29, 2791, 3567, 430, 267, 876, 409, 2208, 18245, 14, 740, 8, 21508, 8173, 14, 1574, 1012, 267, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 275, 298, 344, 12172, 435, 620, 8, 73, 9, 267, 570, 275, 31825, 8, 1807, 29, 797, 12, 2935, 29, 15171, 59, 73, 467, 4739, 25356, 1001, 531, 267, 570, 14, 952, 8, 1001, 14, 4180, 8, 25701, 2208, 18245, 59, 73, 2459, 267, 570, 14, 1600, 342, 339, 299, 275, 510, 3958, 2988, 8, 15171, 12, 7478, 29, 549, 9, 272, 367, 284, 315, 1425, 8, 1507, 304, 267, 702, 876, 409, 2208, 18245, 59, 73, 2733, 344, 418, 315, 299, 14, 657, 2193, 267, 20978, 8, 15171, 59, 73, 467, 3686, 63, 2550, 29, 549, 9, 199, 199, 32, 3536, 8, 2398, 409, 1726, 9, 199, 318, 511, 63, 10603, 63, 1001, 63, 908, 837, 272, 1449, 340, 876, 409, 965, 282, 4875, 2022, 1475, 781, 4282, 376, 1919, 2344, 272, 289, 275, 2022, 63, 2791, 63, 493, 342, 272, 289, 14, 952, 480, 3638, 91, 2440, 531, 272, 289, 14, 1600, 342, 272, 299, 275, 510, 3958, 2988, 8, 70, 14, 354, 12, 7478, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Spredzy/dci-ansible
modules/dci_new_job.py
1
3559
#!/usr/bin/python # 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 ansible.module_utils.basic import * import os from dciclient.v1.api import context as dci_context from dciclient.v1.api import job as dci_job from dciclient.v1.api import remoteci as dci_remoteci from dciclient.v1.api import topic as dci_topic try: import requests except ImportError: requests_found = False else: requests_found = True DOCUMENTATION = ''' --- module: dci_new_job short_description: An ansible module to schedule a new job with DCI version_added: 2.2 options: login: required: false description: User's DCI login password: required: false description: User's DCI password url: required: false description: DCI Control Server URL topic: required: false description: Topic's to get a job to remoteci: required: true description: RemoteCI to get a job for ''' EXAMPLES = ''' - name: Schedule a new job for DCI dci_new_job: login: john.doe password: 4r4nd0mP4ss topic: RDO-Ocata remoteci: dci-env-ovb1 - name: Schedule a new job for DCI dci_new_job: topic: OSP-8 remoteci: dci-env-ovb1 ''' # TODO RETURN = ''' ''' def get_details(module): """Method that retrieves the appropriate credentials. """ login_list = [module.params['login'], os.getenv('DCI_LOGIN')] login = next((item for item in login_list if item is not None), None) password_list = [module.params['password'], os.getenv('DCI_PASSWORD')] password = next((item for item in password_list if item is not None), None) url_list = [module.params['url'], os.getenv('DCI_CS_URL')] url = next((item for item in url_list if item is not None), 'https://api.distributed-ci.io') return login, password, url def main(): module = AnsibleModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), login=dict(required=False, type='str'), password=dict(required=False, type='str'), topic=dict(required=False, type='str'), remoteci=dict(type='str'), url=dict(required=False, type='str'), ), ) if not requests_found: module.fail_json(msg='The python requests module is required') topic_list = [module.params['topic'], os.getenv('DCI_TOPIC')] topic = next((item for item in topic_list if item is not None), None) login, password, url = get_details(module) if not login or not password: module.fail_json(msg='login and/or password have not been specified') ctx = dci_context.build_dci_context(url, login, password, 'ansible') topic_id = dci_topic.get(ctx, topic).json()['topic']['id'] remoteci = dci_remoteci.get(ctx, module.params['remoteci']).json() remoteci_id = remoteci['remoteci']['id'] dci_job.schedule(ctx, remoteci_id, topic_id=topic_id) jb = dci_job.get_full_data(ctx, ctx.last_job_id) jb['job_id'] = ctx.last_job_id module.exit_json(**jb) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 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, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 646, 747, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 1067, 465, 366, 559, 63, 1100, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 3906, 465, 366, 559, 63, 2423, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 3982, 559, 465, 366, 559, 63, 3846, 559, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 7482, 465, 366, 559, 63, 5746, 199, 199, 893, 26, 272, 492, 4145, 199, 2590, 3545, 26, 272, 4145, 63, 4214, 275, 756, 199, 2836, 26, 272, 4145, 63, 4214, 275, 715, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 366, 559, 63, 1222, 63, 2423, 199, 3612, 63, 1802, 26, 1626, 3242, 859, 370, 8732, 282, 892, 3906, 543, 577, 3553, 199, 1023, 63, 3270, 26, 499, 14, 18, 199, 1419, 26, 523, 4676, 26, 272, 1415, 26, 3055, 272, 1369, 26, 2876, 1159, 577, 3553, 4676, 523, 2505, 26, 272, 1415, 26, 3055, 272, 1369, 26, 2876, 1159, 577, 3553, 2505, 523, 1166, 26, 272, 1415, 26, 3055, 272, 1369, 26, 577, 3553, 8612, 7146, 2851, 523, 7482, 26, 272, 1415, 26, 3055, 272, 1369, 26, 32166, 1159, 370, 664, 282, 3906, 370, 523, 3982, 559, 26, 272, 1415, 26, 2549, 272, 1369, 26, 17283, 3553, 370, 664, 282, 3906, 367, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 24317, 282, 892, 3906, 367, 577, 3553, 523, 366, 559, 63, 1222, 63, 2423, 26, 272, 4676, 26, 5225, 6164, 14, 1117, 69, 272, 2505, 26, 841, 82, 20, 977, 16, 77, 48, 20, 385, 272, 7482, 26, 820, 1649, 13, 16184, 419, 272, 3982, 559, 26, 366, 559, 13, 1813, 13, 8822, 66, 17, 199, 199, 13, 536, 26, 24317, 282, 892, 3906, 367, 577, 3553, 523, 366, 559, 63, 1222, 63, 2423, 26, 272, 7482, 26, 4403, 48, 13, 24, 272, 3982, 559, 26, 366, 559, 13, 1813, 13, 8822, 66, 17, 199, 2344, 199, 199, 3, 3254, 199, 9677, 275, 1449, 199, 2344, 421, 199, 318, 664, 63, 5087, 8, 578, 304, 272, 408, 3767, 626, 9619, 2310, 314, 5827, 6235, 14, 408, 339, 4676, 63, 513, 275, 359, 578, 14, 1162, 459, 2886, 995, 747, 14, 12959, 360, 36, 3553, 63, 17208, 5440, 272, 4676, 275, 2163, 1332, 1053, 367, 1242, 315, 4676, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 2505, 63, 513, 275, 359, 578, 14, 1162, 459, 2060, 995, 747, 14, 12959, 360, 36, 3553, 63, 9032, 5440, 272, 2505, 275, 2163, 1332, 1053, 367, 1242, 315, 2505, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 1166, 63, 513, 275, 359, 578, 14, 1162, 459, 633, 995, 747, 14, 12959, 360, 36, 3553, 63, 3298, 63, 2632, 5440, 272, 1166, 275, 2163, 1332, 1053, 367, 1242, 315, 1166, 63, 513, 340, 1242, 365, 440, 488, 395, 283, 2859, 921, 1246, 14, 16832, 13, 559, 14, 2308, 358, 339, 372, 4676, 12, 2505, 12, 1166, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 995, 730, 534, 495, 659, 288, 4676, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 2505, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 7482, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 3982, 559, 29, 807, 8, 466, 534, 495, 659, 288, 1166, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 267, 2318, 272, 776, 339, 340, 440, 4145, 63, 4214, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 1918, 2366, 4145, 859, 365, 1415, 358, 339, 7482, 63, 513, 275, 359, 578, 14, 1162, 459, 5746, 995, 747, 14, 12959, 360, 36, 3553, 63, 23740, 5440, 272, 7482, 275, 2163, 1332, 1053, 367, 1242, 315, 7482, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 4676, 12, 2505, 12, 1166, 275, 664, 63, 5087, 8, 578, 9, 272, 340, 440, 4676, 503, 440, 2505, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 2886, 436, 15, 269, 2505, 1172, 440, 2757, 2013, 358, 339, 4027, 275, 366, 559, 63, 1100, 14, 1506, 63, 68, 559, 63, 1100, 8, 633, 12, 4676, 12, 2505, 12, 283, 4853, 358, 339, 7482, 63, 344, 275, 366, 559, 63, 5746, 14, 362, 8, 3799, 12, 7482, 680, 1001, 12047, 5746, 2545, 344, 418, 272, 3982, 559, 275, 366, 559, 63, 3846, 559, 14, 362, 8, 3799, 12, 859, 14, 1162, 459, 3846, 559, 13227, 1001, 342, 272, 3982, 559, 63, 344, 275, 3982, 559, 459, 3846, 559, 2545, 344, 418, 339, 366, 559, 63, 2423, 14, 7211, 8, 3799, 12, 3982, 559, 63, 344, 12, 7482, 63, 344, 29, 5746, 63, 344, 9, 272, 1335, 66, 275, 366, 559, 63, 2423, 14, 362, 63, 2861, 63, 576, 8, 3799, 12, 4027, 14, 2019, 63, 2423, 63, 344, 9, 272, 1335, 66, 459, 2423, 63, 344, 418, 275, 4027, 14, 2019, 63, 2423, 63, 344, 339, 859, 14, 2224, 63, 1001, 3682, 26257, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342 ]
[ 2647, 15, 1393, 15, 1548, 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, 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, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 646, 747, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 1067, 465, 366, 559, 63, 1100, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 3906, 465, 366, 559, 63, 2423, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 3982, 559, 465, 366, 559, 63, 3846, 559, 199, 504, 12326, 530, 864, 14, 86, 17, 14, 1246, 492, 7482, 465, 366, 559, 63, 5746, 199, 199, 893, 26, 272, 492, 4145, 199, 2590, 3545, 26, 272, 4145, 63, 4214, 275, 756, 199, 2836, 26, 272, 4145, 63, 4214, 275, 715, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 366, 559, 63, 1222, 63, 2423, 199, 3612, 63, 1802, 26, 1626, 3242, 859, 370, 8732, 282, 892, 3906, 543, 577, 3553, 199, 1023, 63, 3270, 26, 499, 14, 18, 199, 1419, 26, 523, 4676, 26, 272, 1415, 26, 3055, 272, 1369, 26, 2876, 1159, 577, 3553, 4676, 523, 2505, 26, 272, 1415, 26, 3055, 272, 1369, 26, 2876, 1159, 577, 3553, 2505, 523, 1166, 26, 272, 1415, 26, 3055, 272, 1369, 26, 577, 3553, 8612, 7146, 2851, 523, 7482, 26, 272, 1415, 26, 3055, 272, 1369, 26, 32166, 1159, 370, 664, 282, 3906, 370, 523, 3982, 559, 26, 272, 1415, 26, 2549, 272, 1369, 26, 17283, 3553, 370, 664, 282, 3906, 367, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 24317, 282, 892, 3906, 367, 577, 3553, 523, 366, 559, 63, 1222, 63, 2423, 26, 272, 4676, 26, 5225, 6164, 14, 1117, 69, 272, 2505, 26, 841, 82, 20, 977, 16, 77, 48, 20, 385, 272, 7482, 26, 820, 1649, 13, 16184, 419, 272, 3982, 559, 26, 366, 559, 13, 1813, 13, 8822, 66, 17, 199, 199, 13, 536, 26, 24317, 282, 892, 3906, 367, 577, 3553, 523, 366, 559, 63, 1222, 63, 2423, 26, 272, 7482, 26, 4403, 48, 13, 24, 272, 3982, 559, 26, 366, 559, 13, 1813, 13, 8822, 66, 17, 199, 2344, 199, 199, 3, 3254, 199, 9677, 275, 1449, 199, 2344, 421, 199, 318, 664, 63, 5087, 8, 578, 304, 272, 408, 3767, 626, 9619, 2310, 314, 5827, 6235, 14, 408, 339, 4676, 63, 513, 275, 359, 578, 14, 1162, 459, 2886, 995, 747, 14, 12959, 360, 36, 3553, 63, 17208, 5440, 272, 4676, 275, 2163, 1332, 1053, 367, 1242, 315, 4676, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 2505, 63, 513, 275, 359, 578, 14, 1162, 459, 2060, 995, 747, 14, 12959, 360, 36, 3553, 63, 9032, 5440, 272, 2505, 275, 2163, 1332, 1053, 367, 1242, 315, 2505, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 1166, 63, 513, 275, 359, 578, 14, 1162, 459, 633, 995, 747, 14, 12959, 360, 36, 3553, 63, 3298, 63, 2632, 5440, 272, 1166, 275, 2163, 1332, 1053, 367, 1242, 315, 1166, 63, 513, 340, 1242, 365, 440, 488, 395, 283, 2859, 921, 1246, 14, 16832, 13, 559, 14, 2308, 358, 339, 372, 4676, 12, 2505, 12, 1166, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 995, 730, 534, 495, 659, 288, 4676, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 2505, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 7482, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 3982, 559, 29, 807, 8, 466, 534, 495, 659, 288, 1166, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 267, 2318, 272, 776, 339, 340, 440, 4145, 63, 4214, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 1918, 2366, 4145, 859, 365, 1415, 358, 339, 7482, 63, 513, 275, 359, 578, 14, 1162, 459, 5746, 995, 747, 14, 12959, 360, 36, 3553, 63, 23740, 5440, 272, 7482, 275, 2163, 1332, 1053, 367, 1242, 315, 7482, 63, 513, 340, 1242, 365, 440, 488, 395, 488, 9, 339, 4676, 12, 2505, 12, 1166, 275, 664, 63, 5087, 8, 578, 9, 272, 340, 440, 4676, 503, 440, 2505, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 2886, 436, 15, 269, 2505, 1172, 440, 2757, 2013, 358, 339, 4027, 275, 366, 559, 63, 1100, 14, 1506, 63, 68, 559, 63, 1100, 8, 633, 12, 4676, 12, 2505, 12, 283, 4853, 358, 339, 7482, 63, 344, 275, 366, 559, 63, 5746, 14, 362, 8, 3799, 12, 7482, 680, 1001, 12047, 5746, 2545, 344, 418, 272, 3982, 559, 275, 366, 559, 63, 3846, 559, 14, 362, 8, 3799, 12, 859, 14, 1162, 459, 3846, 559, 13227, 1001, 342, 272, 3982, 559, 63, 344, 275, 3982, 559, 459, 3846, 559, 2545, 344, 418, 339, 366, 559, 63, 2423, 14, 7211, 8, 3799, 12, 3982, 559, 63, 344, 12, 7482, 63, 344, 29, 5746, 63, 344, 9, 272, 1335, 66, 275, 366, 559, 63, 2423, 14, 362, 63, 2861, 63, 576, 8, 3799, 12, 4027, 14, 2019, 63, 2423, 63, 344, 9, 272, 1335, 66, 459, 2423, 63, 344, 418, 275, 4027, 14, 2019, 63, 2423, 63, 344, 339, 859, 14, 2224, 63, 1001, 3682, 26257, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kapt/django-oscar
oscar/apps/catalogue/south_migrations/0008_auto__add_unique_option_code.py
18
13043
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding unique constraint on 'Option', fields ['code'] db.create_unique('catalogue_option', ['code']) def backwards(self, orm): # Removing unique constraint on 'Option', fields ['code'] db.delete_unique('catalogue_option', ['code']) models = { 'catalogue.attributeentity': { 'Meta': {'object_name': 'AttributeEntity'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'entities'", 'to': "orm['catalogue.AttributeEntityType']"}) }, 'catalogue.attributeentitytype': { 'Meta': {'object_name': 'AttributeEntityType'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}) }, 'catalogue.attributeoption': { 'Meta': {'object_name': 'AttributeOption'}, 'group': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'options'", 'to': "orm['catalogue.AttributeOptionGroup']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'option': ('django.db.models.fields.CharField', [], {'max_length': '255'}) }, 'catalogue.attributeoptiongroup': { 'Meta': {'object_name': 'AttributeOptionGroup'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}) }, 'catalogue.category': { 'Meta': {'ordering': "['full_name']", 'object_name': 'Category'}, 'depth': ('django.db.models.fields.PositiveIntegerField', [], {}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), 'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}) }, 'catalogue.contributor': { 'Meta': {'object_name': 'Contributor'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}) }, 'catalogue.contributorrole': { 'Meta': {'object_name': 'ContributorRole'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'name_plural': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}) }, 'catalogue.option': { 'Meta': {'object_name': 'Option'}, 'code': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'type': ('django.db.models.fields.CharField', [], {'default': "'Required'", 'max_length': '128'}) }, 'catalogue.product': { 'Meta': {'ordering': "['-date_created']", 'object_name': 'Product'}, 'attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.ProductAttribute']", 'through': "orm['catalogue.ProductAttributeValue']", 'symmetrical': 'False'}), 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Category']", 'through': "orm['catalogue.ProductCategory']", 'symmetrical': 'False'}), 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'date_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_discountable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'variants'", 'null': 'True', 'to': "orm['catalogue.Product']"}), 'product_class': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.ProductClass']", 'null': 'True'}), 'product_options': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Option']", 'symmetrical': 'False', 'blank': 'True'}), 'recommended_products': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Product']", 'symmetrical': 'False', 'through': "orm['catalogue.ProductRecommendation']", 'blank': 'True'}), 'related_products': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'relations'", 'blank': 'True', 'to': "orm['catalogue.Product']"}), 'score': ('django.db.models.fields.FloatField', [], {'default': '0.0', 'db_index': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'db_index': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'null': 'True', 'blank': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'upc': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'}) }, 'catalogue.productattribute': { 'Meta': {'ordering': "['code']", 'object_name': 'ProductAttribute'}, 'code': ('django.db.models.fields.SlugField', [], {'max_length': '128', 'db_index': 'True'}), 'entity_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeEntityType']", 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'option_group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeOptionGroup']", 'null': 'True', 'blank': 'True'}), 'product_class': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attributes'", 'null': 'True', 'to': "orm['catalogue.ProductClass']"}), 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '20'}) }, 'catalogue.productattributevalue': { 'Meta': {'object_name': 'ProductAttributeValue'}, 'attribute': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.ProductAttribute']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'product': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attribute_values'", 'to': "orm['catalogue.Product']"}), 'value_boolean': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'value_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'value_entity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeEntity']", 'null': 'True', 'blank': 'True'}), 'value_float': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'value_integer': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), 'value_option': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeOption']", 'null': 'True', 'blank': 'True'}), 'value_richtext': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'value_text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) }, 'catalogue.productcategory': { 'Meta': {'ordering': "['-is_canonical']", 'object_name': 'ProductCategory'}, 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Category']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_canonical': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Product']"}) }, 'catalogue.productclass': { 'Meta': {'ordering': "['name']", 'object_name': 'ProductClass'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'options': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Option']", 'symmetrical': 'False', 'blank': 'True'}), 'requires_shipping': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}), 'track_stock': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'catalogue.productcontributor': { 'Meta': {'object_name': 'ProductContributor'}, 'contributor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Contributor']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Product']"}), 'role': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.ContributorRole']", 'null': 'True', 'blank': 'True'}) }, 'catalogue.productimage': { 'Meta': {'ordering': "['display_order']", 'unique_together': "(('product', 'display_order'),)", 'object_name': 'ProductImage'}, 'caption': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'display_order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'original': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}), 'product': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'images'", 'to': "orm['catalogue.Product']"}) }, 'catalogue.productrecommendation': { 'Meta': {'object_name': 'ProductRecommendation'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'primary': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'primary_recommendations'", 'to': "orm['catalogue.Product']"}), 'ranking': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}), 'recommendation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Product']"}) } } complete_apps = ['catalogue']
bsd-3-clause
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 3747, 5828, 641, 283, 2602, 297, 1504, 788, 600, 418, 267, 1592, 14, 981, 63, 3235, 360, 22330, 63, 1422, 297, 788, 600, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 29343, 3747, 5828, 641, 283, 2602, 297, 1504, 788, 600, 418, 267, 1592, 14, 1807, 63, 3235, 360, 22330, 63, 1422, 297, 788, 600, 1105, 2378, 1709, 275, 469, 267, 283, 22330, 14, 3215, 4502, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 7302, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 8327, 4662, 283, 475, 356, 298, 1025, 459, 22330, 14, 1646, 7302, 804, 13687, 267, 1660, 267, 283, 22330, 14, 3215, 4502, 466, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 7302, 804, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 3215, 1422, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 2602, 2267, 288, 283, 923, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 1419, 4662, 283, 475, 356, 298, 1025, 459, 22330, 14, 1646, 2602, 2448, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1422, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 3071, 267, 1660, 267, 283, 22330, 14, 3215, 1422, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 2602, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 3071, 267, 1660, 267, 283, 22330, 14, 3710, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 2861, 63, 354, 6256, 283, 785, 63, 354, 356, 283, 7841, 2267, 288, 283, 4631, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 8613, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2861, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1569, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 1725, 14, 21910, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1507, 1739, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 515, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 16833, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 714, 1925, 4139, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 16833, 3756, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 714, 1925, 4139, 7422, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 1604, 288, 283, 354, 63, 10019, 356, 661, 1176, 14, 697, 14 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 3747, 5828, 641, 283, 2602, 297, 1504, 788, 600, 418, 267, 1592, 14, 981, 63, 3235, 360, 22330, 63, 1422, 297, 788, 600, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 29343, 3747, 5828, 641, 283, 2602, 297, 1504, 788, 600, 418, 267, 1592, 14, 1807, 63, 3235, 360, 22330, 63, 1422, 297, 788, 600, 1105, 2378, 1709, 275, 469, 267, 283, 22330, 14, 3215, 4502, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 7302, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 8327, 4662, 283, 475, 356, 298, 1025, 459, 22330, 14, 1646, 7302, 804, 13687, 267, 1660, 267, 283, 22330, 14, 3215, 4502, 466, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 7302, 804, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 3215, 1422, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 2602, 2267, 288, 283, 923, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 1419, 4662, 283, 475, 356, 298, 1025, 459, 22330, 14, 1646, 2602, 2448, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1422, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 3071, 267, 1660, 267, 283, 22330, 14, 3215, 1422, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1646, 2602, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 3071, 267, 1660, 267, 283, 22330, 14, 3710, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 25280, 2861, 63, 354, 6256, 283, 785, 63, 354, 356, 283, 7841, 2267, 288, 283, 4631, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 8613, 288, 283, 1802, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2861, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1569, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 1725, 14, 21910, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1507, 1739, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 515, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 16833, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 714, 1925, 4139, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 17315, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 283, 22330, 14, 16833, 3756, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 714, 1925, 4139, 7422, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 1604, 288, 283, 354, 63, 10019, 356, 661, 1176, 14, 697, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
abircse06/youtube-dl
youtube_dl/extractor/yourupload.py
142
1537
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class YourUploadIE(InfoExtractor): _VALID_URL = r'''(?x)https?://(?:www\.)? (?:yourupload\.com/watch| embed\.yourupload\.com| embed\.yucache\.net )/(?P<id>[A-Za-z0-9]+) ''' _TESTS = [ { 'url': 'http://yourupload.com/watch/14i14h', 'md5': '5e2c63385454c557f97c4c4131a393cd', 'info_dict': { 'id': '14i14h', 'ext': 'mp4', 'title': 'BigBuckBunny_320x180.mp4', 'thumbnail': 're:^https?://.*\.jpe?g', } }, { 'url': 'http://embed.yourupload.com/14i14h', 'only_matching': True, }, { 'url': 'http://embed.yucache.net/14i14h?client_file_id=803349', 'only_matching': True, }, ] def _real_extract(self, url): video_id = self._match_id(url) embed_url = 'http://embed.yucache.net/{0:}'.format(video_id) webpage = self._download_webpage(embed_url, video_id) title = self._og_search_title(webpage) video_url = self._og_search_video_url(webpage) thumbnail = self._og_search_thumbnail(webpage, default=None) return { 'id': video_id, 'title': title, 'url': video_url, 'thumbnail': thumbnail, 'http_headers': { 'Referer': embed_url, }, }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 19519, 10301, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 2859, 24524, 1544, 20316, 267, 16697, 12695, 5064, 4537, 957, 15, 6821, 92, 1779, 6441, 4537, 12695, 5064, 4537, 957, 92, 1779, 6441, 4537, 16366, 1637, 4537, 846, 267, 776, 9448, 48, 28, 344, 9514, 33, 13, 13163, 13, 90, 16, 13, 25, 11896, 267, 1449, 272, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 12695, 5064, 14, 957, 15, 6821, 15, 1079, 73, 1079, 72, 297, 288, 283, 1064, 21, 356, 283, 21, 69, 18, 67, 22, 13744, 1477, 1477, 67, 18725, 70, 2576, 67, 20, 67, 20, 11780, 65, 15490, 2866, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1079, 73, 1079, 72, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 7279, 1713, 346, 34, 324, 9745, 63, 12122, 88, 7663, 14, 311, 20, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 74, 321, 31, 71, 297, 288, 789, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 6427, 14, 12695, 5064, 14, 957, 15, 1079, 73, 1079, 72, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 6427, 14, 16366, 1637, 14, 846, 15, 1079, 73, 1079, 72, 31, 1258, 63, 493, 63, 344, 29, 1257, 8425, 25, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 272, 1622, 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, 6441, 63, 633, 275, 283, 1014, 921, 6427, 14, 16366, 1637, 14, 846, 5321, 16, 26, 5285, 908, 8, 3722, 63, 344, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 6427, 63, 633, 12, 3991, 63, 344, 9, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 3991, 63, 633, 275, 291, 423, 974, 63, 1733, 63, 3722, 63, 633, 8, 12022, 9, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 12, 849, 29, 403, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 1014, 63, 2139, 356, 469, 355, 283, 28900, 356, 6441, 63, 633, 12, 288, 1660, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 19519, 10301, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 2859, 24524, 1544, 20316, 267, 16697, 12695, 5064, 4537, 957, 15, 6821, 92, 1779, 6441, 4537, 12695, 5064, 4537, 957, 92, 1779, 6441, 4537, 16366, 1637, 4537, 846, 267, 776, 9448, 48, 28, 344, 9514, 33, 13, 13163, 13, 90, 16, 13, 25, 11896, 267, 1449, 272, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 12695, 5064, 14, 957, 15, 6821, 15, 1079, 73, 1079, 72, 297, 288, 283, 1064, 21, 356, 283, 21, 69, 18, 67, 22, 13744, 1477, 1477, 67, 18725, 70, 2576, 67, 20, 67, 20, 11780, 65, 15490, 2866, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1079, 73, 1079, 72, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 7279, 1713, 346, 34, 324, 9745, 63, 12122, 88, 7663, 14, 311, 20, 297, 355, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 74, 321, 31, 71, 297, 288, 789, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 6427, 14, 12695, 5064, 14, 957, 15, 1079, 73, 1079, 72, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 6427, 14, 16366, 1637, 14, 846, 15, 1079, 73, 1079, 72, 31, 1258, 63, 493, 63, 344, 29, 1257, 8425, 25, 297, 288, 283, 2118, 63, 9467, 356, 715, 12, 267, 1660, 272, 1622, 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, 6441, 63, 633, 275, 283, 1014, 921, 6427, 14, 16366, 1637, 14, 846, 5321, 16, 26, 5285, 908, 8, 3722, 63, 344, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 6427, 63, 633, 12, 3991, 63, 344, 9, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 3991, 63, 633, 275, 291, 423, 974, 63, 1733, 63, 3722, 63, 633, 8, 12022, 9, 267, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 12, 849, 29, 403, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 1014, 63, 2139, 356, 469, 355, 283, 28900, 356, 6441, 63, 633, 12, 288, 1660, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
oinopion/django
tests/gis_tests/geos_tests/test_io.py
282
3918
from __future__ import unicode_literals import binascii import unittest from unittest import skipUnless from django.contrib.gis.geos import ( HAS_GEOS, GEOSGeometry, WKBReader, WKBWriter, WKTReader, WKTWriter, ) from django.utils.six import memoryview @skipUnless(HAS_GEOS, "Geos is required.") class GEOSIOTest(unittest.TestCase): def test01_wktreader(self): # Creating a WKTReader instance wkt_r = WKTReader() wkt = 'POINT (5 23)' # read() should return a GEOSGeometry ref = GEOSGeometry(wkt) g1 = wkt_r.read(wkt.encode()) g2 = wkt_r.read(wkt) for geom in (g1, g2): self.assertEqual(ref, geom) # Should only accept six.string_types objects. self.assertRaises(TypeError, wkt_r.read, 1) self.assertRaises(TypeError, wkt_r.read, memoryview(b'foo')) def test02_wktwriter(self): # Creating a WKTWriter instance, testing its ptr property. wkt_w = WKTWriter() self.assertRaises(TypeError, wkt_w._set_ptr, WKTReader.ptr_type()) ref = GEOSGeometry('POINT (5 23)') ref_wkt = 'POINT (5.0000000000000000 23.0000000000000000)' self.assertEqual(ref_wkt, wkt_w.write(ref).decode()) def test03_wkbreader(self): # Creating a WKBReader instance wkb_r = WKBReader() hex = b'000000000140140000000000004037000000000000' wkb = memoryview(binascii.a2b_hex(hex)) ref = GEOSGeometry(hex) # read() should return a GEOSGeometry on either a hex string or # a WKB buffer. g1 = wkb_r.read(wkb) g2 = wkb_r.read(hex) for geom in (g1, g2): self.assertEqual(ref, geom) bad_input = (1, 5.23, None, False) for bad_wkb in bad_input: self.assertRaises(TypeError, wkb_r.read, bad_wkb) def test04_wkbwriter(self): wkb_w = WKBWriter() # Representations of 'POINT (5 23)' in hex -- one normal and # the other with the byte order changed. g = GEOSGeometry('POINT (5 23)') hex1 = b'010100000000000000000014400000000000003740' wkb1 = memoryview(binascii.a2b_hex(hex1)) hex2 = b'000000000140140000000000004037000000000000' wkb2 = memoryview(binascii.a2b_hex(hex2)) self.assertEqual(hex1, wkb_w.write_hex(g)) self.assertEqual(wkb1, wkb_w.write(g)) # Ensuring bad byteorders are not accepted. for bad_byteorder in (-1, 2, 523, 'foo', None): # Equivalent of `wkb_w.byteorder = bad_byteorder` self.assertRaises(ValueError, wkb_w._set_byteorder, bad_byteorder) # Setting the byteorder to 0 (for Big Endian) wkb_w.byteorder = 0 self.assertEqual(hex2, wkb_w.write_hex(g)) self.assertEqual(wkb2, wkb_w.write(g)) # Back to Little Endian wkb_w.byteorder = 1 # Now, trying out the 3D and SRID flags. g = GEOSGeometry('POINT (5 23 17)') g.srid = 4326 hex3d = b'0101000080000000000000144000000000000037400000000000003140' wkb3d = memoryview(binascii.a2b_hex(hex3d)) hex3d_srid = b'01010000A0E6100000000000000000144000000000000037400000000000003140' wkb3d_srid = memoryview(binascii.a2b_hex(hex3d_srid)) # Ensuring bad output dimensions are not accepted for bad_outdim in (-1, 0, 1, 4, 423, 'foo', None): # Equivalent of `wkb_w.outdim = bad_outdim` self.assertRaises(ValueError, wkb_w._set_outdim, bad_outdim) # Now setting the output dimensions to be 3 wkb_w.outdim = 3 self.assertEqual(hex3d, wkb_w.write_hex(g)) self.assertEqual(wkb3d, wkb_w.write(g)) # Telling the WKBWriter to include the srid in the representation. wkb_w.srid = True self.assertEqual(hex3d_srid, wkb_w.write_hex(g)) self.assertEqual(wkb3d_srid, wkb_w.write(g))
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 14755, 199, 646, 2882, 199, 504, 2882, 492, 3372, 5524, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 334, 272, 7509, 63, 14151, 12, 21479, 12, 644, 12780, 5929, 12, 644, 12780, 6261, 12, 22561, 5929, 12, 22561, 6261, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 4174, 492, 20228, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 2090, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 614, 63, 11412, 5503, 8, 277, 304, 267, 327, 20507, 282, 22561, 5929, 1256, 267, 21992, 63, 82, 275, 22561, 5929, 342, 267, 21992, 275, 283, 7217, 334, 21, 6546, 3171, 398, 327, 1586, 342, 1077, 372, 282, 21479, 267, 2984, 275, 21479, 8, 11412, 9, 267, 486, 17, 275, 21992, 63, 82, 14, 739, 8, 11412, 14, 2143, 1012, 267, 486, 18, 275, 21992, 63, 82, 14, 739, 8, 11412, 9, 398, 367, 9671, 315, 334, 71, 17, 12, 486, 18, 304, 288, 291, 14, 629, 8, 1121, 12, 9671, 9, 398, 327, 7719, 1454, 4729, 3816, 14, 875, 63, 1313, 2251, 14, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 82, 14, 739, 12, 413, 9, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 82, 14, 739, 12, 20228, 8, 66, 7, 1421, 1333, 339, 347, 511, 996, 63, 11412, 5491, 8, 277, 304, 267, 327, 20507, 282, 22561, 6261, 1256, 12, 5343, 2399, 12448, 3324, 14, 267, 21992, 63, 87, 275, 22561, 6261, 342, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 87, 423, 409, 63, 4695, 12, 22561, 5929, 14, 4695, 63, 466, 1012, 398, 2984, 275, 21479, 360, 7217, 334, 21, 6546, 5942, 267, 2984, 63, 11412, 275, 283, 7217, 334, 21, 14, 9409, 6546, 14, 9409, 3171, 267, 291, 14, 629, 8, 1121, 63, 11412, 12, 21992, 63, 87, 14, 952, 8, 1121, 680, 2708, 1012, 339, 347, 511, 1644, 63, 18914, 5503, 8, 277, 304, 267, 327, 20507, 282, 644, 12780, 5929, 1256, 267, 24249, 63, 82, 275, 644, 12780, 5929, 342, 398, 6318, 275, 330, 7, 3607, 614, 8854, 20, 15672, 2167, 1401, 15672, 7, 267, 24249, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 430, 267, 2984, 275, 21479, 8, 4097, 9, 398, 327, 1586, 342, 1077, 372, 282, 21479, 641, 1902, 282, 6318, 1059, 503, 267, 327, 282, 644, 12780, 3335, 14, 267, 486, 17, 275, 24249, 63, 82, 14, 739, 8, 18914, 9, 267, 486, 18, 275, 24249, 63, 82, 14, 739, 8, 4097, 9, 267, 367, 9671, 315, 334, 71, 17, 12, 486, 18, 304, 288, 291, 14, 629, 8, 1121, 12, 9671, 9, 398, 4875, 63, 1210, 275, 334, 17, 12, 959, 14, 1789, 12, 488, 12, 756, 9, 267, 367, 4875, 63, 18914, 315, 4875, 63, 1210, 26, 288, 291, 14, 1855, 8, 4333, 12, 24249, 63, 82, 14, 739, 12, 4875, 63, 18914, 9, 339, 347, 511, 966, 63, 18914, 5491, 8, 277, 304, 267, 24249, 63, 87, 275, 644, 12780, 6261, 342, 398, 327, 17634, 1298, 402, 283, 7217, 334, 21, 6546, 3171, 315, 6318, 1553, 1373, 3293, 436, 267, 327, 314, 1163, 543, 314, 3696, 1865, 2896, 14, 267, 486, 275, 21479, 360, 7217, 334, 21, 6546, 5942, 267, 6318, 17, 275, 330, 7, 11502, 15672, 3273, 9862, 15672, 1644, 17702, 7, 267, 24249, 17, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 17, 430, 267, 6318, 18, 275, 330, 7, 3607, 614, 8854, 20, 15672, 2167, 1401, 15672, 7, 267, 24249, 18, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 18, 430, 398, 291, 14, 629, 8, 4097, 17, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 17, 12, 24249, 63, 87, 14, 952, 8, 71, 430, 398, 327, 23312, 4039, 4875, 3696, 14387, 787, 440, 10226, 14, 267, 367, 4875, 63, 19415, 315, 5868, 17, 12, 499, 12, 959, 1789, 12, 283, 1421, 297, 488, 304, 288, 327, 24228, 402, 658, 18914, 63, 87, 14, 19415, 275, 4875, 63, 19415, 64, 288, 291, 14, 1855, 8, 3393, 12, 24249, 63, 87, 423, 409, 63, 19415, 12, 4875, 63, 19415, 9, 398, 327, 13510, 314, 30310, 370, 378, 334, 509, 13123, 3447, 6268, 9, 267, 24249, 63, 87, 14, 19415, 275, 378, 267, 291, 14, 629, 8, 4097, 18, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 18, 12, 24249, 63, 87, 14, 952, 8, 71, 430, 398, 327, 10257, 370, 491, 390, 1118, 3447, 6268, 267, 24249, 63, 87, 14, 19415, 275, 413, 398, 327, 7356, 12, 9936, 734, 314, 650, 36, 436, 22425, 3285, 14, 267, 486, 275, 21479, 360, 7217, 334, 21, 6546, 5557, 5942, 267, 486, 14, 10498, 275, 26719, 398, 6318, 19, 68, 275, 330, 7, 11502, 993, 24, 15672, 30826, 15672, 1644, 1342, 15672, 1644, 10037, 7, 267, 24249, 19, 68, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 19, 68, 430, 267, 6318, 19, 68, 63, 10498, 275, 330, 7, 11502, 993, 33, 16, 37, 2976, 9409, 30826, 15672, 1644, 1342, 15672, 1644, 10037, 7, 267, 24249, 19, 68, 63, 10498, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 19, 68, 63, 10498, 430, 398, 327, 23312, 4039, 4875, 1072, 7365, 787, 440, 10226, 267, 367, 4875, 63, 548, 3572, 315, 5868, 17, 12, 378, 12, 413, 12, 841, 12, 841, 1789, 12, 283, 1421, 297, 488, 304, 288, 327, 24228, 402, 658, 18914, 63, 87, 14, 548, 3572, 275, 4875, 63, 548, 3572, 64, 288, 291, 14, 1855, 8, 3393, 12, 24249, 63, 87, 423, 409, 63, 548, 3572, 12, 4875, 63, 548, 3572, 9, 398, 327, 7356, 4260, 314, 1072, 7365, 370, 506, 650, 267, 24249, 63, 87, 14, 548, 3572, 275, 650, 398, 291, 14, 629, 8, 4097, 19, 68, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 19, 68, 12, 24249, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 14755, 199, 646, 2882, 199, 504, 2882, 492, 3372, 5524, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 334, 272, 7509, 63, 14151, 12, 21479, 12, 644, 12780, 5929, 12, 644, 12780, 6261, 12, 22561, 5929, 12, 22561, 6261, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 4174, 492, 20228, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 2090, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 614, 63, 11412, 5503, 8, 277, 304, 267, 327, 20507, 282, 22561, 5929, 1256, 267, 21992, 63, 82, 275, 22561, 5929, 342, 267, 21992, 275, 283, 7217, 334, 21, 6546, 3171, 398, 327, 1586, 342, 1077, 372, 282, 21479, 267, 2984, 275, 21479, 8, 11412, 9, 267, 486, 17, 275, 21992, 63, 82, 14, 739, 8, 11412, 14, 2143, 1012, 267, 486, 18, 275, 21992, 63, 82, 14, 739, 8, 11412, 9, 398, 367, 9671, 315, 334, 71, 17, 12, 486, 18, 304, 288, 291, 14, 629, 8, 1121, 12, 9671, 9, 398, 327, 7719, 1454, 4729, 3816, 14, 875, 63, 1313, 2251, 14, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 82, 14, 739, 12, 413, 9, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 82, 14, 739, 12, 20228, 8, 66, 7, 1421, 1333, 339, 347, 511, 996, 63, 11412, 5491, 8, 277, 304, 267, 327, 20507, 282, 22561, 6261, 1256, 12, 5343, 2399, 12448, 3324, 14, 267, 21992, 63, 87, 275, 22561, 6261, 342, 267, 291, 14, 1855, 8, 4333, 12, 21992, 63, 87, 423, 409, 63, 4695, 12, 22561, 5929, 14, 4695, 63, 466, 1012, 398, 2984, 275, 21479, 360, 7217, 334, 21, 6546, 5942, 267, 2984, 63, 11412, 275, 283, 7217, 334, 21, 14, 9409, 6546, 14, 9409, 3171, 267, 291, 14, 629, 8, 1121, 63, 11412, 12, 21992, 63, 87, 14, 952, 8, 1121, 680, 2708, 1012, 339, 347, 511, 1644, 63, 18914, 5503, 8, 277, 304, 267, 327, 20507, 282, 644, 12780, 5929, 1256, 267, 24249, 63, 82, 275, 644, 12780, 5929, 342, 398, 6318, 275, 330, 7, 3607, 614, 8854, 20, 15672, 2167, 1401, 15672, 7, 267, 24249, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 430, 267, 2984, 275, 21479, 8, 4097, 9, 398, 327, 1586, 342, 1077, 372, 282, 21479, 641, 1902, 282, 6318, 1059, 503, 267, 327, 282, 644, 12780, 3335, 14, 267, 486, 17, 275, 24249, 63, 82, 14, 739, 8, 18914, 9, 267, 486, 18, 275, 24249, 63, 82, 14, 739, 8, 4097, 9, 267, 367, 9671, 315, 334, 71, 17, 12, 486, 18, 304, 288, 291, 14, 629, 8, 1121, 12, 9671, 9, 398, 4875, 63, 1210, 275, 334, 17, 12, 959, 14, 1789, 12, 488, 12, 756, 9, 267, 367, 4875, 63, 18914, 315, 4875, 63, 1210, 26, 288, 291, 14, 1855, 8, 4333, 12, 24249, 63, 82, 14, 739, 12, 4875, 63, 18914, 9, 339, 347, 511, 966, 63, 18914, 5491, 8, 277, 304, 267, 24249, 63, 87, 275, 644, 12780, 6261, 342, 398, 327, 17634, 1298, 402, 283, 7217, 334, 21, 6546, 3171, 315, 6318, 1553, 1373, 3293, 436, 267, 327, 314, 1163, 543, 314, 3696, 1865, 2896, 14, 267, 486, 275, 21479, 360, 7217, 334, 21, 6546, 5942, 267, 6318, 17, 275, 330, 7, 11502, 15672, 3273, 9862, 15672, 1644, 17702, 7, 267, 24249, 17, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 17, 430, 267, 6318, 18, 275, 330, 7, 3607, 614, 8854, 20, 15672, 2167, 1401, 15672, 7, 267, 24249, 18, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 18, 430, 398, 291, 14, 629, 8, 4097, 17, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 17, 12, 24249, 63, 87, 14, 952, 8, 71, 430, 398, 327, 23312, 4039, 4875, 3696, 14387, 787, 440, 10226, 14, 267, 367, 4875, 63, 19415, 315, 5868, 17, 12, 499, 12, 959, 1789, 12, 283, 1421, 297, 488, 304, 288, 327, 24228, 402, 658, 18914, 63, 87, 14, 19415, 275, 4875, 63, 19415, 64, 288, 291, 14, 1855, 8, 3393, 12, 24249, 63, 87, 423, 409, 63, 19415, 12, 4875, 63, 19415, 9, 398, 327, 13510, 314, 30310, 370, 378, 334, 509, 13123, 3447, 6268, 9, 267, 24249, 63, 87, 14, 19415, 275, 378, 267, 291, 14, 629, 8, 4097, 18, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 18, 12, 24249, 63, 87, 14, 952, 8, 71, 430, 398, 327, 10257, 370, 491, 390, 1118, 3447, 6268, 267, 24249, 63, 87, 14, 19415, 275, 413, 398, 327, 7356, 12, 9936, 734, 314, 650, 36, 436, 22425, 3285, 14, 267, 486, 275, 21479, 360, 7217, 334, 21, 6546, 5557, 5942, 267, 486, 14, 10498, 275, 26719, 398, 6318, 19, 68, 275, 330, 7, 11502, 993, 24, 15672, 30826, 15672, 1644, 1342, 15672, 1644, 10037, 7, 267, 24249, 19, 68, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 19, 68, 430, 267, 6318, 19, 68, 63, 10498, 275, 330, 7, 11502, 993, 33, 16, 37, 2976, 9409, 30826, 15672, 1644, 1342, 15672, 1644, 10037, 7, 267, 24249, 19, 68, 63, 10498, 275, 20228, 8, 27460, 14, 65, 18, 66, 63, 4097, 8, 4097, 19, 68, 63, 10498, 430, 398, 327, 23312, 4039, 4875, 1072, 7365, 787, 440, 10226, 267, 367, 4875, 63, 548, 3572, 315, 5868, 17, 12, 378, 12, 413, 12, 841, 12, 841, 1789, 12, 283, 1421, 297, 488, 304, 288, 327, 24228, 402, 658, 18914, 63, 87, 14, 548, 3572, 275, 4875, 63, 548, 3572, 64, 288, 291, 14, 1855, 8, 3393, 12, 24249, 63, 87, 423, 409, 63, 548, 3572, 12, 4875, 63, 548, 3572, 9, 398, 327, 7356, 4260, 314, 1072, 7365, 370, 506, 650, 267, 24249, 63, 87, 14, 548, 3572, 275, 650, 398, 291, 14, 629, 8, 4097, 19, 68, 12, 24249, 63, 87, 14, 952, 63, 4097, 8, 71, 430, 267, 291, 14, 629, 8, 18914, 19, 68, 12, 24249, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cherifyass/android_kernel_lge_hammerhead
tools/perf/scripts/python/syscall-counts.py
11181
1522
# system call counts # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os 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 syscall_name usage = "perf script -s syscall-counts.py [comm]\n"; for_comm = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): print "%-40s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ducksboard/libsaas
test/test_pingdom.py
4
8990
import unittest from libsaas import port from libsaas.executors import test_executor from libsaas.services import base, pingdom class PingdomTestCase(unittest.TestCase): def setUp(self): self.executor = test_executor.use() self.executor.set_response(b'{}', 200, {}) self.service = pingdom.Pingdom('username', 'password', 'key') def expect(self, method=None, uri=None, params=None, headers=None): if method is not None: self.assertEqual(method, self.executor.request.method) if uri is not None: self.assertEqual(self.executor.request.uri, 'https://api.pingdom.com/api/2.0' + uri) if params is not None: self.assertEqual(self.executor.request.params, params) if headers is not None: self.assertEqual(self.executor.request.headers, headers) def test_actions(self): paging = {'limit': 100, 'offset': 50} self.service.actions().get() self.expect('GET', '/actions') self.service.actions().get(limit=100, offset=50) self.expect('GET', '/actions', paging) with port.assertRaises(base.MethodNotSupported): self.service.actions().create() self.service.actions().update() self.service.actions().delete() def test_analysis(self): paging = {'limit': 100, 'offset': 50} self.service.analysis(4).get() self.expect('GET', '/analysis/4') self.service.analysis(4).get(limit=100, offset=50) self.expect('GET', '/analysis/4', paging) self.service.analysis(4).get_raw_analysis(10) self.expect('GET', '/analysis/4/10') self.service.check(4).analysis().get(limit=100, offset=50) self.expect('GET', '/analysis/4', paging) self.service.check(4).analysis().get_raw_analysis(10) self.expect('GET', '/analysis/4/10') with port.assertRaises(base.MethodNotSupported): self.service.analysis(4).create() self.service.analysis(4).update() self.service.analysis(4).delete() def test_contacts(self): obj = {'name': 'Super cool contact'} paging = {'limit': 100, 'offset': 50} self.service.contacts().get(offset=50, limit=100) self.expect('GET', '/contacts', paging) self.service.contact(4).update(obj) self.expect('PUT', '/contacts/4', obj) self.service.contact(4).delete() self.expect('DELETE', '/contacts/4') self.service.contacts().create(obj) self.expect('POST', '/contacts', obj) pause = {'paused': True, 'contactids': '1,2'} self.service.contacts().update(pause) self.expect('PUT', '/contacts', pause) delcontacts = {'delcontactids': '1,2'} self.service.contacts().update(delcontacts) self.expect('PUT', '/contacts', delcontacts) with port.assertRaises(base.MethodNotSupported): self.service.contact(4).get() def test_credits(self): self.service.credits().get() self.expect('GET', '/credits') with port.assertRaises(base.MethodNotSupported): self.service.credits().create() self.service.credits().update() self.service.credits().delete() def test_probes(self): paging = {'limit': 100, 'offset': 50} self.service.probes().get() self.expect('GET', '/probes') self.service.probes().get(limit=100, offset=50) self.expect('GET', '/probes', paging) with port.assertRaises(base.MethodNotSupported): self.service.probes().create() self.service.probes().update() self.service.probes().delete() def test_reference(self): self.service.reference().get() self.expect('GET', '/reference') with port.assertRaises(base.MethodNotSupported): self.service.reference().create() self.service.reference().update() self.service.reference().delete() def test_reports_email(self): obj = {'name': 'Super cool report'} self.service.reports_email().get() self.expect('GET', '/reports.email') self.service.report_email(4).update(obj) self.expect('PUT', '/reports.email/4', obj) self.service.report_email(4).delete() self.expect('DELETE', '/reports.email/4') self.service.reports_email().create(obj) self.expect('POST', '/reports.email', obj) with port.assertRaises(base.MethodNotSupported): self.service.report_email(4).get() def test_reports_public(self): obj = {'name': 'Super cool report'} self.service.reports_public().get() self.expect('GET', '/reports.public') self.service.report_public(4).update(obj) self.expect('PUT', '/reports.public/4', obj) self.service.report_public(4).delete() self.expect('DELETE', '/reports.public/4') self.service.reports_public().create(obj) self.expect('POST', '/reports.public', obj) with port.assertRaises(base.MethodNotSupported): self.service.report_public(4).get() def test_reports_shared(self): obj = {'name': 'Super cool report'} self.service.reports_shared().get() self.expect('GET', '/reports.shared') self.service.report_shared(4).update(obj) self.expect('PUT', '/reports.shared/4', obj) self.service.report_shared(4).delete() self.expect('DELETE', '/reports.shared/4') self.service.reports_shared().create(obj) self.expect('POST', '/reports.shared', obj) with port.assertRaises(base.MethodNotSupported): self.service.report_shared(4).get() def test_results(self): paging = {'limit': 100, 'offset': 50} self.service.results(4).get() self.expect('GET', '/results/4') self.service.results(4).get(limit=100, offset=50) self.expect('GET', '/results/4', paging) self.service.check(4).results().get(limit=100, offset=50) self.expect('GET', '/results/4', paging) with port.assertRaises(base.MethodNotSupported): self.service.results(4).create() self.service.results(4).update() self.service.results(4).delete() def test_servertime(self): self.service.servertime().get() self.expect('GET', '/servertime') with port.assertRaises(base.MethodNotSupported): self.service.servertime().create() self.service.servertime().update() self.service.servertime().delete() def test_settings(self): self.service.settings().get() self.expect('GET', '/settings') obj = {'phone': '112231234'} self.service.settings().update(obj) self.expect('PUT', '/settings', obj) with port.assertRaises(base.MethodNotSupported): self.service.settings().create() self.service.settings().delete() def test_summary(self): params = {'from': 1} self.service.summary(4).average(from_=1) self.expect('GET', '/summary.average/4', params) self.service.check(4).summary().average(from_=1) self.expect('GET', '/summary.average/4', params) self.service.summary(4).outage(from_=1) self.expect('GET', '/summary.outage/4', params) self.service.check(4).summary().outage(from_=1) self.expect('GET', '/summary.outage/4', params) self.service.summary(4).hoursofday(from_=1) self.expect('GET', '/summary.hoursofday/4', params) self.service.check(4).summary().hoursofday(from_=1) self.expect('GET', '/summary.hoursofday/4', params) self.service.summary(4).performance(from_=1) self.expect('GET', '/summary.performance/4', params) self.service.check(4).summary().performance(from_=1) self.expect('GET', '/summary.performance/4', params) self.service.summary(4).probes(from_=1) self.expect('GET', '/summary.probes/4', params) self.service.check(4).summary().probes(from_=1) self.expect('GET', '/summary.probes/4', params) def test_single(self): p = {'host': 'ducksboard.com', 'probeid': 17, 'type': 'http'} self.service.single().get(**p) self.expect('GET', '/single', p) with port.assertRaises(base.MethodNotSupported): self.service.single().create() self.service.single().update() self.service.single().delete() def test_traceroute(self): p = {'host': 'ducksboard.com', 'probeid': 17} self.service.traceroute().get(**p) self.expect('GET', '/traceroute', p) with port.assertRaises(base.MethodNotSupported): self.service.traceroute().create() self.service.traceroute().update() self.service.traceroute().delete()
mit
[ 646, 2882, 199, 199, 504, 1973, 2231, 305, 492, 1844, 199, 504, 1973, 2231, 305, 14, 1628, 6622, 492, 511, 63, 13471, 199, 504, 1973, 2231, 305, 14, 5950, 492, 1300, 12, 18249, 4556, 421, 199, 533, 510, 316, 4556, 1746, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 13471, 275, 511, 63, 13471, 14, 1180, 342, 267, 291, 14, 13471, 14, 409, 63, 1310, 8, 66, 7, 2440, 297, 1926, 12, 5009, 398, 291, 14, 1364, 275, 18249, 4556, 14, 22638, 4556, 360, 2473, 297, 283, 2060, 297, 283, 498, 358, 339, 347, 4282, 8, 277, 12, 1083, 29, 403, 12, 5108, 29, 403, 12, 1862, 29, 403, 12, 2323, 29, 403, 304, 267, 340, 1083, 365, 440, 488, 26, 288, 291, 14, 629, 8, 765, 12, 291, 14, 13471, 14, 1069, 14, 765, 9, 267, 340, 5108, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 2302, 12, 2490, 283, 2859, 921, 1246, 14, 4073, 4556, 14, 957, 15, 1246, 15, 18, 14, 16, 7, 435, 5108, 9, 267, 340, 1862, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 1162, 12, 1862, 9, 267, 340, 2323, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 2139, 12, 2323, 9, 339, 347, 511, 63, 3723, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 3723, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 3723, 358, 398, 291, 14, 1364, 14, 3723, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 3723, 297, 299, 7407, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 3723, 1252, 981, 342, 288, 291, 14, 1364, 14, 3723, 1252, 873, 342, 288, 291, 14, 1364, 14, 3723, 1252, 1807, 342, 339, 347, 511, 63, 10466, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 358, 398, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 63, 1773, 63, 10466, 8, 709, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 15, 709, 358, 398, 291, 14, 1364, 14, 1074, 8, 20, 680, 10466, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 1074, 8, 20, 680, 10466, 1252, 362, 63, 1773, 63, 10466, 8, 709, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 15, 709, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 981, 342, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 873, 342, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 1807, 342, 339, 347, 511, 63, 18147, 8, 277, 304, 267, 1559, 275, 791, 354, 356, 283, 11823, 32268, 8966, 936, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 398, 291, 14, 1364, 14, 18147, 1252, 362, 8, 2743, 29, 1400, 12, 2304, 29, 1960, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 18147, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 7811, 8, 20, 680, 873, 8, 1113, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 15, 20, 297, 1559, 9, 398, 291, 14, 1364, 14, 7811, 8, 20, 680, 1807, 342, 267, 291, 14, 4921, 360, 7014, 297, 1994, 18147, 15, 20, 358, 398, 291, 14, 1364, 14, 18147, 1252, 981, 8, 1113, 9, 267, 291, 14, 4921, 360, 4030, 297, 1994, 18147, 297, 1559, 9, 398, 16834, 275, 791, 22478, 356, 715, 12, 283, 388, 27308, 280, 795, 356, 283, 17, 12, 18, 936, 267, 291, 14, 1364, 14, 18147, 1252, 873, 8, 11241, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 297, 16834, 9, 398, 2150, 18147, 275, 791, 2264, 388, 27308, 280, 795, 356, 283, 17, 12, 18, 936, 267, 291, 14, 1364, 14, 18147, 1252, 873, 8, 2264, 18147, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 297, 2150, 18147, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 7811, 8, 20, 680, 362, 342, 339, 347, 511, 63, 22461, 8, 277, 304, 267, 291, 14, 1364, 14, 22461, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 22461, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 22461, 1252, 981, 342, 288, 291, 14, 1364, 14, 22461, 1252, 873, 342, 288, 291, 14, 1364, 14, 22461, 1252, 1807, 342, 339, 347, 511, 63, 6101, 397, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 6101, 397, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 6101, 397, 358, 398, 291, 14, 1364, 14, 6101, 397, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 6101, 397, 297, 299, 7407, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 6101, 397, 1252, 981, 342, 288, 291, 14, 1364, 14, 6101, 397, 1252, 873, 342, 288, 291, 14, 1364, 14, 6101, 397, 1252, 1807, 342, 339, 347, 511, 63, 4443, 8, 277, 304, 267, 291, 14, 1364, 14, 4443, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 4443, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14 ]
[ 2882, 199, 199, 504, 1973, 2231, 305, 492, 1844, 199, 504, 1973, 2231, 305, 14, 1628, 6622, 492, 511, 63, 13471, 199, 504, 1973, 2231, 305, 14, 5950, 492, 1300, 12, 18249, 4556, 421, 199, 533, 510, 316, 4556, 1746, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 13471, 275, 511, 63, 13471, 14, 1180, 342, 267, 291, 14, 13471, 14, 409, 63, 1310, 8, 66, 7, 2440, 297, 1926, 12, 5009, 398, 291, 14, 1364, 275, 18249, 4556, 14, 22638, 4556, 360, 2473, 297, 283, 2060, 297, 283, 498, 358, 339, 347, 4282, 8, 277, 12, 1083, 29, 403, 12, 5108, 29, 403, 12, 1862, 29, 403, 12, 2323, 29, 403, 304, 267, 340, 1083, 365, 440, 488, 26, 288, 291, 14, 629, 8, 765, 12, 291, 14, 13471, 14, 1069, 14, 765, 9, 267, 340, 5108, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 2302, 12, 2490, 283, 2859, 921, 1246, 14, 4073, 4556, 14, 957, 15, 1246, 15, 18, 14, 16, 7, 435, 5108, 9, 267, 340, 1862, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 1162, 12, 1862, 9, 267, 340, 2323, 365, 440, 488, 26, 288, 291, 14, 629, 8, 277, 14, 13471, 14, 1069, 14, 2139, 12, 2323, 9, 339, 347, 511, 63, 3723, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 3723, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 3723, 358, 398, 291, 14, 1364, 14, 3723, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 3723, 297, 299, 7407, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 3723, 1252, 981, 342, 288, 291, 14, 1364, 14, 3723, 1252, 873, 342, 288, 291, 14, 1364, 14, 3723, 1252, 1807, 342, 339, 347, 511, 63, 10466, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 358, 398, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 10466, 8, 20, 680, 362, 63, 1773, 63, 10466, 8, 709, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 15, 709, 358, 398, 291, 14, 1364, 14, 1074, 8, 20, 680, 10466, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 1074, 8, 20, 680, 10466, 1252, 362, 63, 1773, 63, 10466, 8, 709, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 10466, 15, 20, 15, 709, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 981, 342, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 873, 342, 288, 291, 14, 1364, 14, 10466, 8, 20, 680, 1807, 342, 339, 347, 511, 63, 18147, 8, 277, 304, 267, 1559, 275, 791, 354, 356, 283, 11823, 32268, 8966, 936, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 398, 291, 14, 1364, 14, 18147, 1252, 362, 8, 2743, 29, 1400, 12, 2304, 29, 1960, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 18147, 297, 299, 7407, 9, 398, 291, 14, 1364, 14, 7811, 8, 20, 680, 873, 8, 1113, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 15, 20, 297, 1559, 9, 398, 291, 14, 1364, 14, 7811, 8, 20, 680, 1807, 342, 267, 291, 14, 4921, 360, 7014, 297, 1994, 18147, 15, 20, 358, 398, 291, 14, 1364, 14, 18147, 1252, 981, 8, 1113, 9, 267, 291, 14, 4921, 360, 4030, 297, 1994, 18147, 297, 1559, 9, 398, 16834, 275, 791, 22478, 356, 715, 12, 283, 388, 27308, 280, 795, 356, 283, 17, 12, 18, 936, 267, 291, 14, 1364, 14, 18147, 1252, 873, 8, 11241, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 297, 16834, 9, 398, 2150, 18147, 275, 791, 2264, 388, 27308, 280, 795, 356, 283, 17, 12, 18, 936, 267, 291, 14, 1364, 14, 18147, 1252, 873, 8, 2264, 18147, 9, 267, 291, 14, 4921, 360, 4013, 297, 1994, 18147, 297, 2150, 18147, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 7811, 8, 20, 680, 362, 342, 339, 347, 511, 63, 22461, 8, 277, 304, 267, 291, 14, 1364, 14, 22461, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 22461, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 22461, 1252, 981, 342, 288, 291, 14, 1364, 14, 22461, 1252, 873, 342, 288, 291, 14, 1364, 14, 22461, 1252, 1807, 342, 339, 347, 511, 63, 6101, 397, 8, 277, 304, 267, 299, 7407, 275, 791, 3097, 356, 2948, 12, 283, 2743, 356, 5238, 93, 267, 291, 14, 1364, 14, 6101, 397, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 6101, 397, 358, 398, 291, 14, 1364, 14, 6101, 397, 1252, 362, 8, 3097, 29, 1960, 12, 3268, 29, 1400, 9, 267, 291, 14, 4921, 360, 2970, 297, 1994, 6101, 397, 297, 299, 7407, 9, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 6101, 397, 1252, 981, 342, 288, 291, 14, 1364, 14, 6101, 397, 1252, 873, 342, 288, 291, 14, 1364, 14, 6101, 397, 1252, 1807, 342, 339, 347, 511, 63, 4443, 8, 277, 304, 267, 291, 14, 1364, 14, 4443, 1252, 362, 342, 267, 291, 14, 4921, 360, 2970, 297, 1994, 4443, 358, 398, 543, 1844, 14, 1855, 8, 1095, 14, 3767, 26077, 304, 288, 291, 14, 1364, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
hurricup/intellij-community
python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/pgen2/token.py
353
1244
#! /usr/bin/env python """Token constants (from "token.h").""" # Taken from Python (r53757) and modified to include some tokens # originally monkeypatched in by pgen2.tokenize #--start constants-- ENDMARKER = 0 NAME = 1 NUMBER = 2 STRING = 3 NEWLINE = 4 INDENT = 5 DEDENT = 6 LPAR = 7 RPAR = 8 LSQB = 9 RSQB = 10 COLON = 11 COMMA = 12 SEMI = 13 PLUS = 14 MINUS = 15 STAR = 16 SLASH = 17 VBAR = 18 AMPER = 19 LESS = 20 GREATER = 21 EQUAL = 22 DOT = 23 PERCENT = 24 BACKQUOTE = 25 LBRACE = 26 RBRACE = 27 EQEQUAL = 28 NOTEQUAL = 29 LESSEQUAL = 30 GREATEREQUAL = 31 TILDE = 32 CIRCUMFLEX = 33 LEFTSHIFT = 34 RIGHTSHIFT = 35 DOUBLESTAR = 36 PLUSEQUAL = 37 MINEQUAL = 38 STAREQUAL = 39 SLASHEQUAL = 40 PERCENTEQUAL = 41 AMPEREQUAL = 42 VBAREQUAL = 43 CIRCUMFLEXEQUAL = 44 LEFTSHIFTEQUAL = 45 RIGHTSHIFTEQUAL = 46 DOUBLESTAREQUAL = 47 DOUBLESLASH = 48 DOUBLESLASHEQUAL = 49 AT = 50 OP = 51 COMMENT = 52 NL = 53 RARROW = 54 ERRORTOKEN = 55 N_TOKENS = 56 NT_OFFSET = 256 #--end constants-- tok_name = {} for _name, _value in globals().items(): if type(_value) is type(0): tok_name[_value] = _name def ISTERMINAL(x): return x < NT_OFFSET def ISNONTERMINAL(x): return x >= NT_OFFSET def ISEOF(x): return x == ENDMARKER
apache-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 3264, 5262, 334, 504, 298, 1418, 14, 72, 531, 1041, 199, 199, 3, 221, 32316, 917, 687, 2018, 334, 82, 24416, 1641, 9, 436, 6042, 370, 2387, 2005, 4645, 199, 3, 257, 20657, 17309, 379, 315, 701, 299, 2268, 18, 14, 15246, 199, 199, 3, 306, 928, 5262, 306, 199, 3902, 18997, 275, 378, 199, 2339, 275, 413, 199, 9190, 275, 499, 199, 5353, 275, 650, 199, 28758, 275, 841, 199, 29080, 275, 959, 199, 8280, 1309, 275, 1227, 199, 44, 4014, 275, 1520, 199, 50, 4014, 275, 1695, 199, 5296, 31893, 275, 1749, 199, 15062, 31893, 275, 1616, 199, 3978, 615, 275, 4119, 199, 11265, 2054, 275, 3144, 199, 899, 10709, 275, 4944, 199, 27280, 275, 4329, 199, 18004, 275, 4114, 199, 30302, 275, 3193, 199, 27192, 275, 5557, 199, 54, 13895, 275, 6155, 199, 1156, 4227, 275, 5851, 199, 30928, 275, 3388, 199, 39, 21780, 275, 7829, 199, 16352, 275, 6928, 199, 13203, 275, 6546, 199, 4227, 17349, 275, 5504, 199, 7111, 18495, 275, 5661, 199, 44, 29246, 275, 7875, 199, 50, 29246, 275, 8087, 199, 17420, 16352, 275, 7294, 199, 4609, 16352, 275, 7349, 199, 11344, 7326, 748, 275, 4233, 199, 39, 21780, 16352, 275, 7105, 199, 52, 13922, 275, 4337, 199, 3553, 50, 9976, 275, 9404, 199, 9894, 18013, 275, 8177, 199, 12811, 18013, 275, 8685, 199, 1649, 2533, 44, 1719, 689, 275, 8780, 199, 2749, 4701, 9283, 275, 6877, 199, 45, 3565, 9283, 275, 10448, 199, 840, 8693, 9283, 275, 10551, 199, 4929, 1179, 1645, 9283, 275, 6335, 199, 4227, 17349, 16352, 275, 13385, 199, 1156, 4227, 16352, 275, 5685, 199, 27966, 8693, 9283, 275, 11851, 199, 3553, 50, 9976, 16352, 275, 10868, 199, 9894, 18013, 16352, 275, 10416, 199, 12811, 18013, 16352, 275, 12426, 199, 1649, 2533, 44, 1719, 8693, 9283, 275, 10954, 199, 1649, 2533, 11344, 44, 8100, 275, 9615, 199, 1649, 2533, 11344, 44, 1179, 1645, 9283, 275, 12260, 199, 619, 275, 5238, 199, 1938, 275, 8026, 199, 10973, 275, 14589, 199, 14176, 275, 13564, 199, 50, 689, 11415, 275, 13470, 199, 3170, 8803, 275, 12766, 199, 46, 63, 8803, 51, 275, 12001, 199, 12460, 63, 14839, 275, 7633, 199, 3, 306, 500, 5262, 306, 199, 199, 9305, 63, 354, 275, 1052, 199, 509, 485, 354, 12, 485, 585, 315, 7992, 1252, 1744, 837, 272, 340, 730, 1547, 585, 9, 365, 730, 8, 16, 304, 267, 8431, 63, 354, 13040, 585, 61, 275, 485, 354, 421, 199, 318, 473, 14471, 4896, 748, 8, 88, 304, 272, 372, 671, 665, 23350, 63, 14839, 199, 199, 318, 2281, 13887, 28376, 748, 8, 88, 304, 272, 372, 671, 2356, 23350, 63, 14839, 199, 199, 318, 473, 899, 3359, 8, 88, 304, 272, 372, 671, 508, 7729, 18997, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3264, 5262, 334, 504, 298, 1418, 14, 72, 531, 1041, 199, 199, 3, 221, 32316, 917, 687, 2018, 334, 82, 24416, 1641, 9, 436, 6042, 370, 2387, 2005, 4645, 199, 3, 257, 20657, 17309, 379, 315, 701, 299, 2268, 18, 14, 15246, 199, 199, 3, 306, 928, 5262, 306, 199, 3902, 18997, 275, 378, 199, 2339, 275, 413, 199, 9190, 275, 499, 199, 5353, 275, 650, 199, 28758, 275, 841, 199, 29080, 275, 959, 199, 8280, 1309, 275, 1227, 199, 44, 4014, 275, 1520, 199, 50, 4014, 275, 1695, 199, 5296, 31893, 275, 1749, 199, 15062, 31893, 275, 1616, 199, 3978, 615, 275, 4119, 199, 11265, 2054, 275, 3144, 199, 899, 10709, 275, 4944, 199, 27280, 275, 4329, 199, 18004, 275, 4114, 199, 30302, 275, 3193, 199, 27192, 275, 5557, 199, 54, 13895, 275, 6155, 199, 1156, 4227, 275, 5851, 199, 30928, 275, 3388, 199, 39, 21780, 275, 7829, 199, 16352, 275, 6928, 199, 13203, 275, 6546, 199, 4227, 17349, 275, 5504, 199, 7111, 18495, 275, 5661, 199, 44, 29246, 275, 7875, 199, 50, 29246, 275, 8087, 199, 17420, 16352, 275, 7294, 199, 4609, 16352, 275, 7349, 199, 11344, 7326, 748, 275, 4233, 199, 39, 21780, 16352, 275, 7105, 199, 52, 13922, 275, 4337, 199, 3553, 50, 9976, 275, 9404, 199, 9894, 18013, 275, 8177, 199, 12811, 18013, 275, 8685, 199, 1649, 2533, 44, 1719, 689, 275, 8780, 199, 2749, 4701, 9283, 275, 6877, 199, 45, 3565, 9283, 275, 10448, 199, 840, 8693, 9283, 275, 10551, 199, 4929, 1179, 1645, 9283, 275, 6335, 199, 4227, 17349, 16352, 275, 13385, 199, 1156, 4227, 16352, 275, 5685, 199, 27966, 8693, 9283, 275, 11851, 199, 3553, 50, 9976, 16352, 275, 10868, 199, 9894, 18013, 16352, 275, 10416, 199, 12811, 18013, 16352, 275, 12426, 199, 1649, 2533, 44, 1719, 8693, 9283, 275, 10954, 199, 1649, 2533, 11344, 44, 8100, 275, 9615, 199, 1649, 2533, 11344, 44, 1179, 1645, 9283, 275, 12260, 199, 619, 275, 5238, 199, 1938, 275, 8026, 199, 10973, 275, 14589, 199, 14176, 275, 13564, 199, 50, 689, 11415, 275, 13470, 199, 3170, 8803, 275, 12766, 199, 46, 63, 8803, 51, 275, 12001, 199, 12460, 63, 14839, 275, 7633, 199, 3, 306, 500, 5262, 306, 199, 199, 9305, 63, 354, 275, 1052, 199, 509, 485, 354, 12, 485, 585, 315, 7992, 1252, 1744, 837, 272, 340, 730, 1547, 585, 9, 365, 730, 8, 16, 304, 267, 8431, 63, 354, 13040, 585, 61, 275, 485, 354, 421, 199, 318, 473, 14471, 4896, 748, 8, 88, 304, 272, 372, 671, 665, 23350, 63, 14839, 199, 199, 318, 2281, 13887, 28376, 748, 8, 88, 304, 272, 372, 671, 2356, 23350, 63, 14839, 199, 199, 318, 473, 899, 3359, 8, 88, 304, 272, 372, 671, 508, 7729, 18997, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
varunarya10/python-novaclient
novaclient/v1_1/volumes.py
5
5646
# Copyright 2011 Denali Systems, 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. """ Volume interface (1.1 extension). """ import six from six.moves.urllib import parse from novaclient import base class Volume(base.Resource): """ A volume is an extra block level storage to the OpenStack instances. """ NAME_ATTR = 'display_name' def __repr__(self): return "<Volume: %s>" % self.id def delete(self): """ Delete this volume. """ self.manager.delete(self) class VolumeManager(base.ManagerWithFind): """ Manage :class:`Volume` resources. """ resource_class = Volume def create(self, size, snapshot_id=None, display_name=None, display_description=None, volume_type=None, availability_zone=None, imageRef=None): """ Create a volume. :param size: Size of volume in GB :param snapshot_id: ID of the snapshot :param display_name: Name of the volume :param display_description: Description of the volume :param volume_type: Type of volume :param availability_zone: Availability Zone for volume :rtype: :class:`Volume` :param imageRef: reference to an image stored in glance """ body = {'volume': {'size': size, 'snapshot_id': snapshot_id, 'display_name': display_name, 'display_description': display_description, 'volume_type': volume_type, 'availability_zone': availability_zone, 'imageRef': imageRef}} return self._create('/volumes', body, 'volume') def get(self, volume_id): """ Get a volume. :param volume_id: The ID of the volume to delete. :rtype: :class:`Volume` """ return self._get("/volumes/%s" % volume_id, "volume") def list(self, detailed=True, search_opts=None): """ Get a list of all volumes. :rtype: list of :class:`Volume` """ search_opts = search_opts or {} qparams = dict((k, v) for (k, v) in six.iteritems(search_opts) if v) query_string = '?%s' % parse.urlencode(qparams) if qparams else '' if detailed is True: return self._list("/volumes/detail%s" % query_string, "volumes") else: return self._list("/volumes%s" % query_string, "volumes") def delete(self, volume): """ Delete a volume. :param volume: The :class:`Volume` to delete. """ self._delete("/volumes/%s" % base.getid(volume)) def create_server_volume(self, server_id, volume_id, device): """ Attach a volume identified by the volume ID to the given server ID :param server_id: The ID of the server :param volume_id: The ID of the volume to attach. :param device: The device name :rtype: :class:`Volume` """ body = {'volumeAttachment': {'volumeId': volume_id, 'device': device}} return self._create("/servers/%s/os-volume_attachments" % server_id, body, "volumeAttachment") def update_server_volume(self, server_id, attachment_id, new_volume_id): """ Update the volume identified by the attachment ID, that is attached to the given server ID :param server_id: The ID of the server :param attachment_id: The ID of the attachment :param new_volume_id: The ID of the new volume to attach :rtype: :class:`Volume` """ body = {'volumeAttachment': {'volumeId': new_volume_id}} return self._update("/servers/%s/os-volume_attachments/%s" % (server_id, attachment_id,), body, "volumeAttachment") def get_server_volume(self, server_id, attachment_id): """ Get the volume identified by the attachment ID, that is attached to the given server ID :param server_id: The ID of the server :param attachment_id: The ID of the attachment :rtype: :class:`Volume` """ return self._get("/servers/%s/os-volume_attachments/%s" % (server_id, attachment_id,), "volumeAttachment") def get_server_volumes(self, server_id): """ Get a list of all the attached volumes for the given server ID :param server_id: The ID of the server :rtype: list of :class:`Volume` """ return self._list("/servers/%s/os-volume_attachments" % server_id, "volumeAttachments") def delete_server_volume(self, server_id, attachment_id): """ Detach a volume identified by the attachment ID from the given server :param server_id: The ID of the server :param attachment_id: The ID of the attachment """ self._delete("/servers/%s/os-volume_attachments/%s" % (server_id, attachment_id,))
apache-2.0
[ 3, 1898, 7760, 25187, 10874, 15285, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 6464, 3217, 334, 17, 14, 17, 3329, 680, 199, 624, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 199, 199, 504, 949, 15367, 864, 492, 1300, 421, 199, 533, 15018, 8, 1095, 14, 4031, 304, 272, 408, 272, 437, 3301, 365, 376, 2402, 1853, 2166, 4887, 370, 314, 14260, 4454, 14, 272, 408, 272, 13637, 63, 5280, 275, 283, 2918, 63, 354, 7, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 6464, 26, 450, 83, 4335, 450, 291, 14, 344, 339, 347, 3145, 8, 277, 304, 267, 408, 267, 8496, 642, 3301, 14, 267, 408, 267, 291, 14, 2609, 14, 1807, 8, 277, 9, 421, 199, 533, 15018, 2988, 8, 1095, 14, 2988, 3007, 6591, 304, 272, 408, 272, 14944, 520, 533, 1705, 6464, 64, 5944, 14, 272, 408, 272, 2073, 63, 533, 275, 15018, 339, 347, 1218, 8, 277, 12, 1568, 12, 5740, 63, 344, 29, 403, 12, 490, 2929, 63, 354, 29, 403, 12, 2929, 63, 1802, 29, 403, 12, 490, 3301, 63, 466, 29, 403, 12, 14962, 63, 2619, 29, 403, 12, 490, 1834, 2891, 29, 403, 304, 267, 408, 267, 2790, 282, 3301, 14, 398, 520, 635, 1568, 26, 14579, 402, 3301, 315, 18553, 267, 520, 635, 5740, 63, 344, 26, 2870, 402, 314, 5740, 267, 520, 635, 2929, 63, 354, 26, 2812, 402, 314, 3301, 267, 520, 635, 2929, 63, 1802, 26, 11994, 402, 314, 3301, 267, 520, 635, 3301, 63, 466, 26, 2434, 402, 3301, 267, 520, 635, 14962, 63, 2619, 26, 16599, 7615, 22518, 367, 3301, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 520, 635, 1834, 2891, 26, 3659, 370, 376, 1834, 5489, 315, 21785, 267, 408, 267, 2396, 275, 791, 2405, 356, 791, 890, 356, 1568, 12, 1169, 283, 4753, 63, 344, 356, 5740, 63, 344, 12, 1169, 283, 2918, 63, 354, 356, 2929, 63, 354, 12, 1169, 283, 2918, 63, 1802, 356, 2929, 63, 1802, 12, 1169, 283, 2405, 63, 466, 356, 3301, 63, 466, 12, 1169, 283, 11856, 63, 2619, 356, 14962, 63, 2619, 12, 1169, 283, 1569, 2891, 356, 1834, 2891, 4863, 267, 372, 291, 423, 981, 2336, 8838, 297, 2396, 12, 283, 2405, 358, 339, 347, 664, 8, 277, 12, 3301, 63, 344, 304, 267, 408, 267, 2372, 282, 3301, 14, 398, 520, 635, 3301, 63, 344, 26, 710, 2870, 402, 314, 3301, 370, 3145, 14, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 372, 291, 423, 362, 4769, 8838, 3149, 83, 2, 450, 3301, 63, 344, 12, 298, 2405, 531, 339, 347, 769, 8, 277, 12, 16212, 29, 549, 12, 2754, 63, 3291, 29, 403, 304, 267, 408, 267, 2372, 282, 769, 402, 1006, 12158, 14, 398, 520, 4500, 26, 769, 402, 520, 533, 1705, 6464, 64, 267, 408, 267, 2754, 63, 3291, 275, 2754, 63, 3291, 503, 1052, 398, 1894, 1162, 275, 1211, 1332, 75, 12, 373, 9, 367, 334, 75, 12, 373, 9, 315, 3816, 14, 4611, 8, 1733, 63, 3291, 9, 340, 373, 9, 398, 1827, 63, 875, 275, 8720, 5, 83, 7, 450, 2198, 14, 10738, 8, 81, 1162, 9, 340, 1894, 1162, 587, 2125, 398, 340, 16212, 365, 715, 26, 288, 372, 291, 423, 513, 4769, 8838, 15, 5506, 5, 83, 2, 450, 1827, 63, 875, 12, 298, 8838, 531, 267, 587, 26, 288, 372, 291, 423, 513, 4769, 8838, 5, 83, 2, 450, 1827, 63, 875, 12, 298, 8838, 531, 339, 347, 3145, 8, 277, 12, 3301, 304, 267, 408, 267, 8496, 282, 3301, 14, 398, 520, 635, 3301, 26, 710, 520, 533, 1705, 6464, 64, 370, 3145, 14, 267, 408, 267, 291, 423, 1807, 4769, 8838, 3149, 83, 2, 450, 1300, 14, 303, 5700, 8, 2405, 430, 339, 347, 1218, 63, 1000, 63, 2405, 8, 277, 12, 1654, 63, 344, 12, 3301, 63, 344, 12, 2243, 304, 267, 408, 267, 21328, 282, 3301, 15836, 701, 314, 3301, 2870, 370, 314, 1627, 1654, 2870, 398, 520, 635, 1654, 63, 344, 26, 710, 2870, 402, 314, 1654, 267, 520, 635, 3301, 63, 344, 26, 710, 2870, 402, 314, 3301, 370, 6554, 14, 267, 520, 635, 2243, 26, 710, 2243, 536, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 2396, 275, 791, 2405, 22662, 356, 791, 2405, 1304, 356, 3301, 63, 344, 12, 1169, 283, 1782, 356, 2243, 4863, 267, 372, 291, 423, 981, 4769, 5871, 3149, 83, 15, 736, 13, 2405, 63, 15855, 2, 450, 1654, 63, 344, 12, 288, 2396, 12, 298, 2405, 22662, 531, 339, 347, 1678, 63, 1000, 63, 2405, 8, 277, 12, 1654, 63, 344, 12, 12193, 63, 344, 12, 892, 63, 2405, 63, 344, 304, 267, 408, 267, 6162, 314, 3301, 15836, 701, 314, 12193, 2870, 12, 626, 365, 10102, 370, 267, 314, 1627, 1654, 2870, 398, 520, 635, 1654, 63, 344, 26, 710, 2870, 402, 314, 1654, 267, 520, 635, 12193, 63, 344, 26, 710, 2870, 402, 314, 12193, 267, 520, 635, 892, 63, 2405, 63, 344, 26, 710, 2870, 402, 314, 892, 3301, 370, 6554, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 2396, 275, 791, 2405, 22662, 356, 791, 2405, 1304, 356, 892, 63, 2405, 63, 344, 4863 ]
[ 1898, 7760, 25187, 10874, 15285, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 6464, 3217, 334, 17, 14, 17, 3329, 680, 199, 624, 199, 199, 646, 3816, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 199, 199, 504, 949, 15367, 864, 492, 1300, 421, 199, 533, 15018, 8, 1095, 14, 4031, 304, 272, 408, 272, 437, 3301, 365, 376, 2402, 1853, 2166, 4887, 370, 314, 14260, 4454, 14, 272, 408, 272, 13637, 63, 5280, 275, 283, 2918, 63, 354, 7, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 6464, 26, 450, 83, 4335, 450, 291, 14, 344, 339, 347, 3145, 8, 277, 304, 267, 408, 267, 8496, 642, 3301, 14, 267, 408, 267, 291, 14, 2609, 14, 1807, 8, 277, 9, 421, 199, 533, 15018, 2988, 8, 1095, 14, 2988, 3007, 6591, 304, 272, 408, 272, 14944, 520, 533, 1705, 6464, 64, 5944, 14, 272, 408, 272, 2073, 63, 533, 275, 15018, 339, 347, 1218, 8, 277, 12, 1568, 12, 5740, 63, 344, 29, 403, 12, 490, 2929, 63, 354, 29, 403, 12, 2929, 63, 1802, 29, 403, 12, 490, 3301, 63, 466, 29, 403, 12, 14962, 63, 2619, 29, 403, 12, 490, 1834, 2891, 29, 403, 304, 267, 408, 267, 2790, 282, 3301, 14, 398, 520, 635, 1568, 26, 14579, 402, 3301, 315, 18553, 267, 520, 635, 5740, 63, 344, 26, 2870, 402, 314, 5740, 267, 520, 635, 2929, 63, 354, 26, 2812, 402, 314, 3301, 267, 520, 635, 2929, 63, 1802, 26, 11994, 402, 314, 3301, 267, 520, 635, 3301, 63, 466, 26, 2434, 402, 3301, 267, 520, 635, 14962, 63, 2619, 26, 16599, 7615, 22518, 367, 3301, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 520, 635, 1834, 2891, 26, 3659, 370, 376, 1834, 5489, 315, 21785, 267, 408, 267, 2396, 275, 791, 2405, 356, 791, 890, 356, 1568, 12, 1169, 283, 4753, 63, 344, 356, 5740, 63, 344, 12, 1169, 283, 2918, 63, 354, 356, 2929, 63, 354, 12, 1169, 283, 2918, 63, 1802, 356, 2929, 63, 1802, 12, 1169, 283, 2405, 63, 466, 356, 3301, 63, 466, 12, 1169, 283, 11856, 63, 2619, 356, 14962, 63, 2619, 12, 1169, 283, 1569, 2891, 356, 1834, 2891, 4863, 267, 372, 291, 423, 981, 2336, 8838, 297, 2396, 12, 283, 2405, 358, 339, 347, 664, 8, 277, 12, 3301, 63, 344, 304, 267, 408, 267, 2372, 282, 3301, 14, 398, 520, 635, 3301, 63, 344, 26, 710, 2870, 402, 314, 3301, 370, 3145, 14, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 372, 291, 423, 362, 4769, 8838, 3149, 83, 2, 450, 3301, 63, 344, 12, 298, 2405, 531, 339, 347, 769, 8, 277, 12, 16212, 29, 549, 12, 2754, 63, 3291, 29, 403, 304, 267, 408, 267, 2372, 282, 769, 402, 1006, 12158, 14, 398, 520, 4500, 26, 769, 402, 520, 533, 1705, 6464, 64, 267, 408, 267, 2754, 63, 3291, 275, 2754, 63, 3291, 503, 1052, 398, 1894, 1162, 275, 1211, 1332, 75, 12, 373, 9, 367, 334, 75, 12, 373, 9, 315, 3816, 14, 4611, 8, 1733, 63, 3291, 9, 340, 373, 9, 398, 1827, 63, 875, 275, 8720, 5, 83, 7, 450, 2198, 14, 10738, 8, 81, 1162, 9, 340, 1894, 1162, 587, 2125, 398, 340, 16212, 365, 715, 26, 288, 372, 291, 423, 513, 4769, 8838, 15, 5506, 5, 83, 2, 450, 1827, 63, 875, 12, 298, 8838, 531, 267, 587, 26, 288, 372, 291, 423, 513, 4769, 8838, 5, 83, 2, 450, 1827, 63, 875, 12, 298, 8838, 531, 339, 347, 3145, 8, 277, 12, 3301, 304, 267, 408, 267, 8496, 282, 3301, 14, 398, 520, 635, 3301, 26, 710, 520, 533, 1705, 6464, 64, 370, 3145, 14, 267, 408, 267, 291, 423, 1807, 4769, 8838, 3149, 83, 2, 450, 1300, 14, 303, 5700, 8, 2405, 430, 339, 347, 1218, 63, 1000, 63, 2405, 8, 277, 12, 1654, 63, 344, 12, 3301, 63, 344, 12, 2243, 304, 267, 408, 267, 21328, 282, 3301, 15836, 701, 314, 3301, 2870, 370, 314, 1627, 1654, 2870, 398, 520, 635, 1654, 63, 344, 26, 710, 2870, 402, 314, 1654, 267, 520, 635, 3301, 63, 344, 26, 710, 2870, 402, 314, 3301, 370, 6554, 14, 267, 520, 635, 2243, 26, 710, 2243, 536, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 2396, 275, 791, 2405, 22662, 356, 791, 2405, 1304, 356, 3301, 63, 344, 12, 1169, 283, 1782, 356, 2243, 4863, 267, 372, 291, 423, 981, 4769, 5871, 3149, 83, 15, 736, 13, 2405, 63, 15855, 2, 450, 1654, 63, 344, 12, 288, 2396, 12, 298, 2405, 22662, 531, 339, 347, 1678, 63, 1000, 63, 2405, 8, 277, 12, 1654, 63, 344, 12, 12193, 63, 344, 12, 892, 63, 2405, 63, 344, 304, 267, 408, 267, 6162, 314, 3301, 15836, 701, 314, 12193, 2870, 12, 626, 365, 10102, 370, 267, 314, 1627, 1654, 2870, 398, 520, 635, 1654, 63, 344, 26, 710, 2870, 402, 314, 1654, 267, 520, 635, 12193, 63, 344, 26, 710, 2870, 402, 314, 12193, 267, 520, 635, 892, 63, 2405, 63, 344, 26, 710, 2870, 402, 314, 892, 3301, 370, 6554, 267, 520, 4500, 26, 520, 533, 1705, 6464, 64, 267, 408, 267, 2396, 275, 791, 2405, 22662, 356, 791, 2405, 1304, 356, 892, 63, 2405, 63, 344, 4863, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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Common from odoo.tests import tagged @tagged('post_install', '-at_install') class TestAccountIncomingSupplierInvoice(AccountTestCommon): def setUp(self): super(TestAccountIncomingSupplierInvoice, self).setUp() self.env['ir.config_parameter'].sudo().set_param('mail.catchall.domain', 'test-company.odoo.com') self.internal_user = self.env['res.users'].create({ 'name': 'Internal User', 'login': 'internal.user@test.odoo.com', 'email': 'internal.user@test.odoo.com', }) self.supplier_partner = self.env['res.partner'].create({ 'name': 'Your Supplier', 'email': 'supplier@other.company.com', 'supplier_rank': 10, }) self.journal = self.env['account.journal'].create({ 'name': 'Test Journal', 'code': 'TST', 'type': 'purchase', }) journal_alias = self.env['mail.alias'].create({ 'alias_name': 'test-bill', 'alias_model_id': self.env.ref('account.model_account_move').id, 'alias_defaults': json.dumps({ 'move_type': 'in_invoice', 'company_id': self.env.user.company_id.id, 'journal_id': self.journal.id, }), }) self.journal.write({'alias_id': journal_alias.id}) self.employee_user = self.env.ref('base.user_demo') def test_supplier_invoice_mailed_from_supplier(self): message_parsed = { 'message_id': 'message-id-dead-beef', 'subject': 'Incoming bill', 'from': '%s <%s>' % (self.supplier_partner.name, self.supplier_partner.email), 'to': '%s@%s' % (self.journal.alias_id.alias_name, self.journal.alias_id.alias_domain), 'body': "You know, that thing that you bought.", 'attachments': [b'Hello, invoice'], } invoice = self.env['account.move'].message_new(message_parsed, {'move_type': 'in_invoice', 'journal_id': self.journal.id}) message_ids = invoice.message_ids self.assertEqual(len(message_ids), 1, 'Only one message should be posted in the chatter') self.assertEqual(message_ids.body, '<p>Vendor Bill Created</p>', 'Only the invoice creation should be posted') following_partners = invoice.message_follower_ids.mapped('partner_id') self.assertEqual(following_partners, self.env.ref('base.partner_root')) def test_supplier_invoice_forwarded_by_internal_user_without_supplier(self): """ In this test, the bill was forwarded by an employee, but no partner email address is found in the body.""" message_parsed = { 'message_id': 'message-id-dead-beef', 'subject': 'Incoming bill', 'from': '%s <%s>' % (self.internal_user.name, self.internal_user.email), 'to': '%s@%s' % (self.journal.alias_id.alias_name, self.journal.alias_id.alias_domain), 'body': "You know, that thing that you bought.", 'attachments': [b'Hello, invoice'], } invoice = self.env['account.move'].message_new(message_parsed, {'move_type': 'in_invoice', 'journal_id': self.journal.id}) message_ids = invoice.message_ids self.assertEqual(len(message_ids), 1, 'Only one message should be posted in the chatter') self.assertEqual(message_ids.body, '<p>Vendor Bill Created</p>', 'Only the invoice creation should be posted') following_partners = invoice.message_follower_ids.mapped('partner_id') self.assertEqual(following_partners, self.env.ref('base.partner_root') | self.internal_user.partner_id) def test_supplier_invoice_forwarded_by_internal_with_supplier_in_body(self): """ In this test, the bill was forwarded by an employee, and the partner email address is found in the body.""" message_parsed = { 'message_id': 'message-id-dead-beef', 'subject': 'Incoming bill', 'from': '%s <%s>' % (self.internal_user.name, self.internal_user.email), 'to': '%s@%s' % (self.journal.alias_id.alias_name, self.journal.alias_id.alias_domain), 'body': "Mail sent by %s <%s>:\nYou know, that thing that you bought." % (self.supplier_partner.name, self.supplier_partner.email), 'attachments': [b'Hello, invoice'], } invoice = self.env['account.move'].message_new(message_parsed, {'move_type': 'in_invoice', 'journal_id': self.journal.id}) message_ids = invoice.message_ids self.assertEqual(len(message_ids), 1, 'Only one message should be posted in the chatter') self.assertEqual(message_ids.body, '<p>Vendor Bill Created</p>', 'Only the invoice creation should be posted') following_partners = invoice.message_follower_ids.mapped('partner_id') self.assertEqual(following_partners, self.env.ref('base.partner_root') | self.internal_user.partner_id) def test_supplier_invoice_forwarded_by_internal_with_internal_in_body(self): """ In this test, the bill was forwarded by an employee, and the internal user email address is found in the body.""" message_parsed = { 'message_id': 'message-id-dead-beef', 'subject': 'Incoming bill', 'from': '%s <%s>' % (self.internal_user.name, self.internal_user.email), 'to': '%s@%s' % (self.journal.alias_id.alias_name, self.journal.alias_id.alias_domain), 'body': "Mail sent by %s <%s>:\nYou know, that thing that you bought." % (self.internal_user.name, self.internal_user.email), 'attachments': [b'Hello, invoice'], } invoice = self.env['account.move'].message_new(message_parsed, {'move_type': 'in_invoice', 'journal_id': self.journal.id}) message_ids = invoice.message_ids self.assertEqual(len(message_ids), 1, 'Only one message should be posted in the chatter') self.assertEqual(message_ids.body, '<p>Vendor Bill Created</p>', 'Only the invoice creation should be posted') following_partners = invoice.message_follower_ids.mapped('partner_id') self.assertEqual(following_partners, self.env.ref('base.partner_root') | self.internal_user.partner_id)
agpl-3.0
[ 646, 2022, 199, 199, 504, 28811, 14, 10788, 14, 2048, 14, 2219, 14, 2330, 492, 9973, 774, 7844, 199, 504, 28811, 14, 2219, 492, 20018, 421, 199, 32, 15679, 360, 1932, 63, 3174, 297, 2475, 292, 63, 3174, 358, 199, 533, 1379, 6009, 607, 7909, 30080, 21092, 8, 6009, 774, 7844, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 6009, 607, 7909, 30080, 21092, 12, 291, 680, 5996, 342, 398, 291, 14, 1813, 459, 723, 14, 888, 63, 5329, 2278, 12095, 1252, 409, 63, 635, 360, 1198, 14, 9341, 452, 14, 2261, 297, 283, 396, 13, 4627, 14, 22058, 14, 957, 358, 398, 291, 14, 4672, 63, 751, 275, 291, 14, 1813, 459, 470, 14, 3707, 2278, 981, 2561, 288, 283, 354, 356, 283, 8405, 2876, 297, 288, 283, 2886, 356, 283, 4672, 14, 751, 32, 396, 14, 22058, 14, 957, 297, 288, 283, 2123, 356, 283, 4672, 14, 751, 32, 396, 14, 22058, 14, 957, 297, 267, 3828, 398, 291, 14, 17294, 63, 3899, 275, 291, 14, 1813, 459, 470, 14, 3899, 2278, 981, 2561, 288, 283, 354, 356, 283, 14398, 29083, 5697, 297, 288, 283, 2123, 356, 283, 17294, 32, 1848, 14, 4627, 14, 957, 297, 288, 283, 17294, 63, 4648, 356, 1616, 12, 267, 3828, 398, 291, 14, 7067, 275, 291, 14, 1813, 459, 2048, 14, 7067, 2278, 981, 2561, 288, 283, 354, 356, 283, 774, 22142, 297, 288, 283, 600, 356, 283, 52, 840, 297, 288, 283, 466, 356, 283, 9533, 297, 267, 3828, 398, 9605, 63, 3620, 275, 291, 14, 1813, 459, 1198, 14, 3620, 2278, 981, 2561, 288, 283, 3620, 63, 354, 356, 283, 396, 13, 19815, 297, 288, 283, 3620, 63, 1238, 63, 344, 356, 291, 14, 1813, 14, 1121, 360, 2048, 14, 1238, 63, 2048, 63, 1185, 1959, 344, 12, 288, 283, 3620, 63, 4322, 356, 2022, 14, 4180, 2561, 355, 283, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 355, 283, 4627, 63, 344, 356, 291, 14, 1813, 14, 751, 14, 4627, 63, 344, 14, 344, 12, 355, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 12, 288, 9998, 267, 3828, 267, 291, 14, 7067, 14, 952, 3252, 3620, 63, 344, 356, 9605, 63, 3620, 14, 344, 1552, 398, 291, 14, 10103, 63, 751, 275, 291, 14, 1813, 14, 1121, 360, 1095, 14, 751, 63, 8768, 358, 339, 347, 511, 63, 17294, 63, 5404, 63, 391, 1672, 63, 504, 63, 17294, 8, 277, 304, 267, 1245, 63, 6751, 275, 469, 288, 283, 1188, 63, 344, 356, 283, 1188, 13, 344, 13, 10957, 13, 19446, 70, 297, 288, 283, 5875, 356, 283, 607, 7909, 330, 778, 297, 288, 283, 504, 356, 1543, 83, 21808, 83, 3524, 450, 334, 277, 14, 17294, 63, 3899, 14, 354, 12, 291, 14, 17294, 63, 3899, 14, 2123, 395, 288, 283, 475, 356, 1543, 83, 19437, 83, 7, 450, 334, 277, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 354, 12, 291, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 2261, 395, 288, 283, 2030, 356, 298, 5556, 5715, 12, 626, 8377, 626, 1265, 330, 20816, 4765, 288, 283, 15855, 356, 359, 66, 7, 6257, 12, 8485, 995, 267, 789, 398, 8485, 275, 291, 14, 1813, 459, 2048, 14, 1185, 2278, 1188, 63, 1222, 8, 1188, 63, 6751, 12, 791, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 1552, 398, 1245, 63, 1580, 275, 8485, 14, 1188, 63, 1580, 267, 291, 14, 629, 8, 552, 8, 1188, 63, 1580, 395, 413, 12, 283, 5903, 1373, 1245, 1077, 506, 22752, 315, 314, 682, 3760, 358, 267, 291, 14, 629, 8, 1188, 63, 1580, 14, 2030, 12, 2650, 80, 30, 27111, 699, 778, 18208, 1108, 80, 4206, 283, 5903, 314, 8485, 7143, 1077, 506, 22752, 358, 398, 2569, 63, 23385, 275, 8485, 14, 1188, 63, 25615, 63, 1580, 14, 11663, 360, 3899, 63, 344, 358, 267, 291, 14, 629, 8, 21589, 63, 23385, 12, 291, 14, 1813, 14, 1121, 360, 1095, 14, 3899, 63, 1231, 1333, 339, 347, 511, 63, 17294, 63, 5404, 63, 509, 15295, 63, 991, 63, 4672, 63, 751, 63, 7395, 63, 17294, 8, 277, 304, 267, 408, 1010, 642, 511, 12, 314, 330, 778, 1990, 24172, 701, 376, 15778, 12, 288, 1325, 949, 5854, 3031, 2287, 365, 1911, 315, 314, 2396, 1041, 267, 1245, 63, 6751, 275, 469, 288, 283, 1188, 63, 344, 356, 283, 1188, 13, 344, 13, 10957, 13, 19446, 70, 297, 288, 283, 5875, 356, 283, 607, 7909, 330, 778, 297, 288, 283, 504, 356, 1543, 83, 21808, 83, 3524, 450, 334, 277, 14, 4672, 63, 751, 14, 354, 12, 291, 14, 4672, 63, 751, 14, 2123, 395, 288, 283, 475, 356, 1543, 83, 19437, 83, 7, 450, 334, 277, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 354, 12, 291, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 2261, 395, 288, 283, 2030, 356, 298, 5556, 5715, 12, 626, 8377, 626, 1265, 330, 20816, 4765, 288, 283, 15855, 356, 359, 66, 7, 6257, 12, 8485, 995, 267, 789, 398, 8485, 275, 291, 14, 1813, 459, 2048, 14, 1185, 2278, 1188, 63, 1222, 8, 1188, 63, 6751, 12, 791, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 1552, 398, 1245, 63, 1580, 275, 8485, 14, 1188, 63, 1580, 267, 291, 14, 629, 8, 552, 8, 1188, 63, 1580, 395, 413, 12, 283, 5903, 1373, 1245, 1077, 506, 22752, 315, 314, 682, 3760, 358, 267, 291, 14, 629, 8, 1188, 63, 1580, 14, 2030, 12, 2650, 80, 30, 27111, 699, 778, 18208, 1108, 80, 4206, 283, 5903, 314, 8485, 7143, 1077, 506, 22752, 358, 398, 2569, 63, 23385, 275, 8485, 14, 1188, 63, 25615, 63, 1580, 14, 11663, 360, 3899, 63, 344, 358, 267, 291, 14, 629, 8, 21589, 63, 23385, 12, 291, 14, 1813, 14, 1121, 360, 1095, 14, 3899, 63, 1231, 358, 1204, 291, 14, 4672, 63, 751, 14, 3899, 63, 344, 9, 339, 347, 511, 63, 17294, 63, 5404, 63, 509, 15295, 63, 991, 63, 4672, 63, 1045, 63, 17294, 63, 262 ]
[ 2022, 199, 199, 504, 28811, 14, 10788, 14, 2048, 14, 2219, 14, 2330, 492, 9973, 774, 7844, 199, 504, 28811, 14, 2219, 492, 20018, 421, 199, 32, 15679, 360, 1932, 63, 3174, 297, 2475, 292, 63, 3174, 358, 199, 533, 1379, 6009, 607, 7909, 30080, 21092, 8, 6009, 774, 7844, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 6009, 607, 7909, 30080, 21092, 12, 291, 680, 5996, 342, 398, 291, 14, 1813, 459, 723, 14, 888, 63, 5329, 2278, 12095, 1252, 409, 63, 635, 360, 1198, 14, 9341, 452, 14, 2261, 297, 283, 396, 13, 4627, 14, 22058, 14, 957, 358, 398, 291, 14, 4672, 63, 751, 275, 291, 14, 1813, 459, 470, 14, 3707, 2278, 981, 2561, 288, 283, 354, 356, 283, 8405, 2876, 297, 288, 283, 2886, 356, 283, 4672, 14, 751, 32, 396, 14, 22058, 14, 957, 297, 288, 283, 2123, 356, 283, 4672, 14, 751, 32, 396, 14, 22058, 14, 957, 297, 267, 3828, 398, 291, 14, 17294, 63, 3899, 275, 291, 14, 1813, 459, 470, 14, 3899, 2278, 981, 2561, 288, 283, 354, 356, 283, 14398, 29083, 5697, 297, 288, 283, 2123, 356, 283, 17294, 32, 1848, 14, 4627, 14, 957, 297, 288, 283, 17294, 63, 4648, 356, 1616, 12, 267, 3828, 398, 291, 14, 7067, 275, 291, 14, 1813, 459, 2048, 14, 7067, 2278, 981, 2561, 288, 283, 354, 356, 283, 774, 22142, 297, 288, 283, 600, 356, 283, 52, 840, 297, 288, 283, 466, 356, 283, 9533, 297, 267, 3828, 398, 9605, 63, 3620, 275, 291, 14, 1813, 459, 1198, 14, 3620, 2278, 981, 2561, 288, 283, 3620, 63, 354, 356, 283, 396, 13, 19815, 297, 288, 283, 3620, 63, 1238, 63, 344, 356, 291, 14, 1813, 14, 1121, 360, 2048, 14, 1238, 63, 2048, 63, 1185, 1959, 344, 12, 288, 283, 3620, 63, 4322, 356, 2022, 14, 4180, 2561, 355, 283, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 355, 283, 4627, 63, 344, 356, 291, 14, 1813, 14, 751, 14, 4627, 63, 344, 14, 344, 12, 355, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 12, 288, 9998, 267, 3828, 267, 291, 14, 7067, 14, 952, 3252, 3620, 63, 344, 356, 9605, 63, 3620, 14, 344, 1552, 398, 291, 14, 10103, 63, 751, 275, 291, 14, 1813, 14, 1121, 360, 1095, 14, 751, 63, 8768, 358, 339, 347, 511, 63, 17294, 63, 5404, 63, 391, 1672, 63, 504, 63, 17294, 8, 277, 304, 267, 1245, 63, 6751, 275, 469, 288, 283, 1188, 63, 344, 356, 283, 1188, 13, 344, 13, 10957, 13, 19446, 70, 297, 288, 283, 5875, 356, 283, 607, 7909, 330, 778, 297, 288, 283, 504, 356, 1543, 83, 21808, 83, 3524, 450, 334, 277, 14, 17294, 63, 3899, 14, 354, 12, 291, 14, 17294, 63, 3899, 14, 2123, 395, 288, 283, 475, 356, 1543, 83, 19437, 83, 7, 450, 334, 277, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 354, 12, 291, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 2261, 395, 288, 283, 2030, 356, 298, 5556, 5715, 12, 626, 8377, 626, 1265, 330, 20816, 4765, 288, 283, 15855, 356, 359, 66, 7, 6257, 12, 8485, 995, 267, 789, 398, 8485, 275, 291, 14, 1813, 459, 2048, 14, 1185, 2278, 1188, 63, 1222, 8, 1188, 63, 6751, 12, 791, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 1552, 398, 1245, 63, 1580, 275, 8485, 14, 1188, 63, 1580, 267, 291, 14, 629, 8, 552, 8, 1188, 63, 1580, 395, 413, 12, 283, 5903, 1373, 1245, 1077, 506, 22752, 315, 314, 682, 3760, 358, 267, 291, 14, 629, 8, 1188, 63, 1580, 14, 2030, 12, 2650, 80, 30, 27111, 699, 778, 18208, 1108, 80, 4206, 283, 5903, 314, 8485, 7143, 1077, 506, 22752, 358, 398, 2569, 63, 23385, 275, 8485, 14, 1188, 63, 25615, 63, 1580, 14, 11663, 360, 3899, 63, 344, 358, 267, 291, 14, 629, 8, 21589, 63, 23385, 12, 291, 14, 1813, 14, 1121, 360, 1095, 14, 3899, 63, 1231, 1333, 339, 347, 511, 63, 17294, 63, 5404, 63, 509, 15295, 63, 991, 63, 4672, 63, 751, 63, 7395, 63, 17294, 8, 277, 304, 267, 408, 1010, 642, 511, 12, 314, 330, 778, 1990, 24172, 701, 376, 15778, 12, 288, 1325, 949, 5854, 3031, 2287, 365, 1911, 315, 314, 2396, 1041, 267, 1245, 63, 6751, 275, 469, 288, 283, 1188, 63, 344, 356, 283, 1188, 13, 344, 13, 10957, 13, 19446, 70, 297, 288, 283, 5875, 356, 283, 607, 7909, 330, 778, 297, 288, 283, 504, 356, 1543, 83, 21808, 83, 3524, 450, 334, 277, 14, 4672, 63, 751, 14, 354, 12, 291, 14, 4672, 63, 751, 14, 2123, 395, 288, 283, 475, 356, 1543, 83, 19437, 83, 7, 450, 334, 277, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 354, 12, 291, 14, 7067, 14, 3620, 63, 344, 14, 3620, 63, 2261, 395, 288, 283, 2030, 356, 298, 5556, 5715, 12, 626, 8377, 626, 1265, 330, 20816, 4765, 288, 283, 15855, 356, 359, 66, 7, 6257, 12, 8485, 995, 267, 789, 398, 8485, 275, 291, 14, 1813, 459, 2048, 14, 1185, 2278, 1188, 63, 1222, 8, 1188, 63, 6751, 12, 791, 1185, 63, 466, 356, 283, 262, 63, 5404, 297, 283, 7067, 63, 344, 356, 291, 14, 7067, 14, 344, 1552, 398, 1245, 63, 1580, 275, 8485, 14, 1188, 63, 1580, 267, 291, 14, 629, 8, 552, 8, 1188, 63, 1580, 395, 413, 12, 283, 5903, 1373, 1245, 1077, 506, 22752, 315, 314, 682, 3760, 358, 267, 291, 14, 629, 8, 1188, 63, 1580, 14, 2030, 12, 2650, 80, 30, 27111, 699, 778, 18208, 1108, 80, 4206, 283, 5903, 314, 8485, 7143, 1077, 506, 22752, 358, 398, 2569, 63, 23385, 275, 8485, 14, 1188, 63, 25615, 63, 1580, 14, 11663, 360, 3899, 63, 344, 358, 267, 291, 14, 629, 8, 21589, 63, 23385, 12, 291, 14, 1813, 14, 1121, 360, 1095, 14, 3899, 63, 1231, 358, 1204, 291, 14, 4672, 63, 751, 14, 3899, 63, 344, 9, 339, 347, 511, 63, 17294, 63, 5404, 63, 509, 15295, 63, 991, 63, 4672, 63, 1045, 63, 17294, 63, 262, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ccsplit/spiderfoot
modules/sfp_junkfiles.py
7
6240
# -*- coding: utf-8 -*- # ------------------------------------------------------------------------------- # Name: sfp_junkfiles # Purpose: From Spidering, identifies backup and temporary files. # # Author: Steve Micallef <steve@binarypool.com> # # Created: 23/08/2014 # Copyright: (c) Steve Micallef 2014 # Licence: GPL # ------------------------------------------------------------------------------- from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent class sfp_junkfiles(SpiderFootPlugin): """Junk Files:Looks for old/temporary and other similar files.""" # Default options opts = { 'fileexts': ['tmp', 'bak', 'old', 'backup', 'new'], 'urlextstry': ['html', 'htm', 'php', 'jsp', 'txt', 'js'], 'files': ['x', 'xxx', 'crap', 'old', 'a', 'aaa', 'z', 'zzz', 'out', 'sql', "passwd", ".htaccess", ".htpasswd", "Thumbs.db", "asd", "asdf"], 'dirs': ['zip', 'tar.gz', 'tgz', 'tar'] } # Option descriptions optdescs = { 'fileexts': "File extensions to try.", 'urlextstry': "Try those extensions against URLs with these extensions.", 'files': "Try to fetch each of these files from the directory of the URL.", 'dirs': "Try to fetch the containing folder with these extensions." } results = list() def setup(self, sfc, userOpts=dict()): self.sf = sfc self.results = list() for opt in userOpts.keys(): self.opts[opt] = userOpts[opt] # What events is this module interested in for input def watchedEvents(self): return ["LINKED_URL_INTERNAL"] # What events this module produces # This is to support the end user in selecting modules based on events # produced. def producedEvents(self): return ["JUNK_FILE"] # Handle events sent to this module def handleEvent(self, event): eventName = event.eventType srcModuleName = event.module eventData = event.data self.sf.debug("Received event, " + eventName + ", from " + srcModuleName) if eventData in self.results: return None else: self.results.append(eventData) # http://www/blah/abc.html -> try http://www/blah/abc.html.[fileexts] for ext in self.opts['urlextstry']: if "." + ext + "?" in eventData or "." + ext + "#" in eventData or \ eventData.endswith(ext): bits = eventData.split("?") for x in self.opts['fileexts']: self.sf.debug("Trying " + x + " against " + eventData) fetch = bits[0] + "." + x if fetch not in self.results: self.results.append(fetch) else: continue res = self.sf.fetchUrl(fetch, timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent']) if res['content'] is not None and res['code'] != "404": evt = SpiderFootEvent("JUNK_FILE", fetch, self.__name__, event) self.notifyListeners(evt) # http://www or http://www/ # -> try index pages if eventData.endswith("/") or eventData.count("/") == 2: for ext in ["index.html", "index.htm", "default.htm"]: self.sf.debug("Trying " + ext + " against " + eventData) for x in self.opts['fileexts']: fetch = eventData + "/" + ext + "." + x if fetch not in self.results: self.results.append(fetch) else: continue res = self.sf.fetchUrl(fetch, timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent']) if res['content'] is not None and res['code'] != "404": evt = SpiderFootEvent("JUNK_FILE", fetch, self.__name__, event) self.notifyListeners(evt) base = self.sf.urlBaseDir(eventData) # don't do anything with the root directory of a site if base == eventData + "/" or base == eventData: return None # http://www/blah/abc.html -> try http://www/blah.[dirs] for dirfile in self.opts['dirs']: self.sf.debug("Trying " + dirfile + " against " + eventData) fetch = base[0:len(base) - 1] + "." + dirfile if fetch not in self.results: self.results.append(fetch) else: continue res = self.sf.fetchUrl(fetch, timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent']) if res['content'] is not None and res['code'] != "404": evt = SpiderFootEvent("JUNK_FILE", fetch, self.__name__, event) self.notifyListeners(evt) # http://www/blah/abc.html -> try http://www/blah/[files] for f in self.opts['files']: self.sf.debug("Trying " + f + " against " + eventData) fetch = base + f if fetch not in self.results: self.results.append(fetch) else: continue res = self.sf.fetchUrl(fetch, timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent']) if res['content'] is not None and res['code'] != "404": evt = SpiderFootEvent("JUNK_FILE", fetch, self.__name__, event) self.notifyListeners(evt) return None # End of sfp_junkfiles class
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 5620, 18964, 202, 199, 3, 2812, 26, 260, 308, 3997, 63, 17941, 1725, 202, 199, 3, 23177, 4070, 26, 420, 11606, 428, 12508, 316, 12, 22975, 6902, 436, 7937, 1584, 14, 202, 199, 3, 202, 199, 3, 6529, 26, 420, 17854, 432, 603, 2652, 21491, 665, 1597, 432, 32, 3008, 2293, 14, 957, 30, 202, 199, 3, 202, 199, 3, 18208, 26, 258, 6546, 15, 2036, 15, 7280, 202, 199, 3, 1898, 26, 257, 334, 67, 9, 17854, 432, 603, 2652, 21491, 6927, 202, 199, 3, 491, 530, 4894, 26, 258, 14629, 202, 199, 3, 5620, 18964, 2999, 199, 504, 13330, 773, 492, 428, 12508, 15563, 357, 12, 428, 12508, 15563, 357, 5061, 12, 428, 12508, 15563, 357, 2390, 8065, 199, 533, 308, 3997, 63, 17941, 1725, 8, 25157, 15563, 357, 5061, 304, 1128, 408, 42, 1778, 16920, 26, 20926, 83, 367, 2269, 15, 13555, 436, 1163, 8545, 1584, 1041, 2958, 327, 3758, 1511, 1128, 3999, 275, 469, 1039, 283, 493, 25752, 356, 788, 2791, 297, 283, 27162, 297, 283, 1753, 297, 283, 5751, 297, 283, 1222, 995, 1039, 283, 300, 274, 400, 27723, 356, 788, 1360, 297, 283, 15575, 297, 283, 8624, 297, 283, 74, 681, 297, 283, 2424, 297, 283, 3596, 995, 1039, 283, 1725, 356, 788, 88, 297, 283, 10013, 297, 283, 67, 1330, 297, 283, 1753, 297, 283, 65, 297, 283, 11629, 297, 283, 90, 297, 283, 29414, 297, 28086, 283, 548, 297, 283, 3009, 297, 298, 12671, 401, 3680, 72, 27308, 670, 401, 3680, 517, 12671, 401, 28086, 298, 2719, 23135, 14, 697, 401, 298, 305, 68, 401, 298, 18196, 2255, 1039, 283, 3220, 356, 788, 3065, 297, 283, 5369, 14, 6838, 297, 283, 27220, 297, 283, 5369, 418, 1128, 789, 2958, 327, 3207, 18714, 1128, 2450, 3257, 83, 275, 469, 1039, 283, 493, 25752, 356, 298, 1173, 5478, 370, 862, 4765, 1039, 283, 300, 274, 400, 27723, 356, 298, 12357, 5204, 5478, 6169, 10867, 543, 3520, 5478, 4765, 1039, 283, 1725, 356, 298, 12357, 370, 5267, 1924, 402, 3520, 1584, 687, 314, 2082, 402, 314, 2851, 4765, 1039, 283, 3220, 356, 298, 12357, 370, 5267, 314, 3035, 4922, 543, 3520, 5478, 2122, 1128, 789, 2958, 2058, 275, 769, 342, 2958, 347, 3272, 8, 277, 12, 308, 3003, 12, 922, 24429, 29, 807, 5109, 1039, 291, 14, 7646, 275, 308, 3003, 1039, 291, 14, 2604, 275, 769, 342, 4341, 367, 2450, 315, 922, 24429, 14, 1612, 837, 1675, 291, 14, 3291, 59, 2992, 61, 275, 922, 24429, 59, 2992, 61, 2958, 327, 14791, 4474, 365, 642, 859, 22201, 315, 367, 1324, 1128, 347, 9626, 379, 11770, 8, 277, 304, 1039, 372, 2097, 7916, 1149, 63, 2632, 63, 17681, 937, 2958, 327, 14791, 4474, 642, 859, 16904, 1128, 327, 961, 365, 370, 2291, 314, 1284, 922, 315, 30090, 4621, 4079, 641, 4474, 1128, 327, 13584, 14, 1128, 347, 13584, 11770, 8, 277, 304, 1039, 372, 2097, 42, 8019, 63, 3817, 937, 2958, 327, 8690, 4474, 4847, 370, 642, 859, 1128, 347, 2429, 2390, 8, 277, 12, 1566, 304, 1039, 1566, 985, 275, 1566, 14, 1430, 804, 1039, 2928, 2377, 985, 275, 1566, 14, 578, 1039, 1566, 1451, 275, 1566, 14, 576, 4341, 291, 14, 7646, 14, 1757, 480, 9392, 1566, 12, 298, 435, 1566, 985, 435, 3872, 687, 298, 435, 2928, 2377, 985, 9, 4341, 340, 1566, 1451, 315, 291, 14, 2604, 26, 1675, 372, 488, 1039, 587, 26, 1675, 291, 14, 2604, 14, 740, 8, 1430, 1451, 9, 4341, 327, 1455, 921, 1544, 15, 12702, 15, 3175, 14, 1360, 1035, 862, 1455, 921, 1544, 15, 12702, 15, 3175, 14, 1360, 24097, 493, 25752, 61, 1039, 367, 1599, 315, 291, 14, 3291, 459, 300, 274, 400, 27723, 2565, 1675, 340, 14530, 435, 1599, 435, 29325, 315, 1566, 1451, 503, 14530, 435, 1599, 435, 5426, 2, 315, 1566, 1451, 503, 971, 4906, 1566, 1451, 14, 4130, 8, 832, 304, 2628, 5821, 275, 1566, 1451, 14, 1294, 480, 18582, 2628, 367, 671, 315, 291, 14, 3291, 459, 493, 25752, 2565, 4906, 291, 14, 7646, 14, 1757, 480, 27693, 298, 435, 671, 435, 298, 6169, 298, 435, 1566, 1451, 9, 4906, 5267, 275, 5821, 59, 16, 61, 435, 14530, 435, 671, 4906, 340, 5267, 440, 315, 291, 14, 2604, 26, 8282, 291, 14, 2604, 14, 740, 8, 3535, 9, 4906, 587, 26, 8282, 1980, 4906, 522, 275, 291, 14, 7646, 14, 3535, 6417, 8, 3535, 12, 202, 5644, 2653, 29, 277, 14, 3291, 8680, 3535, 2593, 995, 202, 5644, 922, 4054, 29, 277, 14, 3291, 8680, 751, 4054, 1105, 4906, 340, 522, 459, 1317, 418, 365, 440, 488, 436, 522, 459, 600, 418, 1137, 298, 5188, 582, 8282, 16330, 275, 428, 12508, 15563, 357, 2390, 480, 42, 8019, 63, 3817, 401, 5267, 12, 202, 6343, 291, 855, 354, 3108, 1566, 9, 8282, 291, 14, 6814, 8687, 1192, 8, 19296, 9, 4341, 327, 1455, 921, 1544, 503, 1455, 921, 1544, 15, 1039, 327, 1035, 862, 1478, 6497, 1039, 340, 1566, 1451, 14, 4130, 19031, 503, 1566, 1451, 14, 835, 19031, 508, 499, 26, 1675, 367, 1599, 315, 2097, 1080, 14, 1360, 401, 298, 1080, 14, 15575, 401, 298, 885, 14, 15575, 6229, 2628, 291, 14, 7646, 14, 1757, 480, 27693, 298, 435, 1599, 435, 298, 6169, 298, 435, 1566, 1451, 9, 2628, 367, 671, 315, 291, 14, 3291, 459, 493, 25752, 2565, 4906, 5267, 275, 1566, 1451, 435, 10609, 435, 1599, 435, 14530, 435, 671, 4906, 340, 5267, 440, 315, 291, 14, 2604, 26, 8282, 291, 14, 2604, 14, 740, 8, 3535, 9, 4906, 587, 26, 8282, 1980, 4906, 522, 275, 291, 14, 7646, 14, 3535, 6417, 8, 3535, 12, 202, 5644, 2653, 29, 277, 14, 3291, 8680, 3535, 2593, 995, 202, 5644, 922, 4054, 29, 277, 14, 3291, 8680, 751, 4054, 1105, 4906, 340, 522, 459, 1317, 418, 365, 440, 488, 436, 522, 459, 600, 418, 1137, 298, 5188, 582, 8282, 16330, 275, 428, 12508, 15563, 357, 2390, 480, 42, 8019, 63, 3817, 401, 5267, 12, 202, 6343, 291, 855, 354, 3108, 1566, 9, 8282, 291, 14, 6814, 8687, 1192, 8, 19296, 9, 4341, 1300, 275, 291, 14, 7646, 14, 633, 1563 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 5620, 18964, 202, 199, 3, 2812, 26, 260, 308, 3997, 63, 17941, 1725, 202, 199, 3, 23177, 4070, 26, 420, 11606, 428, 12508, 316, 12, 22975, 6902, 436, 7937, 1584, 14, 202, 199, 3, 202, 199, 3, 6529, 26, 420, 17854, 432, 603, 2652, 21491, 665, 1597, 432, 32, 3008, 2293, 14, 957, 30, 202, 199, 3, 202, 199, 3, 18208, 26, 258, 6546, 15, 2036, 15, 7280, 202, 199, 3, 1898, 26, 257, 334, 67, 9, 17854, 432, 603, 2652, 21491, 6927, 202, 199, 3, 491, 530, 4894, 26, 258, 14629, 202, 199, 3, 5620, 18964, 2999, 199, 504, 13330, 773, 492, 428, 12508, 15563, 357, 12, 428, 12508, 15563, 357, 5061, 12, 428, 12508, 15563, 357, 2390, 8065, 199, 533, 308, 3997, 63, 17941, 1725, 8, 25157, 15563, 357, 5061, 304, 1128, 408, 42, 1778, 16920, 26, 20926, 83, 367, 2269, 15, 13555, 436, 1163, 8545, 1584, 1041, 2958, 327, 3758, 1511, 1128, 3999, 275, 469, 1039, 283, 493, 25752, 356, 788, 2791, 297, 283, 27162, 297, 283, 1753, 297, 283, 5751, 297, 283, 1222, 995, 1039, 283, 300, 274, 400, 27723, 356, 788, 1360, 297, 283, 15575, 297, 283, 8624, 297, 283, 74, 681, 297, 283, 2424, 297, 283, 3596, 995, 1039, 283, 1725, 356, 788, 88, 297, 283, 10013, 297, 283, 67, 1330, 297, 283, 1753, 297, 283, 65, 297, 283, 11629, 297, 283, 90, 297, 283, 29414, 297, 28086, 283, 548, 297, 283, 3009, 297, 298, 12671, 401, 3680, 72, 27308, 670, 401, 3680, 517, 12671, 401, 28086, 298, 2719, 23135, 14, 697, 401, 298, 305, 68, 401, 298, 18196, 2255, 1039, 283, 3220, 356, 788, 3065, 297, 283, 5369, 14, 6838, 297, 283, 27220, 297, 283, 5369, 418, 1128, 789, 2958, 327, 3207, 18714, 1128, 2450, 3257, 83, 275, 469, 1039, 283, 493, 25752, 356, 298, 1173, 5478, 370, 862, 4765, 1039, 283, 300, 274, 400, 27723, 356, 298, 12357, 5204, 5478, 6169, 10867, 543, 3520, 5478, 4765, 1039, 283, 1725, 356, 298, 12357, 370, 5267, 1924, 402, 3520, 1584, 687, 314, 2082, 402, 314, 2851, 4765, 1039, 283, 3220, 356, 298, 12357, 370, 5267, 314, 3035, 4922, 543, 3520, 5478, 2122, 1128, 789, 2958, 2058, 275, 769, 342, 2958, 347, 3272, 8, 277, 12, 308, 3003, 12, 922, 24429, 29, 807, 5109, 1039, 291, 14, 7646, 275, 308, 3003, 1039, 291, 14, 2604, 275, 769, 342, 4341, 367, 2450, 315, 922, 24429, 14, 1612, 837, 1675, 291, 14, 3291, 59, 2992, 61, 275, 922, 24429, 59, 2992, 61, 2958, 327, 14791, 4474, 365, 642, 859, 22201, 315, 367, 1324, 1128, 347, 9626, 379, 11770, 8, 277, 304, 1039, 372, 2097, 7916, 1149, 63, 2632, 63, 17681, 937, 2958, 327, 14791, 4474, 642, 859, 16904, 1128, 327, 961, 365, 370, 2291, 314, 1284, 922, 315, 30090, 4621, 4079, 641, 4474, 1128, 327, 13584, 14, 1128, 347, 13584, 11770, 8, 277, 304, 1039, 372, 2097, 42, 8019, 63, 3817, 937, 2958, 327, 8690, 4474, 4847, 370, 642, 859, 1128, 347, 2429, 2390, 8, 277, 12, 1566, 304, 1039, 1566, 985, 275, 1566, 14, 1430, 804, 1039, 2928, 2377, 985, 275, 1566, 14, 578, 1039, 1566, 1451, 275, 1566, 14, 576, 4341, 291, 14, 7646, 14, 1757, 480, 9392, 1566, 12, 298, 435, 1566, 985, 435, 3872, 687, 298, 435, 2928, 2377, 985, 9, 4341, 340, 1566, 1451, 315, 291, 14, 2604, 26, 1675, 372, 488, 1039, 587, 26, 1675, 291, 14, 2604, 14, 740, 8, 1430, 1451, 9, 4341, 327, 1455, 921, 1544, 15, 12702, 15, 3175, 14, 1360, 1035, 862, 1455, 921, 1544, 15, 12702, 15, 3175, 14, 1360, 24097, 493, 25752, 61, 1039, 367, 1599, 315, 291, 14, 3291, 459, 300, 274, 400, 27723, 2565, 1675, 340, 14530, 435, 1599, 435, 29325, 315, 1566, 1451, 503, 14530, 435, 1599, 435, 5426, 2, 315, 1566, 1451, 503, 971, 4906, 1566, 1451, 14, 4130, 8, 832, 304, 2628, 5821, 275, 1566, 1451, 14, 1294, 480, 18582, 2628, 367, 671, 315, 291, 14, 3291, 459, 493, 25752, 2565, 4906, 291, 14, 7646, 14, 1757, 480, 27693, 298, 435, 671, 435, 298, 6169, 298, 435, 1566, 1451, 9, 4906, 5267, 275, 5821, 59, 16, 61, 435, 14530, 435, 671, 4906, 340, 5267, 440, 315, 291, 14, 2604, 26, 8282, 291, 14, 2604, 14, 740, 8, 3535, 9, 4906, 587, 26, 8282, 1980, 4906, 522, 275, 291, 14, 7646, 14, 3535, 6417, 8, 3535, 12, 202, 5644, 2653, 29, 277, 14, 3291, 8680, 3535, 2593, 995, 202, 5644, 922, 4054, 29, 277, 14, 3291, 8680, 751, 4054, 1105, 4906, 340, 522, 459, 1317, 418, 365, 440, 488, 436, 522, 459, 600, 418, 1137, 298, 5188, 582, 8282, 16330, 275, 428, 12508, 15563, 357, 2390, 480, 42, 8019, 63, 3817, 401, 5267, 12, 202, 6343, 291, 855, 354, 3108, 1566, 9, 8282, 291, 14, 6814, 8687, 1192, 8, 19296, 9, 4341, 327, 1455, 921, 1544, 503, 1455, 921, 1544, 15, 1039, 327, 1035, 862, 1478, 6497, 1039, 340, 1566, 1451, 14, 4130, 19031, 503, 1566, 1451, 14, 835, 19031, 508, 499, 26, 1675, 367, 1599, 315, 2097, 1080, 14, 1360, 401, 298, 1080, 14, 15575, 401, 298, 885, 14, 15575, 6229, 2628, 291, 14, 7646, 14, 1757, 480, 27693, 298, 435, 1599, 435, 298, 6169, 298, 435, 1566, 1451, 9, 2628, 367, 671, 315, 291, 14, 3291, 459, 493, 25752, 2565, 4906, 5267, 275, 1566, 1451, 435, 10609, 435, 1599, 435, 14530, 435, 671, 4906, 340, 5267, 440, 315, 291, 14, 2604, 26, 8282, 291, 14, 2604, 14, 740, 8, 3535, 9, 4906, 587, 26, 8282, 1980, 4906, 522, 275, 291, 14, 7646, 14, 3535, 6417, 8, 3535, 12, 202, 5644, 2653, 29, 277, 14, 3291, 8680, 3535, 2593, 995, 202, 5644, 922, 4054, 29, 277, 14, 3291, 8680, 751, 4054, 1105, 4906, 340, 522, 459, 1317, 418, 365, 440, 488, 436, 522, 459, 600, 418, 1137, 298, 5188, 582, 8282, 16330, 275, 428, 12508, 15563, 357, 2390, 480, 42, 8019, 63, 3817, 401, 5267, 12, 202, 6343, 291, 855, 354, 3108, 1566, 9, 8282, 291, 14, 6814, 8687, 1192, 8, 19296, 9, 4341, 1300, 275, 291, 14, 7646, 14, 633, 1563, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dmitriy0611/django
tests/forms_tests/tests/test_media.py
169
45896
# -*- coding: utf-8 -*- from django.forms import CharField, Form, Media, MultiWidget, TextInput from django.template import Context, Template from django.test import SimpleTestCase, override_settings from django.utils.encoding import force_text @override_settings( STATIC_URL=None, MEDIA_URL='http://media.example.com/media/', ) class FormsMediaTestCase(SimpleTestCase): """Tests for the media handling on widgets and forms""" def test_construction(self): # Check construction of media objects m = Media(css={'all': ('path/to/css1', '/path/to/css2')}, js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')) self.assertEqual(str(m), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") class Foo: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') m3 = Media(Foo) self.assertEqual(str(m3), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # A widget can exist without a media definition class MyWidget(TextInput): pass w = MyWidget() self.assertEqual(str(w.media), '') def test_media_dsl(self): ############################################################### # DSL Class-based media definitions ############################################################### # A widget can define media if it needs to. # Any absolute path will be preserved; relative paths are combined # with the value of settings.MEDIA_URL class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') w1 = MyWidget1() self.assertEqual(str(w1.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # Media objects can be interrogated by media type self.assertEqual(str(w1.media['css']), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />""") self.assertEqual(str(w1.media['js']), """<script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") def test_combine_media(self): # Media objects can be combined. Any given media resource will appear only # once. Duplicated media definitions are ignored. class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w1 = MyWidget1() w2 = MyWidget2() w3 = MyWidget3() self.assertEqual(str(w1.media + w2.media + w3.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Check that media addition hasn't affected the original objects self.assertEqual(str(w1.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # Regression check for #12879: specifying the same CSS or JS file # multiple times in a single Media instance should result in that file # only being included once. class MyWidget4(TextInput): class Media: css = {'all': ('/path/to/css1', '/path/to/css1')} js = ('/path/to/js1', '/path/to/js1') w4 = MyWidget4() self.assertEqual(str(w4.media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script>""") def test_media_property(self): ############################################################### # Property-based media definitions ############################################################### # Widget media can be defined as a property class MyWidget4(TextInput): def _media(self): return Media(css={'all': ('/some/path',)}, js=('/some/js',)) media = property(_media) w4 = MyWidget4() self.assertEqual(str(w4.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script>""") # Media properties can reference the media of their parents class MyWidget5(MyWidget4): def _media(self): return super(MyWidget5, self).media + Media(css={'all': ('/other/path',)}, js=('/other/js',)) media = property(_media) w5 = MyWidget5() self.assertEqual(str(w5.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script> <script type="text/javascript" src="/other/js"></script>""") def test_media_property_parent_references(self): # Media properties can reference the media of their parents, # even if the parent media was defined using a class class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget6(MyWidget1): def _media(self): return super(MyWidget6, self).media + Media(css={'all': ('/other/path',)}, js=('/other/js',)) media = property(_media) w6 = MyWidget6() self.assertEqual(str(w6.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/other/js"></script>""") def test_media_inheritance(self): ############################################################### # Inheritance of media ############################################################### # If a widget extends another but provides no media definition, it inherits the parent widget's media class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget7(MyWidget1): pass w7 = MyWidget7() self.assertEqual(str(w7.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # If a widget extends another but defines media, it extends the parent widget's media by default class MyWidget8(MyWidget1): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w8 = MyWidget8() self.assertEqual(str(w8.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_from_property(self): # If a widget extends another but defines media, it extends the parents widget's media, # even if the parent defined media using a property. class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget4(TextInput): def _media(self): return Media(css={'all': ('/some/path',)}, js=('/some/js',)) media = property(_media) class MyWidget9(MyWidget4): class Media: css = { 'all': ('/other/path',) } js = ('/other/js',) w9 = MyWidget9() self.assertEqual(str(w9.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script> <script type="text/javascript" src="/other/js"></script>""") # A widget can disable media inheritance by specifying 'extend=False' class MyWidget10(MyWidget1): class Media: extend = False css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w10 = MyWidget10() self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_extends(self): # A widget can explicitly enable full media inheritance by specifying 'extend=True' class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget11(MyWidget1): class Media: extend = True css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w11 = MyWidget11() self.assertEqual(str(w11.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_single_type(self): # A widget can enable inheritance of one media type by specifying extend as a tuple class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget12(MyWidget1): class Media: extend = ('css',) css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w12 = MyWidget12() self.assertEqual(str(w12.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_multi_media(self): ############################################################### # Multi-media handling for CSS ############################################################### # A widget can define CSS media for multiple output media types class MultimediaWidget(TextInput): class Media: css = { 'screen, print': ('/file1', '/file2'), 'screen': ('/file3',), 'print': ('/file4',) } js = ('/path/to/js1', '/path/to/js4') multimedia = MultimediaWidget() self.assertEqual(str(multimedia.media), """<link href="/file4" type="text/css" media="print" rel="stylesheet" /> <link href="/file3" type="text/css" media="screen" rel="stylesheet" /> <link href="/file1" type="text/css" media="screen, print" rel="stylesheet" /> <link href="/file2" type="text/css" media="screen, print" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_multi_widget(self): ############################################################### # Multiwidget media handling ############################################################### class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') # MultiWidgets have a default media definition that gets all the # media from the component widgets class MyMultiWidget(MultiWidget): def __init__(self, attrs=None): widgets = [MyWidget1, MyWidget2, MyWidget3] super(MyMultiWidget, self).__init__(widgets, attrs) mymulti = MyMultiWidget() self.assertEqual(str(mymulti.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_form_media(self): ############################################################### # Media processing for forms ############################################################### class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') # You can ask a form for the media required by its widgets. class MyForm(Form): field1 = CharField(max_length=20, widget=MyWidget1()) field2 = CharField(max_length=20, widget=MyWidget2()) f1 = MyForm() self.assertEqual(str(f1.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Form media can be combined to produce a single media definition. class AnotherForm(Form): field3 = CharField(max_length=20, widget=MyWidget3()) f2 = AnotherForm() self.assertEqual(str(f1.media + f2.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Forms can also define media, following the same rules as widgets. class FormWithMedia(Form): field1 = CharField(max_length=20, widget=MyWidget1()) field2 = CharField(max_length=20, widget=MyWidget2()) class Media: js = ('/some/form/javascript',) css = { 'all': ('/some/form/css',) } f3 = FormWithMedia() self.assertEqual(str(f3.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script> <script type="text/javascript" src="/some/form/javascript"></script>""") # Media works in templates self.assertEqual(Template("{{ form.media.js }}{{ form.media.css }}").render(Context({'form': f3})), """<script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script> <script type="text/javascript" src="/some/form/javascript"></script><link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />""") def test_html_safe(self): media = Media(css={'all': ['/path/to/css']}, js=['/path/to/js']) self.assertTrue(hasattr(Media, '__html__')) self.assertEqual(force_text(media), media.__html__()) @override_settings( STATIC_URL='http://media.example.com/static/', MEDIA_URL='http://media.example.com/media/', ) class StaticFormsMediaTestCase(SimpleTestCase): """Tests for the media handling on widgets and forms""" def test_construction(self): # Check construction of media objects m = Media(css={'all': ('path/to/css1', '/path/to/css2')}, js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')) self.assertEqual(str(m), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") class Foo: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') m3 = Media(Foo) self.assertEqual(str(m3), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # A widget can exist without a media definition class MyWidget(TextInput): pass w = MyWidget() self.assertEqual(str(w.media), '') def test_media_dsl(self): ############################################################### # DSL Class-based media definitions ############################################################### # A widget can define media if it needs to. # Any absolute path will be preserved; relative paths are combined # with the value of settings.MEDIA_URL class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') w1 = MyWidget1() self.assertEqual(str(w1.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # Media objects can be interrogated by media type self.assertEqual(str(w1.media['css']), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />""") self.assertEqual(str(w1.media['js']), """<script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") def test_combine_media(self): # Media objects can be combined. Any given media resource will appear only # once. Duplicated media definitions are ignored. class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w1 = MyWidget1() w2 = MyWidget2() w3 = MyWidget3() self.assertEqual(str(w1.media + w2.media + w3.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Check that media addition hasn't affected the original objects self.assertEqual(str(w1.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # Regression check for #12879: specifying the same CSS or JS file # multiple times in a single Media instance should result in that file # only being included once. class MyWidget4(TextInput): class Media: css = {'all': ('/path/to/css1', '/path/to/css1')} js = ('/path/to/js1', '/path/to/js1') w4 = MyWidget4() self.assertEqual(str(w4.media), """<link href="/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script>""") def test_media_property(self): ############################################################### # Property-based media definitions ############################################################### # Widget media can be defined as a property class MyWidget4(TextInput): def _media(self): return Media(css={'all': ('/some/path',)}, js=('/some/js',)) media = property(_media) w4 = MyWidget4() self.assertEqual(str(w4.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script>""") # Media properties can reference the media of their parents class MyWidget5(MyWidget4): def _media(self): return super(MyWidget5, self).media + Media(css={'all': ('/other/path',)}, js=('/other/js',)) media = property(_media) w5 = MyWidget5() self.assertEqual(str(w5.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script> <script type="text/javascript" src="/other/js"></script>""") def test_media_property_parent_references(self): # Media properties can reference the media of their parents, # even if the parent media was defined using a class class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget6(MyWidget1): def _media(self): return super(MyWidget6, self).media + Media(css={'all': ('/other/path',)}, js=('/other/js',)) media = property(_media) w6 = MyWidget6() self.assertEqual(str(w6.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/other/js"></script>""") def test_media_inheritance(self): ############################################################### # Inheritance of media ############################################################### # If a widget extends another but provides no media definition, it inherits the parent widget's media class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget7(MyWidget1): pass w7 = MyWidget7() self.assertEqual(str(w7.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>""") # If a widget extends another but defines media, it extends the parent widget's media by default class MyWidget8(MyWidget1): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w8 = MyWidget8() self.assertEqual(str(w8.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_from_property(self): # If a widget extends another but defines media, it extends the parents widget's media, # even if the parent defined media using a property. class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget4(TextInput): def _media(self): return Media(css={'all': ('/some/path',)}, js=('/some/js',)) media = property(_media) class MyWidget9(MyWidget4): class Media: css = { 'all': ('/other/path',) } js = ('/other/js',) w9 = MyWidget9() self.assertEqual(str(w9.media), """<link href="/some/path" type="text/css" media="all" rel="stylesheet" /> <link href="/other/path" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/some/js"></script> <script type="text/javascript" src="/other/js"></script>""") # A widget can disable media inheritance by specifying 'extend=False' class MyWidget10(MyWidget1): class Media: extend = False css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w10 = MyWidget10() self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_extends(self): # A widget can explicitly enable full media inheritance by specifying 'extend=True' class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget11(MyWidget1): class Media: extend = True css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w11 = MyWidget11() self.assertEqual(str(w11.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_media_inheritance_single_type(self): # A widget can enable inheritance of one media type by specifying extend as a tuple class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget12(MyWidget1): class Media: extend = ('css',) css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') w12 = MyWidget12() self.assertEqual(str(w12.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_multi_media(self): ############################################################### # Multi-media handling for CSS ############################################################### # A widget can define CSS media for multiple output media types class MultimediaWidget(TextInput): class Media: css = { 'screen, print': ('/file1', '/file2'), 'screen': ('/file3',), 'print': ('/file4',) } js = ('/path/to/js1', '/path/to/js4') multimedia = MultimediaWidget() self.assertEqual(str(multimedia.media), """<link href="/file4" type="text/css" media="print" rel="stylesheet" /> <link href="/file3" type="text/css" media="screen" rel="stylesheet" /> <link href="/file1" type="text/css" media="screen, print" rel="stylesheet" /> <link href="/file2" type="text/css" media="screen, print" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_multi_widget(self): ############################################################### # Multiwidget media handling ############################################################### class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') # MultiWidgets have a default media definition that gets all the # media from the component widgets class MyMultiWidget(MultiWidget): def __init__(self, attrs=None): widgets = [MyWidget1, MyWidget2, MyWidget3] super(MyMultiWidget, self).__init__(widgets, attrs) mymulti = MyMultiWidget() self.assertEqual(str(mymulti.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") def test_form_media(self): ############################################################### # Media processing for forms ############################################################### class MyWidget1(TextInput): class Media: css = { 'all': ('path/to/css1', '/path/to/css2') } js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { 'all': ('/path/to/css2', '/path/to/css3') } js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { 'all': ('/path/to/css3', 'path/to/css1') } js = ('/path/to/js1', '/path/to/js4') # You can ask a form for the media required by its widgets. class MyForm(Form): field1 = CharField(max_length=20, widget=MyWidget1()) field2 = CharField(max_length=20, widget=MyWidget2()) f1 = MyForm() self.assertEqual(str(f1.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Form media can be combined to produce a single media definition. class AnotherForm(Form): field3 = CharField(max_length=20, widget=MyWidget3()) f2 = AnotherForm() self.assertEqual(str(f1.media + f2.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script>""") # Forms can also define media, following the same rules as widgets. class FormWithMedia(Form): field1 = CharField(max_length=20, widget=MyWidget1()) field2 = CharField(max_length=20, widget=MyWidget2()) class Media: js = ('/some/form/javascript',) css = { 'all': ('/some/form/css',) } f3 = FormWithMedia() self.assertEqual(str(f3.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script> <script type="text/javascript" src="/some/form/javascript"></script>""") # Media works in templates self.assertEqual(Template("{{ form.media.js }}{{ form.media.css }}").render(Context({'form': f3})), """<script type="text/javascript" src="/path/to/js1"></script> <script type="text/javascript" src="http://media.other.com/path/to/js2"></script> <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> <script type="text/javascript" src="/path/to/js4"></script> <script type="text/javascript" src="/some/form/javascript"></script><link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />""")
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 3351, 492, 12064, 12, 8204, 12, 12300, 12, 6879, 3339, 12, 4516, 3205, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 32, 4415, 63, 1751, 8, 272, 27815, 63, 2632, 29, 403, 12, 272, 31460, 63, 2632, 534, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 3678, 199, 9, 199, 533, 2104, 706, 11398, 1746, 8, 17968, 304, 272, 408, 2925, 367, 314, 5898, 7252, 641, 11114, 436, 4513, 624, 339, 347, 511, 63, 12708, 8, 277, 304, 267, 327, 2670, 14538, 402, 5898, 2251, 267, 333, 275, 12300, 8, 3919, 3713, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 3904, 8586, 29, 2336, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 1333, 267, 291, 14, 629, 8, 495, 8, 77, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 1021, 8024, 26, 288, 11431, 275, 469, 355, 283, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 358, 288, 789, 288, 8586, 275, 14606, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 358, 398, 333, 19, 275, 12300, 8, 5686, 9, 267, 291, 14, 629, 8, 495, 8, 77, 19, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 327, 437, 3938, 883, 2187, 1928, 282, 5898, 5492, 267, 1021, 4932, 3339, 8, 18362, 304, 288, 986, 398, 336, 275, 4932, 3339, 342, 267, 291, 14, 629, 8, 495, 8, 87, 14, 4603, 395, 4074, 339, 347, 511, 63, 4603, 63, 795, 76, 8, 277, 304, 267, 24515, 14776, 267, 327, 577, 4929, 8089, 13, 6788, 5898, 10269, 267, 24515, 14776, 398, 327, 437, 3938, 883, 5627, 5898, 340, 652, 4839, 370, 14, 267, 327, 6184, 3679, 931, 911, 506, 17731, 27, 3847, 3792, 787, 12149, 267, 327, 543, 314, 574, 402, 2202, 14, 13669, 63, 2632, 267, 1021, 4932, 3339, 17, 8, 18362, 304, 288, 1021, 12300, 26, 355, 11431, 275, 469, 490, 283, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 358, 355, 789, 355, 8586, 275, 14606, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 358, 398, 336, 17, 275, 4932, 3339, 17, 342, 267, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 327, 12300, 2251, 883, 506, 1640, 19029, 972, 701, 5898, 730, 267, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 459, 3919, 3815, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 6141, 398, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 459, 3596, 3815, 8894, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 3351, 492, 12064, 12, 8204, 12, 12300, 12, 6879, 3339, 12, 4516, 3205, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 32, 4415, 63, 1751, 8, 272, 27815, 63, 2632, 29, 403, 12, 272, 31460, 63, 2632, 534, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 3678, 199, 9, 199, 533, 2104, 706, 11398, 1746, 8, 17968, 304, 272, 408, 2925, 367, 314, 5898, 7252, 641, 11114, 436, 4513, 624, 339, 347, 511, 63, 12708, 8, 277, 304, 267, 327, 2670, 14538, 402, 5898, 2251, 267, 333, 275, 12300, 8, 3919, 3713, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 3904, 8586, 29, 2336, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 1333, 267, 291, 14, 629, 8, 495, 8, 77, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 1021, 8024, 26, 288, 11431, 275, 469, 355, 283, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 358, 288, 789, 288, 8586, 275, 14606, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 358, 398, 333, 19, 275, 12300, 8, 5686, 9, 267, 291, 14, 629, 8, 495, 8, 77, 19, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 327, 437, 3938, 883, 2187, 1928, 282, 5898, 5492, 267, 1021, 4932, 3339, 8, 18362, 304, 288, 986, 398, 336, 275, 4932, 3339, 342, 267, 291, 14, 629, 8, 495, 8, 87, 14, 4603, 395, 4074, 339, 347, 511, 63, 4603, 63, 795, 76, 8, 277, 304, 267, 24515, 14776, 267, 327, 577, 4929, 8089, 13, 6788, 5898, 10269, 267, 24515, 14776, 398, 327, 437, 3938, 883, 5627, 5898, 340, 652, 4839, 370, 14, 267, 327, 6184, 3679, 931, 911, 506, 17731, 27, 3847, 3792, 787, 12149, 267, 327, 543, 314, 574, 402, 2202, 14, 13669, 63, 2632, 267, 1021, 4932, 3339, 17, 8, 18362, 304, 288, 1021, 12300, 26, 355, 11431, 275, 469, 490, 283, 452, 356, 661, 515, 15, 475, 15, 3919, 17, 297, 1994, 515, 15, 475, 15, 3919, 18, 358, 355, 789, 355, 8586, 275, 14606, 515, 15, 475, 15, 3596, 17, 297, 283, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 297, 283, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 358, 398, 336, 17, 275, 4932, 3339, 17, 342, 267, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 395, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 15, 3596, 17, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 1014, 921, 4603, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 18, 10070, 1579, 30, 199, 28, 1579, 730, 628, 505, 15, 9554, 2, 2928, 628, 2859, 921, 7817, 14, 1848, 14, 957, 15, 515, 15, 475, 15, 3596, 19, 10070, 1579, 15366, 398, 327, 12300, 2251, 883, 506, 1640, 19029, 972, 701, 5898, 730, 267, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 459, 3919, 3815, 8894, 1073, 4369, 628, 1014, 921, 4603, 14, 2694, 14, 957, 15, 4603, 15, 515, 15, 475, 15, 3919, 17, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 199, 28, 1073, 4369, 9555, 515, 15, 475, 15, 3919, 18, 2, 730, 628, 505, 15, 3919, 2, 5898, 628, 452, 2, 4668, 628, 15479, 2, 7082, 6141, 398, 291, 14, 629, 8, 495, 8, 87, 17, 14, 4603, 459, 3596, 3815, 8894, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 515, 15, 475, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bryk/kubernetes
hack/lookup_pull.py
246
1299
#!/usr/bin/env python # Copyright 2015 The Kubernetes Authors. # # 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. # Script to print out PR info in release note format. import json import sys import urllib2 PULLQUERY=("https://api.github.com/repos/" "GoogleCloudPlatform/kubernetes/pulls/{pull}") LOGIN="login" TITLE="title" USER="user" def print_pulls(pulls): for pull in pulls: d = json.loads(urllib2.urlopen(PULLQUERY.format(pull=pull)).read()) print "* {title} #{pull} ({author})".format( title=d[TITLE], pull=pull, author=d[USER][LOGIN]) if __name__ == "__main__": if len(sys.argv) < 2: print ("Usage: {cmd} <pulls>...: Prints out short " + "markdown description for PRs appropriate for release notes.") sys.exit(1) print_pulls(sys.argv[1:])
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 14914, 370, 870, 734, 12218, 2256, 315, 4683, 5317, 1475, 14, 199, 199, 646, 2022, 199, 646, 984, 199, 646, 4011, 18, 199, 199, 48, 3785, 11938, 15387, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 6687, 1779, 298, 13266, 9089, 10397, 15, 17422, 15, 80, 13072, 5321, 9302, 15412, 199, 17208, 628, 2886, 2, 199, 19091, 628, 1213, 2, 199, 3791, 628, 751, 2, 199, 199, 318, 870, 63, 80, 13072, 8, 80, 13072, 304, 523, 367, 10299, 315, 299, 13072, 26, 272, 366, 275, 2022, 14, 3640, 8, 4078, 18, 14, 10890, 8, 48, 3785, 11938, 14, 908, 8, 9302, 29, 9302, 4992, 739, 1012, 272, 870, 8969, 469, 1213, 93, 327, 91, 9302, 93, 11459, 2502, 25974, 908, 8, 267, 2538, 29, 68, 59, 19091, 467, 10299, 29, 9302, 12, 4132, 29, 68, 59, 3791, 1527, 17208, 566, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 272, 870, 1689, 7692, 26, 469, 1760, 93, 665, 80, 13072, 30, 1396, 26, 9101, 83, 734, 3974, 298, 435, 1779, 298, 15653, 1369, 367, 12218, 83, 5827, 367, 4683, 12681, 2685, 272, 984, 14, 2224, 8, 17, 9, 523, 870, 63, 80, 13072, 8, 1274, 14, 3020, 59, 17, 5728, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6900, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 14914, 370, 870, 734, 12218, 2256, 315, 4683, 5317, 1475, 14, 199, 199, 646, 2022, 199, 646, 984, 199, 646, 4011, 18, 199, 199, 48, 3785, 11938, 15387, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 6687, 1779, 298, 13266, 9089, 10397, 15, 17422, 15, 80, 13072, 5321, 9302, 15412, 199, 17208, 628, 2886, 2, 199, 19091, 628, 1213, 2, 199, 3791, 628, 751, 2, 199, 199, 318, 870, 63, 80, 13072, 8, 80, 13072, 304, 523, 367, 10299, 315, 299, 13072, 26, 272, 366, 275, 2022, 14, 3640, 8, 4078, 18, 14, 10890, 8, 48, 3785, 11938, 14, 908, 8, 9302, 29, 9302, 4992, 739, 1012, 272, 870, 8969, 469, 1213, 93, 327, 91, 9302, 93, 11459, 2502, 25974, 908, 8, 267, 2538, 29, 68, 59, 19091, 467, 10299, 29, 9302, 12, 4132, 29, 68, 59, 3791, 1527, 17208, 566, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 340, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 272, 870, 1689, 7692, 26, 469, 1760, 93, 665, 80, 13072, 30, 1396, 26, 9101, 83, 734, 3974, 298, 435, 1779, 298, 15653, 1369, 367, 12218, 83, 5827, 367, 4683, 12681, 2685, 272, 984, 14, 2224, 8, 17, 9, 523, 870, 63, 80, 13072, 8, 1274, 14, 3020, 59, 17, 5728, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
dongguangming/pexpect
pexpect/fdpexpect.py
5
3371
'''This is like pexpect, but it will work with any file descriptor that you pass it. You are reponsible for opening and close the file descriptor. This allows you to use Pexpect with sockets and named pipes (FIFOs). PEXPECT LICENSE This license is approved by the OSI and FSF as GPL-compatible. http://opensource.org/licenses/isc-license.txt Copyright (c) 2012, Noah Spurrier <noah@noah.org> PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ''' from .spawnbase import SpawnBase from .exceptions import ExceptionPexpect import os __all__ = ['fdspawn'] class fdspawn(SpawnBase): '''This is like pexpect.spawn but allows you to supply your own open file descriptor. For example, you could use it to read through a file looking for patterns, or to control a modem or serial device. ''' def __init__ (self, fd, args=None, timeout=30, maxread=2000, searchwindowsize=None, logfile=None): '''This takes a file descriptor (an int) or an object that support the fileno() method (returning an int). All Python file-like objects support fileno(). ''' if type(fd) != type(0) and hasattr(fd, 'fileno'): fd = fd.fileno() if type(fd) != type(0): raise ExceptionPexpect('The fd argument is not an int. If this is a command string then maybe you want to use pexpect.spawn.') try: # make sure fd is a valid file descriptor os.fstat(fd) except OSError: raise ExceptionPexpect('The fd argument is not a valid file descriptor.') self.args = None self.command = None SpawnBase.__init__(self, timeout, maxread, searchwindowsize, logfile) self.child_fd = fd self.own_fd = False self.closed = False self.name = '<file descriptor %d>' % fd def close (self): """Close the file descriptor. Calling this method a second time does nothing, but if the file descriptor was closed elsewhere, :class:`OSError` will be raised. """ if self.child_fd == -1: return self.flush() os.close(self.child_fd) self.child_fd = -1 self.closed = True def isalive (self): '''This checks if the file descriptor is still valid. If :func:`os.fstat` does not raise an exception then we assume it is alive. ''' if self.child_fd == -1: return False try: os.fstat(self.child_fd) return True except: return False def terminate (self, force=False): # pragma: no cover raise ExceptionPexpect('This method is not valid for file descriptors.')
isc
[ 2344, 2765, 365, 2839, 28855, 12, 1325, 652, 911, 1736, 543, 1263, 570, 5872, 626, 1265, 199, 1529, 652, 14, 2047, 787, 295, 678, 1164, 367, 13618, 436, 4002, 314, 570, 5872, 14, 199, 2765, 6127, 1265, 370, 675, 510, 4921, 543, 18772, 436, 4310, 20988, 334, 20925, 83, 680, 199, 199, 48, 16957, 5113, 339, 961, 4190, 365, 30055, 701, 314, 25718, 436, 481, 13107, 465, 14629, 13, 6490, 14, 267, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 10840, 13, 1682, 14, 2424, 339, 1898, 334, 67, 9, 6029, 12, 3091, 11326, 428, 6653, 10742, 665, 889, 11326, 32, 889, 11326, 14, 1308, 30, 272, 13873, 22320, 2296, 4815, 12, 9357, 12, 10362, 1914, 18114, 12, 2401, 15, 726, 5266, 3027, 2100, 4586, 5749, 4141, 2381, 1821, 272, 3104, 1663, 1549, 2428, 481, 8699, 2281, 869, 28106, 8285, 21772, 1441, 1149, 12, 7049, 4221, 619, 2334, 16054, 272, 5877, 12840, 2401, 5749, 13873, 22320, 12840, 10319, 1510, 689, 1621, 11727, 4658, 2563, 14, 272, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 272, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 272, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 272, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 272, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 272, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 272, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 2344, 199, 199, 504, 1275, 10212, 1095, 492, 17812, 3501, 1563, 199, 504, 1275, 3924, 492, 2186, 48, 4921, 199, 646, 747, 199, 199, 363, 452, 363, 275, 788, 14240, 387, 3501, 418, 199, 199, 533, 289, 795, 387, 3501, 8, 12739, 3501, 1563, 304, 272, 1449, 2765, 365, 2839, 28855, 14, 10212, 1325, 6127, 1265, 370, 17169, 2195, 5705, 1551, 570, 272, 5872, 14, 2104, 2893, 12, 1265, 4293, 675, 652, 370, 1586, 4012, 282, 570, 10023, 272, 367, 7970, 12, 503, 370, 3304, 282, 818, 77, 503, 3012, 2243, 14, 1449, 339, 347, 636, 826, 363, 334, 277, 12, 6111, 12, 1249, 29, 403, 12, 2653, 29, 1216, 12, 1390, 739, 29, 8269, 12, 2754, 3806, 890, 29, 403, 12, 17251, 29, 403, 304, 267, 1449, 2765, 6181, 282, 570, 5872, 334, 290, 1109, 9, 503, 376, 909, 626, 2291, 314, 267, 25255, 342, 1083, 334, 24112, 376, 1109, 680, 2900, 2018, 570, 13, 2930, 2251, 267, 2291, 25255, 1252, 1449, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 9, 436, 2688, 8, 2592, 12, 283, 9843, 735, 288, 6111, 275, 6111, 14, 9843, 342, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 304, 288, 746, 2186, 48, 4921, 360, 1918, 6111, 1423, 365, 440, 376, 1109, 14, 982, 642, 365, 282, 1414, 1059, 2066, 11703, 1265, 2934, 370, 675, 28855, 14, 10212, 2659, 398, 862, 26, 327, 1852, 3238, 6111, 365, 282, 1686, 570, 5872, 288, 747, 14, 32127, 8, 2592, 9, 267, 871, 6440, 26, 288, 746, 2186, 48, 4921, 360, 1918, 6111, 1423, 365, 440, 282, 1686, 570, 5872, 2659, 398, 291, 14, 589, 275, 488, 267, 291, 14, 1531, 275, 488, 267, 17812, 3501, 1563, 855, 826, 721, 277, 12, 2653, 12, 1390, 739, 12, 2754, 3806, 890, 12, 17251, 9, 267, 291, 14, 1739, 63, 2592, 275, 6111, 267, 291, 14, 944, 63, 2592, 275, 756, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 354, 275, 2650, 493, 5872, 450, 68, 3524, 450, 6111, 339, 347, 4002, 334, 277, 304, 267, 408, 4724, 314, 570, 5872, 14, 398, 23892, 642, 1083, 282, 3499, 900, 1630, 6548, 12, 1325, 340, 314, 570, 267, 5872, 1990, 6876, 25320, 12, 520, 533, 1705, 16719, 64, 911, 506, 4915, 14, 267, 408, 267, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 398, 291, 14, 4939, 342, 267, 747, 14, 1600, 8, 277, 14, 1739, 63, 2592, 9, 267, 291, 14, 1739, 63, 2592, 275, 446, 17, 267, 291, 14, 5938, 275, 715, 339, 347, 365, 9631, 334, 277, 304, 267, 1449, 2765, 5920, 340, 314, 570, 5872, 365, 5139, 1686, 14, 982, 520, 1532, 1705, 736, 14, 32127, 64, 267, 1630, 440, 746, 376, 1919, 2066, 781, 5534, 652, 365, 19708, 14, 1449, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 756, 267, 862, 26, 288, 747, 14, 32127, 8, 277, 14, 1739, 63, 2592, 9, 288, 372, 715, 267, 871, 26, 288, 372, 756, 339, 347, 15095, 334, 277, 12, 3542, 29, 797, 304, 221, 327, 11942, 26, 949, 8486, 267, 746, 2186, 48, 4921, 360, 2765, 1083, 365, 440, 1686, 367, 570, 15428, 2659, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 365, 2839, 28855, 12, 1325, 652, 911, 1736, 543, 1263, 570, 5872, 626, 1265, 199, 1529, 652, 14, 2047, 787, 295, 678, 1164, 367, 13618, 436, 4002, 314, 570, 5872, 14, 199, 2765, 6127, 1265, 370, 675, 510, 4921, 543, 18772, 436, 4310, 20988, 334, 20925, 83, 680, 199, 199, 48, 16957, 5113, 339, 961, 4190, 365, 30055, 701, 314, 25718, 436, 481, 13107, 465, 14629, 13, 6490, 14, 267, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 10840, 13, 1682, 14, 2424, 339, 1898, 334, 67, 9, 6029, 12, 3091, 11326, 428, 6653, 10742, 665, 889, 11326, 32, 889, 11326, 14, 1308, 30, 272, 13873, 22320, 2296, 4815, 12, 9357, 12, 10362, 1914, 18114, 12, 2401, 15, 726, 5266, 3027, 2100, 4586, 5749, 4141, 2381, 1821, 272, 3104, 1663, 1549, 2428, 481, 8699, 2281, 869, 28106, 8285, 21772, 1441, 1149, 12, 7049, 4221, 619, 2334, 16054, 272, 5877, 12840, 2401, 5749, 13873, 22320, 12840, 10319, 1510, 689, 1621, 11727, 4658, 2563, 14, 272, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 272, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 272, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 272, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 272, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 272, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 272, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 2344, 199, 199, 504, 1275, 10212, 1095, 492, 17812, 3501, 1563, 199, 504, 1275, 3924, 492, 2186, 48, 4921, 199, 646, 747, 199, 199, 363, 452, 363, 275, 788, 14240, 387, 3501, 418, 199, 199, 533, 289, 795, 387, 3501, 8, 12739, 3501, 1563, 304, 272, 1449, 2765, 365, 2839, 28855, 14, 10212, 1325, 6127, 1265, 370, 17169, 2195, 5705, 1551, 570, 272, 5872, 14, 2104, 2893, 12, 1265, 4293, 675, 652, 370, 1586, 4012, 282, 570, 10023, 272, 367, 7970, 12, 503, 370, 3304, 282, 818, 77, 503, 3012, 2243, 14, 1449, 339, 347, 636, 826, 363, 334, 277, 12, 6111, 12, 1249, 29, 403, 12, 2653, 29, 1216, 12, 1390, 739, 29, 8269, 12, 2754, 3806, 890, 29, 403, 12, 17251, 29, 403, 304, 267, 1449, 2765, 6181, 282, 570, 5872, 334, 290, 1109, 9, 503, 376, 909, 626, 2291, 314, 267, 25255, 342, 1083, 334, 24112, 376, 1109, 680, 2900, 2018, 570, 13, 2930, 2251, 267, 2291, 25255, 1252, 1449, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 9, 436, 2688, 8, 2592, 12, 283, 9843, 735, 288, 6111, 275, 6111, 14, 9843, 342, 398, 340, 730, 8, 2592, 9, 1137, 730, 8, 16, 304, 288, 746, 2186, 48, 4921, 360, 1918, 6111, 1423, 365, 440, 376, 1109, 14, 982, 642, 365, 282, 1414, 1059, 2066, 11703, 1265, 2934, 370, 675, 28855, 14, 10212, 2659, 398, 862, 26, 327, 1852, 3238, 6111, 365, 282, 1686, 570, 5872, 288, 747, 14, 32127, 8, 2592, 9, 267, 871, 6440, 26, 288, 746, 2186, 48, 4921, 360, 1918, 6111, 1423, 365, 440, 282, 1686, 570, 5872, 2659, 398, 291, 14, 589, 275, 488, 267, 291, 14, 1531, 275, 488, 267, 17812, 3501, 1563, 855, 826, 721, 277, 12, 2653, 12, 1390, 739, 12, 2754, 3806, 890, 12, 17251, 9, 267, 291, 14, 1739, 63, 2592, 275, 6111, 267, 291, 14, 944, 63, 2592, 275, 756, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 354, 275, 2650, 493, 5872, 450, 68, 3524, 450, 6111, 339, 347, 4002, 334, 277, 304, 267, 408, 4724, 314, 570, 5872, 14, 398, 23892, 642, 1083, 282, 3499, 900, 1630, 6548, 12, 1325, 340, 314, 570, 267, 5872, 1990, 6876, 25320, 12, 520, 533, 1705, 16719, 64, 911, 506, 4915, 14, 267, 408, 267, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 398, 291, 14, 4939, 342, 267, 747, 14, 1600, 8, 277, 14, 1739, 63, 2592, 9, 267, 291, 14, 1739, 63, 2592, 275, 446, 17, 267, 291, 14, 5938, 275, 715, 339, 347, 365, 9631, 334, 277, 304, 267, 1449, 2765, 5920, 340, 314, 570, 5872, 365, 5139, 1686, 14, 982, 520, 1532, 1705, 736, 14, 32127, 64, 267, 1630, 440, 746, 376, 1919, 2066, 781, 5534, 652, 365, 19708, 14, 1449, 398, 340, 291, 14, 1739, 63, 2592, 508, 446, 17, 26, 288, 372, 756, 267, 862, 26, 288, 747, 14, 32127, 8, 277, 14, 1739, 63, 2592, 9, 288, 372, 715, 267, 871, 26, 288, 372, 756, 339, 347, 15095, 334, 277, 12, 3542, 29, 797, 304, 221, 327, 11942, 26, 949, 8486, 267, 746, 2186, 48, 4921, 360, 2765, 1083, 365, 440, 1686, 367, 570, 15428, 2659, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dnozay/lettuce
tests/integration/lib/Django-1.2.5/django/template/loader_tags.py
44
8017
from django.template import TemplateSyntaxError, TemplateDoesNotExist, Variable from django.template import Library, Node, TextNode from django.template.loader import get_template from django.conf import settings from django.utils.safestring import mark_safe register = Library() BLOCK_CONTEXT_KEY = 'block_context' class ExtendsError(Exception): pass class BlockContext(object): def __init__(self): # Dictionary of FIFO queues. self.blocks = {} def add_blocks(self, blocks): for name, block in blocks.iteritems(): if name in self.blocks: self.blocks[name].insert(0, block) else: self.blocks[name] = [block] def pop(self, name): try: return self.blocks[name].pop() except (IndexError, KeyError): return None def push(self, name, block): self.blocks[name].append(block) def get_block(self, name): try: return self.blocks[name][-1] except (IndexError, KeyError): return None class BlockNode(Node): def __init__(self, name, nodelist, parent=None): self.name, self.nodelist, self.parent = name, nodelist, parent def __repr__(self): return "<Block Node: %s. Contents: %r>" % (self.name, self.nodelist) def render(self, context): block_context = context.render_context.get(BLOCK_CONTEXT_KEY) context.push() if block_context is None: context['block'] = self result = self.nodelist.render(context) else: push = block = block_context.pop(self.name) if block is None: block = self # Create new block so we can store context without thread-safety issues. block = BlockNode(block.name, block.nodelist) block.context = context context['block'] = block result = block.nodelist.render(context) if push is not None: block_context.push(self.name, push) context.pop() return result def super(self): render_context = self.context.render_context if (BLOCK_CONTEXT_KEY in render_context and render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None): return mark_safe(self.render(self.context)) return '' class ExtendsNode(Node): must_be_first = True def __init__(self, nodelist, parent_name, parent_name_expr, template_dirs=None): self.nodelist = nodelist self.parent_name, self.parent_name_expr = parent_name, parent_name_expr self.template_dirs = template_dirs self.blocks = dict([(n.name, n) for n in nodelist.get_nodes_by_type(BlockNode)]) def __repr__(self): if self.parent_name_expr: return "<ExtendsNode: extends %s>" % self.parent_name_expr.token return '<ExtendsNode: extends "%s">' % self.parent_name def get_parent(self, context): if self.parent_name_expr: self.parent_name = self.parent_name_expr.resolve(context) parent = self.parent_name if not parent: error_msg = "Invalid template name in 'extends' tag: %r." % parent if self.parent_name_expr: error_msg += " Got this from the '%s' variable." % self.parent_name_expr.token raise TemplateSyntaxError(error_msg) if hasattr(parent, 'render'): return parent # parent is a Template object return get_template(parent) def render(self, context): compiled_parent = self.get_parent(context) if BLOCK_CONTEXT_KEY not in context.render_context: context.render_context[BLOCK_CONTEXT_KEY] = BlockContext() block_context = context.render_context[BLOCK_CONTEXT_KEY] # Add the block nodes from this node to the block context block_context.add_blocks(self.blocks) # If this block's parent doesn't have an extends node it is the root, # and its block nodes also need to be added to the block context. for node in compiled_parent.nodelist: # The ExtendsNode has to be the first non-text node. if not isinstance(node, TextNode): if not isinstance(node, ExtendsNode): blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) block_context.add_blocks(blocks) break # Call Template._render explicitly so the parser context stays # the same. return compiled_parent._render(context) class ConstantIncludeNode(Node): def __init__(self, template_path): try: t = get_template(template_path) self.template = t except: if settings.TEMPLATE_DEBUG: raise self.template = None def render(self, context): if self.template: return self.template.render(context) else: return '' class IncludeNode(Node): def __init__(self, template_name): self.template_name = Variable(template_name) def render(self, context): try: template_name = self.template_name.resolve(context) t = get_template(template_name) return t.render(context) except: if settings.TEMPLATE_DEBUG: raise return '' def do_block(parser, token): """ Define a block that can be overridden by child templates. """ bits = token.contents.split() if len(bits) != 2: raise TemplateSyntaxError("'%s' tag takes only one argument" % bits[0]) block_name = bits[1] # Keep track of the names of BlockNodes found in this template, so we can # check for duplication. try: if block_name in parser.__loaded_blocks: raise TemplateSyntaxError("'%s' tag with name '%s' appears more than once" % (bits[0], block_name)) parser.__loaded_blocks.append(block_name) except AttributeError: # parser.__loaded_blocks isn't a list yet parser.__loaded_blocks = [block_name] nodelist = parser.parse(('endblock', 'endblock %s' % block_name)) parser.delete_first_token() return BlockNode(block_name, nodelist) def do_extends(parser, token): """ Signal that this template extends a parent template. This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) uses the literal value "base" as the name of the parent template to extend, or ``{% extends variable %}`` uses the value of ``variable`` as either the name of the parent template to extend (if it evaluates to a string) or as the parent tempate itelf (if it evaluates to a Template object). """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("'%s' takes one argument" % bits[0]) parent_name, parent_name_expr = None, None if bits[1][0] in ('"', "'") and bits[1][-1] == bits[1][0]: parent_name = bits[1][1:-1] else: parent_name_expr = parser.compile_filter(bits[1]) nodelist = parser.parse() if nodelist.get_nodes_by_type(ExtendsNode): raise TemplateSyntaxError("'%s' cannot appear more than once in the same template" % bits[0]) return ExtendsNode(nodelist, parent_name, parent_name_expr) def do_include(parser, token): """ Loads a template and renders it with the current context. Example:: {% include "foo/some_include" %} """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("%r tag takes one argument: the name of the template to be included" % bits[0]) path = bits[1] if path[0] in ('"', "'") and path[-1] == path[0]: return ConstantIncludeNode(path[1:-1]) return IncludeNode(bits[1]) register.tag('block', do_block) register.tag('extends', do_extends) register.tag('include', do_include)
gpl-3.0
[ 504, 1639, 14, 1160, 492, 17762, 12, 27193, 12, 4905, 199, 504, 1639, 14, 1160, 492, 11243, 12, 5013, 12, 4516, 1716, 199, 504, 1639, 14, 1160, 14, 3422, 492, 664, 63, 1160, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 2683, 275, 11243, 342, 199, 199, 8475, 63, 9059, 63, 3078, 275, 283, 1457, 63, 1100, 7, 199, 199, 533, 11524, 795, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 8651, 2998, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 11932, 402, 15435, 3230, 21366, 14, 267, 291, 14, 4166, 275, 1052, 339, 347, 1050, 63, 4166, 8, 277, 12, 5664, 304, 267, 367, 536, 12, 1853, 315, 5664, 14, 4611, 837, 288, 340, 536, 315, 291, 14, 4166, 26, 355, 291, 14, 4166, 59, 354, 1055, 3176, 8, 16, 12, 1853, 9, 288, 587, 26, 355, 291, 14, 4166, 59, 354, 61, 275, 359, 1457, 61, 339, 347, 4560, 8, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 14, 4166, 59, 354, 1055, 1935, 342, 267, 871, 334, 12129, 12, 4067, 304, 288, 372, 488, 339, 347, 6675, 8, 277, 12, 536, 12, 1853, 304, 267, 291, 14, 4166, 59, 354, 1055, 740, 8, 1457, 9, 339, 347, 664, 63, 1457, 8, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 14, 4166, 59, 354, 15898, 17, 61, 267, 871, 334, 12129, 12, 4067, 304, 288, 372, 488, 199, 199, 533, 8651, 1716, 8, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 13642, 12, 1676, 29, 403, 304, 267, 291, 14, 354, 12, 291, 14, 14371, 12, 291, 14, 1708, 275, 536, 12, 13642, 12, 1676, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 3142, 5013, 26, 450, 83, 14, 6646, 83, 26, 450, 82, 4335, 450, 334, 277, 14, 354, 12, 291, 14, 14371, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 1853, 63, 1100, 275, 1067, 14, 3352, 63, 1100, 14, 362, 8, 8475, 63, 9059, 63, 3078, 9, 267, 1067, 14, 5335, 342, 267, 340, 1853, 63, 1100, 365, 488, 26, 288, 1067, 459, 1457, 418, 275, 291, 288, 754, 275, 291, 14, 14371, 14, 3352, 8, 1100, 9, 267, 587, 26, 288, 6675, 275, 1853, 275, 1853, 63, 1100, 14, 1935, 8, 277, 14, 354, 9, 288, 340, 1853, 365, 488, 26, 355, 1853, 275, 291, 288, 327, 2790, 892, 1853, 880, 781, 883, 3877, 1067, 1928, 2462, 13, 3489, 369, 10876, 14, 288, 1853, 275, 8651, 1716, 8, 1457, 14, 354, 12, 1853, 14, 14371, 9, 288, 1853, 14, 1100, 275, 1067, 288, 1067, 459, 1457, 418, 275, 1853, 288, 754, 275, 1853, 14, 14371, 14, 3352, 8, 1100, 9, 288, 340, 6675, 365, 440, 488, 26, 355, 1853, 63, 1100, 14, 5335, 8, 277, 14, 354, 12, 6675, 9, 267, 1067, 14, 1935, 342, 267, 372, 754, 339, 347, 1613, 8, 277, 304, 267, 3795, 63, 1100, 275, 291, 14, 1100, 14, 3352, 63, 1100, 267, 340, 334, 8475, 63, 9059, 63, 3078, 315, 3795, 63, 1100, 436, 288, 3795, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 1055, 362, 63, 1457, 8, 277, 14, 354, 9, 365, 440, 488, 304, 288, 372, 2216, 63, 3489, 8, 277, 14, 3352, 8, 277, 14, 1100, 430, 267, 372, 2125, 199, 199, 533, 11524, 795, 1716, 8, 1716, 304, 272, 1471, 63, 1235, 63, 2246, 275, 715, 339, 347, 636, 826, 721, 277, 12, 13642, 12, 1676, 63, 354, 12, 1676, 63, 354, 63, 3684, 12, 1978, 63, 3220, 29, 403, 304, 267, 291, 14, 14371, 275, 13642, 267, 291, 14, 1708, 63, 354, 12, 291, 14, 1708, 63, 354, 63, 3684, 275, 1676, 63, 354, 12, 1676, 63, 354, 63, 3684, 267, 291, 14, 1160, 63, 3220, 275, 1978, 63, 3220, 267, 291, 14, 4166, 275, 1211, 7694, 78, 14, 354, 12, 302, 9, 367, 302, 315, 13642, 14, 362, 63, 2415, 63, 991, 63, 466, 8, 3142, 1716, 3948, 339, 347, 636, 2722, 721, 277, 304, 267, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 288, 372, 3886, 4377, 795, 1716, 26, 16879, 450, 83, 4335, 450, 291, 14, 1708, 63, 354, 63, 3684, 14, 1418, 267, 372, 2650, 4377, 795, 1716, 26, 16879, 2071, 83, 15603, 450, 291, 14, 1708, 63, 354, 339, 347, 664, 63, 1708, 8, 277, 12, 1067, 304, 267, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 288, 291, 14, 1708, 63, 354, 275, 291, 14, 1708, 63, 354, 63, 3684, 14, 6983, 8, 1100, 9, 267, 1676, 275, 291, 14, 1708, 63, 354, 267, 340, 440, 1676, 26, 288, 1125, 63, 1328, 275, 298, 3364, 1978, 536, 315, 283, 11036, 7, 1947, 26, 450, 82, 2122, 450, 1676, 288, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 355, 1125, 63, 1328, 847, 298, 24734, 642, 687, 314, 1543, 83, 7, 1750, 2122, 450, 291, 14, 1708, 63, 354, 63, 3684, 14, 1418, 288, 746, 17762, 8, 705, 63, 1328, 9, 267, 340, 2688, 8, 1708, 12, 283, 3352, 735, 288, 372, 1676, 327, 1676, 365, 282, 5458, 909, 267, 372, 664, 63, 1160, 8, 1708, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 10311, 63, 1708, 275, 291, 14, 362, 63, 1708, 8, 1100, 9, 398, 340, 8068, 63, 9059, 63, 3078, 440, 315, 1067, 14, 3352, 63, 1100, 26, 288, 1067, 14, 3352, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 61, 275, 8651, 2998, 342, 267, 1853, 63, 1100, 275, 1067, 14, 3352, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 61, 398, 327, 2654, 314, 1853, 3380, 687, 642, 1031, 370, 314, 1853, 1067, 267, 1853, 63, 1100, 14, 525, 63, 4166, 8, 277, 14, 4166, 9, 398, 327, 982, 642, 1853, 1159, 1676, 3181, 1133, 1172, 376, 16879, 1031, 652, 365, 314, 1738, 12, 267, 327, 436, 2399, 1853, 3380, 2597, 1929, 370, 506, 3483, 370, 314, 1853, 1067, 14, 267, 367, 1031, 315, 10311, 63, 1708, 14, 14371, 26, 288, 327, 710, 11524, 795, 1716, 965, 370, 506, 314, 1642, 2222, 13, 505 ]
[ 1639, 14, 1160, 492, 17762, 12, 27193, 12, 4905, 199, 504, 1639, 14, 1160, 492, 11243, 12, 5013, 12, 4516, 1716, 199, 504, 1639, 14, 1160, 14, 3422, 492, 664, 63, 1160, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 2683, 275, 11243, 342, 199, 199, 8475, 63, 9059, 63, 3078, 275, 283, 1457, 63, 1100, 7, 199, 199, 533, 11524, 795, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 8651, 2998, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 11932, 402, 15435, 3230, 21366, 14, 267, 291, 14, 4166, 275, 1052, 339, 347, 1050, 63, 4166, 8, 277, 12, 5664, 304, 267, 367, 536, 12, 1853, 315, 5664, 14, 4611, 837, 288, 340, 536, 315, 291, 14, 4166, 26, 355, 291, 14, 4166, 59, 354, 1055, 3176, 8, 16, 12, 1853, 9, 288, 587, 26, 355, 291, 14, 4166, 59, 354, 61, 275, 359, 1457, 61, 339, 347, 4560, 8, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 14, 4166, 59, 354, 1055, 1935, 342, 267, 871, 334, 12129, 12, 4067, 304, 288, 372, 488, 339, 347, 6675, 8, 277, 12, 536, 12, 1853, 304, 267, 291, 14, 4166, 59, 354, 1055, 740, 8, 1457, 9, 339, 347, 664, 63, 1457, 8, 277, 12, 536, 304, 267, 862, 26, 288, 372, 291, 14, 4166, 59, 354, 15898, 17, 61, 267, 871, 334, 12129, 12, 4067, 304, 288, 372, 488, 199, 199, 533, 8651, 1716, 8, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 13642, 12, 1676, 29, 403, 304, 267, 291, 14, 354, 12, 291, 14, 14371, 12, 291, 14, 1708, 275, 536, 12, 13642, 12, 1676, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 3142, 5013, 26, 450, 83, 14, 6646, 83, 26, 450, 82, 4335, 450, 334, 277, 14, 354, 12, 291, 14, 14371, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 1853, 63, 1100, 275, 1067, 14, 3352, 63, 1100, 14, 362, 8, 8475, 63, 9059, 63, 3078, 9, 267, 1067, 14, 5335, 342, 267, 340, 1853, 63, 1100, 365, 488, 26, 288, 1067, 459, 1457, 418, 275, 291, 288, 754, 275, 291, 14, 14371, 14, 3352, 8, 1100, 9, 267, 587, 26, 288, 6675, 275, 1853, 275, 1853, 63, 1100, 14, 1935, 8, 277, 14, 354, 9, 288, 340, 1853, 365, 488, 26, 355, 1853, 275, 291, 288, 327, 2790, 892, 1853, 880, 781, 883, 3877, 1067, 1928, 2462, 13, 3489, 369, 10876, 14, 288, 1853, 275, 8651, 1716, 8, 1457, 14, 354, 12, 1853, 14, 14371, 9, 288, 1853, 14, 1100, 275, 1067, 288, 1067, 459, 1457, 418, 275, 1853, 288, 754, 275, 1853, 14, 14371, 14, 3352, 8, 1100, 9, 288, 340, 6675, 365, 440, 488, 26, 355, 1853, 63, 1100, 14, 5335, 8, 277, 14, 354, 12, 6675, 9, 267, 1067, 14, 1935, 342, 267, 372, 754, 339, 347, 1613, 8, 277, 304, 267, 3795, 63, 1100, 275, 291, 14, 1100, 14, 3352, 63, 1100, 267, 340, 334, 8475, 63, 9059, 63, 3078, 315, 3795, 63, 1100, 436, 288, 3795, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 1055, 362, 63, 1457, 8, 277, 14, 354, 9, 365, 440, 488, 304, 288, 372, 2216, 63, 3489, 8, 277, 14, 3352, 8, 277, 14, 1100, 430, 267, 372, 2125, 199, 199, 533, 11524, 795, 1716, 8, 1716, 304, 272, 1471, 63, 1235, 63, 2246, 275, 715, 339, 347, 636, 826, 721, 277, 12, 13642, 12, 1676, 63, 354, 12, 1676, 63, 354, 63, 3684, 12, 1978, 63, 3220, 29, 403, 304, 267, 291, 14, 14371, 275, 13642, 267, 291, 14, 1708, 63, 354, 12, 291, 14, 1708, 63, 354, 63, 3684, 275, 1676, 63, 354, 12, 1676, 63, 354, 63, 3684, 267, 291, 14, 1160, 63, 3220, 275, 1978, 63, 3220, 267, 291, 14, 4166, 275, 1211, 7694, 78, 14, 354, 12, 302, 9, 367, 302, 315, 13642, 14, 362, 63, 2415, 63, 991, 63, 466, 8, 3142, 1716, 3948, 339, 347, 636, 2722, 721, 277, 304, 267, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 288, 372, 3886, 4377, 795, 1716, 26, 16879, 450, 83, 4335, 450, 291, 14, 1708, 63, 354, 63, 3684, 14, 1418, 267, 372, 2650, 4377, 795, 1716, 26, 16879, 2071, 83, 15603, 450, 291, 14, 1708, 63, 354, 339, 347, 664, 63, 1708, 8, 277, 12, 1067, 304, 267, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 288, 291, 14, 1708, 63, 354, 275, 291, 14, 1708, 63, 354, 63, 3684, 14, 6983, 8, 1100, 9, 267, 1676, 275, 291, 14, 1708, 63, 354, 267, 340, 440, 1676, 26, 288, 1125, 63, 1328, 275, 298, 3364, 1978, 536, 315, 283, 11036, 7, 1947, 26, 450, 82, 2122, 450, 1676, 288, 340, 291, 14, 1708, 63, 354, 63, 3684, 26, 355, 1125, 63, 1328, 847, 298, 24734, 642, 687, 314, 1543, 83, 7, 1750, 2122, 450, 291, 14, 1708, 63, 354, 63, 3684, 14, 1418, 288, 746, 17762, 8, 705, 63, 1328, 9, 267, 340, 2688, 8, 1708, 12, 283, 3352, 735, 288, 372, 1676, 327, 1676, 365, 282, 5458, 909, 267, 372, 664, 63, 1160, 8, 1708, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 10311, 63, 1708, 275, 291, 14, 362, 63, 1708, 8, 1100, 9, 398, 340, 8068, 63, 9059, 63, 3078, 440, 315, 1067, 14, 3352, 63, 1100, 26, 288, 1067, 14, 3352, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 61, 275, 8651, 2998, 342, 267, 1853, 63, 1100, 275, 1067, 14, 3352, 63, 1100, 59, 8475, 63, 9059, 63, 3078, 61, 398, 327, 2654, 314, 1853, 3380, 687, 642, 1031, 370, 314, 1853, 1067, 267, 1853, 63, 1100, 14, 525, 63, 4166, 8, 277, 14, 4166, 9, 398, 327, 982, 642, 1853, 1159, 1676, 3181, 1133, 1172, 376, 16879, 1031, 652, 365, 314, 1738, 12, 267, 327, 436, 2399, 1853, 3380, 2597, 1929, 370, 506, 3483, 370, 314, 1853, 1067, 14, 267, 367, 1031, 315, 10311, 63, 1708, 14, 14371, 26, 288, 327, 710, 11524, 795, 1716, 965, 370, 506, 314, 1642, 2222, 13, 505, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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