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
bruunio/private
node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py
1835
1748
#!/usr/bin/env python # Copyright (c) 2011 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """These functions are executed via gyp-flock-tool when using the Makefile generator. Used on systems that don't have a built-in flock.""" import fcntl import os import struct import subprocess import sys def main(args): executor = FlockTool() executor.Dispatch(args) class FlockTool(object): """This class emulates the 'flock' command.""" def Dispatch(self, args): """Dispatches a string command to a method.""" if len(args) < 1: raise Exception("Not enough arguments") method = "Exec%s" % self._CommandifyName(args[0]) getattr(self, method)(*args[1:]) def _CommandifyName(self, name_string): """Transforms a tool name like copy-info-plist to CopyInfoPlist""" return name_string.title().replace('-', '') def ExecFlock(self, lockfile, *cmd_list): """Emulates the most basic behavior of Linux's flock(1).""" # Rely on exception handling to report errors. # Note that the stock python on SunOS has a bug # where fcntl.flock(fd, LOCK_EX) always fails # with EBADF, that's why we use this F_SETLK # hack instead. fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0666) if sys.platform.startswith('aix'): # Python on AIX is compiled with LARGEFILE support, which changes the # struct size. op = struct.pack('hhIllqq', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) else: op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) fcntl.fcntl(fd, fcntl.F_SETLK, op) return subprocess.call(cmd_list) if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 20676, 3423, 787, 7934, 4799, 4902, 13, 28977, 13, 3557, 1380, 1808, 314, 20618, 199, 4679, 14, 221, 8051, 641, 10460, 626, 2793, 1133, 1172, 282, 6137, 13, 262, 289, 831, 1041, 199, 199, 646, 12871, 199, 646, 747, 199, 646, 2702, 199, 646, 3873, 199, 646, 984, 421, 199, 318, 2446, 8, 589, 304, 523, 13270, 275, 481, 831, 5157, 342, 523, 13270, 14, 20628, 8, 589, 9, 421, 199, 533, 481, 831, 5157, 8, 785, 304, 523, 408, 2765, 1021, 17423, 2335, 314, 283, 28977, 7, 1414, 1041, 523, 347, 28626, 8, 277, 12, 1249, 304, 272, 408, 2825, 11350, 282, 1059, 1414, 370, 282, 1083, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 1083, 275, 298, 4858, 5, 83, 2, 450, 291, 423, 5150, 290, 29552, 985, 8, 589, 59, 16, 566, 272, 2519, 8, 277, 12, 1083, 25967, 589, 59, 17, 5728, 819, 347, 485, 5150, 290, 29552, 985, 8, 277, 12, 536, 63, 875, 304, 272, 408, 3188, 3351, 282, 4744, 536, 2839, 1331, 13, 815, 13, 10265, 370, 11247, 2354, 21073, 624, 272, 372, 536, 63, 875, 14, 1213, 1252, 1814, 13858, 4074, 819, 347, 9434, 38, 831, 8, 277, 12, 4650, 493, 12, 627, 1760, 63, 513, 304, 272, 408, 37, 3703, 2335, 314, 4750, 5678, 5953, 402, 10130, 1159, 289, 831, 8, 17, 10477, 272, 327, 820, 7742, 641, 1919, 7252, 370, 3622, 2552, 14, 272, 327, 3390, 626, 314, 10952, 2366, 641, 25625, 3100, 965, 282, 6519, 272, 327, 2382, 12871, 14, 28977, 8, 2592, 12, 3412, 2504, 63, 1438, 9, 3544, 6918, 272, 327, 543, 662, 9439, 38, 12, 626, 1159, 10842, 781, 675, 642, 481, 63, 3597, 44, 43, 272, 327, 11176, 3140, 14, 272, 6111, 275, 747, 14, 1490, 8, 26204, 12, 747, 14, 47, 63, 6524, 10452, 92, 736, 14, 47, 63, 2826, 1028, 2099, 92, 736, 14, 47, 63, 32120, 12, 378, 11829, 9, 272, 340, 984, 14, 3246, 14, 2460, 360, 65, 1148, 735, 489, 327, 2018, 641, 437, 3867, 365, 10311, 543, 491, 689, 4962, 3817, 2291, 12, 1314, 4493, 314, 489, 327, 2702, 1568, 14, 489, 1687, 275, 2702, 14, 1389, 360, 12156, 41, 914, 16672, 297, 12871, 14, 38, 63, 55, 2431, 2504, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 9, 272, 587, 26, 489, 1687, 275, 2702, 14, 1389, 360, 12156, 914, 12156, 76, 297, 12871, 14, 38, 63, 55, 2431, 2504, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 9, 272, 12871, 14, 24477, 8, 2592, 12, 12871, 14, 38, 63, 3597, 44, 43, 12, 1687, 9, 272, 372, 3873, 14, 1250, 8, 1760, 63, 513, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 20676, 3423, 787, 7934, 4799, 4902, 13, 28977, 13, 3557, 1380, 1808, 314, 20618, 199, 4679, 14, 221, 8051, 641, 10460, 626, 2793, 1133, 1172, 282, 6137, 13, 262, 289, 831, 1041, 199, 199, 646, 12871, 199, 646, 747, 199, 646, 2702, 199, 646, 3873, 199, 646, 984, 421, 199, 318, 2446, 8, 589, 304, 523, 13270, 275, 481, 831, 5157, 342, 523, 13270, 14, 20628, 8, 589, 9, 421, 199, 533, 481, 831, 5157, 8, 785, 304, 523, 408, 2765, 1021, 17423, 2335, 314, 283, 28977, 7, 1414, 1041, 523, 347, 28626, 8, 277, 12, 1249, 304, 272, 408, 2825, 11350, 282, 1059, 1414, 370, 282, 1083, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 1083, 275, 298, 4858, 5, 83, 2, 450, 291, 423, 5150, 290, 29552, 985, 8, 589, 59, 16, 566, 272, 2519, 8, 277, 12, 1083, 25967, 589, 59, 17, 5728, 819, 347, 485, 5150, 290, 29552, 985, 8, 277, 12, 536, 63, 875, 304, 272, 408, 3188, 3351, 282, 4744, 536, 2839, 1331, 13, 815, 13, 10265, 370, 11247, 2354, 21073, 624, 272, 372, 536, 63, 875, 14, 1213, 1252, 1814, 13858, 4074, 819, 347, 9434, 38, 831, 8, 277, 12, 4650, 493, 12, 627, 1760, 63, 513, 304, 272, 408, 37, 3703, 2335, 314, 4750, 5678, 5953, 402, 10130, 1159, 289, 831, 8, 17, 10477, 272, 327, 820, 7742, 641, 1919, 7252, 370, 3622, 2552, 14, 272, 327, 3390, 626, 314, 10952, 2366, 641, 25625, 3100, 965, 282, 6519, 272, 327, 2382, 12871, 14, 28977, 8, 2592, 12, 3412, 2504, 63, 1438, 9, 3544, 6918, 272, 327, 543, 662, 9439, 38, 12, 626, 1159, 10842, 781, 675, 642, 481, 63, 3597, 44, 43, 272, 327, 11176, 3140, 14, 272, 6111, 275, 747, 14, 1490, 8, 26204, 12, 747, 14, 47, 63, 6524, 10452, 92, 736, 14, 47, 63, 2826, 1028, 2099, 92, 736, 14, 47, 63, 32120, 12, 378, 11829, 9, 272, 340, 984, 14, 3246, 14, 2460, 360, 65, 1148, 735, 489, 327, 2018, 641, 437, 3867, 365, 10311, 543, 491, 689, 4962, 3817, 2291, 12, 1314, 4493, 314, 489, 327, 2702, 1568, 14, 489, 1687, 275, 2702, 14, 1389, 360, 12156, 41, 914, 16672, 297, 12871, 14, 38, 63, 55, 2431, 2504, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 9, 272, 587, 26, 489, 1687, 275, 2702, 14, 1389, 360, 12156, 914, 12156, 76, 297, 12871, 14, 38, 63, 55, 2431, 2504, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 9, 272, 12871, 14, 24477, 8, 2592, 12, 12871, 14, 38, 63, 3597, 44, 43, 12, 1687, 9, 272, 372, 3873, 14, 1250, 8, 1760, 63, 513, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 973, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
compuwizard123/RSync
rsyncconfig/fstree.py
2
1958
# Copyright (C) 2011 Thomas W. Most # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import stat import gobject import gtk 'The full file path relative to the root.' COL_PATH = 0 'A stat of the filesystem object.' COL_STAT = 1 'Whether the subtree of the path is currently being spidered.' COL_SPIDERING = 2 class FSTree(object): ''' Maintains a tree representation of the filesystem provided by a spider. ''' def __init__(self): self.store = gtk.TreeStore(gobject.TYPE_STRING, object, gobject.TYPE_BOOLEAN) self.store.set_sort_column_id(COL_PATH, gtk.SORT_ASCENDING) self._dirs = {} def add_path(self, path, stat_t, scanning=True): '''Add a path and metadata to the store. ''' basedir, _ = os.path.split(path) if basedir: parent = self._dirs[basedir] else: parent = None iter = self.store.append(parent, (path, stat_t, scanning)) if stat.S_ISDIR(stat_t): # XXX: Is keeping around iters costly? self._dirs[path] = iter def update_path(self, path, stat, scanning=False): '''Update a path's metadata. ''' pass def remove_path(self, path): '''Remove a path from the store. ''' pass
gpl-3.0
[ 3, 1898, 334, 35, 9, 7760, 27864, 644, 14, 17536, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 5672, 199, 199, 646, 25595, 199, 646, 8116, 199, 199, 7, 1918, 2615, 570, 931, 3847, 370, 314, 1738, 3530, 199, 3978, 63, 3243, 275, 378, 199, 7, 33, 5672, 402, 314, 10036, 909, 3530, 199, 3978, 63, 4315, 275, 413, 199, 7, 26625, 314, 26897, 402, 314, 931, 365, 5544, 3769, 19441, 2995, 3530, 199, 3978, 63, 5763, 998, 540, 1206, 275, 499, 199, 199, 533, 481, 840, 850, 8, 785, 304, 272, 1449, 272, 16593, 8368, 83, 282, 3123, 6025, 402, 314, 10036, 2741, 701, 282, 18094, 14, 272, 1449, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1617, 275, 8116, 14, 3987, 5502, 8, 71, 785, 14, 2711, 63, 5353, 12, 221, 3521, 909, 12, 3521, 25595, 14, 2711, 63, 25312, 9, 267, 291, 14, 1617, 14, 409, 63, 3191, 63, 2301, 63, 344, 8, 3978, 63, 3243, 12, 8116, 14, 23447, 63, 22767, 15219, 9, 267, 291, 423, 3220, 275, 1052, 339, 347, 1050, 63, 515, 8, 277, 12, 931, 12, 5672, 63, 84, 12, 24928, 29, 549, 304, 267, 1449, 1123, 282, 931, 436, 3341, 370, 314, 3877, 14, 267, 1449, 267, 19380, 12, 485, 275, 747, 14, 515, 14, 1294, 8, 515, 9, 267, 340, 19380, 26, 288, 1676, 275, 291, 423, 3220, 59, 12484, 61, 267, 587, 26, 288, 1676, 275, 488, 267, 2740, 275, 291, 14, 1617, 14, 740, 8, 1708, 12, 334, 515, 12, 5672, 63, 84, 12, 24928, 430, 267, 340, 5672, 14, 51, 63, 1311, 3022, 8, 3736, 63, 84, 304, 288, 327, 5787, 26, 6596, 22181, 6818, 284, 878, 7918, 590, 31, 288, 291, 423, 3220, 59, 515, 61, 275, 2740, 339, 347, 1678, 63, 515, 8, 277, 12, 931, 12, 5672, 12, 24928, 29, 797, 304, 267, 1449, 4152, 282, 931, 1159, 3341, 14, 267, 1449, 267, 986, 339, 347, 2813, 63, 515, 8, 277, 12, 931, 304, 267, 1449, 5587, 282, 931, 687, 314, 3877, 14, 267, 1449, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7760, 27864, 644, 14, 17536, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 5672, 199, 199, 646, 25595, 199, 646, 8116, 199, 199, 7, 1918, 2615, 570, 931, 3847, 370, 314, 1738, 3530, 199, 3978, 63, 3243, 275, 378, 199, 7, 33, 5672, 402, 314, 10036, 909, 3530, 199, 3978, 63, 4315, 275, 413, 199, 7, 26625, 314, 26897, 402, 314, 931, 365, 5544, 3769, 19441, 2995, 3530, 199, 3978, 63, 5763, 998, 540, 1206, 275, 499, 199, 199, 533, 481, 840, 850, 8, 785, 304, 272, 1449, 272, 16593, 8368, 83, 282, 3123, 6025, 402, 314, 10036, 2741, 701, 282, 18094, 14, 272, 1449, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1617, 275, 8116, 14, 3987, 5502, 8, 71, 785, 14, 2711, 63, 5353, 12, 221, 3521, 909, 12, 3521, 25595, 14, 2711, 63, 25312, 9, 267, 291, 14, 1617, 14, 409, 63, 3191, 63, 2301, 63, 344, 8, 3978, 63, 3243, 12, 8116, 14, 23447, 63, 22767, 15219, 9, 267, 291, 423, 3220, 275, 1052, 339, 347, 1050, 63, 515, 8, 277, 12, 931, 12, 5672, 63, 84, 12, 24928, 29, 549, 304, 267, 1449, 1123, 282, 931, 436, 3341, 370, 314, 3877, 14, 267, 1449, 267, 19380, 12, 485, 275, 747, 14, 515, 14, 1294, 8, 515, 9, 267, 340, 19380, 26, 288, 1676, 275, 291, 423, 3220, 59, 12484, 61, 267, 587, 26, 288, 1676, 275, 488, 267, 2740, 275, 291, 14, 1617, 14, 740, 8, 1708, 12, 334, 515, 12, 5672, 63, 84, 12, 24928, 430, 267, 340, 5672, 14, 51, 63, 1311, 3022, 8, 3736, 63, 84, 304, 288, 327, 5787, 26, 6596, 22181, 6818, 284, 878, 7918, 590, 31, 288, 291, 423, 3220, 59, 515, 61, 275, 2740, 339, 347, 1678, 63, 515, 8, 277, 12, 931, 12, 5672, 12, 24928, 29, 797, 304, 267, 1449, 4152, 282, 931, 1159, 3341, 14, 267, 1449, 267, 986, 339, 347, 2813, 63, 515, 8, 277, 12, 931, 304, 267, 1449, 5587, 282, 931, 687, 314, 3877, 14, 267, 1449, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
prathamtandon/g4gproblems
Arrays/four_elements_with_given_sum.py
1
3437
import unittest """ Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. Input: 10 2 3 4 5 9 7 8, X = 23 Output: 2 3 10 8 Input: -3 4 112 -1 5 0 5, X = 8 Output: 4 -1 5 0 """ """ Approach 1: 1. Sort the array. 2. Run outermost loop which fixes the first element. 3. Run inner loop which fixes the second element. 4. Find a pair in remaining (sorted) array that sums to X-first-second in linear time. 5. Overall time complexity is O(n^3). """ """ Approach 2: 1. Pre-compute the sum of all pair of elements in the array. Store this in an auxiliary array. 2. For each element in auxiliary array, we can find the other pair in log_n time using binary search. 3. Now, once we have the two pairs, we can return the corresponding elements as the solution. 4. Overall time complexity is O(n^2log_n) and space complexity is O(n^2) """ def binary_search(list_of_numbers, low, high, key): while low < high: mid = low + (high - low) / 2 if list_of_numbers[mid] == key: return mid elif list_of_numbers[mid] < key: low = mid + 1 else: high = mid - 1 return -1 class PairSum: def __init__(self, first, second, pair_sum): self.first = first self.second = second self.pair_sum = pair_sum def __cmp__(self, other): cmp_val = self.pair_sum - other.pair_sum if cmp_val == 0: return 0 if cmp_val < 0: return -1 return 1 def __eq__(self, other): return self.pair_sum == other.pair_sum def find_four_numbers_that_sum_to_given_val(list_of_numbers, desired_sum): pair_sums = [] for i in range(len(list_of_numbers)-1): for j in range(i+1, len(list_of_numbers)): new_pair = PairSum(i, j, list_of_numbers[i] + list_of_numbers[j]) pair_sums.append(new_pair) pair_sums = sorted(pair_sums) for i in range(len(pair_sums)-1): left_pair_sum = pair_sums[i].pair_sum right_pair_sum = desired_sum - left_pair_sum k = pair_sums[i].first l = pair_sums[i].second pair_sums_copy = pair_sums[:] pair_sums_copy.pop(i) j = binary_search([x.pair_sum for x in pair_sums_copy], 0, len(pair_sums_copy)-1, right_pair_sum) if j >= 0 and pair_sums_copy[j].first not in [k, l] and pair_sums_copy[j].second not in [k, l]: return list_of_numbers[k], \ list_of_numbers[l], \ list_of_numbers[pair_sums_copy[j].first], \ list_of_numbers[pair_sums_copy[j].second] return None class TestQuadrupleWithGivenSum(unittest.TestCase): def test_quadruple_with_given_sum(self): list_of_numbers = [10, 2, 3, 4, 5, 9, 7, 8] desired_sum = 23 result = find_four_numbers_that_sum_to_given_val(list_of_numbers, desired_sum) self.assertEqual(len(result), 4) self.assertIn(3, result) self.assertIn(2, result) self.assertIn(10, result) self.assertIn(8, result) list_of_numbers = [-3, 4, 112, -1, 5, 0, 5] desired_sum = 8 result = find_four_numbers_that_sum_to_given_val(list_of_numbers, desired_sum) self.assertEqual(len(result), 4) self.assertIn(4, result) self.assertIn(-1, result) self.assertIn(5, result) self.assertIn(0, result)
mit
[ 646, 2882, 199, 624, 199, 13735, 376, 1625, 402, 9446, 12, 2342, 1006, 14665, 402, 11648, 4008, 315, 314, 1625, 7447, 3089, 199, 374, 4472, 370, 282, 1627, 574, 1323, 14, 199, 3205, 26, 1616, 499, 650, 841, 959, 1749, 1520, 1695, 12, 1323, 275, 6546, 199, 2959, 26, 499, 650, 221, 1616, 1695, 199, 3205, 26, 446, 19, 841, 20240, 446, 17, 959, 378, 959, 12, 1323, 275, 1695, 199, 2959, 26, 841, 446, 17, 959, 378, 199, 624, 199, 199, 624, 199, 25923, 1225, 413, 26, 199, 17, 14, 16722, 314, 1625, 14, 199, 18, 14, 3378, 6890, 2786, 4438, 1314, 25079, 314, 1642, 1819, 14, 199, 19, 14, 3378, 6506, 4438, 1314, 25079, 314, 3499, 1819, 14, 199, 20, 14, 6668, 282, 4092, 315, 7971, 334, 5917, 9, 1625, 626, 27690, 370, 1323, 13, 2246, 13, 4375, 315, 7798, 900, 14, 199, 21, 14, 7259, 452, 900, 6114, 1209, 365, 593, 8, 78, 62, 19, 680, 199, 624, 199, 199, 624, 199, 25923, 1225, 499, 26, 199, 17, 14, 5543, 13, 3357, 314, 3089, 402, 1006, 4092, 402, 4008, 315, 314, 1625, 14, 13874, 642, 315, 376, 31407, 1625, 14, 199, 18, 14, 2104, 1924, 1819, 315, 31407, 1625, 12, 781, 883, 2342, 314, 1163, 4092, 315, 943, 63, 78, 900, 1808, 3366, 2754, 14, 199, 19, 14, 7356, 12, 5403, 781, 1172, 314, 2877, 6342, 12, 781, 883, 372, 314, 5226, 4008, 465, 314, 8744, 14, 199, 20, 14, 7259, 452, 900, 6114, 1209, 365, 593, 8, 78, 62, 18, 793, 63, 78, 9, 436, 4601, 6114, 1209, 365, 593, 8, 78, 62, 18, 9, 199, 624, 421, 199, 318, 3366, 63, 1733, 8, 513, 63, 1618, 63, 10548, 12, 6465, 12, 4721, 12, 790, 304, 339, 1830, 6465, 665, 4721, 26, 267, 10887, 275, 6465, 435, 334, 6260, 446, 6465, 9, 1182, 499, 267, 340, 769, 63, 1618, 63, 10548, 59, 8523, 61, 508, 790, 26, 288, 372, 10887, 267, 916, 769, 63, 1618, 63, 10548, 59, 8523, 61, 665, 790, 26, 288, 6465, 275, 10887, 435, 413, 267, 587, 26, 288, 4721, 275, 10887, 446, 413, 339, 372, 446, 17, 421, 199, 533, 510, 8387, 6959, 26, 272, 347, 636, 826, 721, 277, 12, 1642, 12, 3499, 12, 4092, 63, 1838, 304, 267, 291, 14, 2246, 275, 1642, 267, 291, 14, 4375, 275, 3499, 267, 291, 14, 3852, 63, 1838, 275, 4092, 63, 1838, 339, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 10467, 63, 637, 275, 291, 14, 3852, 63, 1838, 446, 1163, 14, 3852, 63, 1838, 267, 340, 10467, 63, 637, 508, 378, 26, 288, 372, 378, 267, 340, 10467, 63, 637, 665, 378, 26, 288, 372, 446, 17, 267, 372, 413, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 3852, 63, 1838, 508, 1163, 14, 3852, 63, 1838, 421, 199, 318, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 304, 272, 4092, 63, 22178, 275, 942, 339, 367, 284, 315, 1425, 8, 552, 8, 513, 63, 1618, 63, 10548, 7216, 17, 304, 267, 367, 1335, 315, 1425, 8, 73, 11, 17, 12, 822, 8, 513, 63, 1618, 63, 10548, 2298, 288, 892, 63, 3852, 275, 510, 8387, 6959, 8, 73, 12, 1335, 12, 769, 63, 1618, 63, 10548, 59, 73, 61, 435, 769, 63, 1618, 63, 10548, 59, 74, 566, 288, 4092, 63, 22178, 14, 740, 8, 1222, 63, 3852, 9, 339, 4092, 63, 22178, 275, 3355, 8, 3852, 63, 22178, 9, 339, 367, 284, 315, 1425, 8, 552, 8, 3852, 63, 22178, 7216, 17, 304, 267, 3602, 63, 3852, 63, 1838, 275, 4092, 63, 22178, 59, 73, 1055, 3852, 63, 1838, 267, 2451, 63, 3852, 63, 1838, 275, 6387, 63, 1838, 446, 3602, 63, 3852, 63, 1838, 267, 1022, 275, 4092, 63, 22178, 59, 73, 1055, 2246, 267, 634, 275, 4092, 63, 22178, 59, 73, 1055, 4375, 267, 4092, 63, 22178, 63, 1574, 275, 4092, 63, 22178, 5873, 267, 4092, 63, 22178, 63, 1574, 14, 1935, 8, 73, 9, 267, 1335, 275, 3366, 63, 1733, 779, 88, 14, 3852, 63, 1838, 367, 671, 315, 4092, 63, 22178, 63, 1574, 467, 378, 12, 822, 8, 3852, 63, 22178, 63, 1574, 7216, 17, 12, 2451, 63, 3852, 63, 1838, 9, 267, 340, 1335, 2356, 378, 436, 4092, 63, 22178, 63, 1574, 59, 74, 1055, 2246, 440, 315, 359, 75, 12, 634, 61, 436, 4092, 63, 22178, 63, 1574, 59, 74, 1055, 4375, 440, 315, 359, 75, 12, 634, 2189, 288, 372, 769, 63, 1618, 63, 10548, 59, 75, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 76, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 3852, 63, 22178, 63, 1574, 59, 74, 1055, 2246, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 3852, 63, 22178, 63, 1574, 59, 74, 1055, 4375, 61, 339, 372, 488, 421, 199, 533, 1379, 23053, 82, 1363, 3007, 13735, 6959, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 14567, 82, 1363, 63, 1045, 63, 11809, 63, 1838, 8, 277, 304, 267, 769, 63, 1618, 63, 10548, 275, 359, 709, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1749, 12, 1520, 12, 1695, 61, 267, 6387, 63, 1838, 275, 6546, 267, 754, 275, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 395, 841, 9, 267, 291, 14, 4080, 8, 19, 12, 754, 9, 267, 291, 14, 4080, 8, 18, 12, 754, 9, 267, 291, 14, 4080, 8, 709, 12, 754, 9, 267, 291, 14, 4080, 8, 24, 12, 754, 9, 398, 769, 63, 1618, 63, 10548, 275, 5243, 19, 12, 841, 12, 20240, 12, 446, 17, 12, 959, 12, 378, 12, 959, 61, 267, 6387, 63, 1838, 275, 1695, 267, 754, 275, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 395, 841 ]
[ 2882, 199, 624, 199, 13735, 376, 1625, 402, 9446, 12, 2342, 1006, 14665, 402, 11648, 4008, 315, 314, 1625, 7447, 3089, 199, 374, 4472, 370, 282, 1627, 574, 1323, 14, 199, 3205, 26, 1616, 499, 650, 841, 959, 1749, 1520, 1695, 12, 1323, 275, 6546, 199, 2959, 26, 499, 650, 221, 1616, 1695, 199, 3205, 26, 446, 19, 841, 20240, 446, 17, 959, 378, 959, 12, 1323, 275, 1695, 199, 2959, 26, 841, 446, 17, 959, 378, 199, 624, 199, 199, 624, 199, 25923, 1225, 413, 26, 199, 17, 14, 16722, 314, 1625, 14, 199, 18, 14, 3378, 6890, 2786, 4438, 1314, 25079, 314, 1642, 1819, 14, 199, 19, 14, 3378, 6506, 4438, 1314, 25079, 314, 3499, 1819, 14, 199, 20, 14, 6668, 282, 4092, 315, 7971, 334, 5917, 9, 1625, 626, 27690, 370, 1323, 13, 2246, 13, 4375, 315, 7798, 900, 14, 199, 21, 14, 7259, 452, 900, 6114, 1209, 365, 593, 8, 78, 62, 19, 680, 199, 624, 199, 199, 624, 199, 25923, 1225, 499, 26, 199, 17, 14, 5543, 13, 3357, 314, 3089, 402, 1006, 4092, 402, 4008, 315, 314, 1625, 14, 13874, 642, 315, 376, 31407, 1625, 14, 199, 18, 14, 2104, 1924, 1819, 315, 31407, 1625, 12, 781, 883, 2342, 314, 1163, 4092, 315, 943, 63, 78, 900, 1808, 3366, 2754, 14, 199, 19, 14, 7356, 12, 5403, 781, 1172, 314, 2877, 6342, 12, 781, 883, 372, 314, 5226, 4008, 465, 314, 8744, 14, 199, 20, 14, 7259, 452, 900, 6114, 1209, 365, 593, 8, 78, 62, 18, 793, 63, 78, 9, 436, 4601, 6114, 1209, 365, 593, 8, 78, 62, 18, 9, 199, 624, 421, 199, 318, 3366, 63, 1733, 8, 513, 63, 1618, 63, 10548, 12, 6465, 12, 4721, 12, 790, 304, 339, 1830, 6465, 665, 4721, 26, 267, 10887, 275, 6465, 435, 334, 6260, 446, 6465, 9, 1182, 499, 267, 340, 769, 63, 1618, 63, 10548, 59, 8523, 61, 508, 790, 26, 288, 372, 10887, 267, 916, 769, 63, 1618, 63, 10548, 59, 8523, 61, 665, 790, 26, 288, 6465, 275, 10887, 435, 413, 267, 587, 26, 288, 4721, 275, 10887, 446, 413, 339, 372, 446, 17, 421, 199, 533, 510, 8387, 6959, 26, 272, 347, 636, 826, 721, 277, 12, 1642, 12, 3499, 12, 4092, 63, 1838, 304, 267, 291, 14, 2246, 275, 1642, 267, 291, 14, 4375, 275, 3499, 267, 291, 14, 3852, 63, 1838, 275, 4092, 63, 1838, 339, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 10467, 63, 637, 275, 291, 14, 3852, 63, 1838, 446, 1163, 14, 3852, 63, 1838, 267, 340, 10467, 63, 637, 508, 378, 26, 288, 372, 378, 267, 340, 10467, 63, 637, 665, 378, 26, 288, 372, 446, 17, 267, 372, 413, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 3852, 63, 1838, 508, 1163, 14, 3852, 63, 1838, 421, 199, 318, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 304, 272, 4092, 63, 22178, 275, 942, 339, 367, 284, 315, 1425, 8, 552, 8, 513, 63, 1618, 63, 10548, 7216, 17, 304, 267, 367, 1335, 315, 1425, 8, 73, 11, 17, 12, 822, 8, 513, 63, 1618, 63, 10548, 2298, 288, 892, 63, 3852, 275, 510, 8387, 6959, 8, 73, 12, 1335, 12, 769, 63, 1618, 63, 10548, 59, 73, 61, 435, 769, 63, 1618, 63, 10548, 59, 74, 566, 288, 4092, 63, 22178, 14, 740, 8, 1222, 63, 3852, 9, 339, 4092, 63, 22178, 275, 3355, 8, 3852, 63, 22178, 9, 339, 367, 284, 315, 1425, 8, 552, 8, 3852, 63, 22178, 7216, 17, 304, 267, 3602, 63, 3852, 63, 1838, 275, 4092, 63, 22178, 59, 73, 1055, 3852, 63, 1838, 267, 2451, 63, 3852, 63, 1838, 275, 6387, 63, 1838, 446, 3602, 63, 3852, 63, 1838, 267, 1022, 275, 4092, 63, 22178, 59, 73, 1055, 2246, 267, 634, 275, 4092, 63, 22178, 59, 73, 1055, 4375, 267, 4092, 63, 22178, 63, 1574, 275, 4092, 63, 22178, 5873, 267, 4092, 63, 22178, 63, 1574, 14, 1935, 8, 73, 9, 267, 1335, 275, 3366, 63, 1733, 779, 88, 14, 3852, 63, 1838, 367, 671, 315, 4092, 63, 22178, 63, 1574, 467, 378, 12, 822, 8, 3852, 63, 22178, 63, 1574, 7216, 17, 12, 2451, 63, 3852, 63, 1838, 9, 267, 340, 1335, 2356, 378, 436, 4092, 63, 22178, 63, 1574, 59, 74, 1055, 2246, 440, 315, 359, 75, 12, 634, 61, 436, 4092, 63, 22178, 63, 1574, 59, 74, 1055, 4375, 440, 315, 359, 75, 12, 634, 2189, 288, 372, 769, 63, 1618, 63, 10548, 59, 75, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 76, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 3852, 63, 22178, 63, 1574, 59, 74, 1055, 2246, 467, 971, 673, 769, 63, 1618, 63, 10548, 59, 3852, 63, 22178, 63, 1574, 59, 74, 1055, 4375, 61, 339, 372, 488, 421, 199, 533, 1379, 23053, 82, 1363, 3007, 13735, 6959, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 14567, 82, 1363, 63, 1045, 63, 11809, 63, 1838, 8, 277, 304, 267, 769, 63, 1618, 63, 10548, 275, 359, 709, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1749, 12, 1520, 12, 1695, 61, 267, 6387, 63, 1838, 275, 6546, 267, 754, 275, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 395, 841, 9, 267, 291, 14, 4080, 8, 19, 12, 754, 9, 267, 291, 14, 4080, 8, 18, 12, 754, 9, 267, 291, 14, 4080, 8, 709, 12, 754, 9, 267, 291, 14, 4080, 8, 24, 12, 754, 9, 398, 769, 63, 1618, 63, 10548, 275, 5243, 19, 12, 841, 12, 20240, 12, 446, 17, 12, 959, 12, 378, 12, 959, 61, 267, 6387, 63, 1838, 275, 1695, 267, 754, 275, 2342, 63, 13672, 63, 10548, 63, 9099, 63, 1838, 63, 475, 63, 11809, 63, 637, 8, 513, 63, 1618, 63, 10548, 12, 6387, 63, 1838, 9, 267, 291, 14, 629, 8, 552, 8, 1099, 395, 841, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dangillet/cocos
cocos/actions/interval_actions.py
3
21160
# ---------------------------------------------------------------------------- # cocos2d # Copyright (c) 2008-2012 Daniel Moisset, Ricardo Quesada, Rayentray Tappa, # Lucio Torre # Copyright (c) 2009-2015 Richard Jones, Claudio Canepa # 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 cocos2d 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. # ---------------------------------------------------------------------------- """Interval Action Interval Actions ================ An interval action is an action that takes place within a certain period of time. It has an start time, and a finish time. The finish time is the parameter ``duration`` plus the start time. These `IntervalAction` have some interesting properties, like: - They can run normally (default) - They can run reversed with the `Reverse` action. - They can run with the time altered with the `Accelerate`, `AccelDeccel` and `Speed` actions. For example, you can simulate a Ping Pong effect running the action normally and then running it again in Reverse mode. Example:: ping_pong_action = action + Reverse(action) Available IntervalActions ========================= * `MoveTo` * `MoveBy` * `JumpTo` * `JumpBy` * `Bezier` * `Blink` * `RotateTo` * `RotateBy` * `ScaleTo` * `ScaleBy` * `FadeOut` * `FadeIn` * `FadeTo` * `Delay` * `RandomDelay` Modifier actions ================ * `Accelerate` * `AccelDeccel` * `Speed` Examples:: move = MoveBy((200,0), duration=5) # Moves 200 pixels to the right in 5 seconds. move = MoveTo((320,240), duration=5) # Moves to the pixel (320,240) in 5 seconds jump = JumpBy((320,0), 100, 5, duration=5) # Jumps to the right 320 pixels # doing 5 jumps of 100 pixels # of height in 5 seconds accel_move = Accelerate(move) # accelerates action move """ from __future__ import division, print_function, unicode_literals __docformat__ = 'restructuredtext' import random import copy import math from .base_actions import * from cocos.euclid import * __all__ = ['Lerp', # interpolation 'MoveTo', 'MoveBy', # movement actions 'Jump', 'JumpTo', 'JumpBy', 'Bezier', # complex movement actions 'Rotate', "RotateTo", "RotateBy", # object rotation 'ScaleTo', 'ScaleBy', # object scale 'Delay', 'RandomDelay', # Delays 'FadeOut', 'FadeIn', 'FadeTo', # Fades in/out action 'Blink', # Blink action 'Accelerate', 'AccelDeccel', 'Speed', ] # Time alter actions class Lerp(IntervalAction): """ Interpolate between values for some specified attribute """ def init(self, attrib, start, end, duration): """Init method. :Parameters: `attrib` : string The name of the attrbiute where the value is stored `start` : float The start value `end` : float The end value `duration` : float Duration time in seconds """ self.attrib = attrib self.duration = duration self.start_p = start self.end_p = end self.delta = end-start def update(self, t): setattr(self.target, self.attrib, self.start_p + self.delta*t) def __reversed__(self): return Lerp(self.attrib, self.end_p, self.start_p, self.duration) class RotateBy(IntervalAction): """Rotates a `CocosNode` object clockwise a number of degrees by modiying it's rotation attribute. Example:: # rotates the sprite 180 degrees in 2 seconds action = RotateBy(180, 2) sprite.do(action) """ def init(self, angle, duration): """Init method. :Parameters: `angle` : float Degrees that the sprite will be rotated. Positive degrees rotates the sprite clockwise. `duration` : float Duration time in seconds """ self.angle = angle #: Quantity of degrees to rotate self.duration = duration #: Duration in seconds def start(self): self.start_angle = self.target.rotation def update(self, t): self.target.rotation = (self.start_angle + self.angle*t) % 360 def __reversed__(self): return RotateBy(-self.angle, self.duration) Rotate = RotateBy class RotateTo(IntervalAction): """Rotates a `CocosNode` object to a certain angle by modifying it's rotation attribute. The direction will be decided by the shortest angle. Example:: # rotates the sprite to angle 180 in 2 seconds action = RotateTo(180, 2) sprite.do(action) """ def init(self, angle, duration): """Init method. :Parameters: `angle` : float Destination angle in degrees. `duration` : float Duration time in seconds """ self.angle = angle % 360 #: Destination angle in degrees self.duration = duration #: Duration in seconds def start(self): ea = self.angle sa = self.start_angle = (self.target.rotation % 360) self.angle = ((ea % 360) - (sa % 360)) if self.angle > 180: self.angle = -360 + self.angle if self.angle < -180: self.angle = 360 + self.angle def update(self, t): self.target.rotation = (self.start_angle + self.angle*t) % 360 def __reversed__(self): return RotateTo(-self.angle, self.duration) class Speed(IntervalAction): """ Changes the speed of an action, making it take longer (speed>1) or less (speed<1) Example:: # rotates the sprite 180 degrees in 1 secondclockwise action = Speed(Rotate(180, 2), 2) sprite.do(action) """ def init(self, other, speed): """Init method. :Parameters: `other` : IntervalAction The action that will be affected `speed` : float The speed change. 1 is no change. 2 means twice as fast, takes half the time 0.5 means half as fast, takes double the time """ self.other = other self.speed = speed self.duration = other.duration/speed def start(self): self.other.target = self.target self.other.start() def update(self, t): self.other.update(t) def __reversed__(self): return Speed(Reverse(self.other), self.speed) class Accelerate(IntervalAction): """ Changes the acceleration of an action Example:: # rotates the sprite 180 degrees in 2 seconds clockwise # it starts slow and ends fast action = Accelerate(Rotate(180, 2), 4) sprite.do(action) """ def init(self, other, rate=2): """Init method. :Parameters: `other` : IntervalAction The action that will be affected `rate` : float The acceleration rate. 1 is linear. the new t is t**rate """ self.other = other self.rate = rate self.duration = other.duration def start(self): self.other.target = self.target self.other.start() def update(self, t): self.other.update(t ** self.rate) def __reversed__(self): return Accelerate(Reverse(self.other), 1.0 / self.rate) class AccelDeccel(IntervalAction): """ Makes an action change the travel speed but retain near normal speed at the beginning and ending. Example:: # rotates the sprite 180 degrees in 2 seconds clockwise # it starts slow, gets fast and ends slow action = AccelDeccel(RotateBy(180, 2)) sprite.do(action) """ def init(self, other): """Init method. :Parameters: `other` : IntervalAction The action that will be affected """ self.other = other self.duration = other.duration def start(self): self.other.target = self.target self.other.start() def update(self, t): if t != 1.0: ft = (t - 0.5) * 12 t = 1./(1. + math.exp(-ft)) self.other.update(t) def __reversed__(self): return AccelDeccel(Reverse(self.other)) class MoveTo(IntervalAction): """Moves a `CocosNode` object to the position x,y. x and y are absolute coordinates by modifying it's position attribute. Example:: # Move the sprite to coords x=50, y=10 in 8 seconds action = MoveTo((50,10), 8) sprite.do(action) """ def init(self, dst_coords, duration=5): """Init method. :Parameters: `dst_coords` : (x,y) Coordinates where the sprite will be placed at the end of the action `duration` : float Duration time in seconds """ self.end_position = Point2(*dst_coords) self.duration = duration def start(self): self.start_position = self.target.position self.delta = self.end_position-self.start_position def update(self, t): self.target.position = self.start_position + self.delta * t class MoveBy(MoveTo): """Moves a `CocosNode` object x,y pixels by modifying it's position attribute. x and y are relative to the position of the object. Duration is is seconds. Example:: # Move the sprite 50 pixels to the left in 8 seconds action = MoveBy((-50,0), 8) sprite.do(action) """ def init(self, delta, duration=5): """Init method. :Parameters: `delta` : (x,y) Delta coordinates `duration` : float Duration time in seconds """ self.delta = Point2(*delta) self.duration = duration def start(self): self.start_position = self.target.position self.end_position = self.start_position + self.delta def __reversed__(self): return MoveBy(-self.delta, self.duration) class FadeOut(IntervalAction): """Fades out a `CocosNode` object by modifying it's opacity attribute. Example:: action = FadeOut(2) sprite.do(action) """ def init(self, duration): """Init method. :Parameters: `duration` : float Seconds that it will take to fade """ self.duration = duration def update(self, t): self.target.opacity = 255 * (1 - t) def __reversed__(self): return FadeIn(self.duration) class FadeTo(IntervalAction): """Fades a `CocosNode` object to a specific alpha value by modifying it's opacity attribute. Example:: action = FadeTo(128, 2) sprite.do(action) """ def init(self, alpha, duration): """Init method. :Parameters: `alpha` : float 0-255 value of opacity `duration` : float Seconds that it will take to fade """ self.alpha = alpha self.duration = duration def start(self): self.start_alpha = self.target.opacity def update(self, t): self.target.opacity = self.start_alpha + ( self.alpha - self.start_alpha) * t class FadeIn(FadeOut): """Fades in a `CocosNode` object by modifying it's opacity attribute. Example:: action = FadeIn(2) sprite.do(action) """ def update(self, t): self.target.opacity = 255 * t def __reversed__(self): return FadeOut(self.duration) class ScaleTo(IntervalAction): """Scales a `CocosNode` object to a zoom factor by modifying it's scale attribute. Example:: # scales the sprite to 5x in 2 seconds action = ScaleTo(5, 2) sprite.do(action) """ def init(self, scale, duration=5): """Init method. :Parameters: `scale` : float scale factor `duration` : float Duration time in seconds """ self.end_scale = scale self.duration = duration def start(self): self.start_scale = self.target.scale self.delta = self.end_scale - self.start_scale def update(self, t): self.target.scale = self.start_scale + self.delta*t class ScaleBy(ScaleTo): """Scales a `CocosNode` object a zoom factor by modifying it's scale attribute. Example:: # scales the sprite by 5x in 2 seconds action = ScaleBy(5, 2) sprite.do(action) """ def start(self): self.start_scale = self.target.scale self.delta = self.start_scale*self.end_scale - self.start_scale def __reversed__(self): return ScaleBy(1.0 / self.end_scale, self.duration) class Blink(IntervalAction): """Blinks a `CocosNode` object by modifying it's visible attribute The action ends with the same visible state than at the start time. Example:: # Blinks 10 times in 2 seconds action = Blink(10, 2) sprite.do(action) """ def init(self, times, duration): """Init method. :Parameters: `times` : integer Number of times to blink `duration` : float Duration time in seconds """ self.times = times self.duration = duration def start(self): self.end_invisible = not self.target.visible def update(self, t): slice = 1.0 / self.times m = t % slice self.target.visible = self.end_invisible ^ (m < slice/2.0) def __reversed__(self): return self class Bezier(IntervalAction): """Moves a `CocosNode` object through a bezier path by modifying it's position attribute. Example:: action = Bezier(bezier_conf.path1, 5) # Moves the sprite using the sprite.do(action) # bezier path 'bezier_conf.path1' # in 5 seconds """ def init(self, bezier, duration=5, forward=True): """Init method :Parameters: `bezier` : bezier_configuration instance A bezier configuration `duration` : float Duration time in seconds """ self.duration = duration self.bezier = bezier self.forward = forward def start(self): self.start_position = self.target.position def update(self, t): if self.forward: p = self.bezier.at(t) else: p = self.bezier.at(1 - t) self.target.position = (self.start_position + Point2(*p)) def __reversed__(self): return Bezier(self.bezier, self.duration, not self.forward) class Jump(IntervalAction): """Moves a `CocosNode` object simulating a jump movement by modifying it's position attribute. Example:: action = Jump(50,200, 5, 6) # Move the sprite 200 pixels to the right sprite.do(action) # in 6 seconds, doing 5 jumps # of 50 pixels of height """ def init(self, y=150, x=120, jumps=1, duration=5): """Init method :Parameters: `y` : integer Height of jumps `x` : integer horizontal movement relative to the startin position `jumps` : integer quantity of jumps `duration` : float Duration time in seconds """ import warnings warnings.warn('Deprecated "Jump" action. Consider using JumpBy instead', DeprecationWarning) self.y = y self.x = x self.duration = duration self.jumps = jumps def start(self): self.start_position = self.target.position def update(self, t): y = int(self.y * abs(math.sin(t * math.pi * self.jumps))) x = self.x * t self.target.position = self.start_position + Point2(x, y) def __reversed__(self): return Jump(self.y, -self.x, self.jumps, self.duration) class JumpBy(IntervalAction): """Moves a `CocosNode` object simulating a jump movement by modifying it's position attribute. Example:: # Move the sprite 200 pixels to the right and up action = JumpBy((100,100),200, 5, 6) sprite.do(action) # in 6 seconds, doing 5 jumps # of 200 pixels of height """ def init(self, position=(0, 0), height=100, jumps=1, duration=5): """Init method :Parameters: `position` : integer x integer tuple horizontal and vertical movement relative to the starting position `height` : integer Height of jumps `jumps` : integer quantity of jumps `duration` : float Duration time in seconds """ self.position = position self.height = height self.duration = duration self.jumps = jumps def start(self): self.start_position = self.target.position self.delta = Vector2(*self.position) def update(self, t): y = self.height * abs(math.sin(t * math.pi * self.jumps)) y = int(y + self.delta[1]*t) x = self.delta[0] * t self.target.position = self.start_position + Point2(x, y) def __reversed__(self): return JumpBy((-self.position[0], -self.position[1]), self.height, self.jumps, self.duration) class JumpTo(JumpBy): """Moves a `CocosNode` object to a position simulating a jump movement by modifying it's position attribute. Example:: action = JumpTo(50,200, 5, 6) # Move the sprite 200 pixels to the right sprite.do(action) # in 6 seconds, doing 5 jumps # of 50 pixels of height """ def start(self): self.start_position = self.target.position self.delta = Vector2(*self.position) - self.start_position class Delay(IntervalAction): """Delays the action a certain amount of seconds Example:: action = Delay(2.5) sprite.do(action) """ def init(self, delay): """Init method :Parameters: `delay` : float Seconds of delay """ self.duration = delay def __reversed__(self): return self class RandomDelay(Delay): """Delays the actions between *min* and *max* seconds Example:: action = RandomDelay(2.5, 4.5) # delays the action between 2.5 and 4.5 seconds sprite.do(action) """ def init(self, low, hi): """Init method :Parameters: `low` : float Minimun seconds of delay `hi` : float Maximun seconds of delay """ self.low = low self.hi = hi def __deepcopy__(self, memo): new = copy.copy(self) new.duration = self.low + (random.random()*(self.hi - self.low)) return new def __mul__(self, other): if not isinstance(other, int): raise TypeError("Can only multiply actions by ints") if other <= 1: return self return RandomDelay(self.low * other, self.hi * other)
bsd-3-clause
[ 3, 27103, 199, 3, 512, 5197, 18, 68, 199, 3, 1898, 334, 67, 9, 9079, 13, 7409, 24747, 14769, 3930, 374, 409, 12, 820, 530, 1005, 79, 1413, 10138, 10641, 12, 30703, 484, 803, 377, 15999, 12, 199, 3, 30936, 10377, 29659, 264, 199, 3, 1898, 334, 67, 9, 8937, 13, 7806, 221, 30846, 1005, 1603, 4548, 12, 24433, 5208, 445, 5865, 387, 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, 7647, 26, 199, 3, 199, 3, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 257, 627, 11443, 314, 536, 402, 512, 5197, 18, 68, 6590, 314, 1561, 402, 2399, 199, 3, 258, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 258, 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, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 3, 27103, 199, 624, 8227, 10033, 199, 199, 8227, 24367, 199, 1280, 199, 199, 2493, 6252, 1595, 365, 376, 1595, 626, 6181, 4192, 4453, 282, 9842, 6247, 402, 900, 14, 199, 7940, 965, 376, 1343, 900, 12, 436, 282, 9578, 900, 14, 710, 9578, 900, 365, 314, 2725, 199, 1040, 5553, 1040, 12254, 314, 1343, 900, 14, 199, 199, 20676, 658, 8227, 3310, 64, 1172, 2005, 19604, 4382, 12, 2839, 26, 819, 446, 9322, 883, 1255, 12252, 334, 885, 9, 523, 446, 9322, 883, 1255, 10822, 543, 314, 658, 14987, 64, 1595, 14, 523, 446, 9322, 883, 1255, 543, 314, 900, 29815, 543, 314, 658, 1945, 11338, 323, 3559, 658, 1945, 6067, 8584, 6067, 64, 436, 272, 658, 15146, 64, 5445, 14, 199, 199, 1858, 2893, 12, 1265, 883, 20577, 282, 510, 316, 510, 951, 7763, 3879, 314, 1595, 12252, 436, 199, 12726, 3879, 652, 4020, 315, 22734, 818, 14, 199, 199, 9846, 447, 339, 18249, 63, 26992, 63, 1287, 275, 1595, 435, 22734, 8, 1287, 9, 421, 199, 11464, 18766, 9303, 199, 1280, 15495, 819, 627, 658, 10370, 1378, 64, 523, 627, 658, 10370, 2175, 64, 523, 627, 658, 42, 1220, 1378, 64, 523, 627, 658, 42, 1220, 2175, 64, 523, 627, 658, 3655, 90, 4446, 64, 523, 627, 658, 34, 1073, 64, 523, 627, 658, 32638, 1378, 64, 523, 627, 658, 32638, 2175, 64, 523, 627, 658, 9944, 1378, 64, 523, 627, 658, 9944, 2175, 64, 523, 627, 658, 1906, 271, 2204, 64, 523, 627, 658, 1906, 271, 607, 64, 523, 627, 658, 1906, 271, 1378, 64, 523, 627, 658, 10796, 64, 523, 627, 658, 3883, 10796, 64, 421, 199, 23871, 5445, 199, 1280, 819, 627, 658, 1945, 11338, 323, 64, 523, 627, 658, 1945, 6067, 8584, 6067, 64, 523, 627, 658, 15146, 64, 421, 199, 22787, 447, 339, 4057, 275, 14171, 2175, 1332, 1840, 12, 16, 395, 7373, 29, 21, 9, 221, 327, 3930, 2310, 1926, 11094, 370, 314, 2451, 315, 959, 4696, 14, 339, 4057, 275, 14171, 1378, 1332, 12122, 12, 9873, 395, 7373, 29, 21, 9, 327, 3930, 2310, 370, 314, 7148, 334, 12122, 12, 9873, 9, 315, 959, 4696, 339, 14882, 275, 1603, 1220, 2175, 1332, 12122, 12, 16, 395, 2948, 12, 959, 12, 7373, 29, 21, 9, 327, 1603, 1220, 83, 370, 314, 2451, 25611, 11094, 6059, 327, 9689, 959, 14882, 83, 402, 2948, 11094, 6059, 327, 402, 4569, 315, 959, 4696, 339, 1066, 6067, 63, 1185, 275, 4473, 11338, 323, 8, 1185, 9, 5185, 327, 1066, 11338, 2335, 1595, 4057, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 421, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 199, 646, 2196, 199, 646, 1331, 199, 646, 3473, 199, 199, 504, 1275, 1095, 63, 3723, 492, 627, 199, 504, 512, 5197, 14, 15149, 7401, 492, 627, 199, 199, 363, 452, 363, 275, 788, 44, 281, 80, 297, 22456, 327, 14046, 1779, 283, 10370, 1378, 297, 283, 10370, 2175, 297, 10473, 327, 4057, 434, 5445, 1779, 283, 42, 1220, 297, 283, 42, 1220, 1378, 297, 283, 42, 1220, 2175, 297, 1779, 283, 3655, 90, 4446, 297, 13293, 327, 6114, 4057, 434, 5445, 1779, 283, 32638, 297, 298, 32638, 1378, 401, 298, 32638, 2175, 401, 263, 327, 909, 13038, 1779, 283, 9944, 1378, 297, 283, 9944, 2175, 297, 8540, 327, 909, 4666, 1779, 283, 10796, 297, 283, 3883, 10796, 297, 8295, 327, 18464, 5758, 1779, 283, 1906, 271, 2204, 297, 283, 1906, 271, 607, 297, 283, 1906, 271, 1378, 297, 3698, 327, 10859, 3424, 315, 15, 548, 1595, 1779, 283, 34, 1073, 297, 2476, 327, 699, 1073, 1595, 1779, 283, 1945, 11338, 323, 297, 283, 1945, 6067, 8584, 6067, 297, 283, 15146, 297, 1622, 221, 327, 4703, 17355, 5445, 421, 199, 533, 491, 281, 80, 8, 8227, 3310, 304, 272, 408, 272 ]
[ 27103, 199, 3, 512, 5197, 18, 68, 199, 3, 1898, 334, 67, 9, 9079, 13, 7409, 24747, 14769, 3930, 374, 409, 12, 820, 530, 1005, 79, 1413, 10138, 10641, 12, 30703, 484, 803, 377, 15999, 12, 199, 3, 30936, 10377, 29659, 264, 199, 3, 1898, 334, 67, 9, 8937, 13, 7806, 221, 30846, 1005, 1603, 4548, 12, 24433, 5208, 445, 5865, 387, 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, 7647, 26, 199, 3, 199, 3, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 3, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 258, 4084, 14, 199, 3, 257, 627, 11443, 314, 536, 402, 512, 5197, 18, 68, 6590, 314, 1561, 402, 2399, 199, 3, 258, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 258, 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, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 3, 27103, 199, 624, 8227, 10033, 199, 199, 8227, 24367, 199, 1280, 199, 199, 2493, 6252, 1595, 365, 376, 1595, 626, 6181, 4192, 4453, 282, 9842, 6247, 402, 900, 14, 199, 7940, 965, 376, 1343, 900, 12, 436, 282, 9578, 900, 14, 710, 9578, 900, 365, 314, 2725, 199, 1040, 5553, 1040, 12254, 314, 1343, 900, 14, 199, 199, 20676, 658, 8227, 3310, 64, 1172, 2005, 19604, 4382, 12, 2839, 26, 819, 446, 9322, 883, 1255, 12252, 334, 885, 9, 523, 446, 9322, 883, 1255, 10822, 543, 314, 658, 14987, 64, 1595, 14, 523, 446, 9322, 883, 1255, 543, 314, 900, 29815, 543, 314, 658, 1945, 11338, 323, 3559, 658, 1945, 6067, 8584, 6067, 64, 436, 272, 658, 15146, 64, 5445, 14, 199, 199, 1858, 2893, 12, 1265, 883, 20577, 282, 510, 316, 510, 951, 7763, 3879, 314, 1595, 12252, 436, 199, 12726, 3879, 652, 4020, 315, 22734, 818, 14, 199, 199, 9846, 447, 339, 18249, 63, 26992, 63, 1287, 275, 1595, 435, 22734, 8, 1287, 9, 421, 199, 11464, 18766, 9303, 199, 1280, 15495, 819, 627, 658, 10370, 1378, 64, 523, 627, 658, 10370, 2175, 64, 523, 627, 658, 42, 1220, 1378, 64, 523, 627, 658, 42, 1220, 2175, 64, 523, 627, 658, 3655, 90, 4446, 64, 523, 627, 658, 34, 1073, 64, 523, 627, 658, 32638, 1378, 64, 523, 627, 658, 32638, 2175, 64, 523, 627, 658, 9944, 1378, 64, 523, 627, 658, 9944, 2175, 64, 523, 627, 658, 1906, 271, 2204, 64, 523, 627, 658, 1906, 271, 607, 64, 523, 627, 658, 1906, 271, 1378, 64, 523, 627, 658, 10796, 64, 523, 627, 658, 3883, 10796, 64, 421, 199, 23871, 5445, 199, 1280, 819, 627, 658, 1945, 11338, 323, 64, 523, 627, 658, 1945, 6067, 8584, 6067, 64, 523, 627, 658, 15146, 64, 421, 199, 22787, 447, 339, 4057, 275, 14171, 2175, 1332, 1840, 12, 16, 395, 7373, 29, 21, 9, 221, 327, 3930, 2310, 1926, 11094, 370, 314, 2451, 315, 959, 4696, 14, 339, 4057, 275, 14171, 1378, 1332, 12122, 12, 9873, 395, 7373, 29, 21, 9, 327, 3930, 2310, 370, 314, 7148, 334, 12122, 12, 9873, 9, 315, 959, 4696, 339, 14882, 275, 1603, 1220, 2175, 1332, 12122, 12, 16, 395, 2948, 12, 959, 12, 7373, 29, 21, 9, 327, 1603, 1220, 83, 370, 314, 2451, 25611, 11094, 6059, 327, 9689, 959, 14882, 83, 402, 2948, 11094, 6059, 327, 402, 4569, 315, 959, 4696, 339, 1066, 6067, 63, 1185, 275, 4473, 11338, 323, 8, 1185, 9, 5185, 327, 1066, 11338, 2335, 1595, 4057, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 421, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 199, 646, 2196, 199, 646, 1331, 199, 646, 3473, 199, 199, 504, 1275, 1095, 63, 3723, 492, 627, 199, 504, 512, 5197, 14, 15149, 7401, 492, 627, 199, 199, 363, 452, 363, 275, 788, 44, 281, 80, 297, 22456, 327, 14046, 1779, 283, 10370, 1378, 297, 283, 10370, 2175, 297, 10473, 327, 4057, 434, 5445, 1779, 283, 42, 1220, 297, 283, 42, 1220, 1378, 297, 283, 42, 1220, 2175, 297, 1779, 283, 3655, 90, 4446, 297, 13293, 327, 6114, 4057, 434, 5445, 1779, 283, 32638, 297, 298, 32638, 1378, 401, 298, 32638, 2175, 401, 263, 327, 909, 13038, 1779, 283, 9944, 1378, 297, 283, 9944, 2175, 297, 8540, 327, 909, 4666, 1779, 283, 10796, 297, 283, 3883, 10796, 297, 8295, 327, 18464, 5758, 1779, 283, 1906, 271, 2204, 297, 283, 1906, 271, 607, 297, 283, 1906, 271, 1378, 297, 3698, 327, 10859, 3424, 315, 15, 548, 1595, 1779, 283, 34, 1073, 297, 2476, 327, 699, 1073, 1595, 1779, 283, 1945, 11338, 323, 297, 283, 1945, 6067, 8584, 6067, 297, 283, 15146, 297, 1622, 221, 327, 4703, 17355, 5445, 421, 199, 533, 491, 281, 80, 8, 8227, 3310, 304, 272, 408, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
scotthartbti/android_external_chromium_org
tools/json_schema_compiler/code_test.py
131
4108
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from code import Code import unittest class CodeTest(unittest.TestCase): def testAppend(self): c = Code() c.Append('line') self.assertEquals('line', c.Render()) def testBlock(self): c = Code() (c.Append('line') .Sblock('sblock') .Append('inner') .Append('moreinner') .Sblock('moresblock') .Append('inner') .Eblock('out') .Append('inner') .Eblock('out') ) self.assertEquals( 'line\n' 'sblock\n' ' inner\n' ' moreinner\n' ' moresblock\n' ' inner\n' ' out\n' ' inner\n' 'out', c.Render()) def testConcat(self): b = Code() (b.Sblock('2') .Append('2') .Eblock('2') ) c = Code() (c.Sblock('1') .Concat(b) .Append('1') .Eblock('1') ) self.assertEquals( '1\n' ' 2\n' ' 2\n' ' 2\n' ' 1\n' '1', c.Render()) d = Code() a = Code() a.Concat(d) self.assertEquals('', a.Render()) a.Concat(c) self.assertEquals( '1\n' ' 2\n' ' 2\n' ' 2\n' ' 1\n' '1', a.Render()) def testConcatErrors(self): c = Code() d = Code() d.Append('%s') self.assertRaises(TypeError, c.Concat, d) d = Code() d.Append('%(classname)s') self.assertRaises(TypeError, c.Concat, d) d = 'line of code' self.assertRaises(TypeError, c.Concat, d) def testSubstitute(self): c = Code() c.Append('%(var1)s %(var2)s %(var1)s') c.Substitute({'var1': 'one', 'var2': 'two'}) self.assertEquals('one two one', c.Render()) c.Append('%(var1)s %(var2)s %(var3)s') c.Append('%(var2)s %(var1)s %(var3)s') c.Substitute({'var1': 'one', 'var2': 'two', 'var3': 'three'}) self.assertEquals( 'one two one\n' 'one two three\n' 'two one three', c.Render()) def testSubstituteErrors(self): # No unnamed placeholders allowed when substitute is run c = Code() c.Append('%s %s') self.assertRaises(TypeError, c.Substitute, ('var1', 'one')) c = Code() c.Append('%s %(var1)s') self.assertRaises(TypeError, c.Substitute, {'var1': 'one'}) c = Code() c.Append('%s %(var1)s') self.assertRaises(TypeError, c.Substitute, {'var1': 'one'}) c = Code() c.Append('%(var1)s') self.assertRaises(KeyError, c.Substitute, {'clearlynotvar1': 'one'}) def testIsEmpty(self): c = Code() self.assertTrue(c.IsEmpty()) c.Append('asdf') self.assertFalse(c.IsEmpty()) def testComment(self): long_comment = ('This comment is eighty nine characters in longness, ' 'that is, to use another word, length') c = Code() c.Comment(long_comment) self.assertEquals( '// This comment is eighty nine characters ' 'in longness, that is, to use another\n' '// word, length', c.Render()) c = Code() c.Sblock('sblock') c.Comment(long_comment) c.Eblock('eblock') c.Comment(long_comment) self.assertEquals( 'sblock\n' ' // This comment is eighty nine characters ' 'in longness, that is, to use\n' ' // another word, length\n' 'eblock\n' '// This comment is eighty nine characters in ' 'longness, that is, to use another\n' '// word, length', c.Render()) long_word = 'x' * 100 c = Code() c.Comment(long_word) self.assertEquals( '// ' + 'x' * 77 + '\n' '// ' + 'x' * 23, c.Render()) def testCommentWithSpecialCharacters(self): c = Code() c.Comment('20% of 80%s') c.Substitute({}) self.assertEquals('// 20% of 80%s', c.Render()) d = Code() d.Append('90') d.Concat(c) self.assertEquals('90\n' '// 20% of 80%s', d.Render()) if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 1233, 492, 5495, 199, 646, 2882, 199, 199, 533, 5495, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 8310, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 360, 604, 358, 272, 291, 14, 2947, 360, 604, 297, 286, 14, 9216, 1012, 819, 347, 511, 3142, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 334, 67, 14, 8310, 360, 604, 358, 489, 1275, 51, 1457, 360, 83, 1457, 358, 267, 1275, 8310, 360, 5216, 358, 267, 1275, 8310, 360, 6878, 5216, 358, 267, 1275, 51, 1457, 360, 573, 470, 1457, 358, 881, 1275, 8310, 360, 5216, 358, 267, 1275, 37, 1457, 360, 548, 358, 267, 1275, 8310, 360, 5216, 358, 489, 1275, 37, 1457, 360, 548, 358, 272, 776, 272, 291, 14, 2947, 8, 489, 283, 604, 60, 78, 7, 489, 283, 83, 1457, 60, 78, 7, 489, 283, 221, 6506, 60, 78, 7, 489, 283, 221, 1655, 5216, 60, 78, 7, 489, 283, 221, 1303, 470, 1457, 60, 78, 7, 489, 283, 259, 6506, 60, 78, 7, 489, 283, 221, 734, 60, 78, 7, 489, 283, 221, 6506, 60, 78, 7, 489, 283, 548, 297, 489, 286, 14, 9216, 1012, 819, 347, 511, 25536, 8, 277, 304, 272, 330, 275, 5495, 342, 272, 334, 66, 14, 51, 1457, 360, 18, 358, 267, 1275, 8310, 360, 18, 358, 489, 1275, 37, 1457, 360, 18, 358, 272, 776, 272, 286, 275, 5495, 342, 272, 334, 67, 14, 51, 1457, 360, 17, 358, 267, 1275, 25536, 8, 66, 9, 267, 1275, 8310, 360, 17, 358, 489, 1275, 37, 1457, 360, 17, 358, 272, 776, 272, 291, 14, 2947, 8, 489, 283, 17, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 259, 499, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 221, 413, 60, 78, 7, 489, 283, 17, 297, 489, 286, 14, 9216, 1012, 272, 366, 275, 5495, 342, 272, 282, 275, 5495, 342, 272, 282, 14, 25536, 8, 68, 9, 272, 291, 14, 2947, 8594, 282, 14, 9216, 1012, 272, 282, 14, 25536, 8, 67, 9, 272, 291, 14, 2947, 8, 489, 283, 17, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 259, 499, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 221, 413, 60, 78, 7, 489, 283, 17, 297, 489, 282, 14, 9216, 1012, 819, 347, 511, 25536, 9298, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 366, 275, 5495, 342, 272, 366, 14, 8310, 3508, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 272, 366, 275, 5495, 342, 272, 366, 14, 8310, 24713, 19851, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 272, 366, 275, 283, 604, 402, 1233, 7, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 819, 347, 511, 2610, 25585, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 2818, 1391, 18, 9, 83, 2818, 1391, 17, 9, 83, 358, 272, 286, 14, 2610, 25585, 3252, 1391, 17, 356, 283, 368, 297, 283, 1391, 18, 356, 283, 5601, 3071, 272, 291, 14, 2947, 360, 368, 2877, 1373, 297, 286, 14, 9216, 1012, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 2818, 1391, 18, 9, 83, 2818, 1391, 19, 9, 83, 358, 272, 286, 14, 8310, 24713, 1391, 18, 9, 83, 2818, 1391, 17, 9, 83, 2818, 1391, 19, 9, 83, 358, 272, 286, 14, 2610, 25585, 3252, 1391, 17, 356, 283, 368, 297, 283, 1391, 18, 356, 283, 5601, 297, 283, 1391, 19, 356, 283, 10480, 3071, 272, 291, 14, 2947, 8, 267, 283, 368, 2877, 1373, 60, 78, 7, 267, 283, 368, 2877, 7795, 60, 78, 7, 267, 283, 5601, 1373, 7795, 297, 267, 286, 14, 9216, 1012, 819, 347, 511, 2610, 25585, 9298, 8, 277, 304, 272, 327, 3091, 625, 4579, 24987, 4370, 1380, 23080, 365, 1255, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 450, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 661, 1391, 17, 297, 283, 368, 1333, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 2818, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 791, 1391, 17, 356, 283, 368, 3071, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 2818, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 791, 1391, 17, 356, 283, 368, 3071, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 10230, 12, 286, 14, 2610, 25585, 12, 791, 3584, 590, 1397, 1391, 17, 356, 283, 368, 3071, 819, 347, 511, 1831, 4699, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 291, 14, 1815, 8, 67, 14, 1831, 4699, 1012, 272, 286, 14, 8310, 360, 18196, 358, 272, 291, 14, 3334, 8, 67, 14, 1831, 4699, 1012, 819, 347, 511, 7488, 8, 277, 304, 272, 1846, 63, 3349, 275, 661, 2765, 3721, 365, 325, 2056, 369, 302, 1132, 4110, 315, 1846, 4171, 12, 283, 267, 283, 9099, 365, 12, 370, 675, 4573, 4349, 12, 2582, 358, 272, 286, 275, 5495, 342, 272, 286, 14, 7488, 8, 2809, 63, 3349, 9, 272, 291, 14, 2947, 8, 267, 18290, 961, 3721, 365, 325, 2056, 369, 302, 1132, 4110, 283, 267, 283, 262, 1846, 4171, 12, 626, 365, 12, 370, 675, 4573, 60, 78, 7, 267, 18290, 4349, 12, 2582, 297, 267, 286, 14, 9216, 1012, 272, 286, 275, 5495, 342, 272, 286, 14, 51, 1457, 360, 83, 1457, 358, 272, 286, 14, 7488, 8, 2809, 63, 3349, 9, 272, 286, 14, 37, 1457, 360, 69 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 1233, 492, 5495, 199, 646, 2882, 199, 199, 533, 5495, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 8310, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 360, 604, 358, 272, 291, 14, 2947, 360, 604, 297, 286, 14, 9216, 1012, 819, 347, 511, 3142, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 334, 67, 14, 8310, 360, 604, 358, 489, 1275, 51, 1457, 360, 83, 1457, 358, 267, 1275, 8310, 360, 5216, 358, 267, 1275, 8310, 360, 6878, 5216, 358, 267, 1275, 51, 1457, 360, 573, 470, 1457, 358, 881, 1275, 8310, 360, 5216, 358, 267, 1275, 37, 1457, 360, 548, 358, 267, 1275, 8310, 360, 5216, 358, 489, 1275, 37, 1457, 360, 548, 358, 272, 776, 272, 291, 14, 2947, 8, 489, 283, 604, 60, 78, 7, 489, 283, 83, 1457, 60, 78, 7, 489, 283, 221, 6506, 60, 78, 7, 489, 283, 221, 1655, 5216, 60, 78, 7, 489, 283, 221, 1303, 470, 1457, 60, 78, 7, 489, 283, 259, 6506, 60, 78, 7, 489, 283, 221, 734, 60, 78, 7, 489, 283, 221, 6506, 60, 78, 7, 489, 283, 548, 297, 489, 286, 14, 9216, 1012, 819, 347, 511, 25536, 8, 277, 304, 272, 330, 275, 5495, 342, 272, 334, 66, 14, 51, 1457, 360, 18, 358, 267, 1275, 8310, 360, 18, 358, 489, 1275, 37, 1457, 360, 18, 358, 272, 776, 272, 286, 275, 5495, 342, 272, 334, 67, 14, 51, 1457, 360, 17, 358, 267, 1275, 25536, 8, 66, 9, 267, 1275, 8310, 360, 17, 358, 489, 1275, 37, 1457, 360, 17, 358, 272, 776, 272, 291, 14, 2947, 8, 489, 283, 17, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 259, 499, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 221, 413, 60, 78, 7, 489, 283, 17, 297, 489, 286, 14, 9216, 1012, 272, 366, 275, 5495, 342, 272, 282, 275, 5495, 342, 272, 282, 14, 25536, 8, 68, 9, 272, 291, 14, 2947, 8594, 282, 14, 9216, 1012, 272, 282, 14, 25536, 8, 67, 9, 272, 291, 14, 2947, 8, 489, 283, 17, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 259, 499, 60, 78, 7, 489, 283, 221, 499, 60, 78, 7, 489, 283, 221, 413, 60, 78, 7, 489, 283, 17, 297, 489, 282, 14, 9216, 1012, 819, 347, 511, 25536, 9298, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 366, 275, 5495, 342, 272, 366, 14, 8310, 3508, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 272, 366, 275, 5495, 342, 272, 366, 14, 8310, 24713, 19851, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 272, 366, 275, 283, 604, 402, 1233, 7, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 25536, 12, 366, 9, 819, 347, 511, 2610, 25585, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 2818, 1391, 18, 9, 83, 2818, 1391, 17, 9, 83, 358, 272, 286, 14, 2610, 25585, 3252, 1391, 17, 356, 283, 368, 297, 283, 1391, 18, 356, 283, 5601, 3071, 272, 291, 14, 2947, 360, 368, 2877, 1373, 297, 286, 14, 9216, 1012, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 2818, 1391, 18, 9, 83, 2818, 1391, 19, 9, 83, 358, 272, 286, 14, 8310, 24713, 1391, 18, 9, 83, 2818, 1391, 17, 9, 83, 2818, 1391, 19, 9, 83, 358, 272, 286, 14, 2610, 25585, 3252, 1391, 17, 356, 283, 368, 297, 283, 1391, 18, 356, 283, 5601, 297, 283, 1391, 19, 356, 283, 10480, 3071, 272, 291, 14, 2947, 8, 267, 283, 368, 2877, 1373, 60, 78, 7, 267, 283, 368, 2877, 7795, 60, 78, 7, 267, 283, 5601, 1373, 7795, 297, 267, 286, 14, 9216, 1012, 819, 347, 511, 2610, 25585, 9298, 8, 277, 304, 272, 327, 3091, 625, 4579, 24987, 4370, 1380, 23080, 365, 1255, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 450, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 661, 1391, 17, 297, 283, 368, 1333, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 2818, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 791, 1391, 17, 356, 283, 368, 3071, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 3508, 83, 2818, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 4333, 12, 286, 14, 2610, 25585, 12, 791, 1391, 17, 356, 283, 368, 3071, 272, 286, 275, 5495, 342, 272, 286, 14, 8310, 24713, 1391, 17, 9, 83, 358, 272, 291, 14, 1855, 8, 10230, 12, 286, 14, 2610, 25585, 12, 791, 3584, 590, 1397, 1391, 17, 356, 283, 368, 3071, 819, 347, 511, 1831, 4699, 8, 277, 304, 272, 286, 275, 5495, 342, 272, 291, 14, 1815, 8, 67, 14, 1831, 4699, 1012, 272, 286, 14, 8310, 360, 18196, 358, 272, 291, 14, 3334, 8, 67, 14, 1831, 4699, 1012, 819, 347, 511, 7488, 8, 277, 304, 272, 1846, 63, 3349, 275, 661, 2765, 3721, 365, 325, 2056, 369, 302, 1132, 4110, 315, 1846, 4171, 12, 283, 267, 283, 9099, 365, 12, 370, 675, 4573, 4349, 12, 2582, 358, 272, 286, 275, 5495, 342, 272, 286, 14, 7488, 8, 2809, 63, 3349, 9, 272, 291, 14, 2947, 8, 267, 18290, 961, 3721, 365, 325, 2056, 369, 302, 1132, 4110, 283, 267, 283, 262, 1846, 4171, 12, 626, 365, 12, 370, 675, 4573, 60, 78, 7, 267, 18290, 4349, 12, 2582, 297, 267, 286, 14, 9216, 1012, 272, 286, 275, 5495, 342, 272, 286, 14, 51, 1457, 360, 83, 1457, 358, 272, 286, 14, 7488, 8, 2809, 63, 3349, 9, 272, 286, 14, 37, 1457, 360, 69, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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/>. # this is a windows documentation stub. actual code lives in the .ps1 # file of the same name DOCUMENTATION = ''' --- module: win_webpicmd version_added: "2.0" short_description: Installs packages using Web Platform Installer command-line description: - Installs packages using Web Platform Installer command-line (http://www.iis.net/learn/install/web-platform-installer/web-platform-installer-v4-command-line-webpicmdexe-rtw-release). - Must be installed and present in PATH (see win_chocolatey module; 'webpicmd' is the package name, and you must install 'lessmsi' first too) - Install IIS first (see win_feature module) notes: - accepts EULAs and suppresses reboot - you will need to check manage reboots yourself (see win_reboot module) options: name: description: - Name of the package to be installed required: true author: Peter Mounce ''' EXAMPLES = ''' # Install URLRewrite2. win_webpicmd: name: URLRewrite2 '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 22912, 3930, 10222, 665, 3455, 32, 18178, 1065, 1045, 551, 19857, 1384, 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, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4747, 63, 2520, 12475, 1064, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 3612, 63, 1802, 26, 13276, 83, 6117, 1808, 6001, 16078, 14089, 9230, 1414, 13, 604, 199, 1802, 26, 272, 446, 13276, 83, 6117, 1808, 6001, 16078, 14089, 9230, 1414, 13, 604, 334, 1014, 921, 1544, 14, 73, 374, 14, 846, 15, 4643, 15, 3174, 15, 2520, 13, 3246, 13, 17047, 15, 2520, 13, 3246, 13, 17047, 13, 86, 20, 13, 1531, 13, 604, 13, 2520, 12475, 77, 731, 69, 13, 2591, 87, 13, 3221, 680, 272, 446, 9498, 506, 4903, 436, 3451, 315, 15097, 334, 3239, 4747, 63, 2239, 331, 750, 89, 859, 27, 283, 2520, 12475, 1064, 7, 365, 314, 2559, 536, 12, 436, 1265, 1471, 3907, 283, 2003, 77, 338, 7, 1642, 4634, 9, 272, 446, 13276, 473, 1311, 1642, 334, 3239, 4747, 63, 4445, 859, 9, 199, 5983, 26, 272, 446, 11479, 662, 1293, 2822, 436, 4973, 4357, 19457, 446, 1265, 911, 1929, 370, 1104, 9635, 19457, 83, 28225, 334, 3239, 4747, 63, 15051, 859, 9, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2559, 370, 506, 4903, 272, 1415, 26, 2549, 199, 2502, 26, 22912, 3930, 10222, 199, 2344, 199, 199, 8918, 275, 1449, 523, 327, 13276, 2851, 497, 952, 18, 14, 523, 4747, 63, 2520, 12475, 1064, 26, 272, 536, 26, 2851, 497, 952, 18, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 22912, 3930, 10222, 665, 3455, 32, 18178, 1065, 1045, 551, 19857, 1384, 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, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4747, 63, 2520, 12475, 1064, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 3612, 63, 1802, 26, 13276, 83, 6117, 1808, 6001, 16078, 14089, 9230, 1414, 13, 604, 199, 1802, 26, 272, 446, 13276, 83, 6117, 1808, 6001, 16078, 14089, 9230, 1414, 13, 604, 334, 1014, 921, 1544, 14, 73, 374, 14, 846, 15, 4643, 15, 3174, 15, 2520, 13, 3246, 13, 17047, 15, 2520, 13, 3246, 13, 17047, 13, 86, 20, 13, 1531, 13, 604, 13, 2520, 12475, 77, 731, 69, 13, 2591, 87, 13, 3221, 680, 272, 446, 9498, 506, 4903, 436, 3451, 315, 15097, 334, 3239, 4747, 63, 2239, 331, 750, 89, 859, 27, 283, 2520, 12475, 1064, 7, 365, 314, 2559, 536, 12, 436, 1265, 1471, 3907, 283, 2003, 77, 338, 7, 1642, 4634, 9, 272, 446, 13276, 473, 1311, 1642, 334, 3239, 4747, 63, 4445, 859, 9, 199, 5983, 26, 272, 446, 11479, 662, 1293, 2822, 436, 4973, 4357, 19457, 446, 1265, 911, 1929, 370, 1104, 9635, 19457, 83, 28225, 334, 3239, 4747, 63, 15051, 859, 9, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2559, 370, 506, 4903, 272, 1415, 26, 2549, 199, 2502, 26, 22912, 3930, 10222, 199, 2344, 199, 199, 8918, 275, 1449, 523, 327, 13276, 2851, 497, 952, 18, 14, 523, 4747, 63, 2520, 12475, 1064, 26, 272, 536, 26, 2851, 497, 952, 18, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
Shraddha512/servo
components/script/dom/bindings/codegen/Codegen.py
37
239292
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. # Common codegen classes. import os import string import operator from WebIDL import * from Configuration import NoSuchDescriptorError AUTOGENERATED_WARNING_COMMENT = \ "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n" ADDPROPERTY_HOOK_NAME = '_addProperty' FINALIZE_HOOK_NAME = '_finalize' TRACE_HOOK_NAME = '_trace' CONSTRUCT_HOOK_NAME = '_constructor' HASINSTANCE_HOOK_NAME = '_hasInstance' def replaceFileIfChanged(filename, newContents): """ Read a copy of the old file, so that we don't touch it if it hasn't changed. Returns True if the file was updated, false otherwise. """ oldFileContents = "" try: oldFile = open(filename, 'rb') oldFileContents = ''.join(oldFile.readlines()) oldFile.close() except: pass if newContents == oldFileContents: return False f = open(filename, 'wb') f.write(newContents) f.close() def toStringBool(arg): return str(not not arg).lower() def toBindingNamespace(arg): return re.sub("((_workers)?$)", "Binding\\1", arg); class CGThing(): """ Abstract base class for things that spit out code. """ def __init__(self): pass # Nothing for now def declare(self): """Produce code for a header file.""" assert(False) # Override me! def define(self): """Produce code for a cpp file.""" assert(False) # Override me! class CGNativePropertyHooks(CGThing): """ Generate a NativePropertyHooks for a given descriptor """ def __init__(self, descriptor): CGThing.__init__(self) self.descriptor = descriptor def declare(self): if self.descriptor.workers: return "" return "extern const NativePropertyHooks NativeHooks;\n" def define(self): if self.descriptor.workers: return "" if self.descriptor.concrete and self.descriptor.proxy: resolveOwnProperty = "ResolveOwnProperty" enumerateOwnProperties = "EnumerateOwnProperties" else: enumerateOwnProperties = resolveOwnProperty = "NULL" parent = self.descriptor.interface.parent parentHooks = ("&" + toBindingNamespace(parent.identifier.name) + "::NativeHooks" if parent else 'NULL') return """ const NativePropertyHooks NativeHooks = { %s, ResolveProperty, %s, EnumerateProperties, %s }; """ % (resolveOwnProperty, enumerateOwnProperties, parentHooks) def DOMClass(descriptor): protoList = ['prototypes::id::' + proto for proto in descriptor.prototypeChain] # Pad out the list to the right length with _ID_Count so we # guarantee that all the lists are the same length. _ID_Count # is never the ID of any prototype, so it's safe to use as # padding. protoList.extend(['prototypes::id::_ID_Count'] * (descriptor.config.maxProtoChainLength - len(protoList))) prototypeChainString = ', '.join(protoList) nativeHooks = "NULL" if descriptor.workers else "&NativeHooks" return """{ { %s }, %s, %s }""" % (prototypeChainString, toStringBool(descriptor.nativeIsISupports), nativeHooks) class CGDOMJSClass(CGThing): """ Generate a DOMJSClass for a given descriptor """ def __init__(self, descriptor): CGThing.__init__(self) self.descriptor = descriptor def declare(self): return "extern DOMJSClass Class;\n" def define(self): traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else 'NULL' return """ DOMJSClass Class = { { "%s", JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1), %s, /* addProperty */ JS_PropertyStub, /* delProperty */ JS_PropertyStub, /* getProperty */ JS_StrictPropertyStub, /* setProperty */ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, %s, /* finalize */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* hasInstance */ NULL, /* construct */ %s, /* trace */ JSCLASS_NO_INTERNAL_MEMBERS }, %s }; """ % (self.descriptor.interface.identifier.name, ADDPROPERTY_HOOK_NAME if self.descriptor.concrete and not self.descriptor.workers and self.descriptor.wrapperCache else 'JS_PropertyStub', FINALIZE_HOOK_NAME, traceHook, CGIndenter(CGGeneric(DOMClass(self.descriptor))).define()) class CGPrototypeJSClass(CGThing): def __init__(self, descriptor): CGThing.__init__(self) self.descriptor = descriptor def declare(self): # We're purely for internal consumption return "" def define(self): return """static JSClass PrototypeClass = { "%sPrototype", JSCLASS_HAS_RESERVED_SLOTS(1), JS_PropertyStub, /* addProperty */ JS_PropertyStub, /* delProperty */ JS_PropertyStub, /* getProperty */ JS_StrictPropertyStub, /* setProperty */ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* hasInstance */ NULL, /* construct */ NULL, /* trace */ JSCLASS_NO_INTERNAL_MEMBERS }; """ % (self.descriptor.interface.identifier.name) class CGInterfaceObjectJSClass(CGThing): def __init__(self, descriptor): CGThing.__init__(self) self.descriptor = descriptor def declare(self): # We're purely for internal consumption return "" def define(self): if not self.descriptor.hasInstanceInterface: return "" ctorname = "NULL" if not self.descriptor.interface.ctor() else CONSTRUCT_HOOK_NAME hasinstance = HASINSTANCE_HOOK_NAME return """ static JSClass InterfaceObjectClass = { "Function", 0, JS_PropertyStub, /* addProperty */ JS_PropertyStub, /* delProperty */ JS_PropertyStub, /* getProperty */ JS_StrictPropertyStub, /* setProperty */ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ NULL, /* checkAccess */ %s, /* call */ %s, /* hasInstance */ %s, /* construct */ NULL, /* trace */ JSCLASS_NO_INTERNAL_MEMBERS }; """ % (ctorname, hasinstance, ctorname) class CGList(CGThing): """ Generate code for a list of GCThings. Just concatenates them together, with an optional joiner string. "\n" is a common joiner. """ def __init__(self, children, joiner=""): CGThing.__init__(self) self.children = children self.joiner = joiner def append(self, child): self.children.append(child) def prepend(self, child): self.children.insert(0, child) def join(self, generator): return self.joiner.join(filter(lambda s: len(s) > 0, (child for child in generator))) def declare(self): return self.join(child.declare() for child in self.children if child is not None) def define(self): return self.join(child.define() for child in self.children if child is not None) class CGGeneric(CGThing): """ A class that spits out a fixed string into the codegen. Can spit out a separate string for the declaration too. """ def __init__(self, define="", declare=""): self.declareText = declare self.defineText = define def declare(self): return self.declareText def define(self): return self.defineText # We'll want to insert the indent at the beginnings of lines, but we # don't want to indent empty lines. So only indent lines that have a # non-newline character on them. lineStartDetector = re.compile("^(?=[^\n#])", re.MULTILINE) class CGIndenter(CGThing): """ A class that takes another CGThing and generates code that indents that CGThing by some number of spaces. The default indent is two spaces. """ def __init__(self, child, indentLevel=2, declareOnly=False): CGThing.__init__(self) self.child = child self.indent = " " * indentLevel self.declareOnly = declareOnly def declare(self): decl = self.child.declare() if decl is not "": return re.sub(lineStartDetector, self.indent, decl) else: return "" def define(self): defn = self.child.define() if defn is not "" and not self.declareOnly: return re.sub(lineStartDetector, self.indent, defn) else: return defn class CGWrapper(CGThing): """ Generic CGThing that wraps other CGThings with pre and post text. """ def __init__(self, child, pre="", post="", declarePre=None, declarePost=None, definePre=None, definePost=None, declareOnly=False, defineOnly=False, reindent=False): CGThing.__init__(self) self.child = child self.declarePre = declarePre or pre self.declarePost = declarePost or post self.definePre = definePre or pre self.definePost = definePost or post self.declareOnly = declareOnly self.defineOnly = defineOnly self.reindent = reindent def declare(self): if self.defineOnly: return '' decl = self.child.declare() if self.reindent: # We don't use lineStartDetector because we don't want to # insert whitespace at the beginning of our _first_ line. decl = stripTrailingWhitespace( decl.replace("\n", "\n" + (" " * len(self.declarePre)))) return self.declarePre + decl + self.declarePost def define(self): if self.declareOnly: return '' defn = self.child.define() if self.reindent: # We don't use lineStartDetector because we don't want to # insert whitespace at the beginning of our _first_ line. defn = stripTrailingWhitespace( defn.replace("\n", "\n" + (" " * len(self.definePre)))) return self.definePre + defn + self.definePost class CGIfWrapper(CGWrapper): def __init__(self, child, condition): pre = CGWrapper(CGGeneric(condition), pre="if (", post=") {\n", reindent=True) CGWrapper.__init__(self, CGIndenter(child), pre=pre.define(), post="\n}") class CGNamespace(CGWrapper): def __init__(self, namespace, child, declareOnly=False): pre = "namespace %s {\n" % namespace post = "} // namespace %s\n" % namespace CGWrapper.__init__(self, child, pre=pre, post=post, declareOnly=declareOnly) @staticmethod def build(namespaces, child, declareOnly=False): """ Static helper method to build multiple wrapped namespaces. """ if not namespaces: return CGWrapper(child, declareOnly=declareOnly) inner = CGNamespace.build(namespaces[1:], child, declareOnly=declareOnly) return CGNamespace(namespaces[0], inner, declareOnly=declareOnly) class CGIncludeGuard(CGWrapper): """ Generates include guards for a header. """ def __init__(self, prefix, child): """|prefix| is the filename without the extension.""" define = 'mozilla_dom_%s_h__' % prefix CGWrapper.__init__(self, child, declarePre='#ifndef %s\n#define %s\n\n' % (define, define), declarePost='\n#endif // %s\n' % define) def getTypes(descriptor): """ Get all argument and return types for all members of the descriptor """ members = [m for m in descriptor.interface.members] if descriptor.interface.ctor(): members.append(descriptor.interface.ctor()) signatures = [s for m in members if m.isMethod() for s in m.signatures()] types = [] for s in signatures: assert len(s) == 2 (returnType, arguments) = s types.append(returnType) types.extend([a.type for a in arguments]) types.extend(a.type for a in members if a.isAttr()) return types class CGHeaders(CGWrapper): """ Generates the appropriate include statements. """ def __init__(self, descriptors, dictionaries, declareIncludes, defineIncludes, child): """ Builds a set of includes to cover |descriptors|. Also includes the files in |declareIncludes| in the header file and the files in |defineIncludes| in the .cpp. """ # Determine the filenames for which we need headers. interfaceDeps = [d.interface for d in descriptors] ancestors = [] for iface in interfaceDeps: while iface.parent: ancestors.append(iface.parent) iface = iface.parent interfaceDeps.extend(ancestors) bindingIncludes = set(self.getDeclarationFilename(d) for d in interfaceDeps) # Grab all the implementation declaration files we need. implementationIncludes = set(d.headerFile for d in descriptors) # Now find all the things we'll need as arguments because we # need to wrap or unwrap them. bindingHeaders = set() for d in descriptors: types = getTypes(d) for dictionary in dictionaries: curDict = dictionary while curDict: types.extend([m.type for m in curDict.members]) curDict = curDict.parent for t in types: if t.unroll().isUnion(): # UnionConversions.h includes UnionTypes.h bindingHeaders.add("mozilla/dom/UnionConversions.h") elif t.unroll().isInterface(): if t.unroll().isSpiderMonkeyInterface(): bindingHeaders.add("jsfriendapi.h") bindingHeaders.add("mozilla/dom/TypedArray.h") else: typeDesc = d.getDescriptor(t.unroll().inner.identifier.name) if typeDesc is not None: implementationIncludes.add(typeDesc.headerFile) bindingHeaders.add(self.getDeclarationFilename(typeDesc.interface)) elif t.unroll().isDictionary(): bindingHeaders.add(self.getDeclarationFilename(t.unroll().inner)) declareIncludes = set(declareIncludes) for d in dictionaries: if d.parent: declareIncludes.add(self.getDeclarationFilename(d.parent)) bindingHeaders.add(self.getDeclarationFilename(d)) # Let the machinery do its thing. def _includeString(includes): return ''.join(['#include "%s"\n' % i for i in includes]) + '\n' CGWrapper.__init__(self, child, declarePre=_includeString(sorted(declareIncludes)), definePre=_includeString(sorted(set(defineIncludes) | bindingIncludes | bindingHeaders | implementationIncludes))) @staticmethod def getDeclarationFilename(decl): # Use our local version of the header, not the exported one, so that # test bindings, which don't export, will work correctly. basename = os.path.basename(decl.filename()) return basename.replace('.webidl', 'Binding.h') def SortedTuples(l): """ Sort a list of tuples based on the first item in the tuple """ return sorted(l, key=operator.itemgetter(0)) def SortedDictValues(d): """ Returns a list of values from the dict sorted by key. """ # Create a list of tuples containing key and value, sorted on key. d = SortedTuples(d.items()) # We're only interested in the values. return (i[1] for i in d) def UnionTypes(descriptors): """ Returns a tuple containing a set of header filenames to include, a set of tuples containing a type declaration and a boolean if the type is a struct for member types of the unions and a CGList containing CGUnionStructs for every union. """ # Now find all the things we'll need as arguments and return values because # we need to wrap or unwrap them. headers = set() declarations = set() unionStructs = dict() for d in descriptors: if d.interface.isExternal(): continue for t in getTypes(d): t = t.unroll() if t.isUnion(): name = str(t) if not name in unionStructs: unionStructs[name] = CGUnionStruct(t, d) for f in t.flatMemberTypes: f = f.unroll() if f.isInterface(): if f.isSpiderMonkeyInterface(): headers.add("jsfriendapi.h") headers.add("mozilla/dom/TypedArray.h") else: typeDesc = d.getDescriptor(f.inner.identifier.name) if typeDesc is not None: declarations.add((typeDesc.nativeType, False)) elif f.isDictionary(): declarations.add((f.inner.identifier.name, True)) return (headers, declarations, CGList(SortedDictValues(unionStructs), "\n")) def UnionConversions(descriptors): """ Returns a CGThing to declare all union argument conversion helper structs. """ # Now find all the things we'll need as arguments because we # need to unwrap them. unionConversions = dict() for d in descriptors: if d.interface.isExternal(): continue def addUnionTypes(type): if type.isUnion(): type = type.unroll() name = str(type) if not name in unionConversions: unionConversions[name] = CGUnionConversionStruct(type, d) members = [m for m in d.interface.members] if d.interface.ctor(): members.append(d.interface.ctor()) signatures = [s for m in members if m.isMethod() for s in m.signatures()] for s in signatures: assert len(s) == 2 (_, arguments) = s for a in arguments: addUnionTypes(a.type) for m in members: if m.isAttr() and not m.readonly: addUnionTypes(m.type) return CGWrapper(CGList(SortedDictValues(unionConversions), "\n"), post="\n\n") class Argument(): """ A class for outputting the type and name of an argument """ def __init__(self, argType, name): self.argType = argType self.name = name def __str__(self): return self.argType + ' ' + self.name class CGAbstractMethod(CGThing): """ An abstract class for generating code for a method. Subclasses should override definition_body to create the actual code. descriptor is the descriptor for the interface the method is associated with name is the name of the method as a string returnType is the IDLType of the return value args is a list of Argument objects inline should be True to generate an inline method, whose body is part of the declaration. alwaysInline should be True to generate an inline method annotated with MOZ_ALWAYS_INLINE. static should be True to generate a static method, which only has a definition. If templateArgs is not None it should be a list of strings containing template arguments, and the function will be templatized using those arguments. """ def __init__(self, descriptor, name, returnType, args, inline=False, alwaysInline=False, static=False, templateArgs=None): CGThing.__init__(self) self.descriptor = descriptor self.name = name self.returnType = returnType self.args = args self.inline = inline self.alwaysInline = alwaysInline self.static = static self.templateArgs = templateArgs def _argstring(self): return ', '.join([str(a) for a in self.args]) def _template(self): if self.templateArgs is None: return '' return 'template <%s>\n' % ', '.join(self.templateArgs) def _decorators(self): decorators = [] if self.alwaysInline: decorators.append('MOZ_ALWAYS_INLINE') elif self.inline: decorators.append('inline') if self.static: decorators.append('static') decorators.append(self.returnType) maybeNewline = " " if self.inline else "\n" return ' '.join(decorators) + maybeNewline def declare(self): if self.inline: return self._define() return "%s%s%s(%s);\n" % (self._template(), self._decorators(), self.name, self._argstring()) def _define(self): return self.definition_prologue() + "\n" + self.definition_body() + self.definition_epilogue() def define(self): return "" if self.inline else self._define() def definition_prologue(self): return "%s%s%s(%s)\n{" % (self._template(), self._decorators(), self.name, self._argstring()) def definition_epilogue(self): return "\n}\n" def definition_body(self): assert(False) # Override me! class CGAbstractStaticMethod(CGAbstractMethod): """ Abstract base class for codegen of implementation-only (no declaration) static methods. """ def __init__(self, descriptor, name, returnType, args): CGAbstractMethod.__init__(self, descriptor, name, returnType, args, inline=False, static=True) def declare(self): # We only have implementation return "" class CGAbstractClassHook(CGAbstractStaticMethod): """ Meant for implementing JSClass hooks, like Finalize or Trace. Does very raw 'this' unwrapping as it assumes that the unwrapped type is always known. """ def __init__(self, descriptor, name, returnType, args): CGAbstractStaticMethod.__init__(self, descriptor, name, returnType, args) def definition_body_prologue(self): return """ %s* self = UnwrapDOMObject<%s>(obj, eRegularDOMObject); """ % (self.descriptor.nativeType, self.descriptor.nativeType) def definition_body(self): return self.definition_body_prologue() + self.generate_code() def generate_code(self): # Override me assert(False) class CGAddPropertyHook(CGAbstractClassHook): """ A hook for addProperty, used to preserve our wrapper from GC. """ def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'), Argument('JSHandleId', 'id'), Argument('JSMutableHandleValue', 'vp')] CGAbstractClassHook.__init__(self, descriptor, ADDPROPERTY_HOOK_NAME, 'JSBool', args) def generate_code(self): # FIXME https://bugzilla.mozilla.org/show_bug.cgi?id=774279 # Using a real trace hook might enable us to deal with non-nsISupports # wrappercached things here. assert self.descriptor.nativeIsISupports return """ nsContentUtils::PreserveWrapper(reinterpret_cast<nsISupports*>(self), self); return true;""" def finalizeHook(descriptor, hookName, context): if descriptor.customFinalize: return """if (self) { self->%s(%s); }""" % (hookName, context) clearWrapper = "ClearWrapper(self, self);\n" if descriptor.wrapperCache else "" if descriptor.workers: release = "self->Release();" else: assert descriptor.nativeIsISupports release = """XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance(); if (rt) { rt->DeferredRelease(reinterpret_cast<nsISupports*>(self)); } else { NS_RELEASE(self); }""" return clearWrapper + release class CGClassFinalizeHook(CGAbstractClassHook): """ A hook for finalize, used to release our native object. """ def __init__(self, descriptor): args = [Argument('JSFreeOp*', 'fop'), Argument('JSObject*', 'obj')] CGAbstractClassHook.__init__(self, descriptor, FINALIZE_HOOK_NAME, 'void', args) def generate_code(self): return CGIndenter(CGGeneric(finalizeHook(self.descriptor, self.name, self.args[0].name))).define() class CGClassTraceHook(CGAbstractClassHook): """ A hook to trace through our native object; used for GC and CC """ def __init__(self, descriptor): args = [Argument('JSTracer*', 'trc'), Argument('JSObject*', 'obj')] CGAbstractClassHook.__init__(self, descriptor, TRACE_HOOK_NAME, 'void', args) def generate_code(self): return """ if (self) { self->%s(%s); }""" % (self.name, self.args[0].name) class CGClassConstructHook(CGAbstractStaticMethod): """ JS-visible constructor for our objects """ def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'), Argument('JS::Value*', 'vp')] CGAbstractStaticMethod.__init__(self, descriptor, CONSTRUCT_HOOK_NAME, 'JSBool', args) self._ctor = self.descriptor.interface.ctor() def define(self): if not self._ctor: return "" return CGAbstractStaticMethod.define(self) def definition_body(self): return self.generate_code() def generate_code(self): preamble = """ JSObject* obj = JS_GetGlobalForObject(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))); """ if self.descriptor.workers: preArgs = ["cx", "obj"] else: preamble += """ nsISupports* global; xpc_qsSelfRef globalRef; { nsresult rv; JS::Value val = OBJECT_TO_JSVAL(obj); rv = xpc_qsUnwrapArg<nsISupports>(cx, val, &global, &globalRef.ptr, &val); if (NS_FAILED(rv)) { return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS); } } """ preArgs = ["global"] name = self._ctor.identifier.name nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name)) callGenerator = CGMethodCall(preArgs, nativeName, True, self.descriptor, self._ctor) return preamble + callGenerator.define(); class CGClassHasInstanceHook(CGAbstractStaticMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'), Argument('JSMutableHandleValue', 'vp'), Argument('JSBool*', 'bp')] CGAbstractStaticMethod.__init__(self, descriptor, HASINSTANCE_HOOK_NAME, 'JSBool', args) def define(self): if not self.descriptor.hasInstanceInterface: return "" return CGAbstractStaticMethod.define(self) def definition_body(self): return self.generate_code() def generate_code(self): return """ if (!vp.isObject()) { *bp = false; return true; } jsval protov; if (!JS_GetProperty(cx, obj, "prototype", &protov)) return false; if (!protov.isObject()) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_PROTOTYPE, "%s"); return false; } JSObject *objProto = &protov.toObject(); JSObject* instance = &vp.toObject(); JSObject* proto; if (!JS_GetPrototype(cx, instance, &proto)) return false; while (proto) { if (proto == objProto) { *bp = true; return true; } if (!JS_GetPrototype(cx, proto, &proto)) return false; } nsISupports* native = nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, instance); nsCOMPtr<%s> qiResult = do_QueryInterface(native); *bp = !!qiResult; return true; """ % (self.descriptor.name, self.descriptor.hasInstanceInterface) def isChromeOnly(m): return m.getExtendedAttribute("ChromeOnly") class PropertyDefiner: """ A common superclass for defining things on prototype objects. Subclasses should implement generateArray to generate the actual arrays of things we're defining. They should also set self.chrome to the list of things exposed to chrome and self.regular to the list of things exposed to web pages. self.chrome must be a superset of self.regular but also include all the ChromeOnly stuff. """ def __init__(self, descriptor, name): self.descriptor = descriptor self.name = name # self.prefCacheData will store an array of (prefname, bool*) # pairs for our bool var caches. generateArray will fill it # in as needed. self.prefCacheData = [] def hasChromeOnly(self): return len(self.chrome) > len(self.regular) def hasNonChromeOnly(self): return len(self.regular) > 0 def variableName(self, chrome): if chrome and self.hasChromeOnly(): return "sChrome" + self.name if self.hasNonChromeOnly(): return "s" + self.name return "NULL" def usedForXrays(self, chrome): # We only need Xrays for methods, attributes and constants. And we only # need them for the non-chrome ones if we have no chromeonly things. # Otherwise (we have chromeonly attributes) we need Xrays for the chrome # methods/attributes/constants. Finally, in workers there are no Xrays. return ((self.name is "Methods" or self.name is "Attributes" or self.name is "Constants") and chrome == self.hasChromeOnly() and not self.descriptor.workers) def __str__(self): # We only need to generate id arrays for things that will end # up used via ResolveProperty or EnumerateProperties. str = self.generateArray(self.regular, self.variableName(False), self.usedForXrays(False)) if self.hasChromeOnly(): str += self.generateArray(self.chrome, self.variableName(True), self.usedForXrays(True)) return str @staticmethod def getControllingPref(interfaceMember): prefName = interfaceMember.getExtendedAttribute("Pref") if prefName is None: return None # It's a list of strings assert(len(prefName) is 1) assert(prefName[0] is not None) return prefName[0] def generatePrefableArray(self, array, name, specTemplate, specTerminator, specType, getPref, getDataTuple, doIdArrays): """ This method generates our various arrays. array is an array of interface members as passed to generateArray name is the name as passed to generateArray specTemplate is a template for each entry of the spec array specTerminator is a terminator for the spec array (inserted every time our controlling pref changes and at the end of the array) specType is the actual typename of our spec getPref is a callback function that takes an array entry and returns the corresponding pref value. getDataTuple is a callback function that takes an array entry and returns a tuple suitable for substitution into specTemplate. """ # We want to generate a single list of specs, but with specTerminator # inserted at every point where the pref name controlling the member # changes. That will make sure the order of the properties as exposed # on the interface and interface prototype objects does not change when # pref control is added to members while still allowing us to define all # the members in the smallest number of JSAPI calls. assert(len(array) is not 0) lastPref = getPref(array[0]) # So we won't put a specTerminator # at the very front of the list. specs = [] prefableSpecs = [] if doIdArrays: prefableIds = [] prefableTemplate = ' { true, &%s[%d] }' prefCacheTemplate = '&%s[%d].enabled' def switchToPref(props, pref): # Remember the info about where our pref-controlled # booleans live. if pref is not None: props.prefCacheData.append( (pref, prefCacheTemplate % (name, len(prefableSpecs))) ) # Set up pointers to the new sets of specs and ids # inside prefableSpecs and prefableIds prefableSpecs.append(prefableTemplate % (name + "_specs", len(specs))) switchToPref(self, lastPref) for member in array: curPref = getPref(member) if lastPref != curPref: # Terminate previous list specs.append(specTerminator) # And switch to our new pref switchToPref(self, curPref) lastPref = curPref # And the actual spec specs.append(specTemplate % getDataTuple(member)) specs.append(specTerminator) prefableSpecs.append(" { false, NULL }"); arrays = (("static %s %s_specs[] = {\n" + ',\n'.join(specs) + "\n" + "};\n\n" + "static Prefable<%s> %s[] = {\n" + ',\n'.join(prefableSpecs) + "\n" + "};\n\n") % (specType, name, specType, name)) if doIdArrays: arrays += ("static jsid %s_ids[%i] = { JSID_VOID };\n\n" % (name, len(specs))) return arrays # The length of a method is the maximum of the lengths of the # argument lists of all its overloads. def methodLength(method): signatures = method.signatures() return max([len(arguments) for (retType, arguments) in signatures]) class MethodDefiner(PropertyDefiner): """ A class for defining methods on a prototype object. """ def __init__(self, descriptor, name, static): PropertyDefiner.__init__(self, descriptor, name) # FIXME https://bugzilla.mozilla.org/show_bug.cgi?id=772822 # We should be able to check for special operations without an # identifier. For now we check if the name starts with __ methods = [m for m in descriptor.interface.members if m.isMethod() and m.isStatic() == static and not m.isIdentifierLess()] self.chrome = [{"name": m.identifier.name, "length": methodLength(m), "flags": "JSPROP_ENUMERATE", "pref": PropertyDefiner.getControllingPref(m) } for m in methods] self.regular = [{"name": m.identifier.name, "length": methodLength(m), "flags": "JSPROP_ENUMERATE", "pref": PropertyDefiner.getControllingPref(m) } for m in methods if not isChromeOnly(m)] # FIXME Check for an existing iterator on the interface first. if any(m.isGetter() and m.isIndexed() for m in methods): self.chrome.append({"name": 'iterator', "methodInfo": False, "nativeName": "JS_ArrayIterator", "length": 0, "flags": "JSPROP_ENUMERATE", "pref": None }) self.regular.append({"name": 'iterator', "methodInfo": False, "nativeName": "JS_ArrayIterator", "length": 0, "flags": "JSPROP_ENUMERATE", "pref": None }) if not descriptor.interface.parent and not static and not descriptor.workers: self.chrome.append({"name": 'QueryInterface', "methodInfo": False, "length": 1, "flags": "0", "pref": None }) if static: if not descriptor.interface.hasInterfaceObject(): # static methods go on the interface object assert not self.hasChromeOnly() and not self.hasNonChromeOnly() else: if not descriptor.interface.hasInterfacePrototypeObject(): # non-static methods go on the interface prototype object assert not self.hasChromeOnly() and not self.hasNonChromeOnly() def generateArray(self, array, name, doIdArrays): if len(array) == 0: return "" def pref(m): return m["pref"] def specData(m): if m.get("methodInfo", True): jitinfo = ("&%s_methodinfo" % m["name"]) accessor = "genericMethod" else: jitinfo = "nullptr" accessor = m.get("nativeName", m["name"]) return (m["name"], accessor, jitinfo, m["length"], m["flags"]) return self.generatePrefableArray( array, name, ' JS_FNINFO("%s", %s, %s, %s, %s)', ' JS_FS_END', 'JSFunctionSpec', pref, specData, doIdArrays) class AttrDefiner(PropertyDefiner): def __init__(self, descriptor, name): PropertyDefiner.__init__(self, descriptor, name) self.name = name self.chrome = [m for m in descriptor.interface.members if m.isAttr()] self.regular = [m for m in self.chrome if not isChromeOnly(m)] def generateArray(self, array, name, doIdArrays): if len(array) == 0: return "" def flags(attr): return "JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS" def getter(attr): native = ("genericLenientGetter" if attr.hasLenientThis() else "genericGetter") return ("{(JSPropertyOp)%(native)s, &%(name)s_getterinfo}" % {"name" : attr.identifier.name, "native" : native}) def setter(attr): if attr.readonly: return "JSOP_NULLWRAPPER" native = ("genericLenientSetter" if attr.hasLenientThis() else "genericSetter") return ("{(JSStrictPropertyOp)%(native)s, &%(name)s_setterinfo}" % {"name" : attr.identifier.name, "native" : native}) def specData(attr): return (attr.identifier.name, flags(attr), getter(attr), setter(attr)) return self.generatePrefableArray( array, name, ' { "%s", 0, %s, %s, %s}', ' { 0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER }', 'JSPropertySpec', PropertyDefiner.getControllingPref, specData, doIdArrays) class ConstDefiner(PropertyDefiner): """ A class for definining constants on the interface object """ def __init__(self, descriptor, name): PropertyDefiner.__init__(self, descriptor, name) self.name = name self.chrome = [m for m in descriptor.interface.members if m.isConst()] self.regular = [m for m in self.chrome if not isChromeOnly(m)] def generateArray(self, array, name, doIdArrays): if len(array) == 0: return "" def specData(const): return (const.identifier.name, convertConstIDLValueToJSVal(const.value)) return self.generatePrefableArray( array, name, ' { "%s", %s }', ' { 0, JSVAL_VOID }', 'ConstantSpec', PropertyDefiner.getControllingPref, specData, doIdArrays) class PropertyArrays(): def __init__(self, descriptor): self.staticMethods = MethodDefiner(descriptor, "StaticMethods", True) self.methods = MethodDefiner(descriptor, "Methods", False) self.attrs = AttrDefiner(descriptor, "Attributes") self.consts = ConstDefiner(descriptor, "Constants") @staticmethod def arrayNames(): return [ "staticMethods", "methods", "attrs", "consts" ] @staticmethod def xrayRelevantArrayNames(): return [ "methods", "attrs", "consts" ] def hasChromeOnly(self): return reduce(lambda b, a: b or getattr(self, a).hasChromeOnly(), self.arrayNames(), False) def variableNames(self, chrome): names = {} for array in self.arrayNames(): names[array] = getattr(self, array).variableName(chrome) return names def __str__(self): define = "" for array in self.arrayNames(): define += str(getattr(self, array)) return define class CGCreateInterfaceObjectsMethod(CGAbstractMethod): """ Generate the CreateInterfaceObjects method for an interface descriptor. properties should be a PropertyArrays instance. """ def __init__(self, descriptor, properties): args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aGlobal'), Argument('JSObject*', 'aReceiver')] CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'JSObject*', args) self.properties = properties def definition_body(self): protoChain = self.descriptor.prototypeChain if len(protoChain) == 1: getParentProto = "JS_GetObjectPrototype(aCx, aGlobal)" else: parentProtoName = self.descriptor.prototypeChain[-2] getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" % toBindingNamespace(parentProtoName)) needInterfaceObject = self.descriptor.interface.hasInterfaceObject() needInterfacePrototypeObject = self.descriptor.interface.hasInterfacePrototypeObject() # if we don't need to create anything, why are we generating this? assert needInterfaceObject or needInterfacePrototypeObject idsToInit = [] # There is no need to init any IDs in workers, because worker bindings # don't have Xrays. if not self.descriptor.workers: for var in self.properties.xrayRelevantArrayNames(): props = getattr(self.properties, var) # We only have non-chrome ids to init if we have no chrome ids. if props.hasChromeOnly(): idsToInit.append(props.variableName(True)) elif props.hasNonChromeOnly(): idsToInit.append(props.variableName(False)) if len(idsToInit) > 0: initIds = CGList( [CGGeneric("!InitIds(aCx, %s, %s_ids)" % (varname, varname)) for varname in idsToInit], ' ||\n') if len(idsToInit) > 1: initIds = CGWrapper(initIds, pre="(", post=")", reindent=True) initIds = CGList( [CGGeneric("%s_ids[0] == JSID_VOID &&" % idsToInit[0]), initIds], "\n") initIds = CGWrapper(initIds, pre="if (", post=") {", reindent=True) initIds = CGList( [initIds, CGGeneric((" %s_ids[0] = JSID_VOID;\n" " return NULL;") % idsToInit[0]), CGGeneric("}")], "\n") else: initIds = None prefCacheData = [] for var in self.properties.arrayNames(): props = getattr(self.properties, var) prefCacheData.extend(props.prefCacheData) if len(prefCacheData) is not 0: prefCacheData = [ CGGeneric('Preferences::AddBoolVarCache(%s, "%s");' % (ptr, pref)) for (pref, ptr) in prefCacheData] prefCache = CGWrapper(CGIndenter(CGList(prefCacheData, "\n")), pre=("static bool sPrefCachesInited = false;\n" "if (!sPrefCachesInited) {\n" " sPrefCachesInited = true;\n"), post="\n}") else: prefCache = None getParentProto = ("JSObject* parentProto = %s;\n" + "if (!parentProto) {\n" + " return NULL;\n" + "}\n") % getParentProto needInterfaceObjectClass = (needInterfaceObject and self.descriptor.hasInstanceInterface) needConstructor = (needInterfaceObject and not self.descriptor.hasInstanceInterface) if self.descriptor.interface.ctor(): constructHook = CONSTRUCT_HOOK_NAME constructArgs = methodLength(self.descriptor.interface.ctor()) else: constructHook = "ThrowingConstructor" constructArgs = 0 if self.descriptor.concrete: if self.descriptor.proxy: domClass = "&Class" else: domClass = "&Class.mClass" else: domClass = "nullptr" call = """return dom::CreateInterfaceObjects(aCx, aGlobal, aReceiver, parentProto, %s, %s, %s, %d, %s, %%(methods)s, %%(attrs)s, %%(consts)s, %%(staticMethods)s, %s);""" % ( "&PrototypeClass" if needInterfacePrototypeObject else "NULL", "&InterfaceObjectClass" if needInterfaceObjectClass else "NULL", constructHook if needConstructor else "NULL", constructArgs, domClass, '"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "NULL") if self.properties.hasChromeOnly(): if self.descriptor.workers: accessCheck = "mozilla::dom::workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker()" else: accessCheck = "xpc::AccessCheck::isChrome(js::GetObjectCompartment(aGlobal))" chrome = CGIfWrapper(CGGeneric(call % self.properties.variableNames(True)), accessCheck) chrome = CGWrapper(chrome, pre="\n\n") else: chrome = None functionBody = CGList( [CGGeneric(getParentProto), initIds, prefCache, chrome, CGGeneric(call % self.properties.variableNames(False))], "\n\n") return CGIndenter(functionBody).define() class CGGetPerInterfaceObject(CGAbstractMethod): """ A method for getting a per-interface object (a prototype object or interface constructor object). """ def __init__(self, descriptor, name, idPrefix=""): args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aGlobal'), Argument('JSObject*', 'aReceiver')] CGAbstractMethod.__init__(self, descriptor, name, 'JSObject*', args, inline=True) self.id = idPrefix + "id::" + self.descriptor.name def definition_body(self): return """ /* aGlobal and aReceiver are usually the same, but they can be different too. For example a sandbox often has an xray wrapper for a window as the prototype of the sandbox's global. In that case aReceiver is the xray wrapper and aGlobal is the sandbox's global. */ /* Make sure our global is sane. Hopefully we can remove this sometime */ if (!(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL)) { return NULL; } /* Check to see whether the interface objects are already installed */ JSObject** protoOrIfaceArray = GetProtoOrIfaceArray(aGlobal); JSObject* cachedObject = protoOrIfaceArray[%s]; if (!cachedObject) { protoOrIfaceArray[%s] = cachedObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); } /* cachedObject might _still_ be null, but that's OK */ return cachedObject;""" % (self.id, self.id) class CGGetProtoObjectMethod(CGGetPerInterfaceObject): """ A method for getting the interface prototype object. """ def __init__(self, descriptor): CGGetPerInterfaceObject.__init__(self, descriptor, "GetProtoObject", "prototypes::") def definition_body(self): return """ /* Get the interface prototype object for this class. This will create the object as needed. */""" + CGGetPerInterfaceObject.definition_body(self) class CGGetConstructorObjectMethod(CGGetPerInterfaceObject): """ A method for getting the interface constructor object. """ def __init__(self, descriptor): CGGetPerInterfaceObject.__init__(self, descriptor, "GetConstructorObject", "constructors::") def definition_body(self): return """ /* Get the interface object for this class. This will create the object as needed. */""" + CGGetPerInterfaceObject.definition_body(self) def CheckPref(descriptor, globalName, varName, retval, wrapperCache = None): """ Check whether bindings should be enabled for this descriptor. If not, set varName to false and return retval. """ if not descriptor.prefable: return "" if wrapperCache: wrapperCache = " %s->ClearIsDOMBinding();\n" % (wrapperCache) else: wrapperCache = "" failureCode = (" %s = false;\n" + " return %s;") % (varName, retval) return """ { XPCWrappedNativeScope* scope = XPCWrappedNativeScope::FindInJSObjectScope(aCx, %s); if (!scope) { %s } if (!scope->ExperimentalBindingsEnabled()) { %s%s } } """ % (globalName, failureCode, wrapperCache, failureCode) class CGDefineDOMInterfaceMethod(CGAbstractMethod): """ A method for resolve hooks to try to lazily define the interface object for a given interface. """ def __init__(self, descriptor): args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aReceiver'), Argument('bool*', 'aEnabled')] CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'bool', args) def declare(self): if self.descriptor.workers: return '' return CGAbstractMethod.declare(self) def define(self): if self.descriptor.workers: return '' return CGAbstractMethod.define(self) def definition_body(self): if self.descriptor.interface.hasInterfacePrototypeObject(): # We depend on GetProtoObject defining an interface constructor # object as needed. getter = "GetProtoObject" else: getter = "GetConstructorObject" return (" JSObject* global = JS_GetGlobalForObject(aCx, aReceiver);\n" + CheckPref(self.descriptor, "global", "*aEnabled", "false") + """ *aEnabled = true; return !!%s(aCx, global, aReceiver);""" % (getter)) class CGPrefEnabled(CGAbstractMethod): """ A method for testing whether the preference controlling this interface is enabled. When it's not, the interface should not be visible on the global. """ def __init__(self, descriptor): CGAbstractMethod.__init__(self, descriptor, 'PrefEnabled', 'bool', []) def declare(self): return CGAbstractMethod.declare(self) def define(self): return CGAbstractMethod.define(self) def definition_body(self): return " return %s::PrefEnabled();" % self.descriptor.nativeType class CGIsMethod(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('JSObject*', 'obj')] CGAbstractMethod.__init__(self, descriptor, 'Is', 'bool', args) def definition_body(self): # Non-proxy implementation would check # js::GetObjectJSClass(obj) == &Class.mBase return """ return IsProxy(obj);""" def CreateBindingJSObject(descriptor, parent): if descriptor.proxy: create = """ JSObject *obj = NewProxyObject(aCx, DOMProxyHandler::getInstance(), JS::PrivateValue(aObject), proto, %s); if (!obj) { return NULL; } """ else: create = """ JSObject* obj = JS_NewObject(aCx, &Class.mBase, proto, %s); if (!obj) { return NULL; } js::SetReservedSlot(obj, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL(aObject)); """ return create % parent class CGWrapWithCacheMethod(CGAbstractMethod): def __init__(self, descriptor): assert descriptor.interface.hasInterfacePrototypeObject() args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aScope'), Argument(descriptor.nativeType + '*', 'aObject'), Argument('nsWrapperCache*', 'aCache'), Argument('bool*', 'aTriedToWrap')] CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args) def definition_body(self): if self.descriptor.workers: return """ *aTriedToWrap = true; return aObject->GetJSObject();""" return """ *aTriedToWrap = true; JSObject* parent = WrapNativeParent(aCx, aScope, aObject->GetParentObject()); if (!parent) { return NULL; } JSAutoCompartment ac(aCx, parent); JSObject* global = JS_GetGlobalForObject(aCx, parent); %s JSObject* proto = GetProtoObject(aCx, global, global); if (!proto) { return NULL; } %s NS_ADDREF(aObject); aCache->SetWrapper(obj); return obj;""" % (CheckPref(self.descriptor, "global", "*aTriedToWrap", "NULL", "aCache"), CreateBindingJSObject(self.descriptor, "parent")) class CGWrapMethod(CGAbstractMethod): def __init__(self, descriptor): # XXX can we wrap if we don't have an interface prototype object? assert descriptor.interface.hasInterfacePrototypeObject() args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aScope'), Argument('T*', 'aObject'), Argument('bool*', 'aTriedToWrap')] CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args, inline=True, templateArgs=["class T"]) def definition_body(self): return " return Wrap(aCx, aScope, aObject, aObject, aTriedToWrap);" class CGWrapNonWrapperCacheMethod(CGAbstractMethod): def __init__(self, descriptor): # XXX can we wrap if we don't have an interface prototype object? assert descriptor.interface.hasInterfacePrototypeObject() args = [Argument('JSContext*', 'aCx'), Argument('JSObject*', 'aScope'), Argument(descriptor.nativeType + '*', 'aObject')] CGAbstractMethod.__init__(self, descriptor, 'Wrap', 'JSObject*', args) def definition_body(self): return """ JSObject* global = JS_GetGlobalForObject(aCx, aScope); JSObject* proto = GetProtoObject(aCx, global, global); if (!proto) { return NULL; } %s NS_ADDREF(aObject); return obj;""" % CreateBindingJSObject(self.descriptor, "global") builtinNames = { IDLType.Tags.bool: 'bool', IDLType.Tags.int8: 'int8_t', IDLType.Tags.int16: 'int16_t', IDLType.Tags.int32: 'int32_t', IDLType.Tags.int64: 'int64_t', IDLType.Tags.uint8: 'uint8_t', IDLType.Tags.uint16: 'uint16_t', IDLType.Tags.uint32: 'uint32_t', IDLType.Tags.uint64: 'uint64_t', IDLType.Tags.float: 'float', IDLType.Tags.double: 'double' } numericTags = [ IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16, IDLType.Tags.uint16, IDLType.Tags.int32, IDLType.Tags.uint32, IDLType.Tags.int64, IDLType.Tags.uint64, IDLType.Tags.float, IDLType.Tags.double ] class CastableObjectUnwrapper(): """ A class for unwrapping an object named by the "source" argument based on the passed-in descriptor and storing it in a variable called by the name in the "target" argument. codeOnFailure is the code to run if unwrapping fails. """ def __init__(self, descriptor, source, target, codeOnFailure): assert descriptor.castable self.substitution = { "type" : descriptor.nativeType, "protoID" : "prototypes::id::" + descriptor.name, "source" : source, "target" : target, "codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define() } if descriptor.hasXPConnectImpls: # We don't use xpc_qsUnwrapThis because it will always throw on # unwrap failure, whereas we want to control whether we throw or # not. self.substitution["codeOnFailure"] = CGIndenter(CGGeneric(string.Template( "${type} *objPtr;\n" "xpc_qsSelfRef objRef;\n" "JS::Value val = JS::ObjectValue(*${source});\n" "nsresult rv = xpc_qsUnwrapArg<${type}>(cx, val, &objPtr, &objRef.ptr, &val);\n" "if (NS_FAILED(rv)) {\n" "${codeOnFailure}\n" "}\n" "// We should be castable!\n" "MOZ_ASSERT(!objRef.ptr);\n" "// We should have an object, too!\n" "MOZ_ASSERT(objPtr);\n" "${target} = objPtr;").substitute(self.substitution)), 4).define() def __str__(self): return string.Template( """{ nsresult rv = UnwrapObject<${protoID}, ${type}>(cx, ${source}, ${target}); if (NS_FAILED(rv)) { ${codeOnFailure} } }""").substitute(self.substitution) class FailureFatalCastableObjectUnwrapper(CastableObjectUnwrapper): """ As CastableObjectUnwrapper, but defaulting to throwing if unwrapping fails """ def __init__(self, descriptor, source, target): CastableObjectUnwrapper.__init__(self, descriptor, source, target, "return Throw<%s>(cx, rv);" % toStringBool(not descriptor.workers)) class CallbackObjectUnwrapper: """ A class for unwrapping objects implemented in JS. |source| is the JSObject we want to use in native code. |target| is an nsCOMPtr of the appropriate type in which we store the result. """ def __init__(self, descriptor, source, target, codeOnFailure=None): if codeOnFailure is None: codeOnFailure = ("return Throw<%s>(cx, rv);" % toStringBool(not descriptor.workers)) self.descriptor = descriptor self.substitution = { "nativeType" : descriptor.nativeType, "source" : source, "target" : target, "codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure)).define() } def __str__(self): if self.descriptor.workers: return string.Template( "${target} = ${source};" ).substitute(self.substitution) return string.Template( """nsresult rv; XPCCallContext ccx(JS_CALLER, cx); if (!ccx.IsValid()) { rv = NS_ERROR_XPC_BAD_CONVERT_JS; ${codeOnFailure} } const nsIID& iid = NS_GET_IID(${nativeType}); nsRefPtr<nsXPCWrappedJS> wrappedJS; rv = nsXPCWrappedJS::GetNewOrUsed(ccx, ${source}, iid, NULL, getter_AddRefs(wrappedJS)); if (NS_FAILED(rv) || !wrappedJS) { ${codeOnFailure} } // Use a temp nsCOMPtr for the null-check, because ${target} might be // OwningNonNull, not an nsCOMPtr. nsCOMPtr<${nativeType}> tmp = do_QueryObject(wrappedJS.get()); if (!tmp) { ${codeOnFailure} } ${target} = tmp.forget();""").substitute(self.substitution) def dictionaryHasSequenceMember(dictionary): return (any(typeIsSequenceOrHasSequenceMember(m.type) for m in dictionary.members) or (dictionary.parent and dictionaryHasSequenceMember(dictionary.parent))) def typeIsSequenceOrHasSequenceMember(type): if type.nullable(): type = type.inner if type.isSequence(): return True if type.isArray(): elementType = type.inner return typeIsSequenceOrHasSequenceMember(elementType) if type.isDictionary(): return dictionaryHasSequenceMember(type.inner) if type.isUnion(): return any(typeIsSequenceOrHasSequenceMember(m.type) for m in type.flatMemberTypes) return False def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, isDefinitelyObject=False, isMember=False, isOptional=False, invalidEnumValueFatal=True, defaultValue=None, treatNullAs="Default", treatUndefinedAs="Default", isEnforceRange=False, isClamp=False): """ Get a template for converting a JS value to a native object based on the given type and descriptor. If failureCode is given, then we're actually testing whether we can convert the argument to the desired type. That means that failures to convert due to the JS value being the wrong type of value need to use failureCode instead of throwing exceptions. Failures to convert that are due to JS exceptions (from toString or valueOf methods) or out of memory conditions need to throw exceptions no matter what failureCode is. If isDefinitelyObject is True, that means we know the value isObject() and we have no need to recheck that. if isMember is True, we're being converted from a property of some JS object, not from an actual method argument, so we can't rely on our jsval being rooted or outliving us in any way. Any caller passing true needs to ensure that it is handled correctly in typeIsSequenceOrHasSequenceMember. If isOptional is true, then we are doing conversion of an optional argument with no default value. invalidEnumValueFatal controls whether an invalid enum value conversion attempt will throw (if true) or simply return without doing anything (if false). If defaultValue is not None, it's the IDL default value for this conversion If isEnforceRange is true, we're converting an integer and throwing if the value is out of range. If isClamp is true, we're converting an integer and clamping if the value is out of range. The return value from this function is a tuple consisting of four things: 1) A string representing the conversion code. This will have template substitution performed on it as follows: ${val} replaced by an expression for the JS::Value in question ${valPtr} is a pointer to the JS::Value in question ${holderName} replaced by the holder's name, if any ${declName} replaced by the declaration's name ${haveValue} replaced by an expression that evaluates to a boolean for whether we have a JS::Value. Only used when defaultValue is not None. 2) A CGThing representing the native C++ type we're converting to (declType). This is allowed to be None if the conversion code is supposed to be used as-is. 3) A CGThing representing the type of a "holder" (holderType) which will hold a possible reference to the C++ thing whose type we returned in #1, or None if no such holder is needed. 4) A boolean indicating whether the caller has to do optional-argument handling. This will only be true if isOptional is true and if the returned template expects both declType and holderType to be wrapped in Optional<>, with ${declName} and ${holderName} adjusted to point to the Value() of the Optional, and Construct() calls to be made on the Optional<>s as needed. ${declName} must be in scope before the generated code is entered. If holderType is not None then ${holderName} must be in scope before the generated code is entered. """ # If we have a defaultValue then we're not actually optional for # purposes of what we need to be declared as. assert(defaultValue is None or not isOptional) # Also, we should not have a defaultValue if we know we're an object assert(not isDefinitelyObject or defaultValue is None) # Helper functions for dealing with failures due to the JS value being the # wrong type of value def onFailureNotAnObject(failureCode): return CGWrapper(CGGeneric( failureCode or 'return ThrowErrorMessage(cx, MSG_NOT_OBJECT);'), post="\n") def onFailureBadType(failureCode, typeName): return CGWrapper(CGGeneric( failureCode or 'return ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "%s");' % typeName), post="\n") # A helper function for handling default values. Takes a template # body and the C++ code to set the default value and wraps the # given template body in handling for the default value. def handleDefault(template, setDefault): if defaultValue is None: return template return CGWrapper( CGIndenter(CGGeneric(template)), pre="if (${haveValue}) {\n", post=("\n" "} else {\n" "%s;\n" "}" % CGIndenter(CGGeneric(setDefault)).define())).define() # A helper function for handling null default values. Much like # handleDefault, but checks that the default value, if it exists, is null. def handleDefaultNull(template, codeToSetNull): if (defaultValue is not None and not isinstance(defaultValue, IDLNullValue)): raise TypeError("Can't handle non-null default value here") return handleDefault(template, codeToSetNull) # A helper function for wrapping up the template body for # possibly-nullable objecty stuff def wrapObjectTemplate(templateBody, isDefinitelyObject, type, codeToSetNull, failureCode=None): if not isDefinitelyObject: # Handle the non-object cases by wrapping up the whole # thing in an if cascade. templateBody = ( "if (${val}.isObject()) {\n" + CGIndenter(CGGeneric(templateBody)).define() + "\n") if type.nullable(): templateBody += ( "} else if (${val}.isNullOrUndefined()) {\n" " %s;\n" % codeToSetNull) templateBody += ( "} else {\n" + CGIndenter(onFailureNotAnObject(failureCode)).define() + "}") if type.nullable(): templateBody = handleDefaultNull(templateBody, codeToSetNull) else: assert(defaultValue is None) return templateBody assert not (isEnforceRange and isClamp) # These are mutually exclusive if type.isArray(): raise TypeError("Can't handle array arguments yet") if type.isSequence(): assert not isEnforceRange and not isClamp if failureCode is not None: raise TypeError("Can't handle sequences when failureCode is not None") nullable = type.nullable(); # Be very careful not to change "type": we need it later if nullable: elementType = type.inner.inner else: elementType = type.inner # We have to be careful with reallocation behavior for arrays. In # particular, if we have a sequence of elements which are themselves # sequences (so nsAutoTArrays) or have sequences as members, we have a # problem. In that case, resizing the outermost nsAutoTarray to the # right size will memmove its elements, but nsAutoTArrays are not # memmovable and hence will end up with pointers to bogus memory, which # is bad. To deal with this, we disallow sequences, arrays, # dictionaries, and unions which contain sequences as sequence item # types. If WebIDL ever adds another container type, we'd have to # disallow it as well. if typeIsSequenceOrHasSequenceMember(elementType): raise TypeError("Can't handle a sequence containing another " "sequence as an element or member of an element. " "See the big comment explaining why.\n%s" % str(type.location)) (elementTemplate, elementDeclType, elementHolderType, dealWithOptional) = getJSToNativeConversionTemplate( elementType, descriptorProvider, isMember=True) if dealWithOptional: raise TypeError("Shouldn't have optional things in sequences") if elementHolderType is not None: raise TypeError("Shouldn't need holders for sequences") typeName = CGWrapper(elementDeclType, pre="Sequence< ", post=" >") if nullable: typeName = CGWrapper(typeName, pre="Nullable< ", post=" >") arrayRef = "${declName}.Value()" else: arrayRef = "${declName}" # If we're optional, the const will come from the Optional mutableTypeName = typeName if not isOptional: typeName = CGWrapper(typeName, pre="const ") templateBody = ("""JSObject* seq = &${val}.toObject();\n if (!IsArrayLike(cx, seq)) { return Throw<%s>(cx, NS_ERROR_XPC_BAD_CONVERT_JS); } uint32_t length; // JS_GetArrayLength actually works on all objects if (!JS_GetArrayLength(cx, seq, &length)) { return false; } Sequence< %s > &arr = const_cast< Sequence< %s >& >(%s); if (!arr.SetCapacity(length)) { return Throw<%s>(cx, NS_ERROR_OUT_OF_MEMORY); } for (uint32_t i = 0; i < length; ++i) { jsval temp; if (!JS_GetElement(cx, seq, i, &temp)) { return false; } """ % (toStringBool(descriptorProvider.workers), elementDeclType.define(), elementDeclType.define(), arrayRef, toStringBool(descriptorProvider.workers))) templateBody += CGIndenter(CGGeneric( string.Template(elementTemplate).substitute( { "val" : "temp", "valPtr": "&temp", "declName" : "(*arr.AppendElement())" } ))).define() templateBody += "\n}" templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject, type, "const_cast< %s & >(${declName}).SetNull()" % mutableTypeName.define()) return (templateBody, typeName, None, isOptional) if type.isUnion(): if isMember: raise TypeError("Can't handle unions as members, we have a " "holderType") nullable = type.nullable(); if nullable: type = type.inner assert(defaultValue is None or (isinstance(defaultValue, IDLNullValue) and nullable)) unionArgumentObj = "${holderName}" if isOptional or nullable: unionArgumentObj += ".ref()" memberTypes = type.flatMemberTypes names = [] interfaceMemberTypes = filter(lambda t: t.isNonCallbackInterface(), memberTypes) if len(interfaceMemberTypes) > 0: interfaceObject = [] for memberType in interfaceMemberTypes: if type.isGeckoInterface(): name = memberType.inner.identifier.name else: name = memberType.name interfaceObject.append(CGGeneric("(failed = !%s.TrySetTo%s(cx, ${val}, ${valPtr}, tryNext)) || !tryNext" % (unionArgumentObj, name))) names.append(name) interfaceObject = CGWrapper(CGList(interfaceObject, " ||\n"), pre="done = ", post=";\n", reindent=True) else: interfaceObject = None arrayObjectMemberTypes = filter(lambda t: t.isArray() or t.isSequence(), memberTypes) if len(arrayObjectMemberTypes) > 0: assert len(arrayObjectMemberTypes) == 1 memberType = arrayObjectMemberTypes[0] name = memberType.name arrayObject = CGGeneric("done = (failed = !%s.TrySetTo%s(cx, ${val}, ${valPtr}, tryNext)) || !tryNext;" % (unionArgumentObj, name)) # XXX Now we're supposed to check for an array or a platform object # that supports indexed properties... skip that last for now. It's a # bit of a pain. arrayObject = CGWrapper(CGIndenter(arrayObject), pre="if (IsArrayLike(cx, &argObj)) {\n", post="}") names.append(name) else: arrayObject = None dateObjectMemberTypes = filter(lambda t: t.isDate(), memberTypes) if len(dateObjectMemberTypes) > 0: assert len(dateObjectMemberTypes) == 1 memberType = dateObjectMemberTypes[0] name = memberType.name dateObject = CGGeneric("%s.SetTo%s(cx, ${val}, ${valPtr});\n" "done = true;" % (unionArgumentObj, name)) dateObject = CGWrapper(CGIndenter(dateObject), pre="if (JS_ObjectIsDate(cx, &argObj)) {\n", post="\n}") names.append(name) else: dateObject = None callbackMemberTypes = filter(lambda t: t.isCallback() or t.isCallbackInterface(), memberTypes) if len(callbackMemberTypes) > 0: assert len(callbackMemberTypes) == 1 memberType = callbackMemberTypes[0] name = memberType.name callbackObject = CGGeneric("done = (failed = !%s.TrySetTo%s(cx, ${val}, ${valPtr}, tryNext)) || !tryNext;" % (unionArgumentObj, name)) names.append(name) else: callbackObject = None dictionaryMemberTypes = filter(lambda t: t.isDictionary(), memberTypes) if len(dictionaryMemberTypes) > 0: raise TypeError("No support for unwrapping dictionaries as member " "of a union") else: dictionaryObject = None if callbackObject or dictionaryObject: nonPlatformObject = CGList([callbackObject, dictionaryObject], "\n") nonPlatformObject = CGWrapper(CGIndenter(nonPlatformObject), pre="if (!IsPlatformObject(cx, &argObj)) {\n", post="\n}") else: nonPlatformObject = None objectMemberTypes = filter(lambda t: t.isObject(), memberTypes) if len(objectMemberTypes) > 0: object = CGGeneric("%s.SetToObject(&argObj);\n" "done = true;" % unionArgumentObj) else: object = None hasObjectTypes = interfaceObject or arrayObject or dateObject or nonPlatformObject or object if hasObjectTypes: # If we try more specific object types first then we need to check # whether that succeeded before converting to object. if object and (interfaceObject or arrayObject or dateObject or nonPlatformObject): object = CGWrapper(CGIndenter(object), pre="if (!done) {\n", post=("\n}")) if arrayObject or dateObject or nonPlatformObject: # An object can be both an array object and not a platform # object, but we shouldn't have both in the union's members # because they are not distinguishable. assert not (arrayObject and nonPlatformObject) templateBody = CGList([arrayObject, dateObject, nonPlatformObject], " else ") else: templateBody = None if interfaceObject: if templateBody: templateBody = CGList([templateBody, object], "\n") templateBody = CGWrapper(CGIndenter(templateBody), pre="if (!done) {\n", post=("\n}")) templateBody = CGList([interfaceObject, templateBody], "\n") else: templateBody = CGList([templateBody, object], "\n") if any([arrayObject, dateObject, nonPlatformObject, object]): templateBody.prepend(CGGeneric("JSObject& argObj = ${val}.toObject();")) templateBody = CGWrapper(CGIndenter(templateBody), pre="if (${val}.isObject()) {\n", post="\n}") else: templateBody = CGGeneric() otherMemberTypes = filter(lambda t: t.isString() or t.isEnum(), memberTypes) otherMemberTypes.extend(t for t in memberTypes if t.isPrimitive()) if len(otherMemberTypes) > 0: assert len(otherMemberTypes) == 1 memberType = otherMemberTypes[0] if memberType.isEnum(): name = memberType.inner.identifier.name else: name = memberType.name other = CGGeneric("done = (failed = !%s.TrySetTo%s(cx, ${val}, ${valPtr}, tryNext)) || !tryNext;" % (unionArgumentObj, name)) names.append(name) if hasObjectTypes: other = CGWrapper(CGIndenter(other), "{\n", post="\n}") if object: join = " else " else: other = CGWrapper(other, pre="if (!done) ") join = "\n" templateBody = CGList([templateBody, other], join) else: other = None templateBody = CGWrapper(templateBody, pre="bool done = false, failed = false, tryNext;\n") throw = CGGeneric("if (failed) {\n" " return false;\n" "}\n" "if (!done) {\n" " return ThrowErrorMessage(cx, MSG_NOT_IN_UNION, \"%s\");\n" "}" % ", ".join(names)) templateBody = CGWrapper(CGIndenter(CGList([templateBody, throw], "\n")), pre="{\n", post="\n}") typeName = type.name argumentTypeName = typeName + "Argument" if nullable: typeName = "Nullable<" + typeName + " >" if isOptional: nonConstDecl = "const_cast<Optional<" + typeName + " >& >(${declName})" else: nonConstDecl = "const_cast<" + typeName + "& >(${declName})" typeName = "const " + typeName def handleNull(templateBody, setToNullVar, extraConditionForNull=""): null = CGGeneric("if (%s${val}.isNullOrUndefined()) {\n" " %s.SetNull();\n" "}" % (extraConditionForNull, setToNullVar)) templateBody = CGWrapper(CGIndenter(templateBody), pre="{\n", post="\n}") return CGList([null, templateBody], " else ") if type.hasNullableType: templateBody = handleNull(templateBody, unionArgumentObj) declType = CGGeneric(typeName) holderType = CGGeneric(argumentTypeName) if isOptional: mutableDecl = nonConstDecl + ".Value()" declType = CGWrapper(declType, pre="const Optional<", post=" >") holderType = CGWrapper(holderType, pre="Maybe<", post=" >") constructDecl = CGGeneric(nonConstDecl + ".Construct();") if nullable: constructHolder = CGGeneric("${holderName}.construct(%s.SetValue());" % mutableDecl) else: constructHolder = CGGeneric("${holderName}.construct(${declName}.Value());") else: mutableDecl = nonConstDecl constructDecl = None if nullable: holderType = CGWrapper(holderType, pre="Maybe<", post=" >") constructHolder = CGGeneric("${holderName}.construct(%s.SetValue());" % mutableDecl) else: constructHolder = CGWrapper(holderType, post=" ${holderName}(${declName});") holderType = None templateBody = CGList([constructHolder, templateBody], "\n") if nullable: if defaultValue: assert(isinstance(defaultValue, IDLNullValue)) valueMissing = "!(${haveValue}) || " else: valueMissing = "" templateBody = handleNull(templateBody, mutableDecl, extraConditionForNull=valueMissing) templateBody = CGList([constructDecl, templateBody], "\n") return templateBody.define(), declType, holderType, False if type.isGeckoInterface(): assert not isEnforceRange and not isClamp descriptor = descriptorProvider.getDescriptor( type.unroll().inner.identifier.name) # This is an interface that we implement as a concrete class # or an XPCOM interface. # Allow null pointers for nullable types and old-binding classes argIsPointer = type.nullable() or type.unroll().inner.isExternal() # Sequences and non-worker callbacks have to hold a strong ref to the # thing being passed down. forceOwningType = (descriptor.interface.isCallback() and not descriptor.workers) or isMember typeName = descriptor.nativeType typePtr = typeName + "*" # Compute a few things: # - declType is the type we want to return as the first element of our # tuple. # - holderType is the type we want to return as the third element # of our tuple. # Set up some sensible defaults for these things insofar as we can. holderType = None if argIsPointer: if forceOwningType: declType = "nsRefPtr<" + typeName + ">" else: declType = typePtr else: if forceOwningType: declType = "OwningNonNull<" + typeName + ">" else: declType = "NonNull<" + typeName + ">" templateBody = "" if descriptor.castable: if descriptor.prefable: raise TypeError("We don't support prefable castable object " "arguments (like %s), because we don't know " "how to handle them being preffed off" % descriptor.interface.identifier.name) if descriptor.interface.isConsequential(): raise TypeError("Consequential interface %s being used as an " "argument but flagged as castable" % descriptor.interface.identifier.name) if failureCode is not None: templateBody += str(CastableObjectUnwrapper( descriptor, "&${val}.toObject()", "${declName}", failureCode)) else: templateBody += str(FailureFatalCastableObjectUnwrapper( descriptor, "&${val}.toObject()", "${declName}")) elif descriptor.interface.isCallback(): templateBody += str(CallbackObjectUnwrapper( descriptor, "&${val}.toObject()", "${declName}", codeOnFailure=failureCode)) elif descriptor.workers: templateBody += "${declName} = &${val}.toObject();" else: # Either external, or new-binding non-castable. We always have a # holder for these, because we don't actually know whether we have # to addref when unwrapping or not. So we just pass an # getter_AddRefs(nsRefPtr) to XPConnect and if we'll need a release # it'll put a non-null pointer in there. if forceOwningType: # Don't return a holderType in this case; our declName # will just own stuff. templateBody += "nsRefPtr<" + typeName + "> ${holderName};\n" else: holderType = "nsRefPtr<" + typeName + ">" templateBody += ( "jsval tmpVal = ${val};\n" + typePtr + " tmp;\n" "if (NS_FAILED(xpc_qsUnwrapArg<" + typeName + ">(cx, ${val}, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName})), &tmpVal))) {\n") templateBody += CGIndenter(onFailureBadType(failureCode, descriptor.interface.identifier.name)).define() templateBody += ("}\n" "MOZ_ASSERT(tmp);\n") if not isDefinitelyObject: # Our tmpVal will go out of scope, so we can't rely on it # for rooting templateBody += ( "if (tmpVal != ${val} && !${holderName}) {\n" " // We have to have a strong ref, because we got this off\n" " // some random object that might get GCed\n" " ${holderName} = tmp;\n" "}\n") # And store our tmp, before it goes out of scope. templateBody += "${declName} = tmp;" templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject, type, "${declName} = NULL", failureCode) declType = CGGeneric(declType) if holderType is not None: holderType = CGGeneric(holderType) return (templateBody, declType, holderType, isOptional) if type.isSpiderMonkeyInterface(): assert not isEnforceRange and not isClamp if isMember: raise TypeError("Can't handle member arraybuffers or " "arraybuffer views because making sure all the " "objects are properly rooted is hard") name = type.name # By default, we use a Maybe<> to hold our typed array. And in the optional # non-nullable case we want to pass Optional<TypedArray> to consumers, not # Optional<NonNull<TypedArray> >, so jump though some hoops to do that. holderType = "Maybe<%s>" % name constructLoc = "${holderName}" constructMethod = "construct" constructInternal = "ref" if type.nullable(): if isOptional: declType = "const Optional<" + name + "*>" else: declType = name + "*" else: if isOptional: declType = "const Optional<" + name + ">" # We don't need a holder in this case holderType = None constructLoc = "(const_cast<Optional<" + name + ">& >(${declName}))" constructMethod = "Construct" constructInternal = "Value" else: declType = "NonNull<" + name + ">" template = ( "%s.%s(cx, &${val}.toObject());\n" "if (!%s.%s().inited()) {\n" "%s" # No newline here because onFailureBadType() handles that "}\n" % (constructLoc, constructMethod, constructLoc, constructInternal, CGIndenter(onFailureBadType(failureCode, type.name)).define())) nullableTarget = "" if type.nullable(): if isOptional: mutableDecl = "(const_cast<Optional<" + name + "*>& >(${declName}))" template += "%s.Construct();\n" % mutableDecl nullableTarget = "%s.Value()" % mutableDecl else: nullableTarget = "${declName}" template += "%s = ${holderName}.addr();" % nullableTarget elif not isOptional: template += "${declName} = ${holderName}.addr();" template = wrapObjectTemplate(template, isDefinitelyObject, type, "%s = NULL" % nullableTarget, failureCode) if holderType is not None: holderType = CGGeneric(holderType) # We handle all the optional stuff ourselves; no need for caller to do it. return (template, CGGeneric(declType), holderType, False) if type.isString(): assert not isEnforceRange and not isClamp treatAs = { "Default": "eStringify", "EmptyString": "eEmpty", "Null": "eNull" } if type.nullable(): # For nullable strings null becomes a null string. treatNullAs = "Null" # For nullable strings undefined becomes a null string unless # specified otherwise. if treatUndefinedAs == "Default": treatUndefinedAs = "Null" nullBehavior = treatAs[treatNullAs] if treatUndefinedAs == "Missing": raise TypeError("We don't support [TreatUndefinedAs=Missing]") undefinedBehavior = treatAs[treatUndefinedAs] def getConversionCode(varName): conversionCode = ( "if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, %s)) {\n" " return false;\n" "}" % (nullBehavior, undefinedBehavior, varName)) if defaultValue is None: return conversionCode if isinstance(defaultValue, IDLNullValue): assert(type.nullable()) return handleDefault(conversionCode, "%s.SetNull()" % varName) return handleDefault( conversionCode, ("static const PRUnichar data[] = { %s };\n" "%s.SetData(data, ArrayLength(data) - 1)" % (", ".join(["'" + char + "'" for char in defaultValue.value] + ["0"]), varName))) if isMember: # We have to make a copy, because our jsval may well not # live as long as our string needs to. declType = CGGeneric("nsString") return ( "{\n" " FakeDependentString str;\n" "%s\n" " ${declName} = str;\n" "}\n" % CGIndenter(CGGeneric(getConversionCode("str"))).define(), declType, None, isOptional) if isOptional: declType = "Optional<nsAString>" else: declType = "NonNull<nsAString>" return ( "%s\n" "const_cast<%s&>(${declName}) = &${holderName};" % (getConversionCode("${holderName}"), declType), CGGeneric("const " + declType), CGGeneric("FakeDependentString"), # No need to deal with Optional here; we have handled it already False) if type.isEnum(): assert not isEnforceRange and not isClamp if type.nullable(): raise TypeError("We don't support nullable enumerated arguments " "yet") enum = type.inner.identifier.name if invalidEnumValueFatal: handleInvalidEnumValueCode = " MOZ_ASSERT(index >= 0);\n" else: handleInvalidEnumValueCode = ( " if (index < 0) {\n" " return true;\n" " }\n") template = ( "{\n" " bool ok;\n" " int index = FindEnumStringIndex<%(invalidEnumValueFatal)s>(cx, ${val}, %(values)s, \"%(enumtype)s\", &ok);\n" " if (!ok) {\n" " return false;\n" " }\n" "%(handleInvalidEnumValueCode)s" " ${declName} = static_cast<%(enumtype)s>(index);\n" "}" % { "enumtype" : enum, "values" : enum + "Values::strings", "invalidEnumValueFatal" : toStringBool(invalidEnumValueFatal), "handleInvalidEnumValueCode" : handleInvalidEnumValueCode }) if defaultValue is not None: assert(defaultValue.type.tag() == IDLType.Tags.domstring) template = handleDefault(template, ("${declName} = %sValues::%s" % (enum, getEnumValueName(defaultValue.value)))) return (template, CGGeneric(enum), None, isOptional) if type.isCallback(): assert not isEnforceRange and not isClamp if isMember: raise TypeError("Can't handle member callbacks; need to sort out " "rooting issues") # XXXbz we're going to assume that callback types are always # nullable and always have [TreatNonCallableAsNull] for now. haveCallable = "${val}.isObject() && JS_ObjectIsCallable(cx, &${val}.toObject())" if defaultValue is not None: assert(isinstance(defaultValue, IDLNullValue)) haveCallable = "${haveValue} && " + haveCallable return ( "if (%s) {\n" " ${declName} = &${val}.toObject();\n" "} else {\n" " ${declName} = NULL;\n" "}" % haveCallable, CGGeneric("JSObject*"), None, isOptional) if type.isAny(): assert not isEnforceRange and not isClamp if isMember: raise TypeError("Can't handle member 'any'; need to sort out " "rooting issues") templateBody = "${declName} = ${val};" templateBody = handleDefaultNull(templateBody, "${declName} = JS::NullValue()") return (templateBody, CGGeneric("JS::Value"), None, isOptional) if type.isObject(): assert not isEnforceRange and not isClamp if isMember: raise TypeError("Can't handle member 'object'; need to sort out " "rooting issues") template = wrapObjectTemplate("${declName} = &${val}.toObject();", isDefinitelyObject, type, "${declName} = NULL", failureCode) if type.nullable(): declType = CGGeneric("JSObject*") else: declType = CGGeneric("NonNull<JSObject>") return (template, declType, None, isOptional) if type.isDictionary(): if failureCode is not None: raise TypeError("Can't handle dictionaries when failureCode is not None") # There are no nullable dictionaries assert not type.nullable() # All optional dictionaries always have default values, so we # should be able to assume not isOptional here. assert not isOptional typeName = CGDictionary.makeDictionaryName(type.inner, descriptorProvider.workers) actualTypeName = typeName selfRef = "${declName}" declType = CGGeneric(actualTypeName) # If we're a member of something else, the const # will come from the Optional or our container. if not isMember: declType = CGWrapper(declType, pre="const ") selfRef = "const_cast<%s&>(%s)" % (typeName, selfRef) # We do manual default value handling here, because we # actually do want a jsval, and we only handle null anyway if defaultValue is not None: assert(isinstance(defaultValue, IDLNullValue)) val = "(${haveValue}) ? ${val} : JSVAL_NULL" else: val = "${val}" template = ("if (!%s.Init(cx, %s)) {\n" " return false;\n" "}" % (selfRef, val)) return (template, declType, None, False) if not type.isPrimitive(): raise TypeError("Need conversion for argument type '%s'" % str(type)) typeName = builtinNames[type.tag()] conversionBehavior = "eDefault" if isEnforceRange: conversionBehavior = "eEnforceRange" elif isClamp: conversionBehavior = "eClamp" if type.nullable(): dataLoc = "${declName}.SetValue()" nullCondition = "${val}.isNullOrUndefined()" if defaultValue is not None and isinstance(defaultValue, IDLNullValue): nullCondition = "!(${haveValue}) || " + nullCondition template = ( "if (%s) {\n" " ${declName}.SetNull();\n" "} else if (!ValueToPrimitive<%s, %s>(cx, ${val}, &%s)) {\n" " return false;\n" "}" % (nullCondition, typeName, conversionBehavior, dataLoc)) declType = CGGeneric("Nullable<" + typeName + ">") else: assert(defaultValue is None or not isinstance(defaultValue, IDLNullValue)) dataLoc = "${declName}" template = ( "if (!ValueToPrimitive<%s, %s>(cx, ${val}, &%s)) {\n" " return false;\n" "}" % (typeName, conversionBehavior, dataLoc)) declType = CGGeneric(typeName) if (defaultValue is not None and # We already handled IDLNullValue, so just deal with the other ones not isinstance(defaultValue, IDLNullValue)): tag = defaultValue.type.tag() if tag in numericTags: defaultStr = defaultValue.value else: assert(tag == IDLType.Tags.bool) defaultStr = toStringBool(defaultValue.value) template = CGWrapper(CGIndenter(CGGeneric(template)), pre="if (${haveValue}) {\n", post=("\n" "} else {\n" " %s = %s;\n" "}" % (dataLoc, defaultStr))).define() return (template, declType, None, isOptional) def instantiateJSToNativeConversionTemplate(templateTuple, replacements, argcAndIndex=None): """ Take a tuple as returned by getJSToNativeConversionTemplate and a set of replacements as required by the strings in such a tuple, and generate code to convert into stack C++ types. If argcAndIndex is not None it must be a dict that can be used to replace ${argc} and ${index}, where ${index} is the index of this argument (0-based) and ${argc} is the total number of arguments. """ (templateBody, declType, holderType, dealWithOptional) = templateTuple if dealWithOptional and argcAndIndex is None: raise TypeError("Have to deal with optional things, but don't know how") if argcAndIndex is not None and declType is None: raise TypeError("Need to predeclare optional things, so they will be " "outside the check for big enough arg count!"); result = CGList([], "\n") # Make a copy of "replacements" since we may be about to start modifying it replacements = dict(replacements) originalHolderName = replacements["holderName"] if holderType is not None: if dealWithOptional: replacements["holderName"] = ( "const_cast< %s & >(%s.Value())" % (holderType.define(), originalHolderName)) mutableHolderType = CGWrapper(holderType, pre="Optional< ", post=" >") holderType = CGWrapper(mutableHolderType, pre="const ") result.append( CGList([holderType, CGGeneric(" "), CGGeneric(originalHolderName), CGGeneric(";")])) originalDeclName = replacements["declName"] if declType is not None: if dealWithOptional: replacements["declName"] = ( "const_cast< %s & >(%s.Value())" % (declType.define(), originalDeclName)) mutableDeclType = CGWrapper(declType, pre="Optional< ", post=" >") declType = CGWrapper(mutableDeclType, pre="const ") result.append( CGList([declType, CGGeneric(" "), CGGeneric(originalDeclName), CGGeneric(";")])) conversion = CGGeneric( string.Template(templateBody).substitute(replacements) ) if argcAndIndex is not None: if dealWithOptional: declConstruct = CGIndenter( CGGeneric("const_cast< %s &>(%s).Construct();" % (mutableDeclType.define(), originalDeclName))) if holderType is not None: holderConstruct = CGIndenter( CGGeneric("const_cast< %s &>(%s).Construct();" % (mutableHolderType.define(), originalHolderName))) else: holderConstruct = None else: declConstruct = None holderConstruct = None conversion = CGList( [CGGeneric( string.Template("if (${index} < ${argc}) {").substitute( argcAndIndex )), declConstruct, holderConstruct, CGIndenter(conversion), CGGeneric("}")], "\n") result.append(conversion) # Add an empty CGGeneric to get an extra newline after the argument # conversion. result.append(CGGeneric("")) return result; def convertConstIDLValueToJSVal(value): if isinstance(value, IDLNullValue): return "JSVAL_NULL" tag = value.type.tag() if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16, IDLType.Tags.uint16, IDLType.Tags.int32]: return "INT_TO_JSVAL(%s)" % (value.value) if tag == IDLType.Tags.uint32: return "UINT_TO_JSVAL(%s)" % (value.value) if tag in [IDLType.Tags.int64, IDLType.Tags.uint64]: return "DOUBLE_TO_JSVAL(%s)" % (value.value) if tag == IDLType.Tags.bool: return "JSVAL_TRUE" if value.value else "JSVAL_FALSE" if tag in [IDLType.Tags.float, IDLType.Tags.double]: return "DOUBLE_TO_JSVAL(%s)" % (value.value) raise TypeError("Const value of unhandled type: " + value.type) class CGArgumentConverter(CGThing): """ A class that takes an IDL argument object, its index in the argument list, and the argv and argc strings and generates code to unwrap the argument to the right native type. """ def __init__(self, argument, index, argv, argc, descriptorProvider, invalidEnumValueFatal=True): CGThing.__init__(self) self.argument = argument if argument.variadic: raise TypeError("We don't support variadic arguments yet " + str(argument.location)) assert(not argument.defaultValue or argument.optional) replacer = { "index" : index, "argc" : argc, "argv" : argv } self.replacementVariables = { "declName" : "arg%d" % index, "holderName" : ("arg%d" % index) + "_holder" } self.replacementVariables["val"] = string.Template( "${argv}[${index}]" ).substitute(replacer) self.replacementVariables["valPtr"] = ( "&" + self.replacementVariables["val"]) if argument.defaultValue: self.replacementVariables["haveValue"] = string.Template( "${index} < ${argc}").substitute(replacer) self.descriptorProvider = descriptorProvider if self.argument.optional and not self.argument.defaultValue: self.argcAndIndex = replacer else: self.argcAndIndex = None self.invalidEnumValueFatal = invalidEnumValueFatal def define(self): return instantiateJSToNativeConversionTemplate( getJSToNativeConversionTemplate(self.argument.type, self.descriptorProvider, isOptional=(self.argcAndIndex is not None), invalidEnumValueFatal=self.invalidEnumValueFatal, defaultValue=self.argument.defaultValue, treatNullAs=self.argument.treatNullAs, treatUndefinedAs=self.argument.treatUndefinedAs, isEnforceRange=self.argument.enforceRange, isClamp=self.argument.clamp), self.replacementVariables, self.argcAndIndex).define() def getWrapTemplateForType(type, descriptorProvider, result, successCode, isCreator): """ Reflect a C++ value stored in "result", of IDL type "type" into JS. The "successCode" is the code to run once we have successfully done the conversion. The resulting string should be used with string.Template, it needs the following keys when substituting: jsvalPtr/jsvalRef/obj. Returns (templateString, infallibility of conversion template) """ haveSuccessCode = successCode is not None if not haveSuccessCode: successCode = "return true;" def setValue(value, callWrapValue=False): """ Returns the code to set the jsval to value. If "callWrapValue" is true JS_WrapValue will be called on the jsval. """ if not callWrapValue: tail = successCode elif haveSuccessCode: tail = ("if (!JS_WrapValue(cx, ${jsvalPtr})) {\n" + " return false;\n" + "}\n" + successCode) else: tail = "return JS_WrapValue(cx, ${jsvalPtr});" return ("${jsvalRef} = %s;\n" + tail) % (value) def wrapAndSetPtr(wrapCall, failureCode=None): """ Returns the code to set the jsval by calling "wrapCall". "failureCode" is the code to run if calling "wrapCall" fails """ if failureCode is None: if not haveSuccessCode: return "return " + wrapCall + ";" failureCode = "return false;" str = ("if (!%s) {\n" + CGIndenter(CGGeneric(failureCode)).define() + "\n" + "}\n" + successCode) % (wrapCall) return str if type is None or type.isVoid(): return (setValue("JSVAL_VOID"), True) if type.isArray(): raise TypeError("Can't handle array return values yet") if type.isSequence(): if type.nullable(): # Nullable sequences are Nullable< nsTArray<T> > (recTemplate, recInfall) = getWrapTemplateForType(type.inner, descriptorProvider, "%s.Value()" % result, successCode, isCreator) return (""" if (%s.IsNull()) { %s } %s""" % (result, CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define(), recTemplate), recInfall) # Now do non-nullable sequences. We use setting the element # in the array as our succcess code because when we succeed in # wrapping that's what we should do. innerTemplate = wrapForType( type.inner, descriptorProvider, { 'result' : "%s[i]" % result, 'successCode': ("if (!JS_DefineElement(cx, returnArray, i, tmp,\n" " NULL, NULL, JSPROP_ENUMERATE)) {\n" " return false;\n" "}"), 'jsvalRef': "tmp", 'jsvalPtr': "&tmp", 'isCreator': isCreator } ) innerTemplate = CGIndenter(CGGeneric(innerTemplate)).define() return ((""" uint32_t length = %s.Length(); JSObject *returnArray = JS_NewArrayObject(cx, length, NULL); if (!returnArray) { return false; } jsval tmp; for (uint32_t i = 0; i < length; ++i) { %s }\n""" % (result, innerTemplate)) + setValue("JS::ObjectValue(*returnArray)"), False) if type.isGeckoInterface(): descriptor = descriptorProvider.getDescriptor(type.unroll().inner.identifier.name) if type.nullable(): wrappingCode = ("if (!%s) {\n" % (result) + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + "}\n") else: wrappingCode = "" if (not descriptor.interface.isExternal() and not descriptor.interface.isCallback()): if descriptor.wrapperCache: wrapMethod = "WrapNewBindingObject" else: if not isCreator: raise MethodNotCreatorError(descriptor.interface.identifier.name) wrapMethod = "WrapNewBindingNonWrapperCachedObject" wrap = "%s(cx, ${obj}, %s, ${jsvalPtr})" % (wrapMethod, result) # We don't support prefable stuff in workers. assert(not descriptor.prefable or not descriptor.workers) if not descriptor.prefable: # Non-prefable bindings can only fail to wrap as a new-binding object # if they already threw an exception. Same thing for # non-prefable bindings. failed = ("MOZ_ASSERT(JS_IsExceptionPending(cx));\n" + "return false;") else: if descriptor.notflattened: raise TypeError("%s is prefable but not flattened; " "fallback won't work correctly" % descriptor.interface.identifier.name) # Try old-style wrapping for bindings which might be preffed off. failed = wrapAndSetPtr("HandleNewBindingWrappingFailure(cx, ${obj}, %s, ${jsvalPtr})" % result) wrappingCode += wrapAndSetPtr(wrap, failed) else: if descriptor.notflattened: getIID = "&NS_GET_IID(%s), " % descriptor.nativeType else: getIID = "" wrap = "WrapObject(cx, ${obj}, %s, %s${jsvalPtr})" % (result, getIID) wrappingCode += wrapAndSetPtr(wrap) return (wrappingCode, False) if type.isString(): if type.nullable(): return (wrapAndSetPtr("xpc::StringToJsval(cx, %s, ${jsvalPtr})" % result), False) else: return (wrapAndSetPtr("xpc::NonVoidStringToJsval(cx, %s, ${jsvalPtr})" % result), False) if type.isEnum(): if type.nullable(): raise TypeError("We don't support nullable enumerated return types " "yet") return ("""MOZ_ASSERT(uint32_t(%(result)s) < ArrayLength(%(strings)s)); JSString* %(resultStr)s = JS_NewStringCopyN(cx, %(strings)s[uint32_t(%(result)s)].value, %(strings)s[uint32_t(%(result)s)].length); if (!%(resultStr)s) { return false; } """ % { "result" : result, "resultStr" : result + "_str", "strings" : type.inner.identifier.name + "Values::strings" } + setValue("JS::StringValue(%s_str)" % result), False) if type.isCallback(): assert not type.isInterface() # XXXbz we're going to assume that callback types are always # nullable and always have [TreatNonCallableAsNull] for now. # See comments in WrapNewBindingObject explaining why we need # to wrap here. # NB: setValue(..., True) calls JS_WrapValue(), so is fallible return (setValue("JS::ObjectOrNullValue(%s)" % result, True), False) if type.tag() == IDLType.Tags.any: # See comments in WrapNewBindingObject explaining why we need # to wrap here. # NB: setValue(..., True) calls JS_WrapValue(), so is fallible return (setValue(result, True), False) if type.isObject() or type.isSpiderMonkeyInterface(): # See comments in WrapNewBindingObject explaining why we need # to wrap here. if type.nullable(): toValue = "JS::ObjectOrNullValue(%s)" else: toValue = "JS::ObjectValue(*%s)" # NB: setValue(..., True) calls JS_WrapValue(), so is fallible return (setValue(toValue % result, True), False) if not type.isPrimitive(): raise TypeError("Need to learn to wrap %s" % type) if type.nullable(): (recTemplate, recInfal) = getWrapTemplateForType(type.inner, descriptorProvider, "%s.Value()" % result, successCode, isCreator) return ("if (%s.IsNull()) {\n" % result + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + "}\n" + recTemplate, recInfal) tag = type.tag() if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16, IDLType.Tags.uint16, IDLType.Tags.int32]: return (setValue("INT_TO_JSVAL(int32_t(%s))" % result), True) elif tag in [IDLType.Tags.int64, IDLType.Tags.uint64, IDLType.Tags.float, IDLType.Tags.double]: # XXXbz will cast to double do the "even significand" thing that webidl # calls for for 64-bit ints? Do we care? return (setValue("JS_NumberValue(double(%s))" % result), True) elif tag == IDLType.Tags.uint32: return (setValue("UINT_TO_JSVAL(%s)" % result), True) elif tag == IDLType.Tags.bool: return (setValue("BOOLEAN_TO_JSVAL(%s)" % result), True) else: raise TypeError("Need to learn to wrap primitive: %s" % type) def wrapForType(type, descriptorProvider, templateValues): """ Reflect a C++ value of IDL type "type" into JS. TemplateValues is a dict that should contain: * 'jsvalRef': a C++ reference to the jsval in which to store the result of the conversion * 'jsvalPtr': a C++ pointer to the jsval in which to store the result of the conversion * 'obj' (optional): the name of the variable that contains the JSObject to use as a scope when wrapping, if not supplied 'obj' will be used as the name * 'result' (optional): the name of the variable in which the C++ value is stored, if not supplied 'result' will be used as the name * 'successCode' (optional): the code to run once we have successfully done the conversion, if not supplied 'return true;' will be used as the code * 'isCreator' (optional): If true, we're wrapping for the return value of a [Creator] method. Assumed false if not set. """ wrap = getWrapTemplateForType(type, descriptorProvider, templateValues.get('result', 'result'), templateValues.get('successCode', None), templateValues.get('isCreator', False))[0] defaultValues = {'obj': 'obj'} return string.Template(wrap).substitute(defaultValues, **templateValues) def infallibleForMember(member, type, descriptorProvider): """ Determine the fallibility of changing a C++ value of IDL type "type" into JS for the given attribute. Apart from isCreator, all the defaults are used, since the fallbility does not change based on the boolean values, and the template will be discarded. CURRENT ASSUMPTIONS: We assume that successCode for wrapping up return values cannot contain failure conditions. """ return getWrapTemplateForType(type, descriptorProvider, 'result', None,\ memberIsCreator(member))[1] def typeNeedsCx(type, retVal=False): if type is None: return False if type.nullable(): type = type.inner if type.isSequence() or type.isArray(): type = type.inner if type.isUnion(): return any(typeNeedsCx(t) for t in type.unroll().flatMemberTypes) if retVal and type.isSpiderMonkeyInterface(): return True return type.isCallback() or type.isAny() or type.isObject() # Returns a tuple consisting of a CGThing containing the type of the return # value, or None if there is no need for a return value, and a boolean signaling # whether the return value is passed in an out parameter. def getRetvalDeclarationForType(returnType, descriptorProvider, resultAlreadyAddRefed): if returnType is None or returnType.isVoid(): # Nothing to declare return None, False if returnType.isPrimitive() and returnType.tag() in builtinNames: result = CGGeneric(builtinNames[returnType.tag()]) if returnType.nullable(): result = CGWrapper(result, pre="Nullable<", post=">") return result, False if returnType.isString(): return CGGeneric("nsString"), True if returnType.isEnum(): if returnType.nullable(): raise TypeError("We don't support nullable enum return values") return CGGeneric(returnType.inner.identifier.name), False if returnType.isGeckoInterface(): result = CGGeneric(descriptorProvider.getDescriptor( returnType.unroll().inner.identifier.name).nativeType) if resultAlreadyAddRefed: result = CGWrapper(result, pre="nsRefPtr<", post=">") else: result = CGWrapper(result, post="*") return result, False if returnType.isCallback(): # XXXbz we're going to assume that callback types are always # nullable for now. return CGGeneric("JSObject*"), False if returnType.isAny(): return CGGeneric("JS::Value"), False if returnType.isObject() or returnType.isSpiderMonkeyInterface(): return CGGeneric("JSObject*"), False if returnType.isSequence(): nullable = returnType.nullable() if nullable: returnType = returnType.inner # If our result is already addrefed, use the right type in the # sequence argument here. (result, _) = getRetvalDeclarationForType(returnType.inner, descriptorProvider, resultAlreadyAddRefed) result = CGWrapper(result, pre="nsTArray< ", post=" >") if nullable: result = CGWrapper(result, pre="Nullable< ", post=" >") return result, True raise TypeError("Don't know how to declare return value for %s" % returnType) def isResultAlreadyAddRefed(descriptor, extendedAttributes): # Default to already_AddRefed on the main thread, raw pointer in workers return not descriptor.workers and not 'resultNotAddRefed' in extendedAttributes class CGCallGenerator(CGThing): """ A class to generate an actual call to a C++ object. Assumes that the C++ object is stored in a variable whose name is given by the |object| argument. errorReport should be a CGThing for an error report or None if no error reporting is needed. """ def __init__(self, errorReport, arguments, argsPre, returnType, extendedAttributes, descriptorProvider, nativeMethodName, static, object="self", declareResult=True): CGThing.__init__(self) assert errorReport is None or isinstance(errorReport, CGThing) isFallible = errorReport is not None resultAlreadyAddRefed = isResultAlreadyAddRefed(descriptorProvider, extendedAttributes) (result, resultOutParam) = getRetvalDeclarationForType(returnType, descriptorProvider, resultAlreadyAddRefed) args = CGList([CGGeneric(arg) for arg in argsPre], ", ") for (a, name) in arguments: # This is a workaround for a bug in Apple's clang. if a.type.isObject() and not a.type.nullable() and not a.optional: name = "(JSObject&)" + name args.append(CGGeneric(name)) # Return values that go in outparams go here if resultOutParam: args.append(CGGeneric("result")) if isFallible: args.append(CGGeneric("rv")) needsCx = (typeNeedsCx(returnType, True) or any(typeNeedsCx(a.type) for (a, _) in arguments) or 'implicitJSContext' in extendedAttributes) if not "cx" in argsPre and needsCx: args.prepend(CGGeneric("cx")) # Build up our actual call self.cgRoot = CGList([], "\n") call = CGGeneric(nativeMethodName) if static: call = CGWrapper(call, pre="%s::" % descriptorProvider.nativeType) else: call = CGWrapper(call, pre="%s->" % object) call = CGList([call, CGWrapper(args, pre="(", post=");")]) if result is not None: if declareResult: result = CGWrapper(result, post=" result;") self.cgRoot.prepend(result) if not resultOutParam: call = CGWrapper(call, pre="result = ") call = CGWrapper(call) self.cgRoot.append(call) if isFallible: self.cgRoot.prepend(CGGeneric("ErrorResult rv;")) self.cgRoot.append(CGGeneric("if (rv.Failed()) {")) self.cgRoot.append(CGIndenter(errorReport)) self.cgRoot.append(CGGeneric("}")) def define(self): return self.cgRoot.define() class MethodNotCreatorError(Exception): def __init__(self, typename): self.typename = typename class CGPerSignatureCall(CGThing): """ This class handles the guts of generating code for a particular call signature. A call signature consists of four things: 1) A return type, which can be None to indicate that there is no actual return value (e.g. this is an attribute setter) or an IDLType if there's an IDL type involved (including |void|). 2) An argument list, which is allowed to be empty. 3) A name of a native method to call. 4) Whether or not this method is static. We also need to know whether this is a method or a getter/setter to do error reporting correctly. The idlNode parameter can be either a method or an attr. We can query |idlNode.identifier| in both cases, so we can be agnostic between the two. """ # XXXbz For now each entry in the argument list is either an # IDLArgument or a FakeArgument, but longer-term we may want to # have ways of flagging things like JSContext* or optional_argc in # there. def __init__(self, returnType, argsPre, arguments, nativeMethodName, static, descriptor, idlNode, argConversionStartsAt=0, getter=False, setter=False): CGThing.__init__(self) self.returnType = returnType self.descriptor = descriptor self.idlNode = idlNode self.extendedAttributes = descriptor.getExtendedAttributes(idlNode, getter=getter, setter=setter) self.argsPre = argsPre self.arguments = arguments self.argCount = len(arguments) if self.argCount > argConversionStartsAt: # Insert our argv in there cgThings = [CGGeneric(self.getArgvDecl())] else: cgThings = [] cgThings.extend([CGArgumentConverter(arguments[i], i, self.getArgv(), self.getArgc(), self.descriptor, invalidEnumValueFatal=not setter) for i in range(argConversionStartsAt, self.argCount)]) cgThings.append(CGCallGenerator( self.getErrorReport() if self.isFallible() else None, self.getArguments(), self.argsPre, returnType, self.extendedAttributes, descriptor, nativeMethodName, static)) self.cgRoot = CGList(cgThings, "\n") def getArgv(self): return "argv" if self.argCount > 0 else "" def getArgvDecl(self): return "\nJS::Value* argv = JS_ARGV(cx, vp);\n" def getArgc(self): return "argc" def getArguments(self): return [(a, "arg" + str(i)) for (i, a) in enumerate(self.arguments)] def isFallible(self): return not 'infallible' in self.extendedAttributes def wrap_return_value(self): isCreator = memberIsCreator(self.idlNode) if isCreator: # We better be returning addrefed things! assert(isResultAlreadyAddRefed(self.descriptor, self.extendedAttributes) or # Workers use raw pointers for new-object return # values or something self.descriptor.workers) resultTemplateValues = { 'jsvalRef': '*vp', 'jsvalPtr': 'vp', 'isCreator': isCreator} try: return wrapForType(self.returnType, self.descriptor, resultTemplateValues) except MethodNotCreatorError, err: assert not isCreator raise TypeError("%s being returned from non-creator method or property %s.%s" % (err.typename, self.descriptor.interface.identifier.name, self.idlNode.identifier.name)) def getErrorReport(self): return CGGeneric('return ThrowMethodFailedWithDetails<%s>(cx, rv, "%s", "%s");' % (toStringBool(not self.descriptor.workers), self.descriptor.interface.identifier.name, self.idlNode.identifier.name)) def define(self): return (self.cgRoot.define() + "\n" + self.wrap_return_value()) class CGSwitch(CGList): """ A class to generate code for a switch statement. Takes three constructor arguments: an expression, a list of cases, and an optional default. Each case is a CGCase. The default is a CGThing for the body of the default case, if any. """ def __init__(self, expression, cases, default=None): CGList.__init__(self, [CGIndenter(c) for c in cases], "\n") self.prepend(CGWrapper(CGGeneric(expression), pre="switch (", post=") {")); if default is not None: self.append( CGIndenter( CGWrapper( CGIndenter(default), pre="default: {\n", post="\n break;\n}" ) ) ) self.append(CGGeneric("}")) class CGCase(CGList): """ A class to generate code for a case statement. Takes three constructor arguments: an expression, a CGThing for the body (allowed to be None if there is no body), and an optional argument (defaulting to False) for whether to fall through. """ def __init__(self, expression, body, fallThrough=False): CGList.__init__(self, [], "\n") self.append(CGWrapper(CGGeneric(expression), pre="case ", post=": {")) bodyList = CGList([body], "\n") if fallThrough: bodyList.append(CGGeneric("/* Fall through */")) else: bodyList.append(CGGeneric("break;")) self.append(CGIndenter(bodyList)); self.append(CGGeneric("}")) class CGMethodCall(CGThing): """ A class to generate selection of a method signature from a set of signatures and generation of a call to that signature. """ def __init__(self, argsPre, nativeMethodName, static, descriptor, method): CGThing.__init__(self) methodName = '"%s.%s"' % (descriptor.interface.identifier.name, method.identifier.name) def requiredArgCount(signature): arguments = signature[1] if len(arguments) == 0: return 0 requiredArgs = len(arguments) while requiredArgs and arguments[requiredArgs-1].optional: requiredArgs -= 1 return requiredArgs def getPerSignatureCall(signature, argConversionStartsAt=0): return CGPerSignatureCall(signature[0], argsPre, signature[1], nativeMethodName, static, descriptor, method, argConversionStartsAt) signatures = method.signatures() if len(signatures) == 1: # Special case: we can just do a per-signature method call # here for our one signature and not worry about switching # on anything. signature = signatures[0] self.cgRoot = CGList([ CGIndenter(getPerSignatureCall(signature)) ]) requiredArgs = requiredArgCount(signature) if requiredArgs > 0: code = ( "if (argc < %d) {\n" " return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n" "}" % (requiredArgs, methodName)) self.cgRoot.prepend( CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n")) return # Need to find the right overload maxArgCount = method.maxArgCount allowedArgCounts = method.allowedArgCounts argCountCases = [] for argCount in allowedArgCounts: possibleSignatures = method.signaturesForArgCount(argCount) if len(possibleSignatures) == 1: # easy case! signature = possibleSignatures[0] # (possibly) important optimization: if signature[1] has > # argCount arguments and signature[1][argCount] is optional and # there is only one signature for argCount+1, then the # signature for argCount+1 is just ourselves and we can fall # through. if (len(signature[1]) > argCount and signature[1][argCount].optional and (argCount+1) in allowedArgCounts and len(method.signaturesForArgCount(argCount+1)) == 1): argCountCases.append( CGCase(str(argCount), None, True)) else: argCountCases.append( CGCase(str(argCount), getPerSignatureCall(signature))) continue distinguishingIndex = method.distinguishingIndexForArgCount(argCount) # We can't handle unions at the distinguishing index. for (returnType, args) in possibleSignatures: if args[distinguishingIndex].type.isUnion(): raise TypeError("No support for unions as distinguishing " "arguments yet: %s", args[distinguishingIndex].location) # Convert all our arguments up to the distinguishing index. # Doesn't matter which of the possible signatures we use, since # they all have the same types up to that point; just use # possibleSignatures[0] caseBody = [CGGeneric("JS::Value* argv_start = JS_ARGV(cx, vp);")] caseBody.extend([ CGArgumentConverter(possibleSignatures[0][1][i], i, "argv_start", "argc", descriptor) for i in range(0, distinguishingIndex) ]) # Select the right overload from our set. distinguishingArg = "argv_start[%d]" % distinguishingIndex def pickFirstSignature(condition, filterLambda): sigs = filter(filterLambda, possibleSignatures) assert len(sigs) < 2 if len(sigs) > 0: if condition is None: caseBody.append( getPerSignatureCall(sigs[0], distinguishingIndex)) else: caseBody.append(CGGeneric("if (" + condition + ") {")) caseBody.append(CGIndenter( getPerSignatureCall(sigs[0], distinguishingIndex))) caseBody.append(CGGeneric("}")) return True return False # First check for null or undefined pickFirstSignature("%s.isNullOrUndefined()" % distinguishingArg, lambda s: (s[1][distinguishingIndex].type.nullable() or s[1][distinguishingIndex].type.isDictionary())) # Now check for distinguishingArg being an object that implements a # non-callback interface. That includes typed arrays and # arraybuffers. interfacesSigs = [ s for s in possibleSignatures if (s[1][distinguishingIndex].type.isObject() or s[1][distinguishingIndex].type.isNonCallbackInterface()) ] # There might be more than one of these; we need to check # which ones we unwrap to. if len(interfacesSigs) > 0: # The spec says that we should check for "platform objects # implementing an interface", but it's enough to guard on these # being an object. The code for unwrapping non-callback # interfaces and typed arrays will just bail out and move on to # the next overload if the object fails to unwrap correctly. We # could even not do the isObject() check up front here, but in # cases where we have multiple object overloads it makes sense # to do it only once instead of for each overload. That will # also allow the unwrapping test to skip having to do codegen # for the null-or-undefined case, which we already handled # above. caseBody.append(CGGeneric("if (%s.isObject()) {" % (distinguishingArg))) for sig in interfacesSigs: caseBody.append(CGIndenter(CGGeneric("do {"))); type = sig[1][distinguishingIndex].type # The argument at index distinguishingIndex can't possibly # be unset here, because we've already checked that argc is # large enough that we can examine this argument. testCode = instantiateJSToNativeConversionTemplate( getJSToNativeConversionTemplate(type, descriptor, failureCode="break;", isDefinitelyObject=True), { "declName" : "arg%d" % distinguishingIndex, "holderName" : ("arg%d" % distinguishingIndex) + "_holder", "val" : distinguishingArg }) # Indent by 4, since we need to indent further than our "do" statement caseBody.append(CGIndenter(testCode, 4)); # If we got this far, we know we unwrapped to the right # interface, so just do the call. Start conversion with # distinguishingIndex + 1, since we already converted # distinguishingIndex. caseBody.append(CGIndenter( getPerSignatureCall(sig, distinguishingIndex + 1), 4)) caseBody.append(CGIndenter(CGGeneric("} while (0);"))) caseBody.append(CGGeneric("}")) # XXXbz Now we're supposed to check for distinguishingArg being # an array or a platform object that supports indexed # properties... skip that last for now. It's a bit of a pain. pickFirstSignature("%s.isObject() && IsArrayLike(cx, &%s.toObject())" % (distinguishingArg, distinguishingArg), lambda s: (s[1][distinguishingIndex].type.isArray() or s[1][distinguishingIndex].type.isSequence() or s[1][distinguishingIndex].type.isObject())) # Check for Date objects # XXXbz Do we need to worry about security wrappers around the Date? pickFirstSignature("%s.isObject() && JS_ObjectIsDate(cx, &%s.toObject())" % (distinguishingArg, distinguishingArg), lambda s: (s[1][distinguishingIndex].type.isDate() or s[1][distinguishingIndex].type.isObject())) # Check for vanilla JS objects # XXXbz Do we need to worry about security wrappers? pickFirstSignature("%s.isObject() && !IsPlatformObject(cx, &%s.toObject())" % (distinguishingArg, distinguishingArg), lambda s: (s[1][distinguishingIndex].type.isCallback() or s[1][distinguishingIndex].type.isCallbackInterface() or s[1][distinguishingIndex].type.isDictionary() or s[1][distinguishingIndex].type.isObject())) # The remaining cases are mutually exclusive. The # pickFirstSignature calls are what change caseBody # Check for strings or enums if pickFirstSignature(None, lambda s: (s[1][distinguishingIndex].type.isString() or s[1][distinguishingIndex].type.isEnum())): pass # Check for primitives elif pickFirstSignature(None, lambda s: s[1][distinguishingIndex].type.isPrimitive()): pass # Check for "any" elif pickFirstSignature(None, lambda s: s[1][distinguishingIndex].type.isAny()): pass else: # Just throw; we have no idea what we're supposed to # do with this. caseBody.append(CGGeneric("return Throw<%s>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);" % toStringBool(not descriptor.workers))) argCountCases.append(CGCase(str(argCount), CGList(caseBody, "\n"))) overloadCGThings = [] overloadCGThings.append( CGGeneric("unsigned argcount = NS_MIN(argc, %du);" % maxArgCount)) overloadCGThings.append( CGSwitch("argcount", argCountCases, CGGeneric("return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n" % methodName))) overloadCGThings.append( CGGeneric('MOZ_NOT_REACHED("We have an always-returning default case");\n' 'return false;')) self.cgRoot = CGWrapper(CGIndenter(CGList(overloadCGThings, "\n")), pre="\n") def define(self): return self.cgRoot.define() class CGGetterCall(CGPerSignatureCall): """ A class to generate a native object getter call for a particular IDL getter. """ def __init__(self, returnType, nativeMethodName, descriptor, attr): CGPerSignatureCall.__init__(self, returnType, [], [], nativeMethodName, False, descriptor, attr, getter=True) class FakeArgument(): """ A class that quacks like an IDLArgument. This is used to make setters look like method calls or for special operations. """ def __init__(self, type, interfaceMember): self.type = type self.optional = False self.variadic = False self.defaultValue = None self.treatNullAs = interfaceMember.treatNullAs self.treatUndefinedAs = interfaceMember.treatUndefinedAs self.enforceRange = False self.clamp = False class CGSetterCall(CGPerSignatureCall): """ A class to generate a native object setter call for a particular IDL setter. """ def __init__(self, argType, nativeMethodName, descriptor, attr): CGPerSignatureCall.__init__(self, None, [], [FakeArgument(argType, attr)], nativeMethodName, False, descriptor, attr, setter=True) def wrap_return_value(self): # We have no return value return "\nreturn true;" def getArgc(self): return "1" def getArgvDecl(self): # We just get our stuff from our last arg no matter what return "" class FakeCastableDescriptor(): def __init__(self, descriptor): self.castable = True self.workers = descriptor.workers self.nativeType = descriptor.nativeType self.name = descriptor.name self.hasXPConnectImpls = descriptor.hasXPConnectImpls class CGAbstractBindingMethod(CGAbstractStaticMethod): """ Common class to generate the JSNatives for all our methods, getters, and setters. This will generate the function declaration and unwrap the |this| object. Subclasses are expected to override the generate_code function to do the rest of the work. This function should return a CGThing which is already properly indented. """ def __init__(self, descriptor, name, args, unwrapFailureCode=None): CGAbstractStaticMethod.__init__(self, descriptor, name, "JSBool", args) if unwrapFailureCode is None: self.unwrapFailureCode = ("return Throw<%s>(cx, rv);" % toStringBool(not descriptor.workers)) else: self.unwrapFailureCode = unwrapFailureCode def definition_body(self): # Our descriptor might claim that we're not castable, simply because # we're someone's consequential interface. But for this-unwrapping, we # know that we're the real deal. So fake a descriptor here for # consumption by FailureFatalCastableObjectUnwrapper. unwrapThis = CGIndenter(CGGeneric( str(CastableObjectUnwrapper( FakeCastableDescriptor(self.descriptor), "obj", "self", self.unwrapFailureCode)))) return CGList([ self.getThis(), unwrapThis, self.generate_code() ], "\n").define() def getThis(self): return CGIndenter( CGGeneric("js::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));\n" "if (!obj) {\n" " return false;\n" "}\n" "\n" "%s* self;" % self.descriptor.nativeType)) def generate_code(self): assert(False) # Override me def MakeNativeName(name): return name[0].upper() + name[1:] class CGGenericMethod(CGAbstractBindingMethod): """ A class for generating the C++ code for an IDL method.. """ def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'), Argument('JS::Value*', 'vp')] CGAbstractBindingMethod.__init__(self, descriptor, 'genericMethod', args) def generate_code(self): return CGIndenter(CGGeneric( "const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" "JSJitMethodOp method = (JSJitMethodOp)info->op;\n" "return method(cx, obj, self, argc, vp);")) class CGSpecializedMethod(CGAbstractStaticMethod): """ A class for generating the C++ code for a specialized method that the JIT can call with lower overhead. """ def __init__(self, descriptor, method): self.method = method name = method.identifier.name args = [Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'), Argument('%s*' % descriptor.nativeType, 'self'), Argument('unsigned', 'argc'), Argument('JS::Value*', 'vp')] CGAbstractStaticMethod.__init__(self, descriptor, name, 'bool', args) def definition_body(self): name = self.method.identifier.name nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name)) return CGMethodCall([], nativeName, self.method.isStatic(), self.descriptor, self.method).define() class CGGenericGetter(CGAbstractBindingMethod): """ A class for generating the C++ code for an IDL attribute getter. """ def __init__(self, descriptor, lenientThis=False): args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'), Argument('JS::Value*', 'vp')] if lenientThis: name = "genericLenientGetter" unwrapFailureCode = ( "MOZ_ASSERT(!JS_IsExceptionPending(cx));\n" "JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n" "return true;") else: name = "genericGetter" unwrapFailureCode = None CGAbstractBindingMethod.__init__(self, descriptor, name, args, unwrapFailureCode) def generate_code(self): return CGIndenter(CGGeneric( "const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" "JSJitPropertyOp getter = info->op;\n" "return getter(cx, obj, self, vp);")) class CGSpecializedGetter(CGAbstractStaticMethod): """ A class for generating the code for a specialized attribute getter that the JIT can call with lower overhead. """ def __init__(self, descriptor, attr): self.attr = attr name = 'get_' + attr.identifier.name args = [ Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'), Argument('%s*' % descriptor.nativeType, 'self'), Argument('JS::Value*', 'vp') ] CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args) def definition_body(self): name = self.attr.identifier.name nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name)) # resultOutParam does not depend on whether resultAlreadyAddRefed is set (_, resultOutParam) = getRetvalDeclarationForType(self.attr.type, self.descriptor, False) infallible = ('infallible' in self.descriptor.getExtendedAttributes(self.attr, getter=True)) if resultOutParam or self.attr.type.nullable() or not infallible: nativeName = "Get" + nativeName return CGIndenter(CGGetterCall(self.attr.type, nativeName, self.descriptor, self.attr)).define() class CGGenericSetter(CGAbstractBindingMethod): """ A class for generating the C++ code for an IDL attribute setter. """ def __init__(self, descriptor, lenientThis=False): args = [Argument('JSContext*', 'cx'), Argument('unsigned', 'argc'), Argument('JS::Value*', 'vp')] if lenientThis: name = "genericLenientSetter" unwrapFailureCode = ( "MOZ_ASSERT(!JS_IsExceptionPending(cx));\n" "return true;") else: name = "genericSetter" unwrapFailureCode = None CGAbstractBindingMethod.__init__(self, descriptor, name, args, unwrapFailureCode) def generate_code(self): return CGIndenter(CGGeneric( "JS::Value* argv = JS_ARGV(cx, vp);\n" "JS::Value undef = JS::UndefinedValue();\n" "if (argc == 0) {\n" " argv = &undef;\n" "}\n" "const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" "JSJitPropertyOp setter = info->op;\n" "if (!setter(cx, obj, self, argv)) {\n" " return false;\n" "}\n" "*vp = JSVAL_VOID;\n" "return true;")) class CGSpecializedSetter(CGAbstractStaticMethod): """ A class for generating the code for a specialized attribute setter that the JIT can call with lower overhead. """ def __init__(self, descriptor, attr): self.attr = attr name = 'set_' + attr.identifier.name args = [ Argument('JSContext*', 'cx'), Argument('JSHandleObject', 'obj'), Argument('%s*' % descriptor.nativeType, 'self'), Argument('JS::Value*', 'argv')] CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args) def definition_body(self): name = self.attr.identifier.name nativeName = "Set" + MakeNativeName(self.descriptor.binaryNames.get(name, name)) return CGIndenter(CGSetterCall(self.attr.type, nativeName, self.descriptor, self.attr)).define() def memberIsCreator(member): return member.getExtendedAttribute("Creator") is not None class CGMemberJITInfo(CGThing): """ A class for generating the JITInfo for a property that points to our specialized getter and setter. """ def __init__(self, descriptor, member): self.member = member self.descriptor = descriptor def declare(self): return "" def defineJitInfo(self, infoName, opName, infallible): protoID = "prototypes::id::%s" % self.descriptor.name depth = "PrototypeTraits<%s>::Depth" % protoID failstr = "true" if infallible else "false" return ("\n" "const JSJitInfo %s = {\n" " %s,\n" " %s,\n" " %s,\n" " %s, /* isInfallible. False in setters. */\n" " false /* isConstant. Only relevant for getters. */\n" "};\n" % (infoName, opName, protoID, depth, failstr)) def define(self): if self.member.isAttr(): getterinfo = ("%s_getterinfo" % self.member.identifier.name) getter = ("(JSJitPropertyOp)get_%s" % self.member.identifier.name) getterinfal = "infallible" in self.descriptor.getExtendedAttributes(self.member, getter=True) getterinfal = getterinfal and infallibleForMember(self.member, self.member.type, self.descriptor) result = self.defineJitInfo(getterinfo, getter, getterinfal) if not self.member.readonly: setterinfo = ("%s_setterinfo" % self.member.identifier.name) setter = ("(JSJitPropertyOp)set_%s" % self.member.identifier.name) # Setters are always fallible, since they have to do a typed unwrap. result += self.defineJitInfo(setterinfo, setter, False) return result if self.member.isMethod(): methodinfo = ("%s_methodinfo" % self.member.identifier.name) # Actually a JSJitMethodOp, but JSJitPropertyOp by struct definition. method = ("(JSJitPropertyOp)%s" % self.member.identifier.name) # Methods are infallible if they are infallible, have no arguments # to unwrap, and have a return type that's infallible to wrap up for # return. methodInfal = False sigs = self.member.signatures() if len(sigs) == 1: # Don't handle overloading. If there's more than one signature, # one of them must take arguments. sig = sigs[0] if len(sig[1]) == 0 and infallibleForMember(self.member, sig[0], self.descriptor): # No arguments and infallible return boxing methodInfal = True result = self.defineJitInfo(methodinfo, method, methodInfal) return result raise TypeError("Illegal member type to CGPropertyJITInfo") def getEnumValueName(value): # Some enum values can be empty strings. Others might have weird # characters in them. Deal with the former by returning "_empty", # deal with possible name collisions from that by throwing if the # enum value is actually "_empty", and throw on any value # containing chars other than [a-z] or '-' for now. Replace '-' with '_'. value = value.replace('-', '_') if value == "_empty": raise SyntaxError('"_empty" is not an IDL enum value we support yet') if value == "": return "_empty" if not re.match("^[a-z_]+$", value): raise SyntaxError('Enum value "' + value + '" contains characters ' 'outside [a-z_]') return MakeNativeName(value) class CGEnum(CGThing): def __init__(self, enum): CGThing.__init__(self) self.enum = enum def declare(self): return """ enum valuelist { %s }; extern const EnumEntry strings[%d]; """ % (",\n ".join(map(getEnumValueName, self.enum.values())), len(self.enum.values()) + 1) def define(self): return """ const EnumEntry strings[%d] = { %s, { NULL, 0 } }; """ % (len(self.enum.values()) + 1, ",\n ".join(['{"' + val + '", ' + str(len(val)) + '}' for val in self.enum.values()])) def getUnionAccessorSignatureType(type, descriptorProvider): """ Returns the types that are used in the getter and setter signatures for union types """ if type.isArray(): raise TypeError("Can't handle array arguments yet") if type.isSequence(): nullable = type.nullable(); if nullable: type = type.inner.inner else: type = type.inner (elementTemplate, elementDeclType, elementHolderType, dealWithOptional) = getJSToNativeConversionTemplate( type, descriptorProvider, isSequenceMember=True) typeName = CGWrapper(elementDeclType, pre="Sequence< ", post=" >&") if nullable: typeName = CGWrapper(typeName, pre="Nullable< ", post=" >&") return typeName if type.isUnion(): typeName = CGGeneric(type.name) if type.nullable(): typeName = CGWrapper(typeName, pre="Nullable< ", post=" >&") return typeName if type.isGeckoInterface(): descriptor = descriptorProvider.getDescriptor( type.unroll().inner.identifier.name) typeName = CGGeneric(descriptor.nativeType) # Allow null pointers for nullable types and old-binding classes if type.nullable() or type.unroll().inner.isExternal(): typeName = CGWrapper(typeName, post="*") else: typeName = CGWrapper(typeName, post="&") return typeName if type.isSpiderMonkeyInterface(): typeName = CGGeneric(type.name) if type.nullable(): typeName = CGWrapper(typeName, post="*") else: typeName = CGWrapper(typeName, post="&") return typeName if type.isString(): return CGGeneric("const nsAString&") if type.isEnum(): if type.nullable(): raise TypeError("We don't support nullable enumerated arguments or " "union members yet") return CGGeneric(type.inner.identifier.name) if type.isCallback(): return CGGeneric("JSObject*") if type.isAny(): return CGGeneric("JS::Value") if type.isObject(): typeName = CGGeneric("JSObject") if type.nullable(): typeName = CGWrapper(typeName, post="*") else: typeName = CGWrapper(typeName, post="&") return typeName if not type.isPrimitive(): raise TypeError("Need native type for argument type '%s'" % str(type)) typeName = CGGeneric(builtinNames[type.tag()]) if type.nullable(): typeName = CGWrapper(typeName, pre="Nullable< ", post=" >&") return typeName def getUnionTypeTemplateVars(type, descriptorProvider): # For dictionaries and sequences we need to pass None as the failureCode # for getJSToNativeConversionTemplate. # Also, for dictionaries we would need to handle conversion of # null/undefined to the dictionary correctly. if type.isDictionary() or type.isSequence(): raise TypeError("Can't handle dictionaries or sequences in unions") if type.isGeckoInterface(): name = type.inner.identifier.name elif type.isEnum(): name = type.inner.identifier.name elif type.isArray() or type.isSequence(): name = str(type) else: name = type.name tryNextCode = """tryNext = true; return true;""" if type.isGeckoInterface(): tryNextCode = ("""if (mUnion.mType != mUnion.eUninitialized) { mUnion.Destroy%s(); }""" % name) + tryNextCode (template, declType, holderType, dealWithOptional) = getJSToNativeConversionTemplate( type, descriptorProvider, failureCode=tryNextCode, isDefinitelyObject=True) # This is ugly, but UnionMember needs to call a constructor with no # arguments so the type can't be const. structType = declType.define() if structType.startswith("const "): structType = structType[6:] externalType = getUnionAccessorSignatureType(type, descriptorProvider).define() if type.isObject(): setter = CGGeneric("void SetToObject(JSObject* obj)\n" "{\n" " mUnion.mValue.mObject.SetValue() = obj;\n" " mUnion.mType = mUnion.eObject;\n" "}") else: jsConversion = string.Template(template).substitute( { "val": "value", "valPtr": "pvalue", "declName": "SetAs" + name + "()", "holderName": "m" + name + "Holder" } ) jsConversion = CGWrapper(CGGeneric(jsConversion), post="\n" "return true;") setter = CGWrapper(CGIndenter(jsConversion), pre="bool TrySetTo" + name + "(JSContext* cx, const JS::Value& value, JS::Value* pvalue, bool& tryNext)\n" "{\n" " tryNext = false;\n", post="\n" "}") return { "name": name, "structType": structType, "externalType": externalType, "setter": CGIndenter(setter).define(), "holderType": holderType.define() if holderType else None } def mapTemplate(template, templateVarArray): return map(lambda v: string.Template(template).substitute(v), templateVarArray) class CGUnionStruct(CGThing): def __init__(self, type, descriptorProvider): CGThing.__init__(self) self.type = type.unroll() self.descriptorProvider = descriptorProvider def declare(self): templateVars = map(lambda t: getUnionTypeTemplateVars(t, self.descriptorProvider), self.type.flatMemberTypes) callDestructors = [] enumValues = [] methods = [] if self.type.hasNullableType: callDestructors.append(" case eNull:\n" " break;") enumValues.append("eNull") methods.append(""" bool IsNull() const { return mType == eNull; }""") destructorTemplate = """ void Destroy${name}() { MOZ_ASSERT(Is${name}(), "Wrong type!"); mValue.m${name}.Destroy(); mType = eUninitialized; }""" destructors = mapTemplate(destructorTemplate, templateVars) callDestructors.extend(mapTemplate(" case e${name}:\n" " Destroy${name}();\n" " break;", templateVars)) enumValues.extend(mapTemplate("e${name}", templateVars)) methodTemplate = """ bool Is${name}() const { return mType == e${name}; } ${externalType} GetAs${name}() const { MOZ_ASSERT(Is${name}(), "Wrong type!"); // The cast to ${externalType} is needed to work around a bug in Apple's // clang compiler, for some reason it doesn't call |S::operator T&| when // casting S<T> to T& and T is forward declared. return (${externalType})mValue.m${name}.Value(); } ${structType}& SetAs${name}() { mType = e${name}; return mValue.m${name}.SetValue(); }""" methods.extend(mapTemplate(methodTemplate, templateVars)) values = mapTemplate("UnionMember<${structType} > m${name};", templateVars) return string.Template(""" class ${structName} { public: ${structName}() : mType(eUninitialized) { } ~${structName}() { switch (mType) { ${callDestructors} case eUninitialized: break; } } ${methods} private: friend class ${structName}Argument; ${destructors} enum Type { eUninitialized, ${enumValues} }; union Value { ${values} }; Type mType; Value mValue; }; """).substitute( { "structName": self.type.__str__(), "callDestructors": "\n".join(callDestructors), "destructors": "\n".join(destructors), "methods": "\n\n".join(methods), "enumValues": ",\n ".join(enumValues), "values": "\n ".join(values), }) def define(self): return """ """ class CGUnionConversionStruct(CGThing): def __init__(self, type, descriptorProvider): CGThing.__init__(self) self.type = type.unroll() self.descriptorProvider = descriptorProvider def declare(self): setters = [] if self.type.hasNullableType: setters.append(""" bool SetNull() { mUnion.mType = mUnion.eNull; return true; }""") templateVars = map(lambda t: getUnionTypeTemplateVars(t, self.descriptorProvider), self.type.flatMemberTypes) structName = self.type.__str__() setters.extend(mapTemplate("${setter}", templateVars)) private = "\n".join(mapTemplate(""" ${structType}& SetAs${name}() { mUnion.mType = mUnion.e${name}; return mUnion.mValue.m${name}.SetValue(); }""", templateVars)) private += "\n\n" holders = filter(lambda v: v["holderType"] is not None, templateVars) if len(holders) > 0: private += "\n".join(mapTemplate(" ${holderType} m${name}Holder;", holders)) private += "\n\n" private += " " + structName + "& mUnion;" return string.Template(""" class ${structName}Argument { public: ${structName}Argument(const ${structName}& aUnion) : mUnion(const_cast<${structName}&>(aUnion)) { } ${setters} private: ${private} }; """).substitute({"structName": structName, "setters": "\n\n".join(setters), "private": private }) def define(self): return """ """ class ClassItem: """ Use with CGClass """ def __init__(self, name, visibility): self.name = name self.visibility = visibility def declare(self, cgClass): assert False def define(self, cgClass): assert False class ClassBase(ClassItem): def __init__(self, name, visibility='public'): ClassItem.__init__(self, name, visibility) def declare(self, cgClass): return '%s %s' % (self.visibility, self.name) def define(self, cgClass): # Only in the header return '' class ClassMethod(ClassItem): def __init__(self, name, returnType, args, inline=False, static=False, virtual=False, const=False, bodyInHeader=False, templateArgs=None, visibility='public', body=None): self.returnType = returnType self.args = args self.inline = inline or bodyInHeader self.static = static self.virtual = virtual self.const = const self.bodyInHeader = bodyInHeader self.templateArgs = templateArgs self.body = body ClassItem.__init__(self, name, visibility) def getDecorators(self, declaring): decorators = [] if self.inline: decorators.append('inline') if declaring: if self.static: decorators.append('static') if self.virtual: decorators.append('virtual') if decorators: return ' '.join(decorators) + ' ' return '' def getBody(self): # Override me or pass a string to constructor assert self.body is not None return self.body def declare(self, cgClass): templateClause = 'template <%s>\n' % ', '.join(self.templateArgs) \ if self.bodyInHeader and self.templateArgs else '' args = ', '.join([str(a) for a in self.args]) if self.bodyInHeader: body = CGIndenter(CGGeneric(self.getBody())).define() body = '\n{\n' + body + '\n}' else: body = ';' return string.Template("""${templateClause}${decorators}${returnType} ${name}(${args})${const}${body} """).substitute({ 'templateClause': templateClause, 'decorators': self.getDecorators(True), 'returnType': self.returnType, 'name': self.name, 'const': ' const' if self.const else '', 'args': args, 'body': body }) def define(self, cgClass): if self.bodyInHeader: return '' templateArgs = cgClass.templateArgs if templateArgs: if cgClass.templateSpecialization: templateArgs = \ templateArgs[len(cgClass.templateSpecialization):] if templateArgs: templateClause = \ 'template <%s>\n' % ', '.join([str(a) for a in templateArgs]) else: templateClause = '' args = ', '.join([str(a) for a in self.args]) body = CGIndenter(CGGeneric(self.getBody())).define() return string.Template("""${templateClause}${decorators}${returnType} ${className}::${name}(${args})${const} { ${body} }\n """).substitute({ 'templateClause': templateClause, 'decorators': self.getDecorators(False), 'returnType': self.returnType, 'className': cgClass.getNameString(), 'name': self.name, 'args': args, 'const': ' const' if self.const else '', 'body': body }) class ClassConstructor(ClassItem): """ Used for adding a constructor to a CGClass. args is a list of Argument objects that are the arguments taken by the constructor. inline should be True if the constructor should be marked inline. bodyInHeader should be True if the body should be placed in the class declaration in the header. visibility determines the visibility of the constructor (public, protected, private), defaults to private. baseConstructors is a list of strings containing calls to base constructors, defaults to None. body contains a string with the code for the constructor, defaults to None. """ def __init__(self, args, inline=False, bodyInHeader=False, visibility="private", baseConstructors=None, body=None): self.args = args self.inline = inline or bodyInHeader self.bodyInHeader = bodyInHeader self.baseConstructors = baseConstructors self.body = body ClassItem.__init__(self, None, visibility) def getDecorators(self, declaring): decorators = [] if self.inline and declaring: decorators.append('inline') if decorators: return ' '.join(decorators) + ' ' return '' def getInitializationList(self, cgClass): items = [str(c) for c in self.baseConstructors] for m in cgClass.members: if not m.static: initialize = m.getBody() if initialize: items.append(m.name + "(" + initialize + ")") if len(items) > 0: return '\n : ' + ',\n '.join(items) return '' def getBody(self): assert self.body is not None return self.body def declare(self, cgClass): args = ', '.join([str(a) for a in self.args]) if self.bodyInHeader: body = ' ' + self.getBody(); body = stripTrailingWhitespace(body.replace('\n', '\n ')) if len(body) > 0: body += '\n' body = self.getInitializationList(cgClass) + '\n{\n' + body + '}' else: body = ';' return string.Template("""${decorators}${className}(${args})${body} """).substitute({ 'decorators': self.getDecorators(True), 'className': cgClass.getNameString(), 'args': args, 'body': body }) def define(self, cgClass): if self.bodyInHeader: return '' args = ', '.join([str(a) for a in self.args]) body = ' ' + self.getBody() body = '\n' + stripTrailingWhitespace(body.replace('\n', '\n ')) if len(body) > 0: body += '\n' return string.Template("""${decorators} ${className}::${className}(${args})${initializationList} {${body}}\n """).substitute({ 'decorators': self.getDecorators(False), 'className': cgClass.getNameString(), 'args': args, 'initializationList': self.getInitializationList(cgClass), 'body': body }) class ClassMember(ClassItem): def __init__(self, name, type, visibility="private", static=False, body=None): self.type = type; self.static = static self.body = body ClassItem.__init__(self, name, visibility) def declare(self, cgClass): return '%s%s %s;\n' % ('static ' if self.static else '', self.type, self.name) def define(self, cgClass): if not self.static: return '' if self.body: body = " = " + self.body else: body = "" return '%s %s::%s%s;\n' % (self.type, cgClass.getNameString(), self.name, body) class ClassTypedef(ClassItem): def __init__(self, name, type, visibility="public"): self.type = type ClassItem.__init__(self, name, visibility) def declare(self, cgClass): return 'typedef %s %s;\n' % (self.type, self.name) def define(self, cgClass): # Only goes in the header return '' class ClassEnum(ClassItem): def __init__(self, name, entries, values=None, visibility="public"): self.entries = entries self.values = values ClassItem.__init__(self, name, visibility) def declare(self, cgClass): entries = [] for i in range(0, len(self.entries)): if i >= len(self.values): entry = '%s' % self.entries[i] else: entry = '%s = %s' % (self.entries[i], self.values[i]) entries.append(entry) name = '' if not self.name else ' ' + self.name return 'enum%s\n{\n %s\n};\n' % (name, ',\n '.join(entries)) def define(self, cgClass): # Only goes in the header return '' class CGClass(CGThing): def __init__(self, name, bases=[], members=[], constructors=[], methods=[], typedefs = [], enums=[], templateArgs=[], templateSpecialization=[], isStruct=False, indent=''): CGThing.__init__(self) self.name = name self.bases = bases self.members = members self.constructors = constructors self.methods = methods self.typedefs = typedefs self.enums = enums self.templateArgs = templateArgs self.templateSpecialization = templateSpecialization self.isStruct = isStruct self.indent = indent self.defaultVisibility ='public' if isStruct else 'private' def getNameString(self): className = self.name if self.templateSpecialization: className = className + \ '<%s>' % ', '.join([str(a) for a in self.templateSpecialization]) return className def declare(self): result = '' if self.templateArgs: templateArgs = [str(a) for a in self.templateArgs] templateArgs = templateArgs[len(self.templateSpecialization):] result = result + self.indent + 'template <%s>\n' \ % ','.join([str(a) for a in templateArgs]) type = 'struct' if self.isStruct else 'class' if self.templateSpecialization: specialization = \ '<%s>' % ', '.join([str(a) for a in self.templateSpecialization]) else: specialization = '' result = result + '%s%s %s%s' \ % (self.indent, type, self.name, specialization) if self.bases: result = result + ' : %s' % ', '.join([d.declare(self) for d in self.bases]) result = result + '\n%s{\n' % self.indent def declareMembers(cgClass, memberList, defaultVisibility, itemCount, separator=''): members = { 'private': [], 'protected': [], 'public': [] } for member in memberList: members[member.visibility].append(member) if defaultVisibility == 'public': order = [ 'public', 'protected', 'private' ] else: order = [ 'private', 'protected', 'public' ] result = '' lastVisibility = defaultVisibility for visibility in order: list = members[visibility] if list: if visibility != lastVisibility: if itemCount: result = result + '\n' result = result + visibility + ':\n' itemCount = 0 for member in list: if itemCount != 0: result = result + separator declaration = member.declare(cgClass) declaration = CGIndenter(CGGeneric(declaration)).define() result = result + declaration itemCount = itemCount + 1 lastVisibility = visibility return (result, lastVisibility, itemCount) order = [(self.enums, ''), (self.typedefs, ''), (self.members, ''), (self.constructors, '\n'), (self.methods, '\n')] lastVisibility = self.defaultVisibility itemCount = 0 for (memberList, separator) in order: (memberString, lastVisibility, itemCount) = \ declareMembers(self, memberList, lastVisibility, itemCount, separator) if self.indent: memberString = CGIndenter(CGGeneric(memberString), len(self.indent)).define() result = result + memberString result = result + self.indent + '};\n' return result def define(self): def defineMembers(cgClass, memberList, itemCount, separator=''): result = '' for member in memberList: if itemCount != 0: result = result + separator result = result + member.define(cgClass) itemCount = itemCount + 1 return (result, itemCount) order = [(self.members, '\n'), (self.constructors, '\n'), (self.methods, '\n')] result = '' itemCount = 0 for (memberList, separator) in order: (memberString, itemCount) = defineMembers(self, memberList, itemCount, separator) result = result + memberString return result class CGResolveOwnProperty(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'), Argument('jsid', 'id'), Argument('bool', 'set'), Argument('JSPropertyDescriptor*', 'desc')] CGAbstractMethod.__init__(self, descriptor, "ResolveOwnProperty", "bool", args) def definition_body(self): return """ JSObject* obj = wrapper; if (xpc::WrapperFactory::IsXrayWrapper(obj)) { obj = js::UnwrapObject(obj); } // We rely on getOwnPropertyDescriptor not shadowing prototype properties by named // properties. If that changes we'll need to filter here. return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, set, desc); """ class CGEnumerateOwnProperties(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'), Argument('JS::AutoIdVector&', 'props')] CGAbstractMethod.__init__(self, descriptor, "EnumerateOwnProperties", "bool", args) def definition_body(self): return """ JSObject* obj = wrapper; if (xpc::WrapperFactory::IsXrayWrapper(obj)) { obj = js::UnwrapObject(obj); } // We rely on getOwnPropertyNames not shadowing prototype properties by named // properties. If that changes we'll need to filter here. return js::GetProxyHandler(obj)->getOwnPropertyNames(cx, wrapper, props); """ class CGXrayHelper(CGAbstractMethod): def __init__(self, descriptor, name, args, properties): CGAbstractMethod.__init__(self, descriptor, name, "bool", args) self.properties = properties def definition_body(self): varNames = self.properties.variableNames(True) methods = self.properties.methods if methods.hasNonChromeOnly() or methods.hasChromeOnly(): methodArgs = """// %(methods)s has an end-of-list marker at the end that we ignore %(methods)s, %(methods)s_ids, %(methods)s_specs, ArrayLength(%(methods)s) - 1""" % varNames else: methodArgs = "NULL, NULL, NULL, 0" methodArgs = CGGeneric(methodArgs) attrs = self.properties.attrs if attrs.hasNonChromeOnly() or attrs.hasChromeOnly(): attrArgs = """// %(attrs)s has an end-of-list marker at the end that we ignore %(attrs)s, %(attrs)s_ids, %(attrs)s_specs, ArrayLength(%(attrs)s) - 1""" % varNames else: attrArgs = "NULL, NULL, NULL, 0" attrArgs = CGGeneric(attrArgs) consts = self.properties.consts if consts.hasNonChromeOnly() or consts.hasChromeOnly(): constArgs = """// %(consts)s has an end-of-list marker at the end that we ignore %(consts)s, %(consts)s_ids, %(consts)s_specs, ArrayLength(%(consts)s) - 1""" % varNames else: constArgs = "NULL, NULL, NULL, 0" constArgs = CGGeneric(constArgs) prefixArgs = CGGeneric(self.getPrefixArgs()) return CGIndenter( CGWrapper(CGList([prefixArgs, methodArgs, attrArgs, constArgs], ",\n"), pre=("return Xray%s(" % self.name), post=");", reindent=True)).define() class CGResolveProperty(CGXrayHelper): def __init__(self, descriptor, properties): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'), Argument('jsid', 'id'), Argument('bool', 'set'), Argument('JSPropertyDescriptor*', 'desc')] CGXrayHelper.__init__(self, descriptor, "ResolveProperty", args, properties) def getPrefixArgs(self): return "cx, wrapper, id, desc" class CGEnumerateProperties(CGXrayHelper): def __init__(self, descriptor, properties): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'), Argument('JS::AutoIdVector&', 'props')] CGXrayHelper.__init__(self, descriptor, "EnumerateProperties", args, properties) def getPrefixArgs(self): return "props" class CGPrototypeTraitsClass(CGClass): def __init__(self, descriptor, indent=''): templateArgs = [Argument('prototypes::ID', 'PrototypeID')] templateSpecialization = ['prototypes::id::' + descriptor.name] enums = [ClassEnum('', ['Depth'], [descriptor.interface.inheritanceDepth()])] typedefs = [ClassTypedef('NativeType', descriptor.nativeType)] CGClass.__init__(self, 'PrototypeTraits', indent=indent, templateArgs=templateArgs, templateSpecialization=templateSpecialization, enums=enums, typedefs=typedefs, isStruct=True) class CGPrototypeIDMapClass(CGClass): def __init__(self, descriptor, indent=''): templateArgs = [Argument('class', 'ConcreteClass')] templateSpecialization = [descriptor.nativeType] enums = [ClassEnum('', ['PrototypeID'], ['prototypes::id::' + descriptor.name])] CGClass.__init__(self, 'PrototypeIDMap', indent=indent, templateArgs=templateArgs, templateSpecialization=templateSpecialization, enums=enums, isStruct=True) class CGClassForwardDeclare(CGThing): def __init__(self, name, isStruct=False): CGThing.__init__(self) self.name = name self.isStruct = isStruct def declare(self): type = 'struct' if self.isStruct else 'class' return '%s %s;\n' % (type, self.name) def define(self): # Header only return '' class CGProxySpecialOperation(CGPerSignatureCall): """ Base class for classes for calling an indexed or named special operation (don't use this directly, use the derived classes below). """ def __init__(self, descriptor, operation): nativeName = MakeNativeName(descriptor.binaryNames.get(operation, operation)) operation = descriptor.operations[operation] assert len(operation.signatures()) == 1 signature = operation.signatures()[0] extendedAttributes = descriptor.getExtendedAttributes(operation) (returnType, arguments) = signature # We pass len(arguments) as the final argument so that the # CGPerSignatureCall won't do any argument conversion of its own. CGPerSignatureCall.__init__(self, returnType, "", arguments, nativeName, False, descriptor, operation, len(arguments)) if operation.isSetter() or operation.isCreator(): # arguments[0] is the index or name of the item that we're setting. argument = arguments[1] template = getJSToNativeConversionTemplate(argument.type, descriptor, treatNullAs=argument.treatNullAs, treatUndefinedAs=argument.treatUndefinedAs) templateValues = { "declName": argument.identifier.name, "holderName": argument.identifier.name + "_holder", "val": "desc->value", "valPtr": "&desc->value" } self.cgRoot.prepend(instantiateJSToNativeConversionTemplate(template, templateValues)) elif operation.isGetter(): self.cgRoot.prepend(CGGeneric("bool found;")) def getArguments(self): args = [(a, a.identifier.name) for a in self.arguments] if self.idlNode.isGetter(): args.append((FakeArgument(BuiltinTypes[IDLBuiltinType.Types.boolean], self.idlNode), "found")) return args def wrap_return_value(self): if not self.idlNode.isGetter() or self.templateValues is None: return "" wrap = CGGeneric(wrapForType(self.returnType, self.descriptor, self.templateValues)) wrap = CGIfWrapper(wrap, "found") return "\n" + wrap.define() class CGProxyIndexedGetter(CGProxySpecialOperation): """ Class to generate a call to an indexed getter. If templateValues is not None the returned value will be wrapped with wrapForType using templateValues. """ def __init__(self, descriptor, templateValues=None): self.templateValues = templateValues CGProxySpecialOperation.__init__(self, descriptor, 'IndexedGetter') class CGProxyIndexedSetter(CGProxySpecialOperation): """ Class to generate a call to an indexed setter. """ def __init__(self, descriptor): CGProxySpecialOperation.__init__(self, descriptor, 'IndexedSetter') class CGProxyNamedGetter(CGProxySpecialOperation): """ Class to generate a call to an named getter. If templateValues is not None the returned value will be wrapped with wrapForType using templateValues. """ def __init__(self, descriptor, templateValues=None): self.templateValues = templateValues CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter') class CGProxyNamedSetter(CGProxySpecialOperation): """ Class to generate a call to a named setter. """ def __init__(self, descriptor): CGProxySpecialOperation.__init__(self, descriptor, 'NamedSetter') class CGProxyIsProxy(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('JSObject*', 'obj')] CGAbstractMethod.__init__(self, descriptor, "IsProxy", "bool", args, alwaysInline=True) def declare(self): return "" def definition_body(self): return " return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();" class CGProxyUnwrap(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('JSObject*', 'obj')] CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", descriptor.nativeType + '*', args, alwaysInline=True) def declare(self): return "" def definition_body(self): return """ if (xpc::WrapperFactory::IsXrayWrapper(obj)) { obj = js::UnwrapObject(obj); } MOZ_ASSERT(IsProxy(obj)); return static_cast<%s*>(js::GetProxyPrivate(obj).toPrivate());""" % (self.descriptor.nativeType) class CGDOMJSProxyHandlerDOMClass(CGThing): def __init__(self, descriptor): CGThing.__init__(self) self.descriptor = descriptor def declare(self): return "extern const DOMClass Class;\n" def define(self): return """ const DOMClass Class = """ + DOMClass(self.descriptor) + """; """ class CGDOMJSProxyHandler_CGDOMJSProxyHandler(ClassConstructor): def __init__(self): ClassConstructor.__init__(self, [], inline=True, visibility="private", baseConstructors=["mozilla::dom::DOMProxyHandler(Class)"], body="") class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('jsid', 'id'), Argument('bool', 'set'), Argument('JSPropertyDescriptor*', 'desc')] ClassMethod.__init__(self, "getOwnPropertyDescriptor", "bool", args) self.descriptor = descriptor def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] indexedSetter = self.descriptor.operations['IndexedSetter'] setOrIndexedGet = "" if indexedGetter or indexedSetter: setOrIndexedGet += "int32_t index = GetArrayIndexFromId(cx, id);\n" if indexedGetter: readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None) fillDescriptor = "FillPropertyDescriptor(desc, proxy, %s);\nreturn true;" % readonly templateValues = {'jsvalRef': 'desc->value', 'jsvalPtr': '&desc->value', 'obj': 'proxy', 'successCode': fillDescriptor} get = ("if (index >= 0) {\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + "}\n") % (self.descriptor.nativeType) if indexedSetter or self.descriptor.operations['NamedSetter']: setOrIndexedGet += "if (set) {\n" if indexedSetter: setOrIndexedGet += (" if (index >= 0) {\n") if not 'IndexedCreator' in self.descriptor.operations: # FIXME need to check that this is a 'supported property index' assert False setOrIndexedGet += (" FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false);\n" + " return true;\n" + " }\n") if self.descriptor.operations['NamedSetter']: setOrIndexedGet += " if (JSID_IS_STRING(id)) {\n" if not 'NamedCreator' in self.descriptor.operations: # FIXME need to check that this is a 'supported property name' assert False setOrIndexedGet += (" FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false);\n" + " return true;\n" + " }\n") setOrIndexedGet += "}" if indexedGetter: setOrIndexedGet += (" else {\n" + CGIndenter(CGGeneric(get)).define() + "}") setOrIndexedGet += "\n\n" elif indexedGetter: setOrIndexedGet += ("if (!set) {\n" + CGIndenter(CGGeneric(get)).define() + "}\n\n") namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None) fillDescriptor = "FillPropertyDescriptor(desc, proxy, %s);\nreturn true;" % readonly templateValues = {'jsvalRef': 'desc->value', 'jsvalPtr': '&desc->value', 'obj': 'proxy', 'successCode': fillDescriptor} # Once we start supporting OverrideBuiltins we need to make # ResolveOwnProperty or EnumerateOwnProperties filter out named # properties that shadow prototype properties. namedGet = ("\n" + "if (!set && JSID_IS_STRING(id) && !HasPropertyOnPrototype(cx, proxy, this, id)) {\n" + " JS::Value nameVal = STRING_TO_JSVAL(JSID_TO_STRING(id));\n" + " FakeDependentString name;\n" " if (!ConvertJSValueToString(cx, nameVal, &nameVal,\n" + " eStringify, eStringify, name)) {\n" + " return false;\n" + " }\n" + "\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + "}\n") % (self.descriptor.nativeType) else: namedGet = "" return setOrIndexedGet + """JSObject* expando; if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) { unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0) | JSRESOLVE_QUALIFIED; if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) { return false; } if (desc->obj) { // Pretend the property lives on the wrapper. desc->obj = proxy; return true; } } """ + namedGet + """ desc->obj = NULL; return true;""" class CGDOMJSProxyHandler_defineProperty(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('jsid', 'id'), Argument('JSPropertyDescriptor*', 'desc')] ClassMethod.__init__(self, "defineProperty", "bool", args) self.descriptor = descriptor def getBody(self): set = "" indexedSetter = self.descriptor.operations['IndexedSetter'] if indexedSetter: if not (self.descriptor.operations['IndexedCreator'] is indexedSetter): raise TypeError("Can't handle creator that's different from the setter") set += ("int32_t index = GetArrayIndexFromId(cx, id);\n" + "if (index >= 0) {\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + " return true;\n" + "}\n") % (self.descriptor.nativeType) elif self.descriptor.operations['IndexedGetter']: set += ("if (GetArrayIndexFromId(cx, id) >= 0) {\n" + " return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + "}\n") % self.descriptor.name namedSetter = self.descriptor.operations['NamedSetter'] if namedSetter: if not self.descriptor.operations['NamedCreator'] is namedSetter: raise TypeError("Can't handle creator that's different from the setter") set += ("if (JSID_IS_STRING(id)) {\n" + " JS::Value nameVal = STRING_TO_JSVAL(JSID_TO_STRING(id));\n" + " FakeDependentString name;\n" " if (!ConvertJSValueToString(cx, nameVal, &nameVal,\n" + " eStringify, eStringify, name)) {\n" + " return false;\n" + " }\n" + "\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + "}\n") % (self.descriptor.nativeType) elif self.descriptor.operations['NamedGetter']: set += ("if (JSID_IS_STRING(id)) {\n" + " JS::Value nameVal = STRING_TO_JSVAL(JSID_TO_STRING(id));\n" + " FakeDependentString name;\n" " if (!ConvertJSValueToString(cx, nameVal, &nameVal,\n" + " eStringify, eStringify, name)) {\n" + " return false;\n" + " }\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + " if (found) {\n" " return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + " }\n" + " return true;\n" "}\n") % (self.descriptor.nativeType, self.descriptor.name) return set + """return mozilla::dom::DOMProxyHandler::defineProperty(%s);""" % ", ".join(a.name for a in self.args) class CGDOMJSProxyHandler_getOwnPropertyNames(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('JS::AutoIdVector&', 'props')] ClassMethod.__init__(self, "getOwnPropertyNames", "bool", args) self.descriptor = descriptor def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: addIndices = """uint32_t length = UnwrapProxy(proxy)->Length(); MOZ_ASSERT(int32_t(length) >= 0); for (int32_t i = 0; i < int32_t(length); ++i) { if (!props.append(INT_TO_JSID(i))) { return false; } } """ else: addIndices = "" return addIndices + """JSObject* expando; if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = DOMProxyHandler::GetExpandoObject(proxy)) && !js::GetPropertyNames(cx, expando, JSITER_OWNONLY | JSITER_HIDDEN, &props)) { return false; } // FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=772869 Add named items return true;""" class CGDOMJSProxyHandler_hasOwn(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('jsid', 'id'), Argument('bool*', 'bp')] ClassMethod.__init__(self, "hasOwn", "bool", args) self.descriptor = descriptor def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: indexed = ("int32_t index = GetArrayIndexFromId(cx, id);\n" + "if (index >= 0) {\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + " *bp = found;\n" + " return true;\n" + "}\n\n") % (self.descriptor.nativeType) else: indexed = "" namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: named = ("if (JSID_IS_STRING(id) && !HasPropertyOnPrototype(cx, proxy, this, id)) {\n" + " jsval nameVal = STRING_TO_JSVAL(JSID_TO_STRING(id));\n" + " FakeDependentString name;\n" " if (!ConvertJSValueToString(cx, nameVal, &nameVal,\n" + " eStringify, eStringify, name)) {\n" + " return false;\n" + " }\n" + "\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + " *bp = found;\n" " return true;\n" "}\n" + "\n") % (self.descriptor.nativeType) else: named = "" return indexed + """JSObject* expando = GetExpandoObject(proxy); if (expando) { JSBool b = true; JSBool ok = JS_HasPropertyById(cx, expando, id, &b); *bp = !!b; if (!ok || *bp) { return ok; } } """ + named + """*bp = false; return true;""" class CGDOMJSProxyHandler_get(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('JSObject*', 'receiver'), Argument('jsid', 'id'), Argument('JS::Value*', 'vp')] ClassMethod.__init__(self, "get", "bool", args) self.descriptor = descriptor def getBody(self): getFromExpando = """JSObject* expando = DOMProxyHandler::GetExpandoObject(proxy); if (expando) { JSBool hasProp; if (!JS_HasPropertyById(cx, expando, id, &hasProp)) { return false; } if (hasProp) { return JS_GetPropertyById(cx, expando, id, vp); } }""" templateValues = {'jsvalRef': '*vp', 'jsvalPtr': 'vp', 'obj': 'proxy'} indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: getIndexedOrExpando = ("int32_t index = GetArrayIndexFromId(cx, id);\n" + "if (index >= 0) {\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) % (self.descriptor.nativeType) getIndexedOrExpando += """ // Even if we don't have this index, we don't forward the // get on to our expando object. } else { %s } """ % (stripTrailingWhitespace(getFromExpando.replace('\n', '\n '))) else: getIndexedOrExpando = getFromExpando + "\n" namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: getNamed = ("if (JSID_IS_STRING(id)) {\n" + " JS::Value nameVal = STRING_TO_JSVAL(JSID_TO_STRING(id));\n" + " FakeDependentString name;\n" " if (!ConvertJSValueToString(cx, nameVal, &nameVal,\n" + " eStringify, eStringify, name)) {\n" + " return false;\n" + " }\n" + "\n" + " %s* self = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "}\n") % (self.descriptor.nativeType) else: getNamed = "" return """MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), "Should not have a XrayWrapper here"); %s bool found; if (!GetPropertyOnPrototype(cx, proxy, id, &found, vp)) { return false; } if (found) { return true; } %s vp->setUndefined(); return true;""" % (getIndexedOrExpando, getNamed) class CGDOMJSProxyHandler_obj_toString(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy')] ClassMethod.__init__(self, "obj_toString", "JSString*", args) self.descriptor = descriptor def getBody(self): stringifier = self.descriptor.operations['Stringifier'] if stringifier: name = stringifier.identifier.name nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name)) signature = stringifier.signatures()[0] returnType = signature[0] extendedAttributes = self.descriptor.getExtendedAttributes(stringifier) infallible = 'infallible' in extendedAttributes if not infallible: error = CGGeneric( ('ThrowMethodFailedWithDetails(cx, rv, "%s", "toString");\n' + "return NULL;") % self.descriptor.interface.identifier.name) else: error = None call = CGCallGenerator(error, [], "", returnType, extendedAttributes, self.descriptor, nativeName, False, object="UnwrapProxy(proxy)") return call.define() + """ JSString* jsresult; return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;""" return "return mozilla::dom::DOMProxyHandler::obj_toString(cx, \"%s\");" % self.descriptor.name class CGDOMJSProxyHandler_finalize(ClassMethod): def __init__(self, descriptor): args = [Argument('JSFreeOp*', 'fop'), Argument('JSObject*', 'proxy')] ClassMethod.__init__(self, "finalize", "void", args) self.descriptor = descriptor def getBody(self): return ("%s self = UnwrapProxy(proxy);\n\n" % (self.descriptor.nativeType + "*") + finalizeHook(self.descriptor, FINALIZE_HOOK_NAME, self.args[0].name)) class CGDOMJSProxyHandler_getElementIfPresent(ClassMethod): def __init__(self, descriptor): args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'), Argument('JSObject*', 'receiver'), Argument('uint32_t', 'index'), Argument('JS::Value*', 'vp'), Argument('bool*', 'present')] ClassMethod.__init__(self, "getElementIfPresent", "bool", args) self.descriptor = descriptor def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: successCode = """*present = found; return true;""" templateValues = {'jsvalRef': '*vp', 'jsvalPtr': 'vp', 'obj': 'proxy', 'successCode': successCode} get = ("%s* self = UnwrapProxy(proxy);\n" + CGProxyIndexedGetter(self.descriptor, templateValues).define() + "\n" "// We skip the expando object if there is an indexed getter.\n" + "\n") % (self.descriptor.nativeType) else: get = """ JSObject* expando = GetExpandoObject(proxy); if (expando) { JSBool isPresent; if (!JS_GetElementIfPresent(cx, expando, index, expando, vp, &isPresent)) { return false; } if (isPresent) { *present = true; return true; } } """ return """MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), "Should not have a XrayWrapper here"); """ + get + """ // No need to worry about name getters here, so just check the proto. JSObject *proto; if (!js::GetObjectProto(cx, proxy, &proto)) { return false; } if (proto) { JSBool isPresent; if (!JS_GetElementIfPresent(cx, proto, index, proxy, vp, &isPresent)) { return false; } *present = isPresent; return true; } *present = false; // Can't Debug_SetValueRangeToCrashOnTouch because it's not public return true;""" class CGDOMJSProxyHandler_getInstance(ClassMethod): def __init__(self): ClassMethod.__init__(self, "getInstance", "DOMProxyHandler*", [], static=True) def getBody(self): return """static DOMProxyHandler instance; return &instance;""" class CGDOMJSProxyHandler(CGClass): def __init__(self, descriptor): constructors = [CGDOMJSProxyHandler_CGDOMJSProxyHandler()] methods = [CGDOMJSProxyHandler_getOwnPropertyDescriptor(descriptor)] if descriptor.operations['IndexedSetter'] or descriptor.operations['NamedSetter']: methods.append(CGDOMJSProxyHandler_defineProperty(descriptor)) methods.extend([CGDOMJSProxyHandler_getOwnPropertyNames(descriptor), CGDOMJSProxyHandler_hasOwn(descriptor), CGDOMJSProxyHandler_get(descriptor), CGDOMJSProxyHandler_obj_toString(descriptor), CGDOMJSProxyHandler_finalize(descriptor), CGDOMJSProxyHandler_getElementIfPresent(descriptor), CGDOMJSProxyHandler_getInstance()]) CGClass.__init__(self, 'DOMProxyHandler', bases=[ClassBase('mozilla::dom::DOMProxyHandler')], constructors=constructors, methods=methods) def stripTrailingWhitespace(text): tail = '\n' if text.endswith('\n') else '' lines = text.splitlines() for i in range(len(lines)): lines[i] = lines[i].rstrip() return '\n'.join(lines) + tail class CGDescriptor(CGThing): def __init__(self, descriptor): CGThing.__init__(self) assert not descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject() cgThings = [] if descriptor.interface.hasInterfacePrototypeObject(): (hasMethod, hasGetter, hasLenientGetter, hasSetter, hasLenientSetter) = False, False, False, False, False for m in descriptor.interface.members: if m.isMethod() and not m.isStatic() and not m.isIdentifierLess(): cgThings.append(CGSpecializedMethod(descriptor, m)) cgThings.append(CGMemberJITInfo(descriptor, m)) hasMethod = True elif m.isAttr(): cgThings.append(CGSpecializedGetter(descriptor, m)) if m.hasLenientThis(): hasLenientGetter = True else: hasGetter = True if not m.readonly: cgThings.append(CGSpecializedSetter(descriptor, m)) if m.hasLenientThis(): hasLenientSetter = True else: hasSetter = True cgThings.append(CGMemberJITInfo(descriptor, m)) if hasMethod: cgThings.append(CGGenericMethod(descriptor)) if hasGetter: cgThings.append(CGGenericGetter(descriptor)) if hasLenientGetter: cgThings.append(CGGenericGetter(descriptor, lenientThis=True)) if hasSetter: cgThings.append(CGGenericSetter(descriptor)) if hasLenientSetter: cgThings.append(CGGenericSetter(descriptor, lenientThis=True)) if descriptor.concrete and not descriptor.proxy: if not descriptor.workers and descriptor.wrapperCache: cgThings.append(CGAddPropertyHook(descriptor)) # Always have a finalize hook, regardless of whether the class wants a # custom hook. cgThings.append(CGClassFinalizeHook(descriptor)) # Only generate a trace hook if the class wants a custom hook. if (descriptor.customTrace): cgThings.append(CGClassTraceHook(descriptor)) if descriptor.interface.hasInterfaceObject(): cgThings.append(CGClassConstructHook(descriptor)) cgThings.append(CGClassHasInstanceHook(descriptor)) cgThings.append(CGInterfaceObjectJSClass(descriptor)) if descriptor.interface.hasInterfacePrototypeObject(): cgThings.append(CGPrototypeJSClass(descriptor)) properties = PropertyArrays(descriptor) cgThings.append(CGGeneric(define=str(properties))) cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties)) if descriptor.interface.hasInterfacePrototypeObject(): cgThings.append(CGGetProtoObjectMethod(descriptor)) else: cgThings.append(CGGetConstructorObjectMethod(descriptor)) # Set up our Xray callbacks as needed. Note that we don't need to do # it in workers. if (descriptor.interface.hasInterfacePrototypeObject() and not descriptor.workers): if descriptor.concrete and descriptor.proxy: cgThings.append(CGResolveOwnProperty(descriptor)) cgThings.append(CGEnumerateOwnProperties(descriptor)) cgThings.append(CGResolveProperty(descriptor, properties)) cgThings.append(CGEnumerateProperties(descriptor, properties)) if descriptor.interface.hasInterfaceObject(): cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) if (not descriptor.interface.isExternal() and # Workers stuff is never pref-controlled not descriptor.workers and descriptor.interface.getExtendedAttribute("PrefControlled") is not None): cgThings.append(CGPrefEnabled(descriptor)) if descriptor.interface.hasInterfacePrototypeObject(): cgThings.append(CGNativePropertyHooks(descriptor)) if descriptor.concrete: if descriptor.proxy: cgThings.append(CGProxyIsProxy(descriptor)) cgThings.append(CGProxyUnwrap(descriptor)) cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor)) cgThings.append(CGDOMJSProxyHandler(descriptor)) cgThings.append(CGIsMethod(descriptor)) else: cgThings.append(CGDOMJSClass(descriptor)) if descriptor.wrapperCache: cgThings.append(CGWrapWithCacheMethod(descriptor)) cgThings.append(CGWrapMethod(descriptor)) else: cgThings.append(CGWrapNonWrapperCacheMethod(descriptor)) cgThings = CGList((CGIndenter(t, declareOnly=True) for t in cgThings), "\n") cgThings = CGWrapper(cgThings, pre='\n', post='\n') self.cgRoot = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name), cgThings), post='\n') def declare(self): return self.cgRoot.declare() def define(self): return self.cgRoot.define() class CGNamespacedEnum(CGThing): def __init__(self, namespace, enumName, names, values, comment=""): if not values: values = [] # Account for explicit enum values. entries = [] for i in range(0, len(names)): if len(values) > i and values[i] is not None: entry = "%s = %s" % (names[i], values[i]) else: entry = names[i] entries.append(entry) # Append a Count. entries.append('_' + enumName + '_Count') # Indent. entries = [' ' + e for e in entries] # Build the enum body. enumstr = comment + 'enum %s\n{\n%s\n};\n' % (enumName, ',\n'.join(entries)) curr = CGGeneric(declare=enumstr) # Add some whitespace padding. curr = CGWrapper(curr, pre='\n',post='\n') # Add the namespace. curr = CGNamespace(namespace, curr) # Add the typedef typedef = '\ntypedef %s::%s %s;\n\n' % (namespace, enumName, enumName) curr = CGList([curr, CGGeneric(declare=typedef)]) # Save the result. self.node = curr def declare(self): return self.node.declare() def define(self): assert False # Only for headers. class CGDictionary(CGThing): def __init__(self, dictionary, descriptorProvider): self.dictionary = dictionary; self.workers = descriptorProvider.workers if all(CGDictionary(d, descriptorProvider).generatable for d in CGDictionary.getDictionaryDependencies(dictionary)): self.generatable = True else: self.generatable = False # Nothing else to do here return # Getting a conversion template for interface types can fail # if we don't have a relevant descriptor when self.workers is True. # If that happens, just mark ourselves as not being # generatable and move on. try: self.memberInfo = [ (member, getJSToNativeConversionTemplate(member.type, descriptorProvider, isMember=True, isOptional=(not member.defaultValue), defaultValue=member.defaultValue)) for member in dictionary.members ] except NoSuchDescriptorError, err: if not self.workers: raise err self.generatable = False def declare(self): if not self.generatable: return "" d = self.dictionary if d.parent: inheritance = ": public %s " % self.makeClassName(d.parent) else: inheritance = "" memberDecls = [" %s %s;" % (self.getMemberType(m), m[0].identifier.name) for m in self.memberInfo] return (string.Template( "struct ${selfName} ${inheritance}{\n" " ${selfName}() {}\n" " bool Init(JSContext* cx, const JS::Value& val);\n" "\n" + "\n".join(memberDecls) + "\n" "private:\n" " // Disallow copy-construction\n" " ${selfName}(const ${selfName}&) MOZ_DELETE;\n" + # NOTE: jsids are per-runtime, so don't use them in workers (" static bool InitIds(JSContext* cx);\n" " static bool initedIds;\n" if not self.workers else "") + "\n".join(" static jsid " + self.makeIdName(m.identifier.name) + ";" for m in d.members) + "\n" "};").substitute( { "selfName": self.makeClassName(d), "inheritance": inheritance })) def define(self): if not self.generatable: return "" d = self.dictionary if d.parent: initParent = ("// Per spec, we init the parent's members first\n" "if (!%s::Init(cx, val)) {\n" " return false;\n" "}\n" % self.makeClassName(d.parent)) else: initParent = "" memberInits = [CGIndenter(self.getMemberConversion(m)).define() for m in self.memberInfo] idinit = [CGGeneric('!InternJSString(cx, %s, "%s")' % (m.identifier.name + "_id", m.identifier.name)) for m in d.members] idinit = CGList(idinit, " ||\n") idinit = CGWrapper(idinit, pre="if (", post=(") {\n" " return false;\n" "}"), reindent=True) return string.Template( # NOTE: jsids are per-runtime, so don't use them in workers ("bool ${selfName}::initedIds = false;\n" + "\n".join("jsid ${selfName}::%s = JSID_VOID;" % self.makeIdName(m.identifier.name) for m in d.members) + "\n" "\n" "bool\n" "${selfName}::InitIds(JSContext* cx)\n" "{\n" " MOZ_ASSERT(!initedIds);\n" "${idInit}\n" " initedIds = true;\n" " return true;\n" "}\n" "\n" if not self.workers else "") + "bool\n" "${selfName}::Init(JSContext* cx, const JS::Value& val)\n" "{\n" + # NOTE: jsids are per-runtime, so don't use them in workers (" if (!initedIds && !InitIds(cx)) {\n" " return false;\n" " }\n" if not self.workers else "") + "${initParent}" " JSBool found;\n" " JS::Value temp;\n" " bool isNull = val.isNullOrUndefined();\n" " if (!isNull && !val.isObject()) {\n" " return Throw<${isMainThread}>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);\n" " }\n" "\n" "${initMembers}\n" " return true;\n" "}").substitute({ "selfName": self.makeClassName(d), "initParent": CGIndenter(CGGeneric(initParent)).define(), "initMembers": "\n\n".join(memberInits), "idInit": CGIndenter(idinit).define(), "isMainThread": toStringBool(not self.workers) }) @staticmethod def makeDictionaryName(dictionary, workers): suffix = "Workers" if workers else "" return dictionary.identifier.name + suffix def makeClassName(self, dictionary): return self.makeDictionaryName(dictionary, self.workers) def getMemberType(self, memberInfo): (member, (templateBody, declType, holderType, dealWithOptional)) = memberInfo # We can't handle having a holderType here assert holderType is None if dealWithOptional: declType = CGWrapper(declType, pre="Optional< ", post=" >") return declType.define() def getMemberConversion(self, memberInfo): (member, (templateBody, declType, holderType, dealWithOptional)) = memberInfo replacements = { "val": "temp", "valPtr": "&temp", # Use this->%s to refer to members, because we don't # control the member names and want to make sure we're # talking about the member, not some local that # shadows the member. Another option would be to move # the guts of init to a static method which is passed # an explicit reference to our dictionary object, so # we couldn't screw this up even if we wanted to.... "declName": ("(this->%s)" % member.identifier.name), # We need a holder name for external interfaces, but # it's scoped down to the conversion so we can just use # anything we want. "holderName": "holder"} # We can't handle having a holderType here assert holderType is None if dealWithOptional: replacements["declName"] = "(" + replacements["declName"] + ".Value())" if member.defaultValue: replacements["haveValue"] = "found" # NOTE: jsids are per-runtime, so don't use them in workers if self.workers: propName = member.identifier.name propCheck = ('JS_HasProperty(cx, &val.toObject(), "%s", &found)' % propName) propGet = ('JS_GetProperty(cx, &val.toObject(), "%s", &temp)' % propName) else: propId = self.makeIdName(member.identifier.name); propCheck = ("JS_HasPropertyById(cx, &val.toObject(), %s, &found)" % propId) propGet = ("JS_GetPropertyById(cx, &val.toObject(), %s, &temp)" % propId) conversionReplacements = { "prop": "(this->%s)" % member.identifier.name, "convert": string.Template(templateBody).substitute(replacements), "propCheck": propCheck, "propGet": propGet } conversion = ("if (isNull) {\n" " found = false;\n" "} else if (!${propCheck}) {\n" " return false;\n" "}\n") if member.defaultValue: conversion += ( "if (found) {\n" " if (!${propGet}) {\n" " return false;\n" " }\n" "}\n" "${convert}") else: conversion += ( "if (found) {\n" " ${prop}.Construct();\n" " if (!${propGet}) {\n" " return false;\n" " }\n" "${convert}\n" "}") conversionReplacements["convert"] = CGIndenter( CGGeneric(conversionReplacements["convert"])).define() return CGGeneric( string.Template(conversion).substitute(conversionReplacements) ) @staticmethod def makeIdName(name): return name + "_id" @staticmethod def getDictionaryDependencies(dictionary): deps = set(); if dictionary.parent: deps.add(dictionary.parent) for member in dictionary.members: if member.type.isDictionary(): deps.add(member.type.unroll().inner) return deps class CGRegisterProtos(CGAbstractMethod): def __init__(self, config): CGAbstractMethod.__init__(self, None, 'Register', 'void', [Argument('nsScriptNameSpaceManager*', 'aNameSpaceManager')]) self.config = config def _defineMacro(self): return """ #define REGISTER_PROTO(_dom_class, _pref_check) \\ aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Binding::DefineDOMInterface, _pref_check);\n\n""" def _undefineMacro(self): return "\n#undef REGISTER_PROTO" def _registerProtos(self): def getPrefCheck(desc): if desc.interface.getExtendedAttribute("PrefControlled") is None: return "nullptr" return "%sBinding::PrefEnabled" % desc.name lines = ["REGISTER_PROTO(%s, %s);" % (desc.name, getPrefCheck(desc)) for desc in self.config.getDescriptors(hasInterfaceObject=True, isExternal=False, workers=False, register=True)] return '\n'.join(lines) + '\n' def definition_body(self): return self._defineMacro() + self._registerProtos() + self._undefineMacro() class CGBindingRoot(CGThing): """ Root codegen class for binding generation. Instantiate the class, and call declare or define to generate header or cpp code (respectively). """ def __init__(self, config, prefix, webIDLFile): descriptors = config.getDescriptors(webIDLFile=webIDLFile, hasInterfaceOrInterfacePrototypeObject=True) dictionaries = config.getDictionaries(webIDLFile) forwardDeclares = [CGClassForwardDeclare('XPCWrappedNativeScope')] descriptorsForForwardDeclaration = list(descriptors) for dictionary in dictionaries: curDict = dictionary ifacemembers = [] while curDict: ifacemembers.extend([m.type.unroll().inner for m in curDict.members if m.type.unroll().isInterface()]) curDict = curDict.parent # Put in all the non-worker descriptors descriptorsForForwardDeclaration.extend( [config.getDescriptor(iface.identifier.name, False) for iface in ifacemembers]) # And now the worker ones. But these may not exist, so we # have to be more careful. for iface in ifacemembers: try: descriptorsForForwardDeclaration.append( config.getDescriptor(iface.identifier.name, True)) except NoSuchDescriptorError: # just move along pass for x in descriptorsForForwardDeclaration: nativeType = x.nativeType components = x.nativeType.split('::') className = components[-1] # JSObject is a struct, not a class declare = CGClassForwardDeclare(className, className is "JSObject") if len(components) > 1: declare = CGNamespace.build(components[:-1], CGWrapper(declare, declarePre='\n', declarePost='\n'), declareOnly=True) forwardDeclares.append(CGWrapper(declare, declarePost='\n')) forwardDeclares = CGList(forwardDeclares) descriptorsWithPrototype = filter(lambda d: d.interface.hasInterfacePrototypeObject(), descriptors) traitsClasses = [CGPrototypeTraitsClass(d) for d in descriptorsWithPrototype] # We must have a 1:1 mapping here, skip for prototypes that have more # than one concrete class implementation. traitsClasses.extend([CGPrototypeIDMapClass(d) for d in descriptorsWithPrototype if d.uniqueImplementation]) # Wrap all of that in our namespaces. if len(traitsClasses) > 0: traitsClasses = CGNamespace.build(['mozilla', 'dom'], CGWrapper(CGList(traitsClasses), declarePre='\n'), declareOnly=True) traitsClasses = CGWrapper(traitsClasses, declarePost='\n') else: traitsClasses = None # Do codegen for all the enums def makeEnum(e): return CGNamespace.build([e.identifier.name + "Values"], CGEnum(e)) def makeEnumTypedef(e): return CGGeneric(declare=("typedef %sValues::valuelist %s;\n" % (e.identifier.name, e.identifier.name))) cgthings = [ fun(e) for e in config.getEnums(webIDLFile) for fun in [makeEnum, makeEnumTypedef] ] # Do codegen for all the dictionaries. We have to be a bit careful # here, because we have to generate these in order from least derived # to most derived so that class inheritance works out. We also have to # generate members before the dictionary that contains them. # # XXXbz this will fail if we have two webidl files A and B such that A # declares a dictionary which inherits from a dictionary in B and B # declares a dictionary (possibly a different one!) that inherits from a # dictionary in A. The good news is that I expect this to never happen. reSortedDictionaries = [] dictionaries = set(dictionaries) while len(dictionaries) != 0: # Find the dictionaries that don't depend on anything else anymore # and move them over. toMove = [d for d in dictionaries if len(CGDictionary.getDictionaryDependencies(d) & dictionaries) == 0] if len(toMove) == 0: raise TypeError("Loop in dictionary dependency graph") dictionaries = dictionaries - set(toMove) reSortedDictionaries.extend(toMove) dictionaries = reSortedDictionaries cgthings.extend([CGDictionary(d, config.getDescriptorProvider(True)) for d in dictionaries]) cgthings.extend([CGDictionary(d, config.getDescriptorProvider(False)) for d in dictionaries]) # Do codegen for all the descriptors cgthings.extend([CGDescriptor(x) for x in descriptors]) # And make sure we have the right number of newlines at the end curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n") # Wrap all of that in our namespaces. curr = CGNamespace.build(['mozilla', 'dom'], CGWrapper(curr, pre="\n")) curr = CGList([forwardDeclares, CGWrapper(CGGeneric("using namespace mozilla::dom;"), defineOnly=True), traitsClasses, curr], "\n") # Add header includes. curr = CGHeaders(descriptors, dictionaries, ['mozilla/dom/BindingUtils.h', 'mozilla/dom/DOMJSClass.h', 'mozilla/dom/DOMJSProxyHandler.h'], ['mozilla/dom/Nullable.h', 'PrimitiveConversions.h', 'XPCQuickStubs.h', 'nsDOMQS.h', 'AccessCheck.h', 'WorkerPrivate.h', 'nsContentUtils.h', 'mozilla/Preferences.h', # Have to include nsDOMQS.h to get fast arg unwrapping # for old-binding things with castability. 'nsDOMQS.h' ], curr) # Add include guards. curr = CGIncludeGuard(prefix, curr) # Add the auto-generated comment. curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) # Store the final result. self.root = curr def declare(self): return stripTrailingWhitespace(self.root.declare()) def define(self): return stripTrailingWhitespace(self.root.define()) class GlobalGenRoots(): """ Roots for global codegen. To generate code, call the method associated with the target, and then call the appropriate define/declare method. """ @staticmethod def PrototypeList(config): # Prototype ID enum. protos = [d.name for d in config.getDescriptors(hasInterfacePrototypeObject=True)] idEnum = CGNamespacedEnum('id', 'ID', protos, [0]) idEnum = CGList([idEnum]) idEnum.append(CGGeneric(declare="const unsigned MaxProtoChainLength = " + str(config.maxProtoChainLength) + ";\n\n")) # Wrap all of that in our namespaces. idEnum = CGNamespace.build(['mozilla', 'dom', 'prototypes'], CGWrapper(idEnum, pre='\n')) idEnum = CGWrapper(idEnum, post='\n') curr = CGList([idEnum]) # Constructor ID enum. constructors = [d.name for d in config.getDescriptors(hasInterfaceObject=True, hasInterfacePrototypeObject=False)] idEnum = CGNamespacedEnum('id', 'ID', constructors, [0]) # Wrap all of that in our namespaces. idEnum = CGNamespace.build(['mozilla', 'dom', 'constructors'], CGWrapper(idEnum, pre='\n')) idEnum = CGWrapper(idEnum, post='\n') curr.append(idEnum) traitsDecl = CGGeneric(declare=""" template <prototypes::ID PrototypeID> struct PrototypeTraits; template <class ConcreteClass> struct PrototypeIDMap; """) traitsDecl = CGNamespace.build(['mozilla', 'dom'], CGWrapper(traitsDecl, post='\n')) curr.append(traitsDecl) # Add include guards. curr = CGIncludeGuard('PrototypeList', curr) # Add the auto-generated comment. curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) # Done. return curr @staticmethod def RegisterBindings(config): # TODO - Generate the methods we want curr = CGRegisterProtos(config) # Wrap all of that in our namespaces. curr = CGNamespace.build(['mozilla', 'dom'], CGWrapper(curr, post='\n')) curr = CGWrapper(curr, post='\n') # Add the includes defineIncludes = [CGHeaders.getDeclarationFilename(desc.interface) for desc in config.getDescriptors(hasInterfaceObject=True, workers=False, register=True)] defineIncludes.append('nsScriptNameSpaceManager.h') curr = CGHeaders([], [], [], defineIncludes, curr) # Add include guards. curr = CGIncludeGuard('RegisterBindings', curr) # Done. return curr @staticmethod def UnionTypes(config): (includes, declarations, unions) = UnionTypes(config.getDescriptors()) includes.add("mozilla/dom/BindingUtils.h") # Wrap all of that in our namespaces. curr = CGNamespace.build(['mozilla', 'dom'], unions) curr = CGWrapper(curr, post='\n') namespaces = [] stack = [CGList([])] for (clazz, isStruct) in SortedTuples(declarations): elements = clazz.split("::") clazz = CGClassForwardDeclare(elements.pop(), isStruct=isStruct) i = 0 if len(elements) > 0: common = min(len(namespaces), len(elements)) while i < common and namespaces[i] == elements[i]: i += 1 # pop all the namespaces that should be closed namespaces = namespaces[:i] # add all the namespaces that should be opened for j, namespace in enumerate(elements[i:]): namespaces.append(namespace) # every CGNamespace that we add holds a CGList list = CGList([]) # add the new namespace to the list on top of the stack stack[i + j].append(CGNamespace(namespace, list)) # set the top of the namespace stack to the list of the new # namespace stack[i + j + 1:] = [list] stack[len(elements)].append(clazz) curr = CGList([stack[0], curr], "\n") curr = CGHeaders([], [], includes, [], curr) # Add include guards. curr = CGIncludeGuard('UnionTypes', curr) # Done. return curr @staticmethod def UnionConversions(config): unions = UnionConversions(config.getDescriptors()) # Wrap all of that in our namespaces. curr = CGNamespace.build(['mozilla', 'dom'], unions) curr = CGWrapper(curr, post='\n') curr = CGHeaders([], [], ["nsDebug.h", "mozilla/dom/UnionTypes.h", "nsDOMQS.h"], [], curr) # Add include guards. curr = CGIncludeGuard('UnionConversions', curr) # Done. return curr
mpl-2.0
[ 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 570, 12, 199, 3, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 3, 13964, 1233, 2268, 3992, 14, 199, 199, 646, 747, 199, 646, 1059, 199, 646, 4182, 199, 199, 504, 22817, 492, 627, 199, 504, 11595, 492, 23798, 4311, 547, 199, 199, 13883, 12795, 6989, 63, 9171, 63, 10973, 275, 971, 272, 3286, 10, 5749, 13024, 2281, 25420, 12795, 6989, 446, 3506, 2845, 24981, 9399, 78, 60, 78, 2, 199, 9732, 25091, 63, 28706, 63, 2339, 275, 2513, 525, 3697, 7, 199, 29270, 11025, 63, 28706, 63, 2339, 275, 2513, 14450, 7, 199, 20112, 63, 28706, 63, 2339, 275, 2513, 3446, 7, 199, 1864, 8893, 63, 28706, 63, 2339, 275, 2513, 1880, 7, 199, 13533, 18235, 63, 28706, 63, 2339, 275, 2513, 1989, 3244, 7, 199, 199, 318, 3350, 1173, 3917, 6970, 8, 1501, 12, 892, 11383, 304, 272, 408, 272, 5574, 282, 1331, 402, 314, 2269, 570, 12, 880, 626, 781, 2793, 1133, 12943, 652, 340, 652, 18699, 1133, 2896, 14, 272, 1803, 715, 340, 314, 570, 1990, 4588, 12, 3055, 4257, 14, 272, 408, 272, 2269, 1173, 11383, 275, 3087, 272, 862, 26, 267, 2269, 1173, 275, 1551, 8, 1501, 12, 283, 4848, 358, 267, 2269, 1173, 11383, 275, 6522, 904, 8, 1753, 1173, 14, 9684, 1012, 267, 2269, 1173, 14, 1600, 342, 272, 871, 26, 267, 986, 339, 340, 892, 11383, 508, 2269, 1173, 11383, 26, 267, 372, 756, 339, 289, 275, 1551, 8, 1501, 12, 283, 6603, 358, 272, 289, 14, 952, 8, 1222, 11383, 9, 272, 289, 14, 1600, 342, 199, 199, 318, 370, 1558, 10349, 8, 1273, 304, 272, 372, 620, 8, 1397, 440, 1680, 680, 2325, 342, 199, 199, 318, 370, 17490, 8814, 8, 1273, 304, 272, 372, 295, 14, 954, 480, 1332, 63, 11009, 5547, 4, 4186, 298, 17490, 1103, 17, 401, 1680, 2736, 199, 199, 533, 18657, 32218, 837, 272, 408, 272, 11836, 1300, 1021, 367, 7645, 626, 2249, 390, 734, 1233, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 986, 327, 20550, 367, 3063, 272, 347, 20771, 8, 277, 304, 267, 408, 24391, 1233, 367, 282, 1406, 570, 1041, 267, 702, 8, 797, 9, 221, 327, 11041, 562, 1, 272, 347, 5627, 8, 277, 304, 267, 408, 24391, 1233, 367, 282, 7246, 570, 1041, 267, 702, 8, 797, 9, 327, 11041, 562, 1, 199, 199, 533, 445, 15306, 1905, 3697, 8481, 83, 8, 4064, 32218, 304, 272, 408, 272, 7958, 282, 653, 1905, 3697, 8481, 83, 367, 282, 1627, 5872, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5872, 304, 267, 18657, 32218, 855, 826, 721, 277, 9, 267, 291, 14, 4120, 275, 5872, 272, 347, 20771, 8, 277, 304, 267, 340, 291, 14, 4120, 14, 11009, 26, 288, 372, 3087, 267, 372, 298, 18587, 950, 653, 1905, 3697, 8481, 83, 653, 1905, 8481, 83, 3779, 78, 2, 272, 347, 5627, 8, 277, 304, 267, 340, 291, 14, 4120, 14, 11009, 26, 288, 372, 3087, 267, 340, 291, 14, 4120, 14, 13455, 436, 291, 14, 4120, 14, 3280, 26, 288, 7512, 28492, 3697, 275, 298, 27459, 28492, 3697, 2, 288, 3874, 28492, 8516, 275, 298, 28858, 1866, 28492, 8516, 2, 267, 587, 26, 288, 3874, 28492, 8516, 275, 7512, 28492, 3697, 275, 298, 8084, 2, 267, 1676, 275, 291, 14, 4120, 14, 3266, 14, 1708, 267, 1676, 8481, 83, 275, 1689, 6, 2, 435, 370, 17490, 8814, 8, 1708, 14, 5364, 14, 354, 9, 435, 27472, 19675, 8481, 83, 2, 2432, 340, 1676, 587, 283, 8084, 358, 267, 372, 408, 199, 1297, 653, 1905, 3697, 8481, 83, 653, 1905, 8481, 83, 275, 469, 450, 83, 12, 31096, 3697, 12, 450, 83, 12, 3447, 940, 1866, 8516, 12, 450, 83, 16735, 199, 624, 450, 334, 6983, 28492, 3697, 12, 3874, 28492, 8516, 12, 1676, 8481, 83, 9, 199, 199, 318, 14316, 2543, 8, 4120, 304, 267, 4104, 1296, 275, 788, 16141, 83, 447, 344, 447, 7, 435, 4104, 367, 4104, 315, 5872, 14, 16141, 10720, 61, 267, 327, 510, 350, 734, 314, 769, 370, 314, 2451, 2582, 543, 485, 998, 63, 2353, 880, 781, 267, 327, 24197, 626, 1006, 314, 5548, 787, 314, 2011, 2582, 14, 221, 485, 998, 63, 2353, 267, 327, 365, 7078, 314, 2870, 402, 1263, 19393, 12, 880, 652, 1159, 5048, 370, 675, 465, 267, 327, 6273, 14, 267, 4104, 1296, 14, 2880, 2941, 16141, 83, 447, 344, 14201, 998, 63, 2353, 418, 627, 334, 4120, 14, 888, 14, 988, 8548, 10720, 4625, 446, 822, 8, 2625, 1296, 1724, 267, 19393, 10720, 1558, 275, 1656, 1987, 904, 8, 2625, 1296, 9, 267, 5438, 8481, 83, 275, 298, 8084, 2, 340, 5872, 14, 11009, 587, 11746, 19675, 8481, 83, 2, 267, 372, 408, 91, 523, 469, 450, 83, 1660, 523, 450, 83, 12, 450, 83, 199, 30437, 450, 334, 16141, 10720, 1558, 12, 370, 1558, 10349, 8, 4120, 14, 6106, 1831, 1311, 384, 5203, 395, 881, 5438, 8481, 83, 9, 199, 199, 533, 18657, 10462, 11378, 2543, 8, 4064, 32218, 304, 272, 408, 272, 7958, 282, 14316, 11378, 2543, 367, 282, 1627, 5872, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5872, 304, 267, 18657, 32218, 855, 826, 721, 277, 9, 267, 291, 14, 4120, 275, 5872, 272, 347, 20771, 8, 277, 304, 267, 372, 298, 18587, 14316, 11378, 2543, 8089, 3779, 78, 2, 272, 347, 5627, 8, 277, 304, 267, 3307, 8481, 275, 9074, 4121, 63, 28706, 63, 2339, 340, 291, 14, 4120, 14, 4229, 3921, 587, 283, 8084, 7, 267, 372, 408, 199, 10462, 11378, 2543, 8089, 275, 469, 523, 469, 2071, 83, 401, 272, 18001, 6885, 63, 1311, 63, 10462, 11378, 6885, 1204, 18001, 6885, 63, 13533, 63, 26933, 63, 32328, 51, 8, 17, 395, 272, 450, 83, 12, 13505, 1050, 3697, 11589, 272, 18001, 63, 3697, 8067, 12, 755, 13505, 2150, 3697, 11589, 272, 18001, 63, 3697, 8067, 12, 755, 13505, 664, 3697, 11589, 272, 18001 ]
[ 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 570, 12, 199, 3, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 3, 13964, 1233, 2268, 3992, 14, 199, 199, 646, 747, 199, 646, 1059, 199, 646, 4182, 199, 199, 504, 22817, 492, 627, 199, 504, 11595, 492, 23798, 4311, 547, 199, 199, 13883, 12795, 6989, 63, 9171, 63, 10973, 275, 971, 272, 3286, 10, 5749, 13024, 2281, 25420, 12795, 6989, 446, 3506, 2845, 24981, 9399, 78, 60, 78, 2, 199, 9732, 25091, 63, 28706, 63, 2339, 275, 2513, 525, 3697, 7, 199, 29270, 11025, 63, 28706, 63, 2339, 275, 2513, 14450, 7, 199, 20112, 63, 28706, 63, 2339, 275, 2513, 3446, 7, 199, 1864, 8893, 63, 28706, 63, 2339, 275, 2513, 1880, 7, 199, 13533, 18235, 63, 28706, 63, 2339, 275, 2513, 1989, 3244, 7, 199, 199, 318, 3350, 1173, 3917, 6970, 8, 1501, 12, 892, 11383, 304, 272, 408, 272, 5574, 282, 1331, 402, 314, 2269, 570, 12, 880, 626, 781, 2793, 1133, 12943, 652, 340, 652, 18699, 1133, 2896, 14, 272, 1803, 715, 340, 314, 570, 1990, 4588, 12, 3055, 4257, 14, 272, 408, 272, 2269, 1173, 11383, 275, 3087, 272, 862, 26, 267, 2269, 1173, 275, 1551, 8, 1501, 12, 283, 4848, 358, 267, 2269, 1173, 11383, 275, 6522, 904, 8, 1753, 1173, 14, 9684, 1012, 267, 2269, 1173, 14, 1600, 342, 272, 871, 26, 267, 986, 339, 340, 892, 11383, 508, 2269, 1173, 11383, 26, 267, 372, 756, 339, 289, 275, 1551, 8, 1501, 12, 283, 6603, 358, 272, 289, 14, 952, 8, 1222, 11383, 9, 272, 289, 14, 1600, 342, 199, 199, 318, 370, 1558, 10349, 8, 1273, 304, 272, 372, 620, 8, 1397, 440, 1680, 680, 2325, 342, 199, 199, 318, 370, 17490, 8814, 8, 1273, 304, 272, 372, 295, 14, 954, 480, 1332, 63, 11009, 5547, 4, 4186, 298, 17490, 1103, 17, 401, 1680, 2736, 199, 199, 533, 18657, 32218, 837, 272, 408, 272, 11836, 1300, 1021, 367, 7645, 626, 2249, 390, 734, 1233, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 986, 327, 20550, 367, 3063, 272, 347, 20771, 8, 277, 304, 267, 408, 24391, 1233, 367, 282, 1406, 570, 1041, 267, 702, 8, 797, 9, 221, 327, 11041, 562, 1, 272, 347, 5627, 8, 277, 304, 267, 408, 24391, 1233, 367, 282, 7246, 570, 1041, 267, 702, 8, 797, 9, 327, 11041, 562, 1, 199, 199, 533, 445, 15306, 1905, 3697, 8481, 83, 8, 4064, 32218, 304, 272, 408, 272, 7958, 282, 653, 1905, 3697, 8481, 83, 367, 282, 1627, 5872, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5872, 304, 267, 18657, 32218, 855, 826, 721, 277, 9, 267, 291, 14, 4120, 275, 5872, 272, 347, 20771, 8, 277, 304, 267, 340, 291, 14, 4120, 14, 11009, 26, 288, 372, 3087, 267, 372, 298, 18587, 950, 653, 1905, 3697, 8481, 83, 653, 1905, 8481, 83, 3779, 78, 2, 272, 347, 5627, 8, 277, 304, 267, 340, 291, 14, 4120, 14, 11009, 26, 288, 372, 3087, 267, 340, 291, 14, 4120, 14, 13455, 436, 291, 14, 4120, 14, 3280, 26, 288, 7512, 28492, 3697, 275, 298, 27459, 28492, 3697, 2, 288, 3874, 28492, 8516, 275, 298, 28858, 1866, 28492, 8516, 2, 267, 587, 26, 288, 3874, 28492, 8516, 275, 7512, 28492, 3697, 275, 298, 8084, 2, 267, 1676, 275, 291, 14, 4120, 14, 3266, 14, 1708, 267, 1676, 8481, 83, 275, 1689, 6, 2, 435, 370, 17490, 8814, 8, 1708, 14, 5364, 14, 354, 9, 435, 27472, 19675, 8481, 83, 2, 2432, 340, 1676, 587, 283, 8084, 358, 267, 372, 408, 199, 1297, 653, 1905, 3697, 8481, 83, 653, 1905, 8481, 83, 275, 469, 450, 83, 12, 31096, 3697, 12, 450, 83, 12, 3447, 940, 1866, 8516, 12, 450, 83, 16735, 199, 624, 450, 334, 6983, 28492, 3697, 12, 3874, 28492, 8516, 12, 1676, 8481, 83, 9, 199, 199, 318, 14316, 2543, 8, 4120, 304, 267, 4104, 1296, 275, 788, 16141, 83, 447, 344, 447, 7, 435, 4104, 367, 4104, 315, 5872, 14, 16141, 10720, 61, 267, 327, 510, 350, 734, 314, 769, 370, 314, 2451, 2582, 543, 485, 998, 63, 2353, 880, 781, 267, 327, 24197, 626, 1006, 314, 5548, 787, 314, 2011, 2582, 14, 221, 485, 998, 63, 2353, 267, 327, 365, 7078, 314, 2870, 402, 1263, 19393, 12, 880, 652, 1159, 5048, 370, 675, 465, 267, 327, 6273, 14, 267, 4104, 1296, 14, 2880, 2941, 16141, 83, 447, 344, 14201, 998, 63, 2353, 418, 627, 334, 4120, 14, 888, 14, 988, 8548, 10720, 4625, 446, 822, 8, 2625, 1296, 1724, 267, 19393, 10720, 1558, 275, 1656, 1987, 904, 8, 2625, 1296, 9, 267, 5438, 8481, 83, 275, 298, 8084, 2, 340, 5872, 14, 11009, 587, 11746, 19675, 8481, 83, 2, 267, 372, 408, 91, 523, 469, 450, 83, 1660, 523, 450, 83, 12, 450, 83, 199, 30437, 450, 334, 16141, 10720, 1558, 12, 370, 1558, 10349, 8, 4120, 14, 6106, 1831, 1311, 384, 5203, 395, 881, 5438, 8481, 83, 9, 199, 199, 533, 18657, 10462, 11378, 2543, 8, 4064, 32218, 304, 272, 408, 272, 7958, 282, 14316, 11378, 2543, 367, 282, 1627, 5872, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5872, 304, 267, 18657, 32218, 855, 826, 721, 277, 9, 267, 291, 14, 4120, 275, 5872, 272, 347, 20771, 8, 277, 304, 267, 372, 298, 18587, 14316, 11378, 2543, 8089, 3779, 78, 2, 272, 347, 5627, 8, 277, 304, 267, 3307, 8481, 275, 9074, 4121, 63, 28706, 63, 2339, 340, 291, 14, 4120, 14, 4229, 3921, 587, 283, 8084, 7, 267, 372, 408, 199, 10462, 11378, 2543, 8089, 275, 469, 523, 469, 2071, 83, 401, 272, 18001, 6885, 63, 1311, 63, 10462, 11378, 6885, 1204, 18001, 6885, 63, 13533, 63, 26933, 63, 32328, 51, 8, 17, 395, 272, 450, 83, 12, 13505, 1050, 3697, 11589, 272, 18001, 63, 3697, 8067, 12, 755, 13505, 2150, 3697, 11589, 272, 18001, 63, 3697, 8067, 12, 755, 13505, 664, 3697, 11589, 272, 18001, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rockyzhang/zhangyanhit-python-for-android-mips
python-modules/twisted/twisted/web/server.py
50
17004
# -*- test-case-name: twisted.web.test.test_web -*- # Copyright (c) 2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. """ This is a web-server which integrates with the twisted.internet infrastructure. """ # System Imports import warnings import string import types import copy import os from urllib import quote from zope.interface import implements try: from twisted.protocols._c_urlarg import unquote except ImportError: from urllib import unquote #some useful constants NOT_DONE_YET = 1 # Twisted Imports from twisted.spread import pb from twisted.internet import defer, address, task from twisted.web import iweb, http from twisted.python import log, reflect, failure, components from twisted import copyright from twisted.web import util as webutil, resource from twisted.web.error import UnsupportedMethod # backwards compatability date_time_string = http.datetimeToString string_date_time = http.stringToDatetime # Support for other methods may be implemented on a per-resource basis. supportedMethods = ('GET', 'HEAD', 'POST') def _addressToTuple(addr): if isinstance(addr, address.IPv4Address): return ('INET', addr.host, addr.port) elif isinstance(addr, address.UNIXAddress): return ('UNIX', addr.name) else: return tuple(addr) class Request(pb.Copyable, http.Request, components.Componentized): implements(iweb.IRequest) site = None appRootURL = None __pychecker__ = 'unusednames=issuer' def __init__(self, *args, **kw): http.Request.__init__(self, *args, **kw) components.Componentized.__init__(self) def getStateToCopyFor(self, issuer): x = self.__dict__.copy() del x['transport'] # XXX refactor this attribute out; it's from protocol # del x['server'] del x['channel'] del x['content'] del x['site'] self.content.seek(0, 0) x['content_data'] = self.content.read() x['remote'] = pb.ViewPoint(issuer, self) # Address objects aren't jellyable x['host'] = _addressToTuple(x['host']) x['client'] = _addressToTuple(x['client']) # Header objects also aren't jellyable. x['requestHeaders'] = list(x['requestHeaders'].getAllRawHeaders()) return x # HTML generation helpers def sibLink(self, name): "Return the text that links to a sibling of the requested resource." if self.postpath: return (len(self.postpath)*"../") + name else: return name def childLink(self, name): "Return the text that links to a child of the requested resource." lpp = len(self.postpath) if lpp > 1: return ((lpp-1)*"../") + name elif lpp == 1: return name else: # lpp == 0 if len(self.prepath) and self.prepath[-1]: return self.prepath[-1] + '/' + name else: return name def process(self): "Process a request." # get site from channel self.site = self.channel.site # set various default headers self.setHeader('server', version) self.setHeader('date', http.datetimeToString()) self.setHeader('content-type', "text/html") # Resource Identification self.prepath = [] self.postpath = map(unquote, string.split(self.path[1:], '/')) try: resrc = self.site.getResourceFor(self) self.render(resrc) except: self.processingFailed(failure.Failure()) def render(self, resrc): try: body = resrc.render(self) except UnsupportedMethod, e: allowedMethods = e.allowedMethods if (self.method == "HEAD") and ("GET" in allowedMethods): # We must support HEAD (RFC 2616, 5.1.1). If the # resource doesn't, fake it by giving the resource # a 'GET' request and then return only the headers, # not the body. log.msg("Using GET to fake a HEAD request for %s" % (resrc,)) self.method = "GET" body = resrc.render(self) if body is NOT_DONE_YET: log.msg("Tried to fake a HEAD request for %s, but " "it got away from me." % resrc) # Oh well, I guess we won't include the content length. else: self.setHeader('content-length', str(len(body))) self.write('') self.finish() return if self.method in (supportedMethods): # We MUST include an Allow header # (RFC 2616, 10.4.6 and 14.7) self.setHeader('Allow', allowedMethods) s = ('''Your browser approached me (at %(URI)s) with''' ''' the method "%(method)s". I only allow''' ''' the method%(plural)s %(allowed)s here.''' % { 'URI': self.uri, 'method': self.method, 'plural': ((len(allowedMethods) > 1) and 's') or '', 'allowed': string.join(allowedMethods, ', ') }) epage = resource.ErrorPage(http.NOT_ALLOWED, "Method Not Allowed", s) body = epage.render(self) else: epage = resource.ErrorPage(http.NOT_IMPLEMENTED, "Huh?", "I don't know how to treat a" " %s request." % (self.method,)) body = epage.render(self) # end except UnsupportedMethod if body == NOT_DONE_YET: return if type(body) is not types.StringType: body = resource.ErrorPage( http.INTERNAL_SERVER_ERROR, "Request did not return a string", "Request: " + html.PRE(reflect.safe_repr(self)) + "<br />" + "Resource: " + html.PRE(reflect.safe_repr(resrc)) + "<br />" + "Value: " + html.PRE(reflect.safe_repr(body))).render(self) if self.method == "HEAD": if len(body) > 0: # This is a Bad Thing (RFC 2616, 9.4) log.msg("Warning: HEAD request %s for resource %s is" " returning a message body." " I think I'll eat it." % (self, resrc)) self.setHeader('content-length', str(len(body))) self.write('') else: self.setHeader('content-length', str(len(body))) self.write(body) self.finish() def processingFailed(self, reason): log.err(reason) if self.site.displayTracebacks: body = ("<html><head><title>web.Server Traceback (most recent call last)</title></head>" "<body><b>web.Server Traceback (most recent call last):</b>\n\n" "%s\n\n</body></html>\n" % webutil.formatFailure(reason)) else: body = ("<html><head><title>Processing Failed</title></head><body>" "<b>Processing Failed</b></body></html>") self.setResponseCode(http.INTERNAL_SERVER_ERROR) self.setHeader('content-type',"text/html") self.setHeader('content-length', str(len(body))) self.write(body) self.finish() return reason def view_write(self, issuer, data): """Remote version of write; same interface. """ self.write(data) def view_finish(self, issuer): """Remote version of finish; same interface. """ self.finish() def view_addCookie(self, issuer, k, v, **kwargs): """Remote version of addCookie; same interface. """ self.addCookie(k, v, **kwargs) def view_setHeader(self, issuer, k, v): """Remote version of setHeader; same interface. """ self.setHeader(k, v) def view_setLastModified(self, issuer, when): """Remote version of setLastModified; same interface. """ self.setLastModified(when) def view_setETag(self, issuer, tag): """Remote version of setETag; same interface. """ self.setETag(tag) def view_setResponseCode(self, issuer, code): """Remote version of setResponseCode; same interface. """ self.setResponseCode(code) def view_registerProducer(self, issuer, producer, streaming): """Remote version of registerProducer; same interface. (requires a remote producer.) """ self.registerProducer(_RemoteProducerWrapper(producer), streaming) def view_unregisterProducer(self, issuer): self.unregisterProducer() ### these calls remain local session = None def getSession(self, sessionInterface = None): # Session management if not self.session: cookiename = string.join(['TWISTED_SESSION'] + self.sitepath, "_") sessionCookie = self.getCookie(cookiename) if sessionCookie: try: self.session = self.site.getSession(sessionCookie) except KeyError: pass # if it still hasn't been set, fix it up. if not self.session: self.session = self.site.makeSession() self.addCookie(cookiename, self.session.uid, path='/') self.session.touch() if sessionInterface: return self.session.getComponent(sessionInterface) return self.session def _prePathURL(self, prepath): port = self.getHost().port if self.isSecure(): default = 443 else: default = 80 if port == default: hostport = '' else: hostport = ':%d' % port return 'http%s://%s%s/%s' % ( self.isSecure() and 's' or '', self.getRequestHostname(), hostport, '/'.join([quote(segment, safe='') for segment in prepath])) def prePathURL(self): return self._prePathURL(self.prepath) def URLPath(self): from twisted.python import urlpath return urlpath.URLPath.fromRequest(self) def rememberRootURL(self): """ Remember the currently-processed part of the URL for later recalling. """ url = self._prePathURL(self.prepath[:-1]) self.appRootURL = url def getRootURL(self): """ Get a previously-remembered URL. """ return self.appRootURL class _RemoteProducerWrapper: def __init__(self, remote): self.resumeProducing = remote.remoteMethod("resumeProducing") self.pauseProducing = remote.remoteMethod("pauseProducing") self.stopProducing = remote.remoteMethod("stopProducing") class Session(components.Componentized): """ A user's session with a system. This utility class contains no functionality, but is used to represent a session. @ivar _reactor: An object providing L{IReactorTime} to use for scheduling expiration. @ivar sessionTimeout: timeout of a session, in seconds. @ivar loopFactory: Deprecated in Twisted 9.0. Does nothing. Do not use. """ sessionTimeout = 900 loopFactory = task.LoopingCall _expireCall = None def __init__(self, site, uid, reactor=None): """ Initialize a session with a unique ID for that session. """ components.Componentized.__init__(self) if reactor is None: from twisted.internet import reactor self._reactor = reactor self.site = site self.uid = uid self.expireCallbacks = [] self.touch() self.sessionNamespaces = {} def startCheckingExpiration(self, lifetime=None): """ Start expiration tracking. @param lifetime: Ignored; deprecated. @return: C{None} """ if lifetime is not None: warnings.warn( "The lifetime parameter to startCheckingExpiration is " "deprecated since Twisted 9.0. See Session.sessionTimeout " "instead.", DeprecationWarning, stacklevel=2) self._expireCall = self._reactor.callLater( self.sessionTimeout, self.expire) def notifyOnExpire(self, callback): """ Call this callback when the session expires or logs out. """ self.expireCallbacks.append(callback) def expire(self): """ Expire/logout of the session. """ del self.site.sessions[self.uid] for c in self.expireCallbacks: c() self.expireCallbacks = [] if self._expireCall and self._expireCall.active(): self._expireCall.cancel() # Break reference cycle. self._expireCall = None def touch(self): """ Notify session modification. """ self.lastModified = self._reactor.seconds() if self._expireCall is not None: self._expireCall.reset(self.sessionTimeout) def checkExpired(self): """ Deprecated; does nothing. """ warnings.warn( "Session.checkExpired is deprecated since Twisted 9.0; sessions " "check themselves now, you don't need to.", stacklevel=2, category=DeprecationWarning) version = "TwistedWeb/%s" % copyright.version class Site(http.HTTPFactory): """ A web site: manage log, sessions, and resources. @ivar counter: increment value used for generating unique sessions ID. @ivar requestFactory: factory creating requests objects. Default to L{Request}. @ivar displayTracebacks: if set, Twisted internal errors are displayed on rendered pages. Default to C{True}. @ivar sessionFactory: factory for sessions objects. Default to L{Session}. @ivar sessionCheckTime: Deprecated. See L{Session.sessionTimeout} instead. """ counter = 0 requestFactory = Request displayTracebacks = True sessionFactory = Session sessionCheckTime = 1800 def __init__(self, resource, logPath=None, timeout=60*60*12): """ Initialize. """ http.HTTPFactory.__init__(self, logPath=logPath, timeout=timeout) self.sessions = {} self.resource = resource def _openLogFile(self, path): from twisted.python import logfile return logfile.LogFile(os.path.basename(path), os.path.dirname(path)) def __getstate__(self): d = self.__dict__.copy() d['sessions'] = {} return d def _mkuid(self): """ (internal) Generate an opaque, unique ID for a user's session. """ from twisted.python.hashlib import md5 import random self.counter = self.counter + 1 return md5("%s_%s" % (str(random.random()) , str(self.counter))).hexdigest() def makeSession(self): """ Generate a new Session instance, and store it for future reference. """ uid = self._mkuid() session = self.sessions[uid] = self.sessionFactory(self, uid) session.startCheckingExpiration() return session def getSession(self, uid): """ Get a previously generated session, by its unique ID. This raises a KeyError if the session is not found. """ return self.sessions[uid] def buildProtocol(self, addr): """ Generate a channel attached to this site. """ channel = http.HTTPFactory.buildProtocol(self, addr) channel.requestFactory = self.requestFactory channel.site = self return channel isLeaf = 0 def render(self, request): """ Redirect because a Site is always a directory. """ request.redirect(request.prePathURL() + '/') request.finish() def getChildWithDefault(self, pathEl, request): """ Emulate a resource's getChild method. """ request.site = self return self.resource.getChildWithDefault(pathEl, request) def getResourceFor(self, request): """ Get a resource for a request. This iterates through the resource heirarchy, calling getChildWithDefault on each resource it finds for a path element, stopping when it hits an element where isLeaf is true. """ request.site = self # Sitepath is used to determine cookie names between distributed # servers and disconnected sites. request.sitepath = copy.copy(request.prepath) return resource.getChildForRequest(self.resource, request) import html
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2520, 14, 396, 14, 396, 63, 2520, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 2765, 365, 282, 3330, 13, 1000, 1314, 21494, 83, 543, 314, 7390, 14, 4901, 199, 19505, 6976, 14, 199, 624, 199, 199, 3, 6187, 24339, 199, 199, 646, 3598, 199, 646, 1059, 199, 646, 2943, 199, 646, 1331, 199, 646, 747, 199, 504, 4011, 492, 6313, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 893, 26, 272, 687, 7390, 14, 16541, 423, 67, 63, 633, 1273, 492, 14342, 199, 2590, 3545, 26, 272, 687, 4011, 492, 14342, 199, 199, 3, 3972, 2997, 5262, 199, 4609, 63, 22162, 63, 57, 775, 275, 413, 199, 199, 3, 17078, 24339, 199, 504, 7390, 14, 29889, 492, 10446, 199, 504, 7390, 14, 4901, 492, 10133, 12, 2287, 12, 2120, 199, 504, 7390, 14, 2520, 492, 284, 2520, 12, 1455, 199, 504, 7390, 14, 1548, 492, 943, 12, 16806, 12, 5988, 12, 7323, 199, 504, 7390, 492, 4248, 199, 504, 7390, 14, 2520, 492, 4884, 465, 781, 464, 2270, 12, 2073, 199, 504, 7390, 14, 2520, 14, 705, 492, 19022, 3767, 199, 199, 3, 8552, 1013, 1936, 2012, 199, 602, 63, 521, 63, 875, 275, 1455, 14, 2083, 7756, 199, 875, 63, 602, 63, 521, 275, 1455, 14, 875, 1378, 19636, 199, 199, 3, 12502, 367, 1163, 3102, 1443, 506, 6366, 641, 282, 1126, 13, 1927, 5597, 14, 199, 4946, 10385, 275, 661, 2970, 297, 283, 5211, 297, 283, 4030, 358, 421, 199, 318, 485, 1562, 1378, 7075, 8, 2697, 304, 272, 340, 1228, 8, 2697, 12, 2287, 14, 12179, 20, 1476, 304, 267, 372, 661, 11367, 297, 5552, 14, 1102, 12, 5552, 14, 719, 9, 272, 916, 1228, 8, 2697, 12, 2287, 14, 19584, 1476, 304, 267, 372, 661, 19584, 297, 5552, 14, 354, 9, 272, 587, 26, 267, 372, 2008, 8, 2697, 9, 199, 199, 533, 4784, 8, 3317, 14, 5116, 461, 12, 1455, 14, 2017, 12, 7323, 14, 2404, 265, 287, 22927, 304, 272, 9031, 8, 73, 2520, 14, 41, 2017, 9, 339, 4770, 275, 488, 272, 1145, 6405, 2632, 275, 488, 272, 636, 647, 6743, 363, 275, 283, 8618, 1247, 29, 26484, 7, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1455, 14, 2017, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 7323, 14, 2404, 265, 287, 22927, 855, 826, 721, 277, 9, 339, 347, 664, 2223, 1378, 5116, 1858, 8, 277, 12, 365, 20166, 304, 267, 671, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 671, 459, 5545, 418, 267, 327, 5787, 24200, 642, 2225, 734, 27, 652, 1159, 687, 4113, 267, 327, 2150, 671, 459, 1000, 418, 267, 2150, 671, 459, 2775, 418, 267, 2150, 671, 459, 1317, 418, 267, 2150, 671, 459, 2124, 418, 267, 291, 14, 1317, 14, 5507, 8, 16, 12, 378, 9, 267, 671, 459, 1317, 63, 576, 418, 275, 291, 14, 1317, 14, 739, 342, 267, 671, 459, 3846, 418, 275, 10446, 14, 2768, 3428, 8, 26484, 12, 291, 9, 398, 327, 9906, 2251, 10621, 1133, 1335, 29051, 461, 267, 671, 459, 1102, 418, 275, 485, 1562, 1378, 7075, 8, 88, 459, 1102, 1105, 267, 671, 459, 1258, 418, 275, 485, 1562, 1378, 7075, 8, 88, 459, 1258, 1105, 398, 327, 10240, 2251, 2597, 10621, 1133, 1335, 29051, 461, 14, 267, 671, 459, 1069, 9883, 418, 275, 769, 8, 88, 459, 1069, 9883, 2278, 31359, 7963, 9883, 1012, 398, 372, 671, 339, 327, 4163, 10152, 10897, 339, 347, 20417, 3834, 8, 277, 12, 536, 304, 267, 298, 1767, 314, 1318, 626, 6220, 370, 282, 24238, 402, 314, 5839, 2073, 2122, 267, 340, 291, 14, 1932, 515, 26, 288, 372, 334, 552, 8, 277, 14, 1932, 515, 3342, 2, 5093, 531, 435, 536, 267, 587, 26, 288, 372, 536, 339, 347, 1982, 3834, 8, 277, 12, 536, 304, 267, 298, 1767, 314, 1318, 626, 6220, 370, 282, 1982, 402, 314, 5839, 2073, 2122, 267, 634, 802, 275, 822, 8, 277, 14, 1932, 515, 9, 267, 340, 634, 802, 690, 413, 26, 288, 372, 3666, 76, 802, 13, 17, 3342, 2, 5093, 531, 435, 536, 267, 916, 634, 802, 508, 413, 26, 288, 372, 536, 267, 587, 26, 327, 634, 802, 508, 378, 288, 340, 822, 8, 277, 14, 657, 515, 9, 436, 291, 14, 657, 515, 1988, 17, 2189, 355, 372, 291, 14, 657, 515, 1988, 17, 61, 435, 7324, 435, 536, 288, 587, 26, 355, 372, 536, 339, 347, 2112, 8, 277, 304, 267, 298, 3498, 282, 1056, 2122, 398, 327, 664, 4770, 687, 3623, 267, 291, 14, 2124, 275, 291, 14, 2775, 14, 2124, 398, 327, 663, 7750, 849, 2323, 267, 291, 14, 409, 2567, 360, 1000, 297, 1015, 9, 267, 291, 14, 409, 2567, 360, 602, 297, 1455, 14, 2083, 7756, 1012, 267, 291, 14, 409, 2567, 360, 1317, 13, 466, 297, 298, 505, 15, 1360, 531, 398, 327, 7337, 473, 24926, 267, 291, 14, 657, 515, 275, 942, 267, 291, 14, 1932, 515, 275, 2341, 8, 12240, 12, 1059, 14, 1294, 8, 277, 14, 515, 59, 17, 8429, 1994, 1333, 267, 862, 26, 288, 522, 1195, 275, 291, 14, 2124, 14, 362, 4031, 1858, 8, 277, 9, 288, 291, 14, 3352, 8, 470, 1195, 9, 267, 871, 26, 288, 291, 14, 6338, 4276, 8, 5328, 14, 6782, 1012, 2378, 347, 3795, 8, 277, 12, 522, 1195, 304, 267, 862, 26, 288, 2396, 275, 522, 1195, 14, 3352, 8, 277, 9, 267, 871, 19022, 3767, 12, 325, 26, 288, 4370, 10385, 275, 325, 14, 6541, 10385, 288, 340, 334, 277, 14, 765, 508, 298, 5211, 531, 436, 1689, 2970, 2, 315, 4370, 10385, 304, 355, 327, 2136, 1471, 2291, 13053, 334, 14468, 7875, 975, 12, 959, 14, 17, 14, 17, 680, 221, 982, 314, 355, 327, 2073, 3181, 1133, 12, 4026, 652, 701, 15131, 314, 2073, 355, 327, 282, 283, 2970, 7, 1056, 436, 2066, 372, 1454, 314, 2323, 12, 355, 327, 440, 314, 2396, 14, 355, 943, 14, 1328, 480 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 2520, 14, 396, 14, 396, 63, 2520, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 2765, 365, 282, 3330, 13, 1000, 1314, 21494, 83, 543, 314, 7390, 14, 4901, 199, 19505, 6976, 14, 199, 624, 199, 199, 3, 6187, 24339, 199, 199, 646, 3598, 199, 646, 1059, 199, 646, 2943, 199, 646, 1331, 199, 646, 747, 199, 504, 4011, 492, 6313, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 893, 26, 272, 687, 7390, 14, 16541, 423, 67, 63, 633, 1273, 492, 14342, 199, 2590, 3545, 26, 272, 687, 4011, 492, 14342, 199, 199, 3, 3972, 2997, 5262, 199, 4609, 63, 22162, 63, 57, 775, 275, 413, 199, 199, 3, 17078, 24339, 199, 504, 7390, 14, 29889, 492, 10446, 199, 504, 7390, 14, 4901, 492, 10133, 12, 2287, 12, 2120, 199, 504, 7390, 14, 2520, 492, 284, 2520, 12, 1455, 199, 504, 7390, 14, 1548, 492, 943, 12, 16806, 12, 5988, 12, 7323, 199, 504, 7390, 492, 4248, 199, 504, 7390, 14, 2520, 492, 4884, 465, 781, 464, 2270, 12, 2073, 199, 504, 7390, 14, 2520, 14, 705, 492, 19022, 3767, 199, 199, 3, 8552, 1013, 1936, 2012, 199, 602, 63, 521, 63, 875, 275, 1455, 14, 2083, 7756, 199, 875, 63, 602, 63, 521, 275, 1455, 14, 875, 1378, 19636, 199, 199, 3, 12502, 367, 1163, 3102, 1443, 506, 6366, 641, 282, 1126, 13, 1927, 5597, 14, 199, 4946, 10385, 275, 661, 2970, 297, 283, 5211, 297, 283, 4030, 358, 421, 199, 318, 485, 1562, 1378, 7075, 8, 2697, 304, 272, 340, 1228, 8, 2697, 12, 2287, 14, 12179, 20, 1476, 304, 267, 372, 661, 11367, 297, 5552, 14, 1102, 12, 5552, 14, 719, 9, 272, 916, 1228, 8, 2697, 12, 2287, 14, 19584, 1476, 304, 267, 372, 661, 19584, 297, 5552, 14, 354, 9, 272, 587, 26, 267, 372, 2008, 8, 2697, 9, 199, 199, 533, 4784, 8, 3317, 14, 5116, 461, 12, 1455, 14, 2017, 12, 7323, 14, 2404, 265, 287, 22927, 304, 272, 9031, 8, 73, 2520, 14, 41, 2017, 9, 339, 4770, 275, 488, 272, 1145, 6405, 2632, 275, 488, 272, 636, 647, 6743, 363, 275, 283, 8618, 1247, 29, 26484, 7, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1455, 14, 2017, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 7323, 14, 2404, 265, 287, 22927, 855, 826, 721, 277, 9, 339, 347, 664, 2223, 1378, 5116, 1858, 8, 277, 12, 365, 20166, 304, 267, 671, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 671, 459, 5545, 418, 267, 327, 5787, 24200, 642, 2225, 734, 27, 652, 1159, 687, 4113, 267, 327, 2150, 671, 459, 1000, 418, 267, 2150, 671, 459, 2775, 418, 267, 2150, 671, 459, 1317, 418, 267, 2150, 671, 459, 2124, 418, 267, 291, 14, 1317, 14, 5507, 8, 16, 12, 378, 9, 267, 671, 459, 1317, 63, 576, 418, 275, 291, 14, 1317, 14, 739, 342, 267, 671, 459, 3846, 418, 275, 10446, 14, 2768, 3428, 8, 26484, 12, 291, 9, 398, 327, 9906, 2251, 10621, 1133, 1335, 29051, 461, 267, 671, 459, 1102, 418, 275, 485, 1562, 1378, 7075, 8, 88, 459, 1102, 1105, 267, 671, 459, 1258, 418, 275, 485, 1562, 1378, 7075, 8, 88, 459, 1258, 1105, 398, 327, 10240, 2251, 2597, 10621, 1133, 1335, 29051, 461, 14, 267, 671, 459, 1069, 9883, 418, 275, 769, 8, 88, 459, 1069, 9883, 2278, 31359, 7963, 9883, 1012, 398, 372, 671, 339, 327, 4163, 10152, 10897, 339, 347, 20417, 3834, 8, 277, 12, 536, 304, 267, 298, 1767, 314, 1318, 626, 6220, 370, 282, 24238, 402, 314, 5839, 2073, 2122, 267, 340, 291, 14, 1932, 515, 26, 288, 372, 334, 552, 8, 277, 14, 1932, 515, 3342, 2, 5093, 531, 435, 536, 267, 587, 26, 288, 372, 536, 339, 347, 1982, 3834, 8, 277, 12, 536, 304, 267, 298, 1767, 314, 1318, 626, 6220, 370, 282, 1982, 402, 314, 5839, 2073, 2122, 267, 634, 802, 275, 822, 8, 277, 14, 1932, 515, 9, 267, 340, 634, 802, 690, 413, 26, 288, 372, 3666, 76, 802, 13, 17, 3342, 2, 5093, 531, 435, 536, 267, 916, 634, 802, 508, 413, 26, 288, 372, 536, 267, 587, 26, 327, 634, 802, 508, 378, 288, 340, 822, 8, 277, 14, 657, 515, 9, 436, 291, 14, 657, 515, 1988, 17, 2189, 355, 372, 291, 14, 657, 515, 1988, 17, 61, 435, 7324, 435, 536, 288, 587, 26, 355, 372, 536, 339, 347, 2112, 8, 277, 304, 267, 298, 3498, 282, 1056, 2122, 398, 327, 664, 4770, 687, 3623, 267, 291, 14, 2124, 275, 291, 14, 2775, 14, 2124, 398, 327, 663, 7750, 849, 2323, 267, 291, 14, 409, 2567, 360, 1000, 297, 1015, 9, 267, 291, 14, 409, 2567, 360, 602, 297, 1455, 14, 2083, 7756, 1012, 267, 291, 14, 409, 2567, 360, 1317, 13, 466, 297, 298, 505, 15, 1360, 531, 398, 327, 7337, 473, 24926, 267, 291, 14, 657, 515, 275, 942, 267, 291, 14, 1932, 515, 275, 2341, 8, 12240, 12, 1059, 14, 1294, 8, 277, 14, 515, 59, 17, 8429, 1994, 1333, 267, 862, 26, 288, 522, 1195, 275, 291, 14, 2124, 14, 362, 4031, 1858, 8, 277, 9, 288, 291, 14, 3352, 8, 470, 1195, 9, 267, 871, 26, 288, 291, 14, 6338, 4276, 8, 5328, 14, 6782, 1012, 2378, 347, 3795, 8, 277, 12, 522, 1195, 304, 267, 862, 26, 288, 2396, 275, 522, 1195, 14, 3352, 8, 277, 9, 267, 871, 19022, 3767, 12, 325, 26, 288, 4370, 10385, 275, 325, 14, 6541, 10385, 288, 340, 334, 277, 14, 765, 508, 298, 5211, 531, 436, 1689, 2970, 2, 315, 4370, 10385, 304, 355, 327, 2136, 1471, 2291, 13053, 334, 14468, 7875, 975, 12, 959, 14, 17, 14, 17, 680, 221, 982, 314, 355, 327, 2073, 3181, 1133, 12, 4026, 652, 701, 15131, 314, 2073, 355, 327, 282, 283, 2970, 7, 1056, 436, 2066, 372, 1454, 314, 2323, 12, 355, 327, 440, 314, 2396, 14, 355, 943, 14, 1328, 480, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lindsayad/sympy
sympy/logic/algorithms/dpll2.py
71
21116
"""Implementation of DPLL algorithm Features: - Clause learning - Watch literal scheme - VSIDS heuristic References: - http://en.wikipedia.org/wiki/DPLL_algorithm """ from __future__ import print_function, division from collections import defaultdict from heapq import heappush, heappop from sympy.core.compatibility import range from sympy import default_sort_key, ordered from sympy.logic.boolalg import conjuncts, to_cnf, to_int_repr, _find_predicates def dpll_satisfiable(expr, all_models=False): """ Check satisfiability of a propositional sentence. It returns a model rather than True when it succeeds. Returns a generator of all models if all_models is True. Examples ======== >>> from sympy.abc import A, B >>> from sympy.logic.algorithms.dpll2 import dpll_satisfiable >>> dpll_satisfiable(A & ~B) {A: True, B: False} >>> dpll_satisfiable(A & ~A) False """ clauses = conjuncts(to_cnf(expr)) if False in clauses: if all_models: return (f for f in [False]) return False symbols = sorted(_find_predicates(expr), key=default_sort_key) symbols_int_repr = range(1, len(symbols) + 1) clauses_int_repr = to_int_repr(clauses, symbols) solver = SATSolver(clauses_int_repr, symbols_int_repr, set(), symbols) models = solver._find_model() if all_models: return _all_models(models) try: return next(models) except StopIteration: return False # Uncomment to confirm the solution is valid (hitting set for the clauses) #else: #for cls in clauses_int_repr: #assert solver.var_settings.intersection(cls) def _all_models(models): satisfiable = False try: while True: yield next(models) satisfiable = True except StopIteration: if not satisfiable: yield False class SATSolver(object): """ Class for representing a SAT solver capable of finding a model to a boolean theory in conjunctive normal form. """ def __init__(self, clauses, variables, var_settings, symbols=None, heuristic='vsids', clause_learning='none', INTERVAL=500): self.var_settings = var_settings self.heuristic = heuristic self.is_unsatisfied = False self._unit_prop_queue = [] self.update_functions = [] self.INTERVAL = INTERVAL if symbols is None: self.symbols = list(ordered(variables)) else: self.symbols = symbols self._initialize_variables(variables) self._initialize_clauses(clauses) if 'vsids' == heuristic: self._vsids_init() self.heur_calculate = self._vsids_calculate self.heur_lit_assigned = self._vsids_lit_assigned self.heur_lit_unset = self._vsids_lit_unset self.heur_clause_added = self._vsids_clause_added # Note: Uncomment this if/when clause learning is enabled #self.update_functions.append(self._vsids_decay) else: raise NotImplementedError if 'simple' == clause_learning: self.add_learned_clause = self._simple_add_learned_clause self.compute_conflict = self.simple_compute_conflict self.update_functions.append(self.simple_clean_clauses) elif 'none' == clause_learning: self.add_learned_clause = lambda x: None self.compute_conflict = lambda: None else: raise NotImplementedError # Create the base level self.levels = [Level(0)] self._current_level.varsettings = var_settings # Keep stats self.num_decisions = 0 self.num_learned_clauses = 0 self.original_num_clauses = len(self.clauses) def _initialize_variables(self, variables): """Set up the variable data structures needed.""" self.sentinels = defaultdict(set) self.occurrence_count = defaultdict(int) self.variable_set = [False] * (len(variables) + 1) def _initialize_clauses(self, clauses): """Set up the clause data structures needed. For each clause, the following changes are made: - Unit clauses are queued for propagation right away. - Non-unit clauses have their first and last literals set as sentinels. - The number of clauses a literal appears in is computed. """ self.clauses = [] for cls in clauses: self.clauses.append(list(cls)) for i in range(len(self.clauses)): # Handle the unit clauses if 1 == len(self.clauses[i]): self._unit_prop_queue.append(self.clauses[i][0]) continue self.sentinels[self.clauses[i][0]].add(i) self.sentinels[self.clauses[i][-1]].add(i) for lit in self.clauses[i]: self.occurrence_count[lit] += 1 def _find_model(self): """ Main DPLL loop. Returns a generator of models. Variables are chosen successively, and assigned to be either True or False. If a solution is not found with this setting, the opposite is chosen and the search continues. The solver halts when every variable has a setting. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> list(l._find_model()) [{1: True, 2: False, 3: False}, {1: True, 2: True, 3: True}] >>> from sympy.abc import A, B, C >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([]), [A, B, C]) >>> list(l._find_model()) [{A: True, B: False, C: False}, {A: True, B: True, C: True}] """ # We use this variable to keep track of if we should flip a # variable setting in successive rounds flip_var = False # Check if unit prop says the theory is unsat right off the bat self._simplify() if self.is_unsatisfied: return # While the theory still has clauses remaining while True: # Perform cleanup / fixup at regular intervals if self.num_decisions % self.INTERVAL == 0: for func in self.update_functions: func() if flip_var: # We have just backtracked and we are trying to opposite literal flip_var = False lit = self._current_level.decision else: # Pick a literal to set lit = self.heur_calculate() self.num_decisions += 1 # Stopping condition for a satisfying theory if 0 == lit: yield dict((self.symbols[abs(lit) - 1], lit > 0) for lit in self.var_settings) while self._current_level.flipped: self._undo() if len(self.levels) == 1: return flip_lit = -self._current_level.decision self._undo() self.levels.append(Level(flip_lit, flipped=True)) flip_var = True continue # Start the new decision level self.levels.append(Level(lit)) # Assign the literal, updating the clauses it satisfies self._assign_literal(lit) # _simplify the theory self._simplify() # Check if we've made the theory unsat if self.is_unsatisfied: self.is_unsatisfied = False # We unroll all of the decisions until we can flip a literal while self._current_level.flipped: self._undo() # If we've unrolled all the way, the theory is unsat if 1 == len(self.levels): return # Detect and add a learned clause self.add_learned_clause(self.compute_conflict()) # Try the opposite setting of the most recent decision flip_lit = -self._current_level.decision self._undo() self.levels.append(Level(flip_lit, flipped=True)) flip_var = True ######################## # Helper Methods # ######################## @property def _current_level(self): """The current decision level data structure Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([1]), set([2])], set([1, 2]), set([])) >>> next(l._find_model()) {1: True, 2: True} >>> l._current_level.decision 0 >>> l._current_level.flipped False >>> l._current_level.var_settings set([1, 2]) """ return self.levels[-1] def _clause_sat(self, cls): """Check if a clause is satisfied by the current variable setting. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([1]), set([-1])], set([1]), set([])) >>> try: ... next(l._find_model()) ... except StopIteration: ... pass >>> l._clause_sat(0) False >>> l._clause_sat(1) True """ for lit in self.clauses[cls]: if lit in self.var_settings: return True return False def _is_sentinel(self, lit, cls): """Check if a literal is a sentinel of a given clause. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> next(l._find_model()) {1: True, 2: False, 3: False} >>> l._is_sentinel(2, 3) True >>> l._is_sentinel(-3, 1) False """ return cls in self.sentinels[lit] def _assign_literal(self, lit): """Make a literal assignment. The literal assignment must be recorded as part of the current decision level. Additionally, if the literal is marked as a sentinel of any clause, then a new sentinel must be chosen. If this is not possible, then unit propagation is triggered and another literal is added to the queue to be set in the future. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> next(l._find_model()) {1: True, 2: False, 3: False} >>> l.var_settings set([-3, -2, 1]) >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l._assign_literal(-1) >>> try: ... next(l._find_model()) ... except StopIteration: ... pass >>> l.var_settings set([-1]) """ self.var_settings.add(lit) self._current_level.var_settings.add(lit) self.variable_set[abs(lit)] = True self.heur_lit_assigned(lit) sentinel_list = list(self.sentinels[-lit]) for cls in sentinel_list: if not self._clause_sat(cls): other_sentinel = None for newlit in self.clauses[cls]: if newlit != -lit: if self._is_sentinel(newlit, cls): other_sentinel = newlit elif not self.variable_set[abs(newlit)]: self.sentinels[-lit].remove(cls) self.sentinels[newlit].add(cls) other_sentinel = None break # Check if no sentinel update exists if other_sentinel: self._unit_prop_queue.append(other_sentinel) def _undo(self): """ _undo the changes of the most recent decision level. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> next(l._find_model()) {1: True, 2: False, 3: False} >>> level = l._current_level >>> level.decision, level.var_settings, level.flipped (-3, set([-3, -2]), False) >>> l._undo() >>> level = l._current_level >>> level.decision, level.var_settings, level.flipped (0, set([1]), False) """ # Undo the variable settings for lit in self._current_level.var_settings: self.var_settings.remove(lit) self.heur_lit_unset(lit) self.variable_set[abs(lit)] = False # Pop the level off the stack self.levels.pop() ######################### # Propagation # ######################### """ Propagation methods should attempt to soundly simplify the boolean theory, and return True if any simplification occurred and False otherwise. """ def _simplify(self): """Iterate over the various forms of propagation to simplify the theory. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.variable_set [False, False, False, False] >>> l.sentinels {-3: set([0, 2]), -2: set([3, 4]), 2: set([0, 3]), 3: set([2, 4])} >>> l._simplify() >>> l.variable_set [False, True, False, False] >>> l.sentinels {-3: set([0, 2]), -2: set([3, 4]), -1: set(), 2: set([0, 3]), ...3: set([2, 4])} """ changed = True while changed: changed = False changed |= self._unit_prop() changed |= self._pure_literal() def _unit_prop(self): """Perform unit propagation on the current theory.""" result = len(self._unit_prop_queue) > 0 while self._unit_prop_queue: next_lit = self._unit_prop_queue.pop() if -next_lit in self.var_settings: self.is_unsatisfied = True self._unit_prop_queue = [] return False else: self._assign_literal(next_lit) return result def _pure_literal(self): """Look for pure literals and assign them when found.""" return False ######################### # Heuristics # ######################### def _vsids_init(self): """Initialize the data structures needed for the VSIDS heuristic.""" self.lit_heap = [] self.lit_scores = {} for var in range(1, len(self.variable_set)): self.lit_scores[var] = float(-self.occurrence_count[var]) self.lit_scores[-var] = float(-self.occurrence_count[-var]) heappush(self.lit_heap, (self.lit_scores[var], var)) heappush(self.lit_heap, (self.lit_scores[-var], -var)) def _vsids_decay(self): """Decay the VSIDS scores for every literal. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.lit_scores {-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0} >>> l._vsids_decay() >>> l.lit_scores {-3: -1.0, -2: -1.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -1.0} """ # We divide every literal score by 2 for a decay factor # Note: This doesn't change the heap property for lit in self.lit_scores.keys(): self.lit_scores[lit] /= 2.0 def _vsids_calculate(self): """ VSIDS Heuristic Calculation Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.lit_heap [(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)] >>> l._vsids_calculate() -3 >>> l.lit_heap [(-2.0, -2), (-2.0, 2), (0.0, -1), (0.0, 1), (-2.0, 3)] """ if len(self.lit_heap) == 0: return 0 # Clean out the front of the heap as long the variables are set while self.variable_set[abs(self.lit_heap[0][1])]: heappop(self.lit_heap) if len(self.lit_heap) == 0: return 0 return heappop(self.lit_heap)[1] def _vsids_lit_assigned(self, lit): """Handle the assignment of a literal for the VSIDS heuristic.""" pass def _vsids_lit_unset(self, lit): """Handle the unsetting of a literal for the VSIDS heuristic. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.lit_heap [(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)] >>> l._vsids_lit_unset(2) >>> l.lit_heap [(-2.0, -3), (-2.0, -2), (-2.0, -2), (-2.0, 2), (-2.0, 3), (0.0, -1), ...(-2.0, 2), (0.0, 1)] """ var = abs(lit) heappush(self.lit_heap, (self.lit_scores[var], var)) heappush(self.lit_heap, (self.lit_scores[-var], -var)) def _vsids_clause_added(self, cls): """Handle the addition of a new clause for the VSIDS heuristic. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.num_learned_clauses 0 >>> l.lit_scores {-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0} >>> l._vsids_clause_added(set([2, -3])) >>> l.num_learned_clauses 1 >>> l.lit_scores {-3: -1.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -2.0} """ self.num_learned_clauses += 1 for lit in cls: self.lit_scores[lit] += 1 ######################## # Clause Learning # ######################## def _simple_add_learned_clause(self, cls): """Add a new clause to the theory. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> l.num_learned_clauses 0 >>> l.clauses [[2, -3], [1], [3, -3], [2, -2], [3, -2]] >>> l.sentinels {-3: set([0, 2]), -2: set([3, 4]), 2: set([0, 3]), 3: set([2, 4])} >>> l._simple_add_learned_clause([3]) >>> l.clauses [[2, -3], [1], [3, -3], [2, -2], [3, -2], [3]] >>> l.sentinels {-3: set([0, 2]), -2: set([3, 4]), 2: set([0, 3]), 3: set([2, 4, 5])} """ cls_num = len(self.clauses) self.clauses.append(cls) for lit in cls: self.occurrence_count[lit] += 1 self.sentinels[cls[0]].add(cls_num) self.sentinels[cls[-1]].add(cls_num) self.heur_clause_added(cls) def _simple_compute_conflict(self): """ Build a clause representing the fact that at least one decision made so far is wrong. Examples ======== >>> from sympy.logic.algorithms.dpll2 import SATSolver >>> l = SATSolver([set([2, -3]), set([1]), set([3, -3]), set([2, -2]), ... set([3, -2])], set([1, 2, 3]), set([])) >>> next(l._find_model()) {1: True, 2: False, 3: False} >>> l._simple_compute_conflict() [3] """ return [-(level.decision) for level in self.levels[1:]] def _simple_clean_clauses(self): """Clean up learned clauses.""" pass class Level(object): """ Represents a single level in the DPLL algorithm, and contains enough information for a sound backtracking procedure. """ def __init__(self, decision, flipped=False): self.decision = decision self.var_settings = set() self.flipped = flipped
bsd-3-clause
[ 624, 7921, 402, 577, 2749, 44, 5563, 199, 199, 10807, 26, 523, 446, 24433, 1180, 9328, 523, 446, 29075, 8785, 5687, 523, 446, 812, 19514, 51, 25332, 199, 199, 15242, 26, 523, 446, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 36, 2749, 44, 63, 8833, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5055, 492, 10018, 199, 504, 13295, 81, 492, 946, 571, 2084, 12, 946, 571, 411, 199, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 492, 849, 63, 3191, 63, 498, 12, 7741, 199, 504, 5840, 14, 15370, 14, 2245, 6731, 492, 14643, 324, 3021, 12, 370, 63, 23600, 12, 370, 63, 442, 63, 2722, 12, 485, 1623, 63, 14463, 83, 421, 199, 318, 12392, 914, 63, 18270, 24183, 8, 3684, 12, 1006, 63, 992, 29, 797, 304, 272, 408, 272, 2670, 13529, 329, 3616, 402, 282, 557, 17867, 14537, 14, 272, 2779, 2529, 282, 1402, 7830, 2419, 715, 1380, 652, 24611, 14, 272, 1803, 282, 4306, 402, 1006, 1709, 340, 1006, 63, 992, 365, 715, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 14, 3175, 492, 437, 12, 699, 272, 1306, 687, 5840, 14, 15370, 14, 24365, 14, 5780, 914, 18, 492, 12392, 914, 63, 18270, 24183, 272, 1306, 12392, 914, 63, 18270, 24183, 8, 33, 1253, 6146, 34, 9, 272, 469, 33, 26, 715, 12, 699, 26, 756, 93, 272, 1306, 12392, 914, 63, 18270, 24183, 8, 33, 1253, 6146, 33, 9, 272, 756, 339, 408, 272, 25089, 275, 14643, 324, 3021, 8, 475, 63, 23600, 8, 3684, 430, 272, 340, 756, 315, 25089, 26, 267, 340, 1006, 63, 992, 26, 288, 372, 334, 70, 367, 289, 315, 359, 797, 566, 267, 372, 756, 272, 6698, 275, 3355, 1547, 1623, 63, 14463, 83, 8, 3684, 395, 790, 29, 885, 63, 3191, 63, 498, 9, 272, 6698, 63, 442, 63, 2722, 275, 1425, 8, 17, 12, 822, 8, 7450, 9, 435, 413, 9, 272, 25089, 63, 442, 63, 2722, 275, 370, 63, 442, 63, 2722, 8, 26089, 12, 6698, 9, 339, 10196, 275, 428, 619, 24755, 8, 26089, 63, 442, 63, 2722, 12, 6698, 63, 442, 63, 2722, 12, 663, 1062, 6698, 9, 272, 1709, 275, 10196, 423, 1623, 63, 1238, 342, 339, 340, 1006, 63, 992, 26, 267, 372, 485, 452, 63, 992, 8, 992, 9, 339, 862, 26, 267, 372, 2163, 8, 992, 9, 272, 871, 10852, 26, 267, 372, 756, 339, 327, 1910, 3349, 370, 12679, 314, 8744, 365, 1686, 334, 12948, 1337, 663, 367, 314, 25089, 9, 272, 327, 2836, 26, 267, 327, 509, 843, 315, 25089, 63, 442, 63, 2722, 26, 288, 327, 479, 10196, 14, 1391, 63, 1751, 14, 12569, 8, 1886, 9, 421, 199, 318, 485, 452, 63, 992, 8, 992, 304, 272, 13529, 24183, 275, 756, 272, 862, 26, 267, 1830, 715, 26, 288, 1995, 2163, 8, 992, 9, 288, 13529, 24183, 275, 715, 272, 871, 10852, 26, 267, 340, 440, 13529, 24183, 26, 288, 1995, 756, 421, 199, 533, 428, 619, 24755, 8, 785, 304, 272, 408, 272, 8089, 367, 6144, 282, 428, 619, 10196, 4021, 461, 402, 1362, 17196, 282, 1402, 370, 282, 5046, 30629, 315, 14643, 1097, 857, 1362, 3293, 1824, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 25089, 12, 2860, 12, 2729, 63, 1751, 12, 6698, 29, 403, 12, 355, 25332, 534, 86, 338, 795, 297, 8502, 63, 10546, 534, 3592, 297, 8729, 3204, 29, 5783, 304, 398, 291, 14, 1391, 63, 1751, 275, 2729, 63, 1751, 267, 291, 14, 426, 20911, 275, 25332, 267, 291, 14, 374, 63, 324, 22878, 275, 756, 267, 291, 423, 3248, 63, 4469, 63, 1825, 275, 942, 267, 291, 14, 873, 63, 5777, 275, 942, 267, 291, 14, 17359, 275, 8729, 3204, 398, 340, 6698, 365, 488, 26, 288, 291, 14, 7450, 275, 769, 8, 8235, 8, 3669, 430, 267, 587, 26, 288, 291, 14, 7450, 275, 6698, 398, 291, 423, 8489, 63, 3669, 8, 3669, 9, 267, 291, 423, 8489, 63, 26089, 8, 26089, 9, 398, 340, 283, 86, 338, 795, 7, 508, 25332, 26, 288, 291, 423, 86, 338, 795, 63, 826, 342, 288, 291, 14, 426, 300, 63, 12063, 275, 291, 423, 86, 338, 795, 63, 12063, 288, 291, 14, 426, 300, 63, 1051, 63, 12941, 275, 291, 423, 86, 338, 795, 63, 1051, 63, 12941, 288, 291, 14, 426, 300, 63, 1051, 63, 16787, 275, 291, 423, 86, 338, 795, 63, 1051, 63, 16787, 288, 291, 14, 426, 300, 63, 8501, 63, 3270, 275, 291, 423, 86, 338, 795, 63, 8501, 63, 3270, 953, 327, 3390, 26, 1910, 3349, 642, 340, 15, 6526, 8502, 9328, 365, 5223, 288, 327, 277, 14, 873, 63, 5777, 14, 740, 8, 277, 423, 86, 338, 795, 63, 16889, 9, 398, 587, 26, 288, 746, 4279, 398, 340, 283, 4129, 7, 508, 8502, 63, 10546, 26, 288, 291, 14, 525, 63, 4643, 379, 63, 8501, 275, 291, 423, 4129, 63, 525, 63, 4643, 379, 63, 8501, 288, 291, 14, 3357, 63, 15207, 275, 291, 14, 4129, 63, 3357, 63, 15207, 288, 291, 14, 873, 63, 5777, 14, 740, 8, 277, 14, 4129, 63, 3118, 63, 26089, 9, 267, 916, 283, 3592, 7, 508, 8502, 63, 10546, 26, 288, 291, 14, 525, 63, 4643, 379, 63, 8501, 275, 2400, 671, 26, 488, 288, 291, 14, 3357, 63, 15207, 275, 2400, 26, 488, 267, 587, 26, 288, 746, 4279, 398, 327, 2790, 314, 1300, 2166, 267, 291, 14, 11402, 275, 359, 4670, 8, 16, 1874, 267, 291, 423, 1818, 63, 1896, 14, 1391, 1751, 275, 2729, 63, 1751, 398, 327, 14797, 5020, 267, 291, 14, 1507, 63, 22612, 1356, 275, 378, 267, 291, 14, 1507, 63, 4643, 379, 63, 26089, 275, 378, 267, 291, 14, 5043, 63, 1507, 63, 26089, 275, 822, 8, 277, 14, 26089, 9, 339, 347, 485, 8489, 63, 3669, 8, 277, 12, 2860, 304, 267, 408, 1084, 1536, 314, 1750, 666, 13955, 4346, 1041, 267, 291, 14, 13400, 83, 275, 10018, 8, 409, 9, 267, 291, 14, 20051, 4646, 63, 835, 275, 10018, 8, 442, 9, 267, 291, 14, 1975, 63, 409, 275 ]
[ 7921, 402, 577, 2749, 44, 5563, 199, 199, 10807, 26, 523, 446, 24433, 1180, 9328, 523, 446, 29075, 8785, 5687, 523, 446, 812, 19514, 51, 25332, 199, 199, 15242, 26, 523, 446, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 36, 2749, 44, 63, 8833, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5055, 492, 10018, 199, 504, 13295, 81, 492, 946, 571, 2084, 12, 946, 571, 411, 199, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 492, 849, 63, 3191, 63, 498, 12, 7741, 199, 504, 5840, 14, 15370, 14, 2245, 6731, 492, 14643, 324, 3021, 12, 370, 63, 23600, 12, 370, 63, 442, 63, 2722, 12, 485, 1623, 63, 14463, 83, 421, 199, 318, 12392, 914, 63, 18270, 24183, 8, 3684, 12, 1006, 63, 992, 29, 797, 304, 272, 408, 272, 2670, 13529, 329, 3616, 402, 282, 557, 17867, 14537, 14, 272, 2779, 2529, 282, 1402, 7830, 2419, 715, 1380, 652, 24611, 14, 272, 1803, 282, 4306, 402, 1006, 1709, 340, 1006, 63, 992, 365, 715, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 14, 3175, 492, 437, 12, 699, 272, 1306, 687, 5840, 14, 15370, 14, 24365, 14, 5780, 914, 18, 492, 12392, 914, 63, 18270, 24183, 272, 1306, 12392, 914, 63, 18270, 24183, 8, 33, 1253, 6146, 34, 9, 272, 469, 33, 26, 715, 12, 699, 26, 756, 93, 272, 1306, 12392, 914, 63, 18270, 24183, 8, 33, 1253, 6146, 33, 9, 272, 756, 339, 408, 272, 25089, 275, 14643, 324, 3021, 8, 475, 63, 23600, 8, 3684, 430, 272, 340, 756, 315, 25089, 26, 267, 340, 1006, 63, 992, 26, 288, 372, 334, 70, 367, 289, 315, 359, 797, 566, 267, 372, 756, 272, 6698, 275, 3355, 1547, 1623, 63, 14463, 83, 8, 3684, 395, 790, 29, 885, 63, 3191, 63, 498, 9, 272, 6698, 63, 442, 63, 2722, 275, 1425, 8, 17, 12, 822, 8, 7450, 9, 435, 413, 9, 272, 25089, 63, 442, 63, 2722, 275, 370, 63, 442, 63, 2722, 8, 26089, 12, 6698, 9, 339, 10196, 275, 428, 619, 24755, 8, 26089, 63, 442, 63, 2722, 12, 6698, 63, 442, 63, 2722, 12, 663, 1062, 6698, 9, 272, 1709, 275, 10196, 423, 1623, 63, 1238, 342, 339, 340, 1006, 63, 992, 26, 267, 372, 485, 452, 63, 992, 8, 992, 9, 339, 862, 26, 267, 372, 2163, 8, 992, 9, 272, 871, 10852, 26, 267, 372, 756, 339, 327, 1910, 3349, 370, 12679, 314, 8744, 365, 1686, 334, 12948, 1337, 663, 367, 314, 25089, 9, 272, 327, 2836, 26, 267, 327, 509, 843, 315, 25089, 63, 442, 63, 2722, 26, 288, 327, 479, 10196, 14, 1391, 63, 1751, 14, 12569, 8, 1886, 9, 421, 199, 318, 485, 452, 63, 992, 8, 992, 304, 272, 13529, 24183, 275, 756, 272, 862, 26, 267, 1830, 715, 26, 288, 1995, 2163, 8, 992, 9, 288, 13529, 24183, 275, 715, 272, 871, 10852, 26, 267, 340, 440, 13529, 24183, 26, 288, 1995, 756, 421, 199, 533, 428, 619, 24755, 8, 785, 304, 272, 408, 272, 8089, 367, 6144, 282, 428, 619, 10196, 4021, 461, 402, 1362, 17196, 282, 1402, 370, 282, 5046, 30629, 315, 14643, 1097, 857, 1362, 3293, 1824, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 25089, 12, 2860, 12, 2729, 63, 1751, 12, 6698, 29, 403, 12, 355, 25332, 534, 86, 338, 795, 297, 8502, 63, 10546, 534, 3592, 297, 8729, 3204, 29, 5783, 304, 398, 291, 14, 1391, 63, 1751, 275, 2729, 63, 1751, 267, 291, 14, 426, 20911, 275, 25332, 267, 291, 14, 374, 63, 324, 22878, 275, 756, 267, 291, 423, 3248, 63, 4469, 63, 1825, 275, 942, 267, 291, 14, 873, 63, 5777, 275, 942, 267, 291, 14, 17359, 275, 8729, 3204, 398, 340, 6698, 365, 488, 26, 288, 291, 14, 7450, 275, 769, 8, 8235, 8, 3669, 430, 267, 587, 26, 288, 291, 14, 7450, 275, 6698, 398, 291, 423, 8489, 63, 3669, 8, 3669, 9, 267, 291, 423, 8489, 63, 26089, 8, 26089, 9, 398, 340, 283, 86, 338, 795, 7, 508, 25332, 26, 288, 291, 423, 86, 338, 795, 63, 826, 342, 288, 291, 14, 426, 300, 63, 12063, 275, 291, 423, 86, 338, 795, 63, 12063, 288, 291, 14, 426, 300, 63, 1051, 63, 12941, 275, 291, 423, 86, 338, 795, 63, 1051, 63, 12941, 288, 291, 14, 426, 300, 63, 1051, 63, 16787, 275, 291, 423, 86, 338, 795, 63, 1051, 63, 16787, 288, 291, 14, 426, 300, 63, 8501, 63, 3270, 275, 291, 423, 86, 338, 795, 63, 8501, 63, 3270, 953, 327, 3390, 26, 1910, 3349, 642, 340, 15, 6526, 8502, 9328, 365, 5223, 288, 327, 277, 14, 873, 63, 5777, 14, 740, 8, 277, 423, 86, 338, 795, 63, 16889, 9, 398, 587, 26, 288, 746, 4279, 398, 340, 283, 4129, 7, 508, 8502, 63, 10546, 26, 288, 291, 14, 525, 63, 4643, 379, 63, 8501, 275, 291, 423, 4129, 63, 525, 63, 4643, 379, 63, 8501, 288, 291, 14, 3357, 63, 15207, 275, 291, 14, 4129, 63, 3357, 63, 15207, 288, 291, 14, 873, 63, 5777, 14, 740, 8, 277, 14, 4129, 63, 3118, 63, 26089, 9, 267, 916, 283, 3592, 7, 508, 8502, 63, 10546, 26, 288, 291, 14, 525, 63, 4643, 379, 63, 8501, 275, 2400, 671, 26, 488, 288, 291, 14, 3357, 63, 15207, 275, 2400, 26, 488, 267, 587, 26, 288, 746, 4279, 398, 327, 2790, 314, 1300, 2166, 267, 291, 14, 11402, 275, 359, 4670, 8, 16, 1874, 267, 291, 423, 1818, 63, 1896, 14, 1391, 1751, 275, 2729, 63, 1751, 398, 327, 14797, 5020, 267, 291, 14, 1507, 63, 22612, 1356, 275, 378, 267, 291, 14, 1507, 63, 4643, 379, 63, 26089, 275, 378, 267, 291, 14, 5043, 63, 1507, 63, 26089, 275, 822, 8, 277, 14, 26089, 9, 339, 347, 485, 8489, 63, 3669, 8, 277, 12, 2860, 304, 267, 408, 1084, 1536, 314, 1750, 666, 13955, 4346, 1041, 267, 291, 14, 13400, 83, 275, 10018, 8, 409, 9, 267, 291, 14, 20051, 4646, 63, 835, 275, 10018, 8, 442, 9, 267, 291, 14, 1975, 63, 409, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1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ial
notebooks/figures/plot_rbf_svm_parameters.py
19
2018
import matplotlib.pyplot as plt import numpy as np from sklearn.svm import SVC from sklearn.datasets import make_blobs from .plot_2d_separator import plot_2d_separator def make_handcrafted_dataset(): # a carefully hand-designed dataset lol X, y = make_blobs(centers=2, random_state=4, n_samples=30) y[np.array([7, 27])] = 0 mask = np.ones(len(X), dtype=np.bool) mask[np.array([0, 1, 5, 26])] = 0 X, y = X[mask], y[mask] return X, y def plot_rbf_svm_parameters(): X, y = make_handcrafted_dataset() fig, axes = plt.subplots(1, 3, figsize=(12, 4)) for ax, C in zip(axes, [1e0, 5, 10, 100]): ax.scatter(X[:, 0], X[:, 1], s=150, c=np.array(['red', 'blue'])[y]) svm = SVC(kernel='rbf', C=C).fit(X, y) plot_2d_separator(svm, X, ax=ax, eps=.5) ax.set_title("C = %f" % C) fig, axes = plt.subplots(1, 4, figsize=(15, 3)) for ax, gamma in zip(axes, [0.1, .5, 1, 10]): ax.scatter(X[:, 0], X[:, 1], s=150, c=np.array(['red', 'blue'])[y]) svm = SVC(gamma=gamma, kernel='rbf', C=1).fit(X, y) plot_2d_separator(svm, X, ax=ax, eps=.5) ax.set_title("gamma = %f" % gamma) def plot_svm(log_C, log_gamma): X, y = make_handcrafted_dataset() C = 10. ** log_C gamma = 10. ** log_gamma svm = SVC(kernel='rbf', C=C, gamma=gamma).fit(X, y) ax = plt.gca() plot_2d_separator(svm, X, ax=ax, eps=.5) # plot data ax.scatter(X[:, 0], X[:, 1], s=150, c=np.array(['red', 'blue'])[y]) # plot support vectors sv = svm.support_vectors_ ax.scatter(sv[:, 0], sv[:, 1], s=230, facecolors='none', zorder=10, linewidth=3) ax.set_title("C = %.4f gamma = %.4f" % (C, gamma)) def plot_svm_interactive(): from IPython.html.widgets import interactive, FloatSlider C_slider = FloatSlider(min=-3, max=3, step=.1, value=0, readout=False) gamma_slider = FloatSlider(min=-2, max=2, step=.1, value=0, readout=False) return interactive(plot_svm, log_C=C_slider, log_gamma=gamma_slider)
cc0-1.0
[ 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 6357, 14, 16820, 492, 428, 9454, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 1275, 2798, 63, 18, 68, 63, 9896, 492, 5137, 63, 18, 68, 63, 9896, 421, 199, 318, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 837, 272, 327, 282, 21191, 8525, 4926, 13, 271, 1737, 4789, 560, 76, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 15660, 29, 18, 12, 2196, 63, 929, 29, 20, 12, 302, 63, 3356, 29, 1216, 9, 272, 612, 59, 1590, 14, 1144, 779, 23, 12, 8087, 12457, 275, 378, 272, 3656, 275, 980, 14, 4548, 8, 552, 8, 56, 395, 2152, 29, 1590, 14, 2245, 9, 272, 3656, 59, 1590, 14, 1144, 779, 16, 12, 413, 12, 959, 12, 7875, 12457, 275, 378, 272, 1323, 12, 612, 275, 1323, 59, 2629, 467, 612, 59, 2629, 61, 272, 372, 1323, 12, 612, 421, 199, 318, 5137, 63, 25853, 63, 16820, 63, 3214, 837, 272, 1323, 12, 612, 275, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 342, 339, 6085, 12, 7824, 275, 4488, 14, 21430, 8, 17, 12, 650, 12, 6085, 890, 2687, 713, 12, 841, 430, 272, 367, 2185, 12, 445, 315, 3482, 8, 6402, 12, 359, 17, 69, 16, 12, 959, 12, 1616, 12, 2948, 4682, 267, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 398, 23044, 275, 428, 9454, 8, 4989, 534, 25853, 297, 445, 29, 35, 680, 3269, 8, 56, 12, 612, 9, 267, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 267, 2185, 14, 409, 63, 1213, 480, 35, 275, 450, 70, 2, 450, 445, 9, 339, 6085, 12, 7824, 275, 4488, 14, 21430, 8, 17, 12, 841, 12, 6085, 890, 2687, 1046, 12, 650, 430, 272, 367, 2185, 12, 10169, 315, 3482, 8, 6402, 12, 359, 16, 14, 17, 12, 1275, 21, 12, 413, 12, 1616, 4682, 267, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 267, 23044, 275, 428, 9454, 8, 7325, 29, 7325, 12, 5114, 534, 25853, 297, 445, 29, 17, 680, 3269, 8, 56, 12, 612, 9, 267, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 267, 2185, 14, 409, 63, 1213, 480, 7325, 275, 450, 70, 2, 450, 10169, 9, 421, 199, 318, 5137, 63, 16820, 8, 793, 63, 35, 12, 943, 63, 7325, 304, 272, 1323, 12, 612, 275, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 342, 272, 445, 275, 1616, 14, 1011, 943, 63, 35, 272, 10169, 275, 1616, 14, 1011, 943, 63, 7325, 272, 23044, 275, 428, 9454, 8, 4989, 534, 25853, 297, 445, 29, 35, 12, 10169, 29, 7325, 680, 3269, 8, 56, 12, 612, 9, 272, 2185, 275, 4488, 14, 71, 696, 342, 272, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 272, 327, 5137, 666, 272, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 272, 327, 5137, 2291, 11102, 272, 19291, 275, 23044, 14, 4058, 63, 12280, 63, 272, 2185, 14, 13512, 8, 2772, 3981, 378, 467, 19291, 3981, 413, 467, 308, 29, 9687, 12, 8870, 7120, 534, 3592, 297, 1315, 1648, 29, 709, 12, 21213, 29, 19, 9, 272, 2185, 14, 409, 63, 1213, 480, 35, 275, 10536, 20, 70, 10169, 275, 10536, 20, 70, 2, 450, 334, 35, 12, 10169, 430, 421, 199, 318, 5137, 63, 16820, 63, 13543, 837, 272, 687, 16243, 14, 1360, 14, 8583, 492, 12777, 12, 11140, 21074, 272, 445, 63, 20860, 275, 11140, 21074, 8, 827, 4022, 19, 12, 1390, 29, 19, 12, 3650, 15856, 17, 12, 574, 29, 16, 12, 1586, 548, 29, 797, 9, 272, 10169, 63, 20860, 275, 11140, 21074, 8, 827, 4022, 18, 12, 1390, 29, 18, 12, 3650, 15856, 17, 12, 574, 29, 16, 12, 1586, 548, 29, 797, 9, 272, 372, 12777, 8, 2798, 63, 16820, 12, 943, 63, 35, 29, 35, 63, 20860, 12, 943, 63, 7325, 29, 7325, 63, 20860, 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 ]
[ 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 6357, 14, 16820, 492, 428, 9454, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 1275, 2798, 63, 18, 68, 63, 9896, 492, 5137, 63, 18, 68, 63, 9896, 421, 199, 318, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 837, 272, 327, 282, 21191, 8525, 4926, 13, 271, 1737, 4789, 560, 76, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 15660, 29, 18, 12, 2196, 63, 929, 29, 20, 12, 302, 63, 3356, 29, 1216, 9, 272, 612, 59, 1590, 14, 1144, 779, 23, 12, 8087, 12457, 275, 378, 272, 3656, 275, 980, 14, 4548, 8, 552, 8, 56, 395, 2152, 29, 1590, 14, 2245, 9, 272, 3656, 59, 1590, 14, 1144, 779, 16, 12, 413, 12, 959, 12, 7875, 12457, 275, 378, 272, 1323, 12, 612, 275, 1323, 59, 2629, 467, 612, 59, 2629, 61, 272, 372, 1323, 12, 612, 421, 199, 318, 5137, 63, 25853, 63, 16820, 63, 3214, 837, 272, 1323, 12, 612, 275, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 342, 339, 6085, 12, 7824, 275, 4488, 14, 21430, 8, 17, 12, 650, 12, 6085, 890, 2687, 713, 12, 841, 430, 272, 367, 2185, 12, 445, 315, 3482, 8, 6402, 12, 359, 17, 69, 16, 12, 959, 12, 1616, 12, 2948, 4682, 267, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 398, 23044, 275, 428, 9454, 8, 4989, 534, 25853, 297, 445, 29, 35, 680, 3269, 8, 56, 12, 612, 9, 267, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 267, 2185, 14, 409, 63, 1213, 480, 35, 275, 450, 70, 2, 450, 445, 9, 339, 6085, 12, 7824, 275, 4488, 14, 21430, 8, 17, 12, 841, 12, 6085, 890, 2687, 1046, 12, 650, 430, 272, 367, 2185, 12, 10169, 315, 3482, 8, 6402, 12, 359, 16, 14, 17, 12, 1275, 21, 12, 413, 12, 1616, 4682, 267, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 267, 23044, 275, 428, 9454, 8, 7325, 29, 7325, 12, 5114, 534, 25853, 297, 445, 29, 17, 680, 3269, 8, 56, 12, 612, 9, 267, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 267, 2185, 14, 409, 63, 1213, 480, 7325, 275, 450, 70, 2, 450, 10169, 9, 421, 199, 318, 5137, 63, 16820, 8, 793, 63, 35, 12, 943, 63, 7325, 304, 272, 1323, 12, 612, 275, 1852, 63, 6868, 67, 345, 70, 471, 63, 5214, 342, 272, 445, 275, 1616, 14, 1011, 943, 63, 35, 272, 10169, 275, 1616, 14, 1011, 943, 63, 7325, 272, 23044, 275, 428, 9454, 8, 4989, 534, 25853, 297, 445, 29, 35, 12, 10169, 29, 7325, 680, 3269, 8, 56, 12, 612, 9, 272, 2185, 275, 4488, 14, 71, 696, 342, 272, 5137, 63, 18, 68, 63, 9896, 8, 16820, 12, 1323, 12, 2185, 29, 1219, 12, 10245, 15856, 21, 9, 272, 327, 5137, 666, 272, 2185, 14, 13512, 8, 56, 3981, 378, 467, 1323, 3981, 413, 467, 308, 29, 8251, 12, 286, 29, 1590, 14, 1144, 2941, 581, 297, 283, 6304, 25945, 89, 566, 272, 327, 5137, 2291, 11102, 272, 19291, 275, 23044, 14, 4058, 63, 12280, 63, 272, 2185, 14, 13512, 8, 2772, 3981, 378, 467, 19291, 3981, 413, 467, 308, 29, 9687, 12, 8870, 7120, 534, 3592, 297, 1315, 1648, 29, 709, 12, 21213, 29, 19, 9, 272, 2185, 14, 409, 63, 1213, 480, 35, 275, 10536, 20, 70, 10169, 275, 10536, 20, 70, 2, 450, 334, 35, 12, 10169, 430, 421, 199, 318, 5137, 63, 16820, 63, 13543, 837, 272, 687, 16243, 14, 1360, 14, 8583, 492, 12777, 12, 11140, 21074, 272, 445, 63, 20860, 275, 11140, 21074, 8, 827, 4022, 19, 12, 1390, 29, 19, 12, 3650, 15856, 17, 12, 574, 29, 16, 12, 1586, 548, 29, 797, 9, 272, 10169, 63, 20860, 275, 11140, 21074, 8, 827, 4022, 18, 12, 1390, 29, 18, 12, 3650, 15856, 17, 12, 574, 29, 16, 12, 1586, 548, 29, 797, 9, 272, 372, 12777, 8, 2798, 63, 16820, 12, 943, 63, 35, 29, 35, 63, 20860, 12, 943, 63, 7325, 29, 7325, 63, 20860, 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, 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 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
brandsoulmates/incubator-airflow
tests/contrib/sensors/test_ftp_sensor.py
42
2085
# -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import unittest from ftplib import error_perm from mock import MagicMock from airflow.contrib.hooks.ftp_hook import FTPHook from airflow.contrib.sensors.ftp_sensor import FTPSensor class TestFTPSensor(unittest.TestCase): def setUp(self): super(TestFTPSensor, self).setUp() self._create_hook_orig = FTPSensor._create_hook self.hook_mock = MagicMock(spec=FTPHook) def _create_hook_mock(sensor): mock = MagicMock() mock.__enter__ = lambda x: self.hook_mock return mock FTPSensor._create_hook = _create_hook_mock def tearDown(self): FTPSensor._create_hook = self._create_hook_orig super(TestFTPSensor, self).tearDown() def test_poke(self): op = FTPSensor(path="foobar.json", ftp_conn_id="bob_ftp", task_id="test_task") self.hook_mock.get_mod_time.side_effect = \ [error_perm("550: Can't check for file existence"), None] self.assertFalse(op.poke(None)) self.assertTrue(op.poke(None)) def test_poke_fails_due_error(self): op = FTPSensor(path="foobar.json", ftp_conn_id="bob_ftp", task_id="test_task") self.hook_mock.get_mod_time.side_effect = \ error_perm("530: Login authentication failed") with self.assertRaises(error_perm) as context: op.execute(None) self.assertTrue("530" in str(context.exception)) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 504, 14904, 773, 492, 1125, 63, 8220, 199, 199, 504, 1683, 492, 10079, 199, 199, 504, 16321, 14, 2828, 14, 7922, 14, 8915, 63, 3664, 492, 23125, 8481, 199, 504, 16321, 14, 2828, 14, 22675, 14, 8915, 63, 8956, 492, 481, 52, 5067, 2616, 421, 199, 533, 1379, 2161, 5067, 2616, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 2161, 5067, 2616, 12, 291, 680, 5996, 342, 267, 291, 423, 981, 63, 3664, 63, 2981, 275, 481, 52, 5067, 2616, 423, 981, 63, 3664, 267, 291, 14, 3664, 63, 1805, 275, 10079, 8, 1650, 29, 15123, 8481, 9, 398, 347, 485, 981, 63, 3664, 63, 1805, 8, 8956, 304, 288, 1683, 275, 10079, 342, 288, 1683, 855, 4200, 363, 275, 2400, 671, 26, 291, 14, 3664, 63, 1805, 953, 372, 1683, 398, 481, 52, 5067, 2616, 423, 981, 63, 3664, 275, 485, 981, 63, 3664, 63, 1805, 339, 347, 6766, 8, 277, 304, 267, 481, 52, 5067, 2616, 423, 981, 63, 3664, 275, 291, 423, 981, 63, 3664, 63, 2981, 267, 1613, 8, 774, 2161, 5067, 2616, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 31696, 8, 277, 304, 267, 1687, 275, 481, 52, 5067, 2616, 8, 515, 628, 9664, 14, 1001, 401, 14904, 63, 1631, 63, 344, 628, 7913, 63, 8915, 401, 2432, 2120, 63, 344, 628, 396, 63, 1765, 531, 398, 291, 14, 3664, 63, 1805, 14, 362, 63, 1494, 63, 521, 14, 2441, 63, 5881, 275, 971, 288, 359, 705, 63, 8220, 480, 16859, 26, 6855, 1133, 1104, 367, 570, 23780, 1288, 488, 61, 398, 291, 14, 3334, 8, 411, 14, 31696, 8, 403, 430, 267, 291, 14, 1815, 8, 411, 14, 31696, 8, 403, 430, 339, 347, 511, 63, 31696, 63, 15762, 63, 11933, 63, 705, 8, 277, 304, 267, 1687, 275, 481, 52, 5067, 2616, 8, 515, 628, 9664, 14, 1001, 401, 14904, 63, 1631, 63, 344, 628, 7913, 63, 8915, 401, 2432, 2120, 63, 344, 628, 396, 63, 1765, 531, 398, 291, 14, 3664, 63, 1805, 14, 362, 63, 1494, 63, 521, 14, 2441, 63, 5881, 275, 971, 288, 1125, 63, 8220, 480, 27030, 26, 16430, 6299, 3405, 531, 398, 543, 291, 14, 1855, 8, 705, 63, 8220, 9, 465, 1067, 26, 288, 1687, 14, 2526, 8, 403, 9, 398, 291, 14, 1815, 480, 27030, 2, 315, 620, 8, 1100, 14, 1971, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 504, 14904, 773, 492, 1125, 63, 8220, 199, 199, 504, 1683, 492, 10079, 199, 199, 504, 16321, 14, 2828, 14, 7922, 14, 8915, 63, 3664, 492, 23125, 8481, 199, 504, 16321, 14, 2828, 14, 22675, 14, 8915, 63, 8956, 492, 481, 52, 5067, 2616, 421, 199, 533, 1379, 2161, 5067, 2616, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 2161, 5067, 2616, 12, 291, 680, 5996, 342, 267, 291, 423, 981, 63, 3664, 63, 2981, 275, 481, 52, 5067, 2616, 423, 981, 63, 3664, 267, 291, 14, 3664, 63, 1805, 275, 10079, 8, 1650, 29, 15123, 8481, 9, 398, 347, 485, 981, 63, 3664, 63, 1805, 8, 8956, 304, 288, 1683, 275, 10079, 342, 288, 1683, 855, 4200, 363, 275, 2400, 671, 26, 291, 14, 3664, 63, 1805, 953, 372, 1683, 398, 481, 52, 5067, 2616, 423, 981, 63, 3664, 275, 485, 981, 63, 3664, 63, 1805, 339, 347, 6766, 8, 277, 304, 267, 481, 52, 5067, 2616, 423, 981, 63, 3664, 275, 291, 423, 981, 63, 3664, 63, 2981, 267, 1613, 8, 774, 2161, 5067, 2616, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 31696, 8, 277, 304, 267, 1687, 275, 481, 52, 5067, 2616, 8, 515, 628, 9664, 14, 1001, 401, 14904, 63, 1631, 63, 344, 628, 7913, 63, 8915, 401, 2432, 2120, 63, 344, 628, 396, 63, 1765, 531, 398, 291, 14, 3664, 63, 1805, 14, 362, 63, 1494, 63, 521, 14, 2441, 63, 5881, 275, 971, 288, 359, 705, 63, 8220, 480, 16859, 26, 6855, 1133, 1104, 367, 570, 23780, 1288, 488, 61, 398, 291, 14, 3334, 8, 411, 14, 31696, 8, 403, 430, 267, 291, 14, 1815, 8, 411, 14, 31696, 8, 403, 430, 339, 347, 511, 63, 31696, 63, 15762, 63, 11933, 63, 705, 8, 277, 304, 267, 1687, 275, 481, 52, 5067, 2616, 8, 515, 628, 9664, 14, 1001, 401, 14904, 63, 1631, 63, 344, 628, 7913, 63, 8915, 401, 2432, 2120, 63, 344, 628, 396, 63, 1765, 531, 398, 291, 14, 3664, 63, 1805, 14, 362, 63, 1494, 63, 521, 14, 2441, 63, 5881, 275, 971, 288, 1125, 63, 8220, 480, 27030, 26, 16430, 6299, 3405, 531, 398, 543, 291, 14, 1855, 8, 705, 63, 8220, 9, 465, 1067, 26, 288, 1687, 14, 2526, 8, 403, 9, 398, 291, 14, 1815, 480, 27030, 2, 315, 620, 8, 1100, 14, 1971, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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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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 ]
OpenMined/PySyft
packages/grid/apps/domain/src/main/core/manager/environment_manager.py
1
2053
# stdlib from datetime import datetime from typing import List from typing import Union # grid relative from ..database.environment.environment import Environment from ..database.environment.environment import states from ..database.environment.user_environment import UserEnvironment from ..exceptions import EnvironmentNotFoundError from .database_manager import DatabaseManager class EnvironmentManager(DatabaseManager): schema = Environment user_env_association_schema = UserEnvironment def __init__(self, database): self._schema = EnvironmentManager.schema self._association_schema = EnvironmentManager.user_env_association_schema self.db = database def association(self, user_id: str, env_id: str): new_association_obj = self._association_schema(user=user_id, environment=env_id) self.db.session.add(new_association_obj) self.db.session.commit() def get_environments(self, **kwargs): objects = ( self.db.session.query(self._association_schema).filter_by(**kwargs).all() ) return objects def get_all_associations(self): return list(self.db.session.query(self._association_schema).all()) def delete_associations(self, environment_id): # Delete User environment Association associations = ( self.db.session.query(self._association_schema) .filter_by(environment=environment_id) .all() ) for association in associations: self.db.session.delete(association) self.db.session.commit() def first(self, **kwargs) -> Union[None, List]: result = super().first(**kwargs) if not result: raise EnvironmentNotFoundError return result def query(self, **kwargs) -> Union[None, List]: results = super().query(**kwargs) if len(results) == 0: raise EnvironmentNotFoundError return results def set(self, id, **kwargs): self.modify({"id": id}, {**kwargs})
apache-2.0
[ 3, 26678, 199, 504, 2197, 492, 2197, 199, 504, 14090, 492, 3820, 199, 504, 14090, 492, 15961, 199, 199, 3, 6068, 3847, 199, 504, 2508, 4659, 14, 5418, 14, 5418, 492, 9711, 199, 504, 2508, 4659, 14, 5418, 14, 5418, 492, 6363, 199, 504, 2508, 4659, 14, 5418, 14, 751, 63, 5418, 492, 2876, 8263, 199, 504, 2508, 3924, 492, 9711, 10870, 199, 504, 1275, 4659, 63, 2609, 492, 8692, 2988, 421, 199, 533, 9711, 2988, 8, 7243, 2988, 304, 339, 4177, 275, 9711, 272, 922, 63, 1813, 63, 20252, 63, 3629, 275, 2876, 8263, 339, 347, 636, 826, 721, 277, 12, 3050, 304, 267, 291, 423, 3629, 275, 9711, 2988, 14, 3629, 267, 291, 423, 20252, 63, 3629, 275, 9711, 2988, 14, 751, 63, 1813, 63, 20252, 63, 3629, 267, 291, 14, 697, 275, 3050, 339, 347, 20640, 8, 277, 12, 922, 63, 344, 26, 620, 12, 2589, 63, 344, 26, 620, 304, 267, 892, 63, 20252, 63, 1113, 275, 291, 423, 20252, 63, 3629, 8, 751, 29, 751, 63, 344, 12, 3734, 29, 1813, 63, 344, 9, 267, 291, 14, 697, 14, 1730, 14, 525, 8, 1222, 63, 20252, 63, 1113, 9, 267, 291, 14, 697, 14, 1730, 14, 3543, 342, 339, 347, 664, 63, 26411, 8, 277, 12, 1011, 958, 304, 267, 2251, 275, 334, 288, 291, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 680, 1541, 63, 991, 3682, 958, 680, 452, 342, 267, 776, 267, 372, 2251, 339, 347, 664, 63, 452, 63, 32600, 8, 277, 304, 267, 372, 769, 8, 277, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 680, 452, 1012, 339, 347, 3145, 63, 32600, 8, 277, 12, 3734, 63, 344, 304, 267, 327, 8496, 2876, 3734, 24207, 425, 267, 4035, 1298, 275, 334, 288, 291, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 9, 288, 1275, 1541, 63, 991, 8, 5418, 29, 5418, 63, 344, 9, 288, 1275, 452, 342, 267, 776, 267, 367, 20640, 315, 4035, 1298, 26, 288, 291, 14, 697, 14, 1730, 14, 1807, 8, 20252, 9, 398, 291, 14, 697, 14, 1730, 14, 3543, 342, 339, 347, 1642, 8, 277, 12, 1011, 958, 9, 1035, 15961, 59, 403, 12, 3820, 2189, 267, 754, 275, 1613, 1252, 2246, 3682, 958, 9, 267, 340, 440, 754, 26, 288, 746, 9711, 10870, 267, 372, 754, 339, 347, 1827, 8, 277, 12, 1011, 958, 9, 1035, 15961, 59, 403, 12, 3820, 2189, 267, 2058, 275, 1613, 1252, 1131, 3682, 958, 9, 267, 340, 822, 8, 2604, 9, 508, 378, 26, 288, 746, 9711, 10870, 267, 372, 2058, 339, 347, 663, 8, 277, 12, 1305, 12, 1011, 958, 304, 267, 291, 14, 8951, 6333, 344, 582, 1305, 1386, 469, 538, 958, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 2197, 492, 2197, 199, 504, 14090, 492, 3820, 199, 504, 14090, 492, 15961, 199, 199, 3, 6068, 3847, 199, 504, 2508, 4659, 14, 5418, 14, 5418, 492, 9711, 199, 504, 2508, 4659, 14, 5418, 14, 5418, 492, 6363, 199, 504, 2508, 4659, 14, 5418, 14, 751, 63, 5418, 492, 2876, 8263, 199, 504, 2508, 3924, 492, 9711, 10870, 199, 504, 1275, 4659, 63, 2609, 492, 8692, 2988, 421, 199, 533, 9711, 2988, 8, 7243, 2988, 304, 339, 4177, 275, 9711, 272, 922, 63, 1813, 63, 20252, 63, 3629, 275, 2876, 8263, 339, 347, 636, 826, 721, 277, 12, 3050, 304, 267, 291, 423, 3629, 275, 9711, 2988, 14, 3629, 267, 291, 423, 20252, 63, 3629, 275, 9711, 2988, 14, 751, 63, 1813, 63, 20252, 63, 3629, 267, 291, 14, 697, 275, 3050, 339, 347, 20640, 8, 277, 12, 922, 63, 344, 26, 620, 12, 2589, 63, 344, 26, 620, 304, 267, 892, 63, 20252, 63, 1113, 275, 291, 423, 20252, 63, 3629, 8, 751, 29, 751, 63, 344, 12, 3734, 29, 1813, 63, 344, 9, 267, 291, 14, 697, 14, 1730, 14, 525, 8, 1222, 63, 20252, 63, 1113, 9, 267, 291, 14, 697, 14, 1730, 14, 3543, 342, 339, 347, 664, 63, 26411, 8, 277, 12, 1011, 958, 304, 267, 2251, 275, 334, 288, 291, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 680, 1541, 63, 991, 3682, 958, 680, 452, 342, 267, 776, 267, 372, 2251, 339, 347, 664, 63, 452, 63, 32600, 8, 277, 304, 267, 372, 769, 8, 277, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 680, 452, 1012, 339, 347, 3145, 63, 32600, 8, 277, 12, 3734, 63, 344, 304, 267, 327, 8496, 2876, 3734, 24207, 425, 267, 4035, 1298, 275, 334, 288, 291, 14, 697, 14, 1730, 14, 1131, 8, 277, 423, 20252, 63, 3629, 9, 288, 1275, 1541, 63, 991, 8, 5418, 29, 5418, 63, 344, 9, 288, 1275, 452, 342, 267, 776, 267, 367, 20640, 315, 4035, 1298, 26, 288, 291, 14, 697, 14, 1730, 14, 1807, 8, 20252, 9, 398, 291, 14, 697, 14, 1730, 14, 3543, 342, 339, 347, 1642, 8, 277, 12, 1011, 958, 9, 1035, 15961, 59, 403, 12, 3820, 2189, 267, 754, 275, 1613, 1252, 2246, 3682, 958, 9, 267, 340, 440, 754, 26, 288, 746, 9711, 10870, 267, 372, 754, 339, 347, 1827, 8, 277, 12, 1011, 958, 9, 1035, 15961, 59, 403, 12, 3820, 2189, 267, 2058, 275, 1613, 1252, 1131, 3682, 958, 9, 267, 340, 822, 8, 2604, 9, 508, 378, 26, 288, 746, 9711, 10870, 267, 372, 2058, 339, 347, 663, 8, 277, 12, 1305, 12, 1011, 958, 304, 267, 291, 14, 8951, 6333, 344, 582, 1305, 1386, 469, 538, 958, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0 ]
nikolas/edx-platform
openedx/core/djangoapps/credit/email_utils.py
24
6905
""" This file contains utility functions which will responsible for sending emails. """ import os import logging import pynliner import urlparse import uuid import HTMLParser from django.conf import settings from django.contrib.auth.models import User from django.contrib.staticfiles import finders from django.core.cache import cache from django.core.mail import EmailMessage from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from eventtracking import tracker from edxmako.shortcuts import render_to_string from edxmako.template import Template from microsite_configuration import microsite from xmodule.modulestore.django import modulestore log = logging.getLogger(__name__) def send_credit_notifications(username, course_key): """Sends email notification to user on different phases during credit course e.g., credit eligibility, credit payment etc. """ try: user = User.objects.get(username=username) except User.DoesNotExist: log.error('No user with %s exist', username) return course = modulestore().get_course(course_key, depth=0) course_display_name = course.display_name tracking_context = tracker.get_tracker().resolve_context() tracking_id = str(tracking_context.get('user_id')) client_id = str(tracking_context.get('client_id')) events = '&t=event&ec=email&ea=open' tracking_pixel = 'https://www.google-analytics.com/collect?v=1&tid' + tracking_id + '&cid' + client_id + events dashboard_link = _email_url_parser('dashboard') credit_course_link = _email_url_parser('courses', '?type=credit') # get attached branded logo logo_image = cache.get('credit.email.attached-logo') if logo_image is None: branded_logo = { 'title': 'Logo', 'path': settings.NOTIFICATION_EMAIL_EDX_LOGO, 'cid': str(uuid.uuid4()) } logo_image_id = branded_logo['cid'] logo_image = attach_image(branded_logo, 'Header Logo') if logo_image: cache.set('credit.email.attached-logo', logo_image, settings.CREDIT_NOTIFICATION_CACHE_TIMEOUT) else: # strip enclosing angle brackets from 'logo_image' cache 'Content-ID' logo_image_id = logo_image.get('Content-ID', '')[1:-1] context = { 'full_name': user.get_full_name(), 'platform_name': settings.PLATFORM_NAME, 'course_name': course_display_name, 'branded_logo': logo_image_id, 'dashboard_link': dashboard_link, 'credit_course_link': credit_course_link, 'tracking_pixel': tracking_pixel, } # create the root email message notification_msg = MIMEMultipart('related') # add 'alternative' part to root email message to encapsulate the plain and # HTML versions, so message agents can decide which they want to display. msg_alternative = MIMEMultipart('alternative') notification_msg.attach(msg_alternative) # render the credit notification templates subject = _(u'Course Credit Eligibility') # add alternative plain text message email_body_plain = render_to_string('credit_notifications/credit_eligibility_email.txt', context) msg_alternative.attach(MIMEText(email_body_plain, _subtype='plain', _charset='utf-8')) # add alternative html message email_body_content = cache.get('credit.email.css-email-body') if email_body_content is None: html_file_path = file_path_finder('templates/credit_notifications/credit_eligibility_email.html') if html_file_path: with open(html_file_path, 'r') as cur_file: cur_text = cur_file.read() # use html parser to unescape html characters which are changed # by the 'pynliner' while adding inline css to html content html_parser = HTMLParser.HTMLParser() email_body_content = html_parser.unescape(with_inline_css(cur_text)) # cache the email body content before rendering it since the # email context will change for each user e.g., 'full_name' cache.set('credit.email.css-email-body', email_body_content, settings.CREDIT_NOTIFICATION_CACHE_TIMEOUT) else: email_body_content = '' email_body = Template(email_body_content).render([context]) msg_alternative.attach(MIMEText(email_body, _subtype='html', _charset='utf-8')) # attach logo image if logo_image: notification_msg.attach(logo_image) # add email addresses of sender and receiver from_address = microsite.get_value('default_from_email', settings.DEFAULT_FROM_EMAIL) to_address = user.email # send the root email message msg = EmailMessage(subject, None, from_address, [to_address]) msg.attach(notification_msg) msg.send() def with_inline_css(html_without_css): """Returns html with inline css if the css file path exists else returns html with out the inline css. """ css_filepath = settings.NOTIFICATION_EMAIL_CSS if not css_filepath.startswith('/'): css_filepath = file_path_finder(settings.NOTIFICATION_EMAIL_CSS) if css_filepath: with open(css_filepath, "r") as _file: css_content = _file.read() # insert style tag in the html and run pyliner. html_with_inline_css = pynliner.fromString('<style>' + css_content + '</style>' + html_without_css) return html_with_inline_css return html_without_css def attach_image(img_dict, filename): """ Attach images in the email headers. """ img_path = img_dict['path'] if not img_path.startswith('/'): img_path = file_path_finder(img_path) if img_path: with open(img_path, 'rb') as img: msg_image = MIMEImage(img.read(), name=os.path.basename(img_path)) msg_image.add_header('Content-ID', '<{}>'.format(img_dict['cid'])) msg_image.add_header("Content-Disposition", "inline", filename=filename) return msg_image def file_path_finder(path): """ Return physical path of file if found. """ return finders.FileSystemFinder().find(path) def _email_url_parser(url_name, extra_param=None): """Parse url according to 'SITE_NAME' which will be used in the mail. Args: url_name(str): Name of the url to be parsed extra_param(str): Any extra parameters to be added with url if any Returns: str """ site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME) dashboard_url_path = reverse(url_name) + extra_param if extra_param else reverse(url_name) dashboard_link_parts = ("https", site_name, dashboard_url_path, '', '', '') return urlparse.urlunparse(dashboard_link_parts)
agpl-3.0
[ 624, 199, 2765, 570, 3509, 11420, 3423, 1314, 911, 17845, 367, 10209, 14931, 14, 199, 624, 199, 199, 646, 747, 199, 199, 646, 2050, 199, 646, 1134, 78, 31338, 199, 646, 7097, 199, 646, 5377, 199, 646, 24581, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 18373, 492, 2583, 7735, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 1198, 492, 11426, 2209, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 199, 504, 3031, 14, 7626, 14, 1569, 492, 14735, 3491, 199, 504, 3031, 14, 7626, 14, 10123, 492, 603, 30596, 1141, 2064, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 1566, 14428, 492, 15271, 199, 199, 504, 22435, 19491, 14, 17469, 492, 3795, 63, 475, 63, 875, 199, 504, 22435, 19491, 14, 1160, 492, 5458, 199, 504, 30489, 63, 4758, 492, 30489, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 3222, 63, 9365, 63, 12782, 8, 2473, 12, 2518, 63, 498, 304, 272, 408, 26276, 3031, 6955, 370, 922, 641, 3365, 22587, 5309, 16630, 272, 2518, 325, 14, 71, 2020, 16630, 325, 17506, 29524, 12, 16630, 11628, 5423, 14, 272, 408, 272, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 2473, 9, 272, 871, 2876, 14, 7400, 26, 267, 943, 14, 705, 360, 1944, 922, 543, 450, 83, 2187, 297, 3434, 9, 267, 372, 339, 2518, 275, 10996, 1252, 362, 63, 1972, 8, 1972, 63, 498, 12, 5818, 29, 16, 9, 272, 2518, 63, 2918, 63, 354, 275, 2518, 14, 2918, 63, 354, 272, 15161, 63, 1100, 275, 15271, 14, 362, 63, 8877, 1252, 6983, 63, 1100, 342, 272, 15161, 63, 344, 275, 620, 8, 14428, 63, 1100, 14, 362, 360, 751, 63, 344, 1333, 272, 1890, 63, 344, 275, 620, 8, 14428, 63, 1100, 14, 362, 360, 1258, 63, 344, 1333, 272, 4474, 275, 7673, 84, 29, 1430, 6, 825, 29, 2123, 6, 4489, 29, 1490, 7, 272, 15161, 63, 8435, 275, 283, 2859, 921, 1544, 14, 3098, 13, 20211, 14, 957, 15, 7112, 31, 86, 29, 17, 6, 5700, 7, 435, 15161, 63, 344, 435, 7673, 7504, 7, 435, 1890, 63, 344, 435, 4474, 272, 17216, 63, 1073, 275, 485, 2123, 63, 633, 63, 2087, 360, 9743, 358, 272, 16630, 63, 1972, 63, 1073, 275, 485, 2123, 63, 633, 63, 2087, 360, 11653, 297, 8720, 466, 29, 9365, 358, 339, 327, 664, 10102, 330, 1312, 770, 23623, 272, 23623, 63, 1569, 275, 2581, 14, 362, 360, 9365, 14, 2123, 14, 17099, 13, 9733, 358, 272, 340, 23623, 63, 1569, 365, 488, 26, 267, 330, 1312, 770, 63, 9733, 275, 469, 288, 283, 1213, 356, 283, 2445, 79, 297, 288, 283, 515, 356, 2202, 14, 22839, 2594, 63, 10089, 63, 1149, 56, 63, 4947, 47, 12, 288, 283, 7504, 356, 620, 8, 2580, 14, 2580, 20, 1012, 267, 789, 267, 23623, 63, 1569, 63, 344, 275, 330, 1312, 770, 63, 9733, 459, 7504, 418, 267, 23623, 63, 1569, 275, 6554, 63, 1569, 8, 66, 1312, 770, 63, 9733, 12, 283, 2567, 5297, 79, 358, 267, 340, 23623, 63, 1569, 26, 288, 2581, 14, 409, 360, 9365, 14, 2123, 14, 17099, 13, 9733, 297, 23623, 63, 1569, 12, 2202, 14, 5798, 3841, 63, 22839, 2594, 63, 8677, 63, 8899, 9, 272, 587, 26, 267, 327, 6202, 25188, 9324, 21873, 687, 283, 9733, 63, 1569, 7, 2581, 283, 2714, 13, 998, 7, 267, 23623, 63, 1569, 63, 344, 275, 23623, 63, 1569, 14, 362, 360, 2714, 13, 998, 297, 4074, 59, 17, 6809, 17, 61, 339, 1067, 275, 469, 267, 283, 2861, 63, 354, 356, 922, 14, 362, 63, 2861, 63, 354, 1062, 267, 283, 3246, 63, 354, 356, 2202, 14, 17805, 63, 2339, 12, 267, 283, 1972, 63, 354, 356, 2518, 63, 2918, 63, 354, 12, 267, 283, 66, 1312, 770, 63, 9733, 356, 23623, 63, 1569, 63, 344, 12, 267, 283, 9743, 63, 1073, 356, 17216, 63, 1073, 12, 267, 283, 9365, 63, 1972, 63, 1073, 356, 16630, 63, 1972, 63, 1073, 12, 267, 283, 14428, 63, 8435, 356, 15161, 63, 8435, 12, 272, 789, 339, 327, 1218, 314, 1738, 3031, 1245, 272, 6955, 63, 1328, 275, 603, 30596, 1141, 2064, 360, 2407, 358, 272, 327, 1050, 283, 19389, 7, 1777, 370, 1738, 3031, 1245, 370, 22667, 5434, 314, 8971, 436, 272, 327, 4163, 5459, 12, 880, 1245, 22867, 883, 19822, 1314, 2985, 2934, 370, 2929, 14, 272, 1499, 63, 19389, 275, 603, 30596, 1141, 2064, 360, 19389, 358, 272, 6955, 63, 1328, 14, 5040, 8, 1328, 63, 19389, 9, 272, 327, 3795, 314, 16630, 6955, 7009, 272, 5420, 275, 12561, 85, 7, 6979, 30473, 662, 17506, 29524, 358, 339, 327, 1050, 13943, 8971, 1318, 1245, 272, 3031, 63, 2030, 63, 6104, 275, 3795, 63, 475, 63, 875, 360, 9365, 63, 12782, 15, 9365, 63, 69, 17506, 29524, 63, 2123, 14, 2424, 297, 1067, 9, 272, 1499, 63, 19389, 14, 5040, 8, 45, 26567, 8, 2123, 63, 2030, 63, 6104, 12, 485, 10512, 534, 6104, 297, 485, 6043, 534, 1624, 13, 24, 1333, 339, 327, 1050, 13943, 3517, 1245, 272, 3031, 63, 2030, 63, 1317, 275, 2581, 14, 362, 360, 9365, 14, 2123, 14, 3919, 13, 2123, 13, 2030, 358, 272, 340, 3031, 63, 2030, 63, 1317, 365, 488, 26, 267, 3517, 63, 493, 63, 515, 275, 570, 63, 515, 63, 11681, 360, 5876, 15, 9365, 63, 12782, 15, 9365, 63, 69, 17506, 29524, 63, 2123, 14, 1360, 358, 267, 340, 3517, 63, 493, 63, 515, 26, 288, 543, 1551, 8, 1360, 63, 493, 63, 515, 12, 283, 82, 358, 465, 1094, 63, 493, 26, 355, 1094, 63, 505, 275, 1094, 63, 493, 14, 739, 342, 355, 327, 675, 3517, 1798, 370, 22221, 3517, 4110, 1314, 787, 2896, 355, 327, 701, 314, 283, 647, 78, 31338, 7, 1830, 7791, 8308, 11431, 370, 3517, 1564, 355, 3517, 63, 2087, 275, 24581, 14, 27375, 342 ]
[ 199, 2765, 570, 3509, 11420, 3423, 1314, 911, 17845, 367, 10209, 14931, 14, 199, 624, 199, 199, 646, 747, 199, 199, 646, 2050, 199, 646, 1134, 78, 31338, 199, 646, 7097, 199, 646, 5377, 199, 646, 24581, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 18373, 492, 2583, 7735, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 1198, 492, 11426, 2209, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 199, 504, 3031, 14, 7626, 14, 1569, 492, 14735, 3491, 199, 504, 3031, 14, 7626, 14, 10123, 492, 603, 30596, 1141, 2064, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 1566, 14428, 492, 15271, 199, 199, 504, 22435, 19491, 14, 17469, 492, 3795, 63, 475, 63, 875, 199, 504, 22435, 19491, 14, 1160, 492, 5458, 199, 504, 30489, 63, 4758, 492, 30489, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 3222, 63, 9365, 63, 12782, 8, 2473, 12, 2518, 63, 498, 304, 272, 408, 26276, 3031, 6955, 370, 922, 641, 3365, 22587, 5309, 16630, 272, 2518, 325, 14, 71, 2020, 16630, 325, 17506, 29524, 12, 16630, 11628, 5423, 14, 272, 408, 272, 862, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 2473, 9, 272, 871, 2876, 14, 7400, 26, 267, 943, 14, 705, 360, 1944, 922, 543, 450, 83, 2187, 297, 3434, 9, 267, 372, 339, 2518, 275, 10996, 1252, 362, 63, 1972, 8, 1972, 63, 498, 12, 5818, 29, 16, 9, 272, 2518, 63, 2918, 63, 354, 275, 2518, 14, 2918, 63, 354, 272, 15161, 63, 1100, 275, 15271, 14, 362, 63, 8877, 1252, 6983, 63, 1100, 342, 272, 15161, 63, 344, 275, 620, 8, 14428, 63, 1100, 14, 362, 360, 751, 63, 344, 1333, 272, 1890, 63, 344, 275, 620, 8, 14428, 63, 1100, 14, 362, 360, 1258, 63, 344, 1333, 272, 4474, 275, 7673, 84, 29, 1430, 6, 825, 29, 2123, 6, 4489, 29, 1490, 7, 272, 15161, 63, 8435, 275, 283, 2859, 921, 1544, 14, 3098, 13, 20211, 14, 957, 15, 7112, 31, 86, 29, 17, 6, 5700, 7, 435, 15161, 63, 344, 435, 7673, 7504, 7, 435, 1890, 63, 344, 435, 4474, 272, 17216, 63, 1073, 275, 485, 2123, 63, 633, 63, 2087, 360, 9743, 358, 272, 16630, 63, 1972, 63, 1073, 275, 485, 2123, 63, 633, 63, 2087, 360, 11653, 297, 8720, 466, 29, 9365, 358, 339, 327, 664, 10102, 330, 1312, 770, 23623, 272, 23623, 63, 1569, 275, 2581, 14, 362, 360, 9365, 14, 2123, 14, 17099, 13, 9733, 358, 272, 340, 23623, 63, 1569, 365, 488, 26, 267, 330, 1312, 770, 63, 9733, 275, 469, 288, 283, 1213, 356, 283, 2445, 79, 297, 288, 283, 515, 356, 2202, 14, 22839, 2594, 63, 10089, 63, 1149, 56, 63, 4947, 47, 12, 288, 283, 7504, 356, 620, 8, 2580, 14, 2580, 20, 1012, 267, 789, 267, 23623, 63, 1569, 63, 344, 275, 330, 1312, 770, 63, 9733, 459, 7504, 418, 267, 23623, 63, 1569, 275, 6554, 63, 1569, 8, 66, 1312, 770, 63, 9733, 12, 283, 2567, 5297, 79, 358, 267, 340, 23623, 63, 1569, 26, 288, 2581, 14, 409, 360, 9365, 14, 2123, 14, 17099, 13, 9733, 297, 23623, 63, 1569, 12, 2202, 14, 5798, 3841, 63, 22839, 2594, 63, 8677, 63, 8899, 9, 272, 587, 26, 267, 327, 6202, 25188, 9324, 21873, 687, 283, 9733, 63, 1569, 7, 2581, 283, 2714, 13, 998, 7, 267, 23623, 63, 1569, 63, 344, 275, 23623, 63, 1569, 14, 362, 360, 2714, 13, 998, 297, 4074, 59, 17, 6809, 17, 61, 339, 1067, 275, 469, 267, 283, 2861, 63, 354, 356, 922, 14, 362, 63, 2861, 63, 354, 1062, 267, 283, 3246, 63, 354, 356, 2202, 14, 17805, 63, 2339, 12, 267, 283, 1972, 63, 354, 356, 2518, 63, 2918, 63, 354, 12, 267, 283, 66, 1312, 770, 63, 9733, 356, 23623, 63, 1569, 63, 344, 12, 267, 283, 9743, 63, 1073, 356, 17216, 63, 1073, 12, 267, 283, 9365, 63, 1972, 63, 1073, 356, 16630, 63, 1972, 63, 1073, 12, 267, 283, 14428, 63, 8435, 356, 15161, 63, 8435, 12, 272, 789, 339, 327, 1218, 314, 1738, 3031, 1245, 272, 6955, 63, 1328, 275, 603, 30596, 1141, 2064, 360, 2407, 358, 272, 327, 1050, 283, 19389, 7, 1777, 370, 1738, 3031, 1245, 370, 22667, 5434, 314, 8971, 436, 272, 327, 4163, 5459, 12, 880, 1245, 22867, 883, 19822, 1314, 2985, 2934, 370, 2929, 14, 272, 1499, 63, 19389, 275, 603, 30596, 1141, 2064, 360, 19389, 358, 272, 6955, 63, 1328, 14, 5040, 8, 1328, 63, 19389, 9, 272, 327, 3795, 314, 16630, 6955, 7009, 272, 5420, 275, 12561, 85, 7, 6979, 30473, 662, 17506, 29524, 358, 339, 327, 1050, 13943, 8971, 1318, 1245, 272, 3031, 63, 2030, 63, 6104, 275, 3795, 63, 475, 63, 875, 360, 9365, 63, 12782, 15, 9365, 63, 69, 17506, 29524, 63, 2123, 14, 2424, 297, 1067, 9, 272, 1499, 63, 19389, 14, 5040, 8, 45, 26567, 8, 2123, 63, 2030, 63, 6104, 12, 485, 10512, 534, 6104, 297, 485, 6043, 534, 1624, 13, 24, 1333, 339, 327, 1050, 13943, 3517, 1245, 272, 3031, 63, 2030, 63, 1317, 275, 2581, 14, 362, 360, 9365, 14, 2123, 14, 3919, 13, 2123, 13, 2030, 358, 272, 340, 3031, 63, 2030, 63, 1317, 365, 488, 26, 267, 3517, 63, 493, 63, 515, 275, 570, 63, 515, 63, 11681, 360, 5876, 15, 9365, 63, 12782, 15, 9365, 63, 69, 17506, 29524, 63, 2123, 14, 1360, 358, 267, 340, 3517, 63, 493, 63, 515, 26, 288, 543, 1551, 8, 1360, 63, 493, 63, 515, 12, 283, 82, 358, 465, 1094, 63, 493, 26, 355, 1094, 63, 505, 275, 1094, 63, 493, 14, 739, 342, 355, 327, 675, 3517, 1798, 370, 22221, 3517, 4110, 1314, 787, 2896, 355, 327, 701, 314, 283, 647, 78, 31338, 7, 1830, 7791, 8308, 11431, 370, 3517, 1564, 355, 3517, 63, 2087, 275, 24581, 14, 27375, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
AndrewPeelMV/Blender2.78c
2.78/scripts/modules/bl_i18n_utils/utils_rtl.py
7
6313
#!/usr/bin/env python3 # ***** BEGIN GPL LICENSE BLOCK ***** # # 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. # # ***** END GPL LICENSE BLOCK ***** # <pep8 compliant> # Preprocess right-to-left languages. # You can use it either standalone, or through import_po_from_branches or # update_trunk. # # Notes: This has been tested on Linux, not 100% it will work nicely on # Windows or OsX. # This uses ctypes, as there is no py3 binding for fribidi currently. # This implies you only need the compiled C library to run it. # Finally, note that it handles some formating/escape codes (like # \", %s, %x12, %.4f, etc.), protecting them from ugly (evil) fribidi, # which seems completely unaware of such things (as unicode is...). import sys import ctypes import re #define FRIBIDI_MASK_NEUTRAL 0x00000040L /* Is neutral */ FRIBIDI_PAR_ON = 0x00000040 #define FRIBIDI_FLAG_SHAPE_MIRRORING 0x00000001 #define FRIBIDI_FLAG_REORDER_NSM 0x00000002 #define FRIBIDI_FLAG_SHAPE_ARAB_PRES 0x00000100 #define FRIBIDI_FLAG_SHAPE_ARAB_LIGA 0x00000200 #define FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE 0x00000400 #define FRIBIDI_FLAG_REMOVE_BIDI 0x00010000 #define FRIBIDI_FLAG_REMOVE_JOINING 0x00020000 #define FRIBIDI_FLAG_REMOVE_SPECIALS 0x00040000 #define FRIBIDI_FLAGS_DEFAULT ( \ # FRIBIDI_FLAG_SHAPE_MIRRORING | \ # FRIBIDI_FLAG_REORDER_NSM | \ # FRIBIDI_FLAG_REMOVE_SPECIALS ) #define FRIBIDI_FLAGS_ARABIC ( \ # FRIBIDI_FLAG_SHAPE_ARAB_PRES | \ # FRIBIDI_FLAG_SHAPE_ARAB_LIGA ) FRIBIDI_FLAG_SHAPE_MIRRORING = 0x00000001 FRIBIDI_FLAG_REORDER_NSM = 0x00000002 FRIBIDI_FLAG_REMOVE_SPECIALS = 0x00040000 FRIBIDI_FLAG_SHAPE_ARAB_PRES = 0x00000100 FRIBIDI_FLAG_SHAPE_ARAB_LIGA = 0x00000200 FRIBIDI_FLAGS_DEFAULT = FRIBIDI_FLAG_SHAPE_MIRRORING | FRIBIDI_FLAG_REORDER_NSM | FRIBIDI_FLAG_REMOVE_SPECIALS FRIBIDI_FLAGS_ARABIC = FRIBIDI_FLAG_SHAPE_ARAB_PRES | FRIBIDI_FLAG_SHAPE_ARAB_LIGA MENU_DETECT_REGEX = re.compile("%x\\d+\\|") ##### Kernel processing funcs. ##### def protect_format_seq(msg): """ Find some specific escaping/formating sequences (like \", %s, etc., and protect them from any modification! """ # LRM = "\u200E" # RLM = "\u200F" LRE = "\u202A" RLE = "\u202B" PDF = "\u202C" LRO = "\u202D" RLO = "\u202E" uctrl = {LRE, RLE, PDF, LRO, RLO} # Most likely incomplete, but seems to cover current needs. format_codes = set("tslfd") digits = set(".0123456789") if not msg: return msg elif MENU_DETECT_REGEX.search(msg): # An ugly "menu" message, just force it whole LRE if not yet done. if msg[0] not in {LRE, LRO}: msg = LRE + msg idx = 0 ret = [] ln = len(msg) while idx < ln: dlt = 1 # # If we find a control char, skip any additional protection! # if msg[idx] in uctrl: # ret.append(msg[idx:]) # break # \" or \' if idx < (ln - 1) and msg[idx] == '\\' and msg[idx + 1] in "\"\'": dlt = 2 # %x12| elif idx < (ln - 2) and msg[idx] == '%' and msg[idx + 1] in "x" and msg[idx + 2] in digits: dlt = 2 while (idx + dlt) < ln and msg[idx + dlt] in digits: dlt += 1 if (idx + dlt) < ln and msg[idx + dlt] is '|': dlt += 1 # %.4f elif idx < (ln - 3) and msg[idx] == '%' and msg[idx + 1] in digits: dlt = 2 while (idx + dlt) < ln and msg[idx + dlt] in digits: dlt += 1 if (idx + dlt) < ln and msg[idx + dlt] in format_codes: dlt += 1 else: dlt = 1 # %s elif idx < (ln - 1) and msg[idx] == '%' and msg[idx + 1] in format_codes: dlt = 2 if dlt > 1: ret.append(LRE) ret += msg[idx:idx + dlt] idx += dlt if dlt > 1: ret.append(PDF) return "".join(ret) def log2vis(msgs, settings): """ Globally mimics deprecated fribidi_log2vis. msgs should be an iterable of messages to rtl-process. """ fbd = ctypes.CDLL(settings.FRIBIDI_LIB) for msg in msgs: msg = protect_format_seq(msg) fbc_str = ctypes.create_unicode_buffer(msg) ln = len(fbc_str) - 1 # print(fbc_str.value, ln) btypes = (ctypes.c_int * ln)() embed_lvl = (ctypes.c_uint8 * ln)() pbase_dir = ctypes.c_int(FRIBIDI_PAR_ON) jtypes = (ctypes.c_uint8 * ln)() flags = FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC # Find out direction of each char. fbd.fribidi_get_bidi_types(fbc_str, ln, ctypes.byref(btypes)) # print(*btypes) fbd.fribidi_get_par_embedding_levels(btypes, ln, ctypes.byref(pbase_dir), embed_lvl) # print(*embed_lvl) # Joinings for arabic chars. fbd.fribidi_get_joining_types(fbc_str, ln, jtypes) # print(*jtypes) fbd.fribidi_join_arabic(btypes, ln, embed_lvl, jtypes) # print(*jtypes) # Final Shaping! fbd.fribidi_shape(flags, embed_lvl, ln, jtypes, fbc_str) # print(fbc_str.value) # print(*(ord(c) for c in fbc_str)) # And now, the reordering. # Note that here, we expect a single line, so no need to do # fancy things... fbd.fribidi_reorder_line(flags, btypes, ln, 0, pbase_dir, embed_lvl, fbc_str, None) # print(fbc_str.value) # print(*(ord(c) for c in fbc_str)) yield fbc_str.value
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1011, 9153, 16427, 14629, 5113, 8068, 1011, 9153, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 1011, 9153, 7729, 14629, 5113, 8068, 1011, 9153, 199, 199, 3, 665, 12636, 24, 1013, 22676, 30, 199, 199, 3, 5543, 1412, 2451, 13, 475, 13, 3039, 10815, 14, 199, 3, 2047, 883, 675, 652, 1902, 18042, 12, 503, 4012, 492, 63, 555, 63, 504, 63, 16896, 503, 199, 3, 1678, 63, 13409, 14, 199, 3, 199, 3, 8144, 26, 961, 965, 2757, 12470, 641, 10130, 12, 440, 2948, 5, 652, 911, 1736, 14213, 590, 641, 199, 3, 263, 5417, 503, 593, 83, 56, 14, 199, 3, 263, 961, 4440, 5577, 12, 465, 2337, 365, 949, 1134, 19, 11696, 367, 289, 322, 21555, 5544, 14, 199, 3, 263, 961, 22660, 1265, 1454, 1929, 314, 10311, 445, 3555, 370, 1255, 652, 14, 199, 3, 263, 19177, 12, 5317, 626, 652, 10022, 2005, 1475, 316, 15, 3765, 9479, 334, 2930, 199, 3, 263, 971, 401, 450, 83, 12, 450, 88, 713, 12, 10536, 20, 70, 12, 5423, 15631, 25863, 316, 3062, 687, 23761, 334, 6857, 382, 9, 289, 322, 21555, 12, 199, 3, 263, 1314, 12237, 14793, 625, 14600, 402, 4066, 7645, 334, 305, 2649, 365, 1396, 680, 199, 199, 646, 984, 199, 646, 5577, 199, 646, 295, 421, 199, 3, 4640, 28671, 2100, 28904, 63, 12880, 63, 6388, 934, 50, 748, 198, 16, 88, 3273, 2167, 44, 198, 6331, 6596, 1279, 29358, 11589, 199, 5372, 2100, 28904, 63, 4014, 63, 615, 275, 378, 88, 3273, 2167, 421, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 198, 16, 88, 23848, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 198, 16, 88, 32764, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 198, 16, 88, 993, 16569, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 198, 16, 88, 993, 24215, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 31774, 198, 16, 88, 993, 27130, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 34, 28904, 198, 16, 88, 4183, 993, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 23321, 1206, 198, 16, 88, 9425, 993, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 198, 16, 88, 16643, 993, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 4831, 63, 3472, 198, 198, 8, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 198, 9, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 4831, 63, 689, 9057, 198, 198, 8, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 198, 9, 199, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 275, 378, 88, 23848, 199, 5372, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 275, 378, 88, 32764, 199, 5372, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 275, 378, 88, 16643, 993, 199, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 275, 378, 88, 993, 16569, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 275, 378, 88, 993, 24215, 199, 199, 5372, 2100, 28904, 63, 4831, 63, 3472, 275, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 1204, 28671, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 1204, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 199, 199, 5372, 2100, 28904, 63, 4831, 63, 689, 9057, 275, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 1204, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 421, 199, 18223, 63, 17442, 3582, 63, 10710, 275, 295, 14, 2014, 3647, 88, 1103, 68, 11, 1103, 92, 531, 421, 199, 8776, 24901, 6661, 18805, 14, 22906, 199, 318, 25863, 63, 908, 63, 3610, 8, 1328, 304, 272, 408, 272, 6668, 2005, 2488, 21375, 15, 908, 316, 8013, 334, 2930, 971, 401, 450, 83, 12, 5423, 2020, 272, 436, 25863, 3062, 687, 1263, 7100, 1, 272, 408, 199, 3, 259, 491, 11026, 275, 1867, 85, 1840, 37, 2, 199, 3, 259, 820, 25526, 275, 1867, 85, 1840, 38, 2, 272, 491, 907, 275, 1867, 85, 4999, 33, 2, 272, 820, 906, 275, 1867, 85, 4999, 34, 2, 272, 15537, 275, 1867, 85, 4999, 35, 2, 272, 491, 1092, 275, 1867, 85, 4999, 36, 2, 272, 820, 1484, 275, 1867, 85, 4999, 37, 2, 272, 399, 12476, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1011, 9153, 16427, 14629, 5113, 8068, 1011, 9153, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 1011, 9153, 7729, 14629, 5113, 8068, 1011, 9153, 199, 199, 3, 665, 12636, 24, 1013, 22676, 30, 199, 199, 3, 5543, 1412, 2451, 13, 475, 13, 3039, 10815, 14, 199, 3, 2047, 883, 675, 652, 1902, 18042, 12, 503, 4012, 492, 63, 555, 63, 504, 63, 16896, 503, 199, 3, 1678, 63, 13409, 14, 199, 3, 199, 3, 8144, 26, 961, 965, 2757, 12470, 641, 10130, 12, 440, 2948, 5, 652, 911, 1736, 14213, 590, 641, 199, 3, 263, 5417, 503, 593, 83, 56, 14, 199, 3, 263, 961, 4440, 5577, 12, 465, 2337, 365, 949, 1134, 19, 11696, 367, 289, 322, 21555, 5544, 14, 199, 3, 263, 961, 22660, 1265, 1454, 1929, 314, 10311, 445, 3555, 370, 1255, 652, 14, 199, 3, 263, 19177, 12, 5317, 626, 652, 10022, 2005, 1475, 316, 15, 3765, 9479, 334, 2930, 199, 3, 263, 971, 401, 450, 83, 12, 450, 88, 713, 12, 10536, 20, 70, 12, 5423, 15631, 25863, 316, 3062, 687, 23761, 334, 6857, 382, 9, 289, 322, 21555, 12, 199, 3, 263, 1314, 12237, 14793, 625, 14600, 402, 4066, 7645, 334, 305, 2649, 365, 1396, 680, 199, 199, 646, 984, 199, 646, 5577, 199, 646, 295, 421, 199, 3, 4640, 28671, 2100, 28904, 63, 12880, 63, 6388, 934, 50, 748, 198, 16, 88, 3273, 2167, 44, 198, 6331, 6596, 1279, 29358, 11589, 199, 5372, 2100, 28904, 63, 4014, 63, 615, 275, 378, 88, 3273, 2167, 421, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 198, 16, 88, 23848, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 198, 16, 88, 32764, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 198, 16, 88, 993, 16569, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 198, 16, 88, 993, 24215, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 31774, 198, 16, 88, 993, 27130, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 34, 28904, 198, 16, 88, 4183, 993, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 23321, 1206, 198, 16, 88, 9425, 993, 199, 3, 4640, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 198, 16, 88, 16643, 993, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 4831, 63, 3472, 198, 198, 8, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 198, 9, 199, 199, 3, 4640, 28671, 2100, 28904, 63, 4831, 63, 689, 9057, 198, 198, 8, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 198, 92, 971, 199, 3, 198, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 198, 9, 199, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 275, 378, 88, 23848, 199, 5372, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 275, 378, 88, 32764, 199, 5372, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 275, 378, 88, 16643, 993, 199, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 275, 378, 88, 993, 16569, 199, 5372, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 275, 378, 88, 993, 24215, 199, 199, 5372, 2100, 28904, 63, 4831, 63, 3472, 275, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 45, 3927, 50, 726, 1206, 1204, 28671, 2100, 28904, 63, 3719, 63, 907, 12125, 63, 2709, 45, 1204, 28671, 2100, 28904, 63, 3719, 63, 25856, 63, 25748, 51, 199, 199, 5372, 2100, 28904, 63, 4831, 63, 689, 9057, 275, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 14956, 1204, 28671, 2100, 28904, 63, 3719, 63, 3234, 25380, 63, 689, 1217, 63, 44, 1277, 33, 421, 199, 18223, 63, 17442, 3582, 63, 10710, 275, 295, 14, 2014, 3647, 88, 1103, 68, 11, 1103, 92, 531, 421, 199, 8776, 24901, 6661, 18805, 14, 22906, 199, 318, 25863, 63, 908, 63, 3610, 8, 1328, 304, 272, 408, 272, 6668, 2005, 2488, 21375, 15, 908, 316, 8013, 334, 2930, 971, 401, 450, 83, 12, 5423, 2020, 272, 436, 25863, 3062, 687, 1263, 7100, 1, 272, 408, 199, 3, 259, 491, 11026, 275, 1867, 85, 1840, 37, 2, 199, 3, 259, 820, 25526, 275, 1867, 85, 1840, 38, 2, 272, 491, 907, 275, 1867, 85, 4999, 33, 2, 272, 820, 906, 275, 1867, 85, 4999, 34, 2, 272, 15537, 275, 1867, 85, 4999, 35, 2, 272, 491, 1092, 275, 1867, 85, 4999, 36, 2, 272, 820, 1484, 275, 1867, 85, 4999, 37, 2, 272, 399, 12476, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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""" import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import matplotlib.animation as animation GRAVITY = -9.81 class Environment: def __init__(self, dimensions=None, dynamic_objects=None, static_objects=None, robot=None): """An environment to run experiments in :param dimensions: (Optional) The dimensions of env :type dimensions: 1x3 numpy.array or None :param dynamic_objects: (Optional) A list of objects that can move :type dynamic_objects: list of maddux.objects.DynamicObject or None :param static_objects: (Optional) A list of stationary objects :type static_objects: list of maddux.objects.StaticObject or None :param robot: (Optional) A robot to simulate :type robot: maddux.robot.Arm or None :rtype: None """ if dimensions is not None: self.dimensions = np.array(dimensions) else: self.dimensions = np.array([10.0, 10.0, 100.0]) self.dynamic_objects = dynamic_objects if dynamic_objects else [] self.static_objects = static_objects if static_objects else [] self.robot = robot def run(self, duration): """Run for a certain duration :param duration: duration to run environment in seconds :type duration: integer :rtype: None """ duration_ms = int(duration * 1000) for _ in xrange(duration_ms): map(lambda obj: obj.step(), self.dynamic_objects) if self.collision(): break def animate(self, duration=None, save_path=None): """Animates the running of the program :param duration: (Optional) Duration of animation in seconds :type duration: int or None :param save_path: (Optional) Path to save mp4 in instead of displaying :type save_path: String or None :rtype: None """ fps = 15 dynamic_iter_per_frame = 10 * fps if duration is None: if self.robot is None: # Sensible Default frames = fps * 5 else: frames = len(self.robot.qs) else: frames = int(fps * duration) def update(i): ax.clear() for _ in xrange(dynamic_iter_per_frame): map(lambda obj: obj.step(), self.dynamic_objects) # Check for collisions self.collision() if self.robot is not None: next_q = self.robot.qs[i] self.robot.update_angles(next_q) self.plot(ax=ax, show=False) fig = plt.figure(figsize=(8, 8)) ax = Axes3D(fig) self.plot(ax=ax, show=False) # If we don't assign its return to something, it doesn't run. # Seems like really weird behavior.. ani = animation.FuncAnimation(fig, update, frames=frames, blit=False) if save_path is None: plt.show() else: Writer = animation.writers['ffmpeg'] writer = Writer( fps=fps, metadata=dict( artist='Maddux'), bitrate=1800) ani.save(save_path, writer=writer) def hypothetical_landing_position(self): """Find the position that the ball would land (or hit a wall) :returns: Position (x, y, z) of hypothetical landing position of a thrown object based on end effector velocity. :rtype: numpy.ndarray or None """ pos = self.robot.end_effector_position().copy() # Only need linear velocity v = self.robot.end_effector_velocity()[0:3] for t in np.linspace(0, 15, 5000): # Check if it hit a target for static in self.static_objects: if static.is_hit(pos): return pos.copy() # Or a wall for i in range(len(pos)): in_negative_space = pos[i] <= 0 past_boundary = pos[i] >= self.dimensions[i] if in_negative_space or past_boundary: return pos.copy() # Otherwise step forward v[2] += t * GRAVITY pos += t * v # If we never hit anything (which is completely impossible (TM)) # return None return None def collision(self): """Check if any dynamic objects collide with any static objects or walls. :return: Whether there was a collision :rtype: bool """ for dynamic in self.dynamic_objects: if dynamic.attached: continue for static in self.static_objects: if static.is_hit(dynamic.position): dynamic.attach() return True for i in range(len(dynamic.position)): in_negative_space = dynamic.position[i] <= 0 past_boundary = (dynamic.position[i] >= self.dimensions[i]) if in_negative_space or past_boundary: dynamic.attach() return True return False def plot(self, ax=None, show=True): """Plot throw trajectory and ball :param ax: Current axis if a figure already exists :type ax: matplotlib.axes :param show: (Default: True) Whether to show the figure :type show: bool :rtype: None """ if ax is None: fig = plt.figure(figsize=(12, 12)) ax = Axes3D(fig) # Set the limits to be environment ranges ax.set_xlim([0, self.dimensions[0]]) ax.set_ylim([0, self.dimensions[1]]) if self.dynamic_objects: zmax = max([o.positions[:, 2].max() for o in self.dynamic_objects]) else: zmax = 10 ax.set_zlim([0, max(10, zmax)]) # And set our labels ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') for dynamic in self.dynamic_objects: # Plot Trajectory ax.plot(dynamic.positions[:, 0], dynamic.positions[:, 1], dynamic.positions[:, 2], 'r--', label='Trajectory') # Plot objects map(lambda obj: obj.plot(ax), self.dynamic_objects) map(lambda obj: obj.plot(ax), self.static_objects) if self.robot: self.robot.plot(ax) if show: plt.show()
mit
[ 624, 199, 47, 300, 11805, 3734, 14, 199, 624, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 437, 12908, 19, 36, 199, 646, 8027, 14, 22228, 465, 24154, 421, 199, 18583, 54, 1922, 275, 446, 25, 14, 2835, 421, 199, 533, 9711, 26, 339, 347, 636, 826, 721, 277, 12, 7365, 29, 403, 12, 8336, 63, 1462, 29, 403, 12, 326, 2955, 63, 1462, 29, 403, 12, 14544, 29, 403, 304, 267, 408, 2493, 3734, 370, 1255, 444, 22263, 315, 398, 520, 635, 7365, 26, 334, 7012, 9, 710, 7365, 402, 2589, 267, 520, 466, 7365, 26, 413, 88, 19, 2680, 14, 1144, 503, 488, 398, 520, 635, 8336, 63, 1462, 26, 334, 7012, 9, 437, 769, 402, 2251, 626, 883, 4057, 267, 520, 466, 8336, 63, 1462, 26, 769, 402, 333, 525, 2521, 14, 1462, 14, 14451, 1692, 503, 488, 398, 520, 635, 2955, 63, 1462, 26, 334, 7012, 9, 437, 769, 402, 16518, 695, 2251, 267, 520, 466, 2955, 63, 1462, 26, 769, 402, 333, 525, 2521, 14, 1462, 14, 9278, 1692, 503, 488, 398, 520, 635, 14544, 26, 334, 7012, 9, 437, 14544, 370, 20577, 267, 520, 466, 14544, 26, 333, 525, 2521, 14, 9751, 14, 1596, 77, 503, 488, 398, 520, 4500, 26, 488, 267, 408, 398, 340, 7365, 365, 440, 488, 26, 288, 291, 14, 13320, 275, 980, 14, 1144, 8, 13320, 9, 267, 587, 26, 288, 291, 14, 13320, 275, 980, 14, 1144, 779, 709, 14, 16, 12, 1616, 14, 16, 12, 2948, 14, 16, 566, 267, 291, 14, 7764, 63, 1462, 275, 8336, 63, 1462, 340, 8336, 63, 1462, 587, 942, 267, 291, 14, 1986, 63, 1462, 275, 2955, 63, 1462, 340, 2955, 63, 1462, 587, 942, 267, 291, 14, 9751, 275, 14544, 339, 347, 1255, 8, 277, 12, 7373, 304, 267, 408, 2540, 367, 282, 9842, 7373, 398, 520, 635, 7373, 26, 7373, 370, 1255, 3734, 315, 4696, 267, 520, 466, 7373, 26, 3000, 398, 520, 4500, 26, 488, 267, 408, 267, 7373, 63, 706, 275, 1109, 8, 5553, 627, 5198, 9, 398, 367, 485, 315, 4945, 8, 5553, 63, 706, 304, 288, 2341, 8, 2734, 1559, 26, 1559, 14, 2926, 1062, 291, 14, 7764, 63, 1462, 9, 288, 340, 291, 14, 761, 23656, 837, 355, 2059, 339, 347, 376, 6897, 8, 277, 12, 7373, 29, 403, 12, 3354, 63, 515, 29, 403, 304, 267, 408, 2493, 18187, 314, 3879, 402, 314, 2240, 398, 520, 635, 7373, 26, 334, 7012, 9, 31836, 402, 24154, 315, 4696, 267, 520, 466, 7373, 26, 1109, 503, 488, 398, 520, 635, 3354, 63, 515, 26, 334, 7012, 9, 6912, 370, 3354, 6118, 20, 315, 3140, 402, 20589, 267, 520, 466, 3354, 63, 515, 26, 2624, 503, 488, 398, 520, 4500, 26, 488, 267, 408, 267, 289, 1190, 275, 4114, 267, 8336, 63, 1661, 63, 529, 63, 1943, 275, 1616, 627, 289, 1190, 398, 340, 7373, 365, 488, 26, 288, 340, 291, 14, 9751, 365, 488, 26, 355, 327, 428, 287, 1164, 3758, 355, 11223, 275, 289, 1190, 627, 959, 288, 587, 26, 355, 11223, 275, 822, 8, 277, 14, 9751, 14, 6177, 9, 267, 587, 26, 288, 11223, 275, 1109, 8, 24709, 627, 7373, 9, 398, 347, 1678, 8, 73, 304, 288, 2185, 14, 3584, 342, 288, 367, 485, 315, 4945, 8, 7764, 63, 1661, 63, 529, 63, 1943, 304, 355, 2341, 8, 2734, 1559, 26, 1559, 14, 2926, 1062, 291, 14, 7764, 63, 1462, 9, 355, 327, 2670, 367, 30063, 355, 291, 14, 761, 23656, 342, 288, 340, 291, 14, 9751, 365, 440, 488, 26, 355, 2163, 63, 81, 275, 291, 14, 9751, 14, 6177, 59, 73, 61, 355, 291, 14, 9751, 14, 873, 63, 13162, 8, 2184, 63, 81, 9, 288, 291, 14, 2798, 8, 1219, 29, 1219, 12, 2498, 29, 797, 9, 398, 6085, 275, 4488, 14, 8941, 8, 23899, 2687, 24, 12, 1695, 430, 267, 2185, 275, 437, 12908, 19, 36, 8, 592, 9, 267, 291, 14, 2798, 8, 1219, 29, 1219, 12, 2498, 29, 797, 9, 398, 327, 982, 781, 2793, 1133, 5090, 2399, 372, 370, 6020, 12, 652, 3181, 1133, 1255, 14, 267, 327, 1666, 706, 2839, 7710, 22965, 5953, 703, 267, 376, 73, 275, 24154, 14, 7465, 15957, 8, 592, 12, 1678, 12, 11223, 29, 8444, 12, 330, 1051, 29, 797, 9, 267, 340, 3354, 63, 515, 365, 488, 26, 288, 4488, 14, 2384, 342, 267, 587, 26, 288, 24441, 275, 24154, 14, 26224, 459, 27648, 418, 288, 7060, 275, 24441, 8, 355, 289, 1190, 29, 24709, 12, 3341, 29, 807, 8, 490, 16459, 534, 45, 525, 2521, 659, 4546, 1866, 29, 1085, 383, 9, 288, 376, 73, 14, 2117, 8, 2117, 63, 515, 12, 7060, 29, 5491, 9, 339, 347, 23701, 1589, 3294, 63, 9688, 316, 63, 3124, 8, 277, 304, 267, 408, 6591, 314, 3421, 626, 314, 330, 452, 3955, 20078, 334, 269, 9793, 282, 19882, 9, 398, 520, 5808, 26, 15483, 334, 88, 12, 612, 12, 1315, 9, 402, 23701, 1589, 3294, 20078, 316, 3421, 402, 282, 2116, 14031, 909, 4079, 641, 1284, 10783, 2406, 20508, 14, 267, 520, 4500, 26, 2680, 14, 8237, 503, 488, 267, 408, 267, 2086, 275, 291, 14, 9751, 14, 500, 63, 3609, 2406, 63, 3124, 1252, 1574, 342, 267, 327, 5972, 1929, 7798, 20508, 267, 373, 275, 291, 14, 9751, 14, 500, 63, 3609, 2406, 63, 16350, 3430, 16, 26, 19, 61, 398, 367, 307, 315, 980, 14, 11649, 8, 16, 12, 4114, 12, 22369, 304, 288, 327, 2670, 340, 652, 9793, 282, 1347, 288, 367, 2955, 315, 291, 14, 1986, 63, 1462, 26, 355, 340, 2955, 14, 374, 63, 12948, 8, 1712, 304, 490, 372, 2086, 14, 1574, 342, 953, 327, 4236, 282, 19882, 288, 367, 284, 315, 1425, 8, 552, 8, 1712, 2298, 355, 315, 63, 7371, 63, 2638, 275, 2086, 59, 73, 61, 2695, 378, 355, 13541, 63, 9891, 275, 2086, 59, 73, 61, 2356, 291, 14, 13320, 59, 73, 61, 2234, 340, 315, 63, 7371, 63, 2638, 503, 13541, 63, 9891, 26, 490, 372, 2086, 14, 1574, 342, 953, 327, 6630, 3650, 7568 ]
[ 199, 47, 300, 11805, 3734, 14, 199, 624, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 437, 12908, 19, 36, 199, 646, 8027, 14, 22228, 465, 24154, 421, 199, 18583, 54, 1922, 275, 446, 25, 14, 2835, 421, 199, 533, 9711, 26, 339, 347, 636, 826, 721, 277, 12, 7365, 29, 403, 12, 8336, 63, 1462, 29, 403, 12, 326, 2955, 63, 1462, 29, 403, 12, 14544, 29, 403, 304, 267, 408, 2493, 3734, 370, 1255, 444, 22263, 315, 398, 520, 635, 7365, 26, 334, 7012, 9, 710, 7365, 402, 2589, 267, 520, 466, 7365, 26, 413, 88, 19, 2680, 14, 1144, 503, 488, 398, 520, 635, 8336, 63, 1462, 26, 334, 7012, 9, 437, 769, 402, 2251, 626, 883, 4057, 267, 520, 466, 8336, 63, 1462, 26, 769, 402, 333, 525, 2521, 14, 1462, 14, 14451, 1692, 503, 488, 398, 520, 635, 2955, 63, 1462, 26, 334, 7012, 9, 437, 769, 402, 16518, 695, 2251, 267, 520, 466, 2955, 63, 1462, 26, 769, 402, 333, 525, 2521, 14, 1462, 14, 9278, 1692, 503, 488, 398, 520, 635, 14544, 26, 334, 7012, 9, 437, 14544, 370, 20577, 267, 520, 466, 14544, 26, 333, 525, 2521, 14, 9751, 14, 1596, 77, 503, 488, 398, 520, 4500, 26, 488, 267, 408, 398, 340, 7365, 365, 440, 488, 26, 288, 291, 14, 13320, 275, 980, 14, 1144, 8, 13320, 9, 267, 587, 26, 288, 291, 14, 13320, 275, 980, 14, 1144, 779, 709, 14, 16, 12, 1616, 14, 16, 12, 2948, 14, 16, 566, 267, 291, 14, 7764, 63, 1462, 275, 8336, 63, 1462, 340, 8336, 63, 1462, 587, 942, 267, 291, 14, 1986, 63, 1462, 275, 2955, 63, 1462, 340, 2955, 63, 1462, 587, 942, 267, 291, 14, 9751, 275, 14544, 339, 347, 1255, 8, 277, 12, 7373, 304, 267, 408, 2540, 367, 282, 9842, 7373, 398, 520, 635, 7373, 26, 7373, 370, 1255, 3734, 315, 4696, 267, 520, 466, 7373, 26, 3000, 398, 520, 4500, 26, 488, 267, 408, 267, 7373, 63, 706, 275, 1109, 8, 5553, 627, 5198, 9, 398, 367, 485, 315, 4945, 8, 5553, 63, 706, 304, 288, 2341, 8, 2734, 1559, 26, 1559, 14, 2926, 1062, 291, 14, 7764, 63, 1462, 9, 288, 340, 291, 14, 761, 23656, 837, 355, 2059, 339, 347, 376, 6897, 8, 277, 12, 7373, 29, 403, 12, 3354, 63, 515, 29, 403, 304, 267, 408, 2493, 18187, 314, 3879, 402, 314, 2240, 398, 520, 635, 7373, 26, 334, 7012, 9, 31836, 402, 24154, 315, 4696, 267, 520, 466, 7373, 26, 1109, 503, 488, 398, 520, 635, 3354, 63, 515, 26, 334, 7012, 9, 6912, 370, 3354, 6118, 20, 315, 3140, 402, 20589, 267, 520, 466, 3354, 63, 515, 26, 2624, 503, 488, 398, 520, 4500, 26, 488, 267, 408, 267, 289, 1190, 275, 4114, 267, 8336, 63, 1661, 63, 529, 63, 1943, 275, 1616, 627, 289, 1190, 398, 340, 7373, 365, 488, 26, 288, 340, 291, 14, 9751, 365, 488, 26, 355, 327, 428, 287, 1164, 3758, 355, 11223, 275, 289, 1190, 627, 959, 288, 587, 26, 355, 11223, 275, 822, 8, 277, 14, 9751, 14, 6177, 9, 267, 587, 26, 288, 11223, 275, 1109, 8, 24709, 627, 7373, 9, 398, 347, 1678, 8, 73, 304, 288, 2185, 14, 3584, 342, 288, 367, 485, 315, 4945, 8, 7764, 63, 1661, 63, 529, 63, 1943, 304, 355, 2341, 8, 2734, 1559, 26, 1559, 14, 2926, 1062, 291, 14, 7764, 63, 1462, 9, 355, 327, 2670, 367, 30063, 355, 291, 14, 761, 23656, 342, 288, 340, 291, 14, 9751, 365, 440, 488, 26, 355, 2163, 63, 81, 275, 291, 14, 9751, 14, 6177, 59, 73, 61, 355, 291, 14, 9751, 14, 873, 63, 13162, 8, 2184, 63, 81, 9, 288, 291, 14, 2798, 8, 1219, 29, 1219, 12, 2498, 29, 797, 9, 398, 6085, 275, 4488, 14, 8941, 8, 23899, 2687, 24, 12, 1695, 430, 267, 2185, 275, 437, 12908, 19, 36, 8, 592, 9, 267, 291, 14, 2798, 8, 1219, 29, 1219, 12, 2498, 29, 797, 9, 398, 327, 982, 781, 2793, 1133, 5090, 2399, 372, 370, 6020, 12, 652, 3181, 1133, 1255, 14, 267, 327, 1666, 706, 2839, 7710, 22965, 5953, 703, 267, 376, 73, 275, 24154, 14, 7465, 15957, 8, 592, 12, 1678, 12, 11223, 29, 8444, 12, 330, 1051, 29, 797, 9, 267, 340, 3354, 63, 515, 365, 488, 26, 288, 4488, 14, 2384, 342, 267, 587, 26, 288, 24441, 275, 24154, 14, 26224, 459, 27648, 418, 288, 7060, 275, 24441, 8, 355, 289, 1190, 29, 24709, 12, 3341, 29, 807, 8, 490, 16459, 534, 45, 525, 2521, 659, 4546, 1866, 29, 1085, 383, 9, 288, 376, 73, 14, 2117, 8, 2117, 63, 515, 12, 7060, 29, 5491, 9, 339, 347, 23701, 1589, 3294, 63, 9688, 316, 63, 3124, 8, 277, 304, 267, 408, 6591, 314, 3421, 626, 314, 330, 452, 3955, 20078, 334, 269, 9793, 282, 19882, 9, 398, 520, 5808, 26, 15483, 334, 88, 12, 612, 12, 1315, 9, 402, 23701, 1589, 3294, 20078, 316, 3421, 402, 282, 2116, 14031, 909, 4079, 641, 1284, 10783, 2406, 20508, 14, 267, 520, 4500, 26, 2680, 14, 8237, 503, 488, 267, 408, 267, 2086, 275, 291, 14, 9751, 14, 500, 63, 3609, 2406, 63, 3124, 1252, 1574, 342, 267, 327, 5972, 1929, 7798, 20508, 267, 373, 275, 291, 14, 9751, 14, 500, 63, 3609, 2406, 63, 16350, 3430, 16, 26, 19, 61, 398, 367, 307, 315, 980, 14, 11649, 8, 16, 12, 4114, 12, 22369, 304, 288, 327, 2670, 340, 652, 9793, 282, 1347, 288, 367, 2955, 315, 291, 14, 1986, 63, 1462, 26, 355, 340, 2955, 14, 374, 63, 12948, 8, 1712, 304, 490, 372, 2086, 14, 1574, 342, 953, 327, 4236, 282, 19882, 288, 367, 284, 315, 1425, 8, 552, 8, 1712, 2298, 355, 315, 63, 7371, 63, 2638, 275, 2086, 59, 73, 61, 2695, 378, 355, 13541, 63, 9891, 275, 2086, 59, 73, 61, 2356, 291, 14, 13320, 59, 73, 61, 2234, 340, 315, 63, 7371, 63, 2638, 503, 13541, 63, 9891, 26, 490, 372, 2086, 14, 1574, 342, 953, 327, 6630, 3650, 7568, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lovelysystems/pyjamas
pyjs/src/pyjs/lib/sys.py
1
1789
from __pyjamas__ import JS # a dictionary of module override names (platform-specific) overrides = None # to be updated by app, on compile # the remote path for loading modules loadpath = None stacktrace = None appname = None def setloadpath(lp): global loadpath loadpath = lp def setappname(an): global appname appname = an def getloadpath(): return loadpath def addoverride(module_name, path): overrides[module_name] = path def exc_info(): le = JS('$pyjs.__last_exception__') if not le: return (None, None, None) if not hasattr(le.error, '__class__'): cls = None else: cls = le.error.__class__ return (cls, le.error, None) def exc_clear(): JS('$pyjs.__last_exception__ = null;') # save_exception_stack is totally javascript, to prevent trackstack pollution JS("""sys.save_exception_stack = function () { var save_stack = []; for (var needle in $pyjs.trackstack) { var t = new Object(); for (var p in $pyjs.trackstack[needle]) { t[p] = $pyjs.trackstack[needle][p]; } save_stack.push(t); $pyjs.__last_exception_stack__ = save_stack; } return null; }""") def trackstackstr(stack=None): if stack is None: stack = JS('$pyjs.__last_exception_stack__') if not stack: return '' stackstrings = [] msg = '' for s in list(stack): JS("msg = eval(s.module + '.__track_lines__[' + s.lineno + ']');") if msg: stackstrings.append(msg) else: stackstrings.append('%s.py, line %d' % (s.module, s.lineno)) return '\n'.join(stackstrings) platform = JS('$pyjs.platform') byteorder = 'little' # Needed in struct.py, assume all systems are little endian and not big endian
apache-2.0
[ 199, 504, 636, 647, 16997, 305, 363, 492, 18001, 199, 199, 3, 282, 2600, 402, 859, 4278, 1561, 334, 3246, 13, 6100, 9, 199, 12867, 275, 488, 327, 370, 506, 4588, 701, 1145, 12, 641, 6555, 199, 199, 3, 314, 3982, 931, 367, 8697, 4621, 199, 912, 515, 275, 488, 199, 199, 32274, 275, 488, 199, 199, 21653, 275, 488, 199, 199, 318, 663, 912, 515, 8, 10343, 304, 272, 2288, 2248, 515, 272, 2248, 515, 275, 13204, 199, 199, 318, 663, 21653, 8, 290, 304, 272, 2288, 20268, 272, 20268, 275, 376, 199, 199, 318, 664, 912, 515, 837, 272, 372, 2248, 515, 199, 199, 318, 1050, 4415, 8, 578, 63, 354, 12, 931, 304, 272, 10580, 59, 578, 63, 354, 61, 275, 931, 199, 199, 318, 3178, 63, 815, 837, 272, 1026, 275, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 13766, 272, 340, 440, 1026, 26, 267, 372, 334, 403, 12, 488, 12, 488, 9, 272, 340, 440, 2688, 8, 274, 14, 705, 12, 2560, 533, 12168, 267, 843, 275, 488, 272, 587, 26, 267, 843, 275, 1026, 14, 705, 855, 533, 363, 272, 372, 334, 1886, 12, 1026, 14, 705, 12, 488, 9, 199, 199, 318, 3178, 63, 3584, 837, 272, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 363, 275, 2973, 10784, 199, 199, 3, 3354, 63, 1971, 63, 2340, 365, 12657, 1183, 18910, 12, 370, 7981, 4426, 2340, 11271, 2206, 199, 11378, 4852, 1274, 14, 2117, 63, 1971, 63, 2340, 275, 805, 6248, 469, 272, 2729, 3354, 63, 2340, 275, 22750, 272, 367, 334, 1391, 1929, 274, 315, 2672, 647, 3596, 14, 3885, 2340, 9, 469, 267, 2729, 307, 275, 892, 6935, 7303, 267, 367, 334, 1391, 299, 315, 2672, 647, 3596, 14, 3885, 2340, 59, 9321, 274, 566, 469, 288, 307, 59, 80, 61, 275, 2672, 647, 3596, 14, 3885, 2340, 59, 9321, 274, 1527, 80, 11566, 267, 789, 267, 3354, 63, 2340, 14, 5335, 8, 84, 2736, 267, 2672, 647, 3596, 855, 2019, 63, 1971, 63, 2340, 363, 275, 3354, 63, 2340, 27, 272, 789, 199, 1107, 2973, 27, 199, 93, 6141, 199, 199, 318, 4426, 2340, 495, 8, 2340, 29, 403, 304, 272, 340, 3464, 365, 488, 26, 267, 3464, 275, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 63, 2340, 13766, 272, 340, 440, 3464, 26, 267, 372, 2125, 272, 3464, 5465, 275, 942, 272, 1499, 275, 2125, 272, 367, 308, 315, 769, 8, 2340, 304, 267, 18001, 480, 1328, 275, 3468, 8, 83, 14, 578, 435, 283, 855, 3885, 63, 1278, 23010, 435, 308, 14, 3469, 435, 283, 10374, 15027, 267, 340, 1499, 26, 288, 3464, 5465, 14, 740, 8, 1328, 9, 267, 587, 26, 288, 3464, 5465, 14, 740, 3508, 83, 14, 647, 12, 1004, 450, 68, 7, 450, 334, 83, 14, 578, 12, 308, 14, 3469, 430, 272, 372, 1557, 78, 1370, 904, 8, 2340, 5465, 9, 199, 199, 3246, 275, 18001, 14676, 647, 3596, 14, 3246, 358, 199, 19415, 275, 283, 10182, 7, 327, 28196, 315, 2702, 14, 647, 12, 5534, 1006, 10460, 787, 12050, 17638, 436, 440, 7282, 17638, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 504, 636, 647, 16997, 305, 363, 492, 18001, 199, 199, 3, 282, 2600, 402, 859, 4278, 1561, 334, 3246, 13, 6100, 9, 199, 12867, 275, 488, 327, 370, 506, 4588, 701, 1145, 12, 641, 6555, 199, 199, 3, 314, 3982, 931, 367, 8697, 4621, 199, 912, 515, 275, 488, 199, 199, 32274, 275, 488, 199, 199, 21653, 275, 488, 199, 199, 318, 663, 912, 515, 8, 10343, 304, 272, 2288, 2248, 515, 272, 2248, 515, 275, 13204, 199, 199, 318, 663, 21653, 8, 290, 304, 272, 2288, 20268, 272, 20268, 275, 376, 199, 199, 318, 664, 912, 515, 837, 272, 372, 2248, 515, 199, 199, 318, 1050, 4415, 8, 578, 63, 354, 12, 931, 304, 272, 10580, 59, 578, 63, 354, 61, 275, 931, 199, 199, 318, 3178, 63, 815, 837, 272, 1026, 275, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 13766, 272, 340, 440, 1026, 26, 267, 372, 334, 403, 12, 488, 12, 488, 9, 272, 340, 440, 2688, 8, 274, 14, 705, 12, 2560, 533, 12168, 267, 843, 275, 488, 272, 587, 26, 267, 843, 275, 1026, 14, 705, 855, 533, 363, 272, 372, 334, 1886, 12, 1026, 14, 705, 12, 488, 9, 199, 199, 318, 3178, 63, 3584, 837, 272, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 363, 275, 2973, 10784, 199, 199, 3, 3354, 63, 1971, 63, 2340, 365, 12657, 1183, 18910, 12, 370, 7981, 4426, 2340, 11271, 2206, 199, 11378, 4852, 1274, 14, 2117, 63, 1971, 63, 2340, 275, 805, 6248, 469, 272, 2729, 3354, 63, 2340, 275, 22750, 272, 367, 334, 1391, 1929, 274, 315, 2672, 647, 3596, 14, 3885, 2340, 9, 469, 267, 2729, 307, 275, 892, 6935, 7303, 267, 367, 334, 1391, 299, 315, 2672, 647, 3596, 14, 3885, 2340, 59, 9321, 274, 566, 469, 288, 307, 59, 80, 61, 275, 2672, 647, 3596, 14, 3885, 2340, 59, 9321, 274, 1527, 80, 11566, 267, 789, 267, 3354, 63, 2340, 14, 5335, 8, 84, 2736, 267, 2672, 647, 3596, 855, 2019, 63, 1971, 63, 2340, 363, 275, 3354, 63, 2340, 27, 272, 789, 199, 1107, 2973, 27, 199, 93, 6141, 199, 199, 318, 4426, 2340, 495, 8, 2340, 29, 403, 304, 272, 340, 3464, 365, 488, 26, 267, 3464, 275, 18001, 14676, 647, 3596, 855, 2019, 63, 1971, 63, 2340, 13766, 272, 340, 440, 3464, 26, 267, 372, 2125, 272, 3464, 5465, 275, 942, 272, 1499, 275, 2125, 272, 367, 308, 315, 769, 8, 2340, 304, 267, 18001, 480, 1328, 275, 3468, 8, 83, 14, 578, 435, 283, 855, 3885, 63, 1278, 23010, 435, 308, 14, 3469, 435, 283, 10374, 15027, 267, 340, 1499, 26, 288, 3464, 5465, 14, 740, 8, 1328, 9, 267, 587, 26, 288, 3464, 5465, 14, 740, 3508, 83, 14, 647, 12, 1004, 450, 68, 7, 450, 334, 83, 14, 578, 12, 308, 14, 3469, 430, 272, 372, 1557, 78, 1370, 904, 8, 2340, 5465, 9, 199, 199, 3246, 275, 18001, 14676, 647, 3596, 14, 3246, 358, 199, 19415, 275, 283, 10182, 7, 327, 28196, 315, 2702, 14, 647, 12, 5534, 1006, 10460, 787, 12050, 17638, 436, 440, 7282, 17638, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
supertom/ansible-modules-core
cloud/azure/azure_rm_storageaccount.py
42
17777
#!/usr/bin/python # # Copyright (c) 2016 Matt Davis, <mdavis@ansible.com> # Chris Houseknecht, <house@redhat.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/>. # DOCUMENTATION = ''' --- module: azure_rm_storageaccount version_added: "2.1" short_description: Manage Azure storage accounts. description: - Create, update or delete a storage account. options: resource_group: description: - Name of the resource group to use. required: true name: description: - Name of the storage account to update or create. required: false default: null state: description: - Assert the state of the storage account. Use 'present' to create or update a storage account and 'absent' to delete an account. default: present required: false choices: - absent - present location: description: - Valid azure location. Defaults to location of the resource group. required: false default: resource_group location account_type: description: - "Type of storage account. Required when creating a storage account. NOTE: Standard_ZRS and Premium_LRS accounts cannot be changed to other account types, and other account types cannot be changed to Standard_ZRS or Premium_LRS." required: false default: null choices: - Premium_LRS - Standard_GRS - Standard_LRS - Standard_RAGRS - Standard_ZRS aliases: - type custom_domain: description: - User domain assigned to the storage account. Must be a dictionary with 'name' and 'use_sub_domain' keys where 'name' is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty string for the custom domain name property. - Can be added to an existing storage account. Will be ignored during storage account creation. required: false default: null kind: description: - The 'kind' of storage. required: false default: 'Storage' choices: - Storage - StorageBlob version_added: "2.2" extends_documentation_fragment: - azure - azure_tags author: - "Chris Houseknecht (@chouseknecht)" - "Matt Davis (@nitzmahone)" ''' EXAMPLES = ''' - name: remove account, if it exists azure_rm_storageaccount: resource_group: Testing name: clh0002 state: absent - name: create an account azure_rm_storageaccount: resource_group: Testing name: clh0002 type: Standard_RAGRS tags: - testing: testing - delete: on-exit ''' RETURN = ''' state: description: Current state of the storage account. returned: always type: dict sample: { "account_type": "Standard_RAGRS", "custom_domain": null, "id": "/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testing/providers/Microsoft.Storage/storageAccounts/clh0003", "location": "eastus2", "name": "clh0003", "primary_endpoints": { "blob": "https://clh0003.blob.core.windows.net/", "queue": "https://clh0003.queue.core.windows.net/", "table": "https://clh0003.table.core.windows.net/" }, "primary_location": "eastus2", "provisioning_state": "Succeeded", "resource_group": "Testing", "secondary_endpoints": { "blob": "https://clh0003-secondary.blob.core.windows.net/", "queue": "https://clh0003-secondary.queue.core.windows.net/", "table": "https://clh0003-secondary.table.core.windows.net/" }, "secondary_location": "centralus", "status_of_primary": "Available", "status_of_secondary": "Available", "tags": null, "type": "Microsoft.Storage/storageAccounts" } ''' from ansible.module_utils.basic import * from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError from azure.storage.cloudstorageaccount import CloudStorageAccount from azure.common import AzureMissingResourceHttpError, AzureHttpError from azure.mgmt.storage.models.storage_management_client_enums import ProvisioningState, SkuName, SkuTier, Kind from azure.mgmt.storage.models import StorageAccountUpdateParameters, CustomDomain, \ StorageAccountCreateParameters, Sku except ImportError: # This is handled in azure_rm_common pass class AzureRMStorageAccount(AzureRMModuleBase): def __init__(self): self.module_arg_spec = dict( account_type=dict(type='str', choices=[], aliases=['type']), custom_domain=dict(type='dict'), location=dict(type='str'), name=dict(type='str', required=True), resource_group=dict(required=True, type='str'), state=dict(default='present', choices=['present', 'absent']), force=dict(type='bool', default=False), tags=dict(type='dict'), kind=dict(type='str', default='Storage', choices=['Storage', 'BlobStorage']) ) for key in SkuName: self.module_arg_spec['account_type']['choices'].append(getattr(key, 'value')) self.results = dict( changed=False, state=dict() ) self.account_dict = None self.resource_group = None self.name = None self.state = None self.location = None self.account_type = None self.custom_domain = None self.tags = None self.force = None self.kind = None super(AzureRMStorageAccount, self).__init__(self.module_arg_spec, supports_check_mode=True) def exec_module(self, **kwargs): for key in self.module_arg_spec.keys() + ['tags']: setattr(self, key, kwargs[key]) resource_group = self.get_resource_group(self.resource_group) if not self.location: # Set default location self.location = resource_group.location if len(self.name) < 3 or len(self.name) > 24: self.fail("Parameter error: name length must be between 3 and 24 characters.") if self.custom_domain: if self.custom_domain.get('name', None) is None: self.fail("Parameter error: expecting custom_domain to have a name attribute of type string.") if self.custom_domain.get('use_sub_domain', None) is None: self.fail("Parameter error: expecting custom_domain to have a use_sub_domain " "attribute of type boolean.") self.account_dict = self.get_account() if self.state == 'present' and self.account_dict and \ self.account_dict['provisioning_state'] != AZURE_SUCCESS_STATE : self.fail("Error: storage account {0} has not completed provisioning. State is {1}. Expecting state " "to be {2}.".format(self.name, self.account_dict['provisioning_state'], AZURE_SUCCESS_STATE)) if self.account_dict is not None: self.results['state'] = self.account_dict else: self.results['state'] = dict() if self.state == 'present': if not self.account_dict: self.results['state'] = self.create_account() else: self.update_account() elif self.state == 'absent' and self.account_dict: self.delete_account() self.results['state'] = dict(Status='Deleted') return self.results def check_name_availability(self): self.log('Checking name availability for {0}'.format(self.name)) try: response = self.storage_client.storage_accounts.check_name_availability(self.name) except AzureHttpError as e: self.log('Error attempting to validate name.') self.fail("Error checking name availability: {0}".format(str(e))) if not response.name_available: self.log('Error name not available.') self.fail("{0} - {1}".format(response.message, response.reason)) def get_account(self): self.log('Get properties for account {0}'.format(self.name)) account_obj = None account_dict = None try: account_obj = self.storage_client.storage_accounts.get_properties(self.resource_group, self.name) except CloudError: pass if account_obj: account_dict = self.account_obj_to_dict(account_obj) return account_dict def account_obj_to_dict(self, account_obj): account_dict = dict( id=account_obj.id, name=account_obj.name, location=account_obj.location, resource_group=self.resource_group, type=account_obj.type, sku_tier=account_obj.sku.tier.value, sku_name=account_obj.sku.name.value, provisioning_state=account_obj.provisioning_state.value, secondary_location=account_obj.secondary_location, status_of_primary=(account_obj.status_of_primary.value if account_obj.status_of_primary is not None else None), status_of_secondary=(account_obj.status_of_secondary.value if account_obj.status_of_secondary is not None else None), primary_location=account_obj.primary_location ) account_dict['custom_domain'] = None if account_obj.custom_domain: account_dict['custom_domain'] = dict( name=account_obj.custom_domain.name, use_sub_domain=account_obj.custom_domain.use_sub_domain ) account_dict['primary_endpoints'] = None if account_obj.primary_endpoints: account_dict['primary_endpoints'] = dict( blob=account_obj.primary_endpoints.blob, queue=account_obj.primary_endpoints.queue, table=account_obj.primary_endpoints.table ) account_dict['secondary_endpoints'] = None if account_obj.secondary_endpoints: account_dict['secondary_endpoints'] = dict( blob=account_obj.secondary_endpoints.blob, queue=account_obj.secondary_endpoints.queue, table=account_obj.secondary_endpoints.table ) account_dict['tags'] = None if account_obj.tags: account_dict['tags'] = account_obj.tags return account_dict def update_account(self): self.log('Update storage account {0}'.format(self.name)) if self.account_type: if self.account_type != self.account_dict['sku_name']: # change the account type if self.account_dict['sku_name'] in [SkuName.premium_lrs, SkuName.standard_zrs]: self.fail("Storage accounts of type {0} and {1} cannot be changed.".format( SkuName.premium_lrs, SkuName.standard_zrs)) if self.account_type in [SkuName.premium_lrs, SkuName.standard_zrs]: self.fail("Storage account of type {0} cannot be changed to a type of {1} or {2}.".format( self.account_dict['sku_name'], SkuName.premium_lrs, SkuName.standard_zrs)) self.results['changed'] = True self.account_dict['sku_name'] = self.account_type if self.results['changed'] and not self.check_mode: # Perform the update. The API only allows changing one attribute per call. try: self.log("sku_name: %s" % self.account_dict['sku_name']) self.log("sku_tier: %s" % self.account_dict['sku_tier']) sku = Sku(SkuName(self.account_dict['sku_name'])) sku.tier = SkuTier(self.account_dict['sku_tier']) parameters = StorageAccountUpdateParameters(sku=sku) self.storage_client.storage_accounts.update(self.resource_group, self.name, parameters) except Exception as exc: self.fail("Failed to update account type: {0}".format(str(exc))) if self.custom_domain: if not self.account_dict['custom_domain'] or \ self.account_dict['custom_domain'] != self.account_dict['custom_domain']: self.results['changed'] = True self.account_dict['custom_domain'] = self.custom_domain if self.results['changed'] and not self.check_mode: new_domain = CustomDomain(name=self.custom_domain['name'], use_sub_domain=self.custom_domain['use_sub_domain']) parameters = StorageAccountUpdateParameters(custom_domain=new_domain) try: self.storage_client.storage_accounts.update(self.resource_group, self.name, parameters) except Exception as exc: self.fail("Failed to update custom domain: {0}".format(str(exc))) update_tags, self.account_dict['tags'] = self.update_tags(self.account_dict['tags']) if update_tags: self.results['changed'] = True if not self.check_mode: parameters = StorageAccountUpdateParameters(tags=self.account_dict['tags']) try: self.storage_client.storage_accounts.update(self.resource_group, self.name, parameters) except Exception as exc: self.fail("Failed to update tags: {0}".format(str(exc))) def create_account(self): self.log("Creating account {0}".format(self.name)) if not self.location: self.fail('Parameter error: location required when creating a storage account.') if not self.account_type: self.fail('Parameter error: account_type required when creating a storage account.') self.check_name_availability() self.results['changed'] = True if self.check_mode: account_dict = dict( location=self.location, account_type=self.account_type, name=self.name, resource_group=self.resource_group, tags=dict() ) if self.tags: account_dict['tags'] = self.tags return account_dict sku = Sku(SkuName(self.account_type)) sku.tier = SkuTier.standard if 'Standard' in self.account_type else SkuTier.premium parameters = StorageAccountCreateParameters(sku, self.kind, self.location, tags=self.tags) self.log(str(parameters)) try: poller = self.storage_client.storage_accounts.create(self.resource_group, self.name, parameters) self.get_poller_result(poller) except AzureHttpError as e: self.log('Error creating storage account.') self.fail("Failed to create account: {0}".format(str(e))) # the poller doesn't actually return anything return self.get_account() def delete_account(self): if self.account_dict['provisioning_state'] == ProvisioningState.succeeded.value and \ self.account_has_blob_containers() and self.force: self.fail("Account contains blob containers. Is it in use? Use the force option to attempt deletion.") self.log('Delete storage account {0}'.format(self.name)) self.results['changed'] = True if not self.check_mode: try: status = self.storage_client.storage_accounts.delete(self.resource_group, self.name) self.log("delete status: ") self.log(str(status)) except AzureHttpError as e: self.fail("Failed to delete the account: {0}".format(str(e))) return True def account_has_blob_containers(self): ''' If there are blob containers, then there are likely VMs depending on this account and it should not be deleted. ''' self.log('Checking for existing blob containers') blob_service = self.get_blob_client(self.resource_group, self.name) try: response = blob_service.list_containers() except AzureMissingResourceHttpError: # No blob storage available? return False if len(response.items) > 0: return True return False def main(): AzureRMStorageAccount() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 31653, 577, 1214, 374, 12, 665, 77, 983, 5068, 32, 4853, 14, 957, 30, 199, 3, 8540, 2799, 5719, 869, 7130, 75, 685, 335, 84, 12, 665, 6740, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 13601, 63, 5682, 63, 3494, 2048, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 14944, 15474, 4887, 12639, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 503, 3145, 282, 4887, 2933, 14, 199, 1419, 26, 272, 2073, 63, 923, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2073, 1572, 370, 675, 14, 267, 1415, 26, 2549, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 4887, 2933, 370, 1678, 503, 1218, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 10716, 314, 1174, 402, 314, 4887, 2933, 14, 3645, 283, 1881, 7, 370, 1218, 503, 1678, 282, 4887, 2933, 436, 1598, 283, 5575, 7, 370, 3145, 376, 2933, 14, 267, 849, 26, 3451, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 9552, 288, 446, 3451, 272, 2909, 26, 267, 1369, 26, 288, 446, 4821, 13601, 2909, 14, 7827, 370, 2909, 402, 314, 2073, 1572, 14, 267, 1415, 26, 3055, 267, 849, 26, 2073, 63, 923, 2909, 272, 2933, 63, 466, 26, 267, 1369, 26, 288, 446, 298, 804, 402, 4887, 2933, 14, 11105, 1380, 6425, 282, 4887, 2933, 14, 6944, 26, 9739, 63, 58, 15062, 436, 5543, 23481, 63, 44, 15062, 1598, 12639, 3913, 506, 2896, 370, 1163, 2933, 2943, 12, 436, 1163, 2933, 2943, 3913, 506, 2896, 370, 1598, 9739, 63, 58, 15062, 503, 5543, 23481, 63, 44, 15062, 2122, 267, 1415, 26, 3055, 267, 849, 26, 2973, 267, 3415, 26, 288, 446, 5543, 23481, 63, 44, 15062, 288, 446, 9739, 63, 3975, 51, 288, 446, 9739, 63, 44, 15062, 288, 446, 9739, 63, 50, 1254, 15062, 288, 446, 9739, 63, 58, 15062, 267, 5481, 26, 288, 446, 730, 272, 3537, 63, 2261, 26, 267, 1369, 26, 288, 446, 2876, 2881, 7943, 370, 314, 4887, 2933, 14, 9498, 506, 282, 2600, 543, 283, 354, 7, 436, 283, 1180, 63, 954, 63, 2261, 7, 1598, 2883, 2382, 283, 354, 7, 365, 314, 445, 2339, 1350, 14, 5972, 1373, 3537, 2881, 365, 3748, 1126, 4887, 2933, 737, 642, 1598, 900, 14, 4005, 5436, 314, 3411, 3537, 2881, 12, 675, 376, 2701, 1059, 367, 314, 3537, 2881, 536, 3324, 14, 288, 446, 6855, 506, 3483, 370, 376, 3411, 4887, 2933, 14, 12823, 506, 5525, 5309, 4887, 2933, 7143, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4928, 26, 267, 1369, 26, 288, 446, 710, 283, 5091, 7, 402, 4887, 14, 267, 1415, 26, 3055, 267, 849, 26, 283, 6408, 7, 267, 3415, 26, 288, 446, 10533, 288, 446, 10533, 16799, 267, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 13601, 272, 446, 13601, 63, 2969, 199, 199, 2502, 26, 272, 446, 298, 1049, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 2924, 272, 446, 298, 45, 6796, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 2924, 199, 199, 2344, 199, 199, 8918, 275, 1449, 272, 446, 536, 26, 2813, 2933, 12, 340, 652, 3495, 489, 13601, 63, 5682, 63, 3494, 2048, 26, 267, 2073, 63, 923, 26, 11940, 267, 536, 26, 824, 72, 9425, 267, 1174, 26, 9552, 339, 446, 536, 26, 1218, 376, 2933, 489, 13601, 63, 5682, 63, 3494, 2048, 26, 267, 2073, 63, 923, 26, 11940, 267, 536, 26, 824, 72, 9425, 267, 730, 26, 9739, 63, 50, 1254, 15062, 267, 3762, 26, 881, 446, 5343, 26, 5343, 881, 446, 3145, 26, 641, 13, 2224, 199, 2344, 421, 199, 9677, 275, 1449, 199, 929, 26, 272, 1369, 26, 9338, 1174, 402, 314, 4887, 2933, 14, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2048, 63, 466, 582, 298, 9232, 63, 50, 1254, 15062, 401, 267, 298, 4229, 63, 2261, 582, 2973, 12, 267, 298, 344, 582, 3286, 13233, 15, 6873, 13933, 13, 6873, 13, 6873, 13, 6873, 13, 13312, 2483, 15, 26952, 15, 4776, 15, 9710, 15, 12940, 14, 6408, 15, 3494, 30682, 15, 429, 72, 16861, 401, 267, 298, 1985, 582, 298, 14346, 527, 18, 401, 267, 298, 354, 582, 298, 429, 72, 16861, 401, 267, 298, 3327, 63, 14461, 582, 469, 288, 298, 6582, 582, 298, 2859, 921, 429, 72, 16861, 14, 6582, 14, 1018, 14, 8258, 14, 846, 10665, 288, 298, 1825, 582, 298, 2859, 921, 429, 72, 16861, 14, 1825, 14, 1018, 14, 8258, 14, 846, 10665, 288, 298, 1224, 582, 298, 2859, 921, 429, 72, 16861, 14, 1224, 14, 1018, 14, 8258, 14, 846, 6687, 267, 1660, 267, 298, 3327, 63, 1985, 582, 298, 14346, 527, 18, 401, 267, 298, 19639, 63, 929, 582, 298, 32453, 401, 267, 298, 1927, 63, 923, 582, 298, 9029, 401, 267, 298, 12371, 63, 14461, 582, 469, 288, 298, 6582, 582, 298, 2859, 921, 429, 72, 16861, 13 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 31653, 577, 1214, 374, 12, 665, 77, 983, 5068, 32, 4853, 14, 957, 30, 199, 3, 8540, 2799, 5719, 869, 7130, 75, 685, 335, 84, 12, 665, 6740, 32, 17164, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 13601, 63, 5682, 63, 3494, 2048, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 14944, 15474, 4887, 12639, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 503, 3145, 282, 4887, 2933, 14, 199, 1419, 26, 272, 2073, 63, 923, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2073, 1572, 370, 675, 14, 267, 1415, 26, 2549, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 4887, 2933, 370, 1678, 503, 1218, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 10716, 314, 1174, 402, 314, 4887, 2933, 14, 3645, 283, 1881, 7, 370, 1218, 503, 1678, 282, 4887, 2933, 436, 1598, 283, 5575, 7, 370, 3145, 376, 2933, 14, 267, 849, 26, 3451, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 9552, 288, 446, 3451, 272, 2909, 26, 267, 1369, 26, 288, 446, 4821, 13601, 2909, 14, 7827, 370, 2909, 402, 314, 2073, 1572, 14, 267, 1415, 26, 3055, 267, 849, 26, 2073, 63, 923, 2909, 272, 2933, 63, 466, 26, 267, 1369, 26, 288, 446, 298, 804, 402, 4887, 2933, 14, 11105, 1380, 6425, 282, 4887, 2933, 14, 6944, 26, 9739, 63, 58, 15062, 436, 5543, 23481, 63, 44, 15062, 1598, 12639, 3913, 506, 2896, 370, 1163, 2933, 2943, 12, 436, 1163, 2933, 2943, 3913, 506, 2896, 370, 1598, 9739, 63, 58, 15062, 503, 5543, 23481, 63, 44, 15062, 2122, 267, 1415, 26, 3055, 267, 849, 26, 2973, 267, 3415, 26, 288, 446, 5543, 23481, 63, 44, 15062, 288, 446, 9739, 63, 3975, 51, 288, 446, 9739, 63, 44, 15062, 288, 446, 9739, 63, 50, 1254, 15062, 288, 446, 9739, 63, 58, 15062, 267, 5481, 26, 288, 446, 730, 272, 3537, 63, 2261, 26, 267, 1369, 26, 288, 446, 2876, 2881, 7943, 370, 314, 4887, 2933, 14, 9498, 506, 282, 2600, 543, 283, 354, 7, 436, 283, 1180, 63, 954, 63, 2261, 7, 1598, 2883, 2382, 283, 354, 7, 365, 314, 445, 2339, 1350, 14, 5972, 1373, 3537, 2881, 365, 3748, 1126, 4887, 2933, 737, 642, 1598, 900, 14, 4005, 5436, 314, 3411, 3537, 2881, 12, 675, 376, 2701, 1059, 367, 314, 3537, 2881, 536, 3324, 14, 288, 446, 6855, 506, 3483, 370, 376, 3411, 4887, 2933, 14, 12823, 506, 5525, 5309, 4887, 2933, 7143, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4928, 26, 267, 1369, 26, 288, 446, 710, 283, 5091, 7, 402, 4887, 14, 267, 1415, 26, 3055, 267, 849, 26, 283, 6408, 7, 267, 3415, 26, 288, 446, 10533, 288, 446, 10533, 16799, 267, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 13601, 272, 446, 13601, 63, 2969, 199, 199, 2502, 26, 272, 446, 298, 1049, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 2924, 272, 446, 298, 45, 6796, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 2924, 199, 199, 2344, 199, 199, 8918, 275, 1449, 272, 446, 536, 26, 2813, 2933, 12, 340, 652, 3495, 489, 13601, 63, 5682, 63, 3494, 2048, 26, 267, 2073, 63, 923, 26, 11940, 267, 536, 26, 824, 72, 9425, 267, 1174, 26, 9552, 339, 446, 536, 26, 1218, 376, 2933, 489, 13601, 63, 5682, 63, 3494, 2048, 26, 267, 2073, 63, 923, 26, 11940, 267, 536, 26, 824, 72, 9425, 267, 730, 26, 9739, 63, 50, 1254, 15062, 267, 3762, 26, 881, 446, 5343, 26, 5343, 881, 446, 3145, 26, 641, 13, 2224, 199, 2344, 421, 199, 9677, 275, 1449, 199, 929, 26, 272, 1369, 26, 9338, 1174, 402, 314, 4887, 2933, 14, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2048, 63, 466, 582, 298, 9232, 63, 50, 1254, 15062, 401, 267, 298, 4229, 63, 2261, 582, 2973, 12, 267, 298, 344, 582, 3286, 13233, 15, 6873, 13933, 13, 6873, 13, 6873, 13, 6873, 13, 13312, 2483, 15, 26952, 15, 4776, 15, 9710, 15, 12940, 14, 6408, 15, 3494, 30682, 15, 429, 72, 16861, 401, 267, 298, 1985, 582, 298, 14346, 527, 18, 401, 267, 298, 354, 582, 298, 429, 72, 16861, 401, 267, 298, 3327, 63, 14461, 582, 469, 288, 298, 6582, 582, 298, 2859, 921, 429, 72, 16861, 14, 6582, 14, 1018, 14, 8258, 14, 846, 10665, 288, 298, 1825, 582, 298, 2859, 921, 429, 72, 16861, 14, 1825, 14, 1018, 14, 8258, 14, 846, 10665, 288, 298, 1224, 582, 298, 2859, 921, 429, 72, 16861, 14, 1224, 14, 1018, 14, 8258, 14, 846, 6687, 267, 1660, 267, 298, 3327, 63, 1985, 582, 298, 14346, 527, 18, 401, 267, 298, 19639, 63, 929, 582, 298, 32453, 401, 267, 298, 1927, 63, 923, 582, 298, 9029, 401, 267, 298, 12371, 63, 14461, 582, 469, 288, 298, 6582, 582, 298, 2859, 921, 429, 72, 16861, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
masters3d/coursebuilder-masters3d
tests/functional/model_student_work.py
16
7522
# Copyright 2013 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Functional tests for models/review.py.""" __author__ = [ 'johncox@google.com (John Cox)', ] from models import entities from models import models from models import student_work from models import transforms from tests.functional import actions from google.appengine.ext import db # Don't require docstrings on tests. pylint: disable-msg=g-missing-docstring # setUp is a name chosen by parent. pylint: disable-msg=g-bad-name class ReferencedModel(entities.BaseEntity): pass class UnvalidatedReference(entities.BaseEntity): referenced_model_key = student_work.KeyProperty() class ValidatedReference(entities.BaseEntity): referenced_model_key = student_work.KeyProperty(kind=ReferencedModel.kind()) class KeyPropertyTest(actions.TestBase): """Tests KeyProperty.""" def setUp(self): super(KeyPropertyTest, self).setUp() self.referenced_model_key = ReferencedModel().put() def test_bidirectional_transforms_succeed(self): """Tests that transforms entity<->dict<->json round trips correctly.""" referenced_model_key = ReferencedModel().put() entity = UnvalidatedReference(referenced_model_key=referenced_model_key) entity.put() transformed = transforms.entity_to_dict(entity) self.assertEqual(referenced_model_key, entity.referenced_model_key) self.assertEqual( referenced_model_key, transformed['referenced_model_key']) new_key = ReferencedModel().put() transformed['referenced_model_key'] = new_key restored = transforms.dict_to_entity(entity, transformed) self.assertEqual(new_key, restored.referenced_model_key) json = transforms.dict_to_json(transformed, None) self.assertEqual(str(new_key), json['referenced_model_key']) from_json = transforms.json_to_dict( json, {'properties': {'referenced_model_key': {'type': 'string'}}}) self.assertEqual({'referenced_model_key': str(new_key)}, from_json) def test_type_not_validated_if_kind_not_passed(self): model_key = db.Model().put() unvalidated = UnvalidatedReference(referenced_model_key=model_key) self.assertEqual(model_key, unvalidated.referenced_model_key) def test_validation_and_datastore_round_trip_of_keys_succeeds(self): """Tests happy path for both validation and (de)serialization.""" model_with_reference = ValidatedReference( referenced_model_key=self.referenced_model_key) model_with_reference_key = model_with_reference.put() model_with_reference_from_datastore = db.get(model_with_reference_key) self.assertEqual( self.referenced_model_key, model_with_reference_from_datastore.referenced_model_key) custom_model_from_datastore = db.get( model_with_reference_from_datastore.referenced_model_key) self.assertEqual( self.referenced_model_key, custom_model_from_datastore.key()) self.assertTrue(isinstance( model_with_reference_from_datastore.referenced_model_key, db.Key)) def test_validation_fails(self): model_key = db.Model().put() self.assertRaises( db.BadValueError, ValidatedReference, referenced_model_key='not_a_key') self.assertRaises( db.BadValueError, ValidatedReference, referenced_model_key=model_key) class ReviewTest(actions.ExportTestBase): def setUp(self): super(ReviewTest, self).setUp() self.reviewee_email = 'reviewee@exmaple.com' self.reviewer_email = 'reviewer@example.com' self.unit_id = 'unit_id' self.reviewee = models.Student(key_name=self.reviewee_email) self.reviewee_key = self.reviewee.put() self.reviewer = models.Student(key_name=self.reviewer_email) self.reviewer_key = self.reviewer.put() self.review = student_work.Review( reviewee_key=self.reviewee_key, reviewer_key=self.reviewer_key, unit_id=self.unit_id) self.review_key = self.review.put() def test_constructor_sets_key_name(self): self.assertEqual( student_work.Review.key_name( self.unit_id, self.reviewee_key, self.reviewer_key), self.review_key.name()) def test_for_export_transforms_correctly(self): exported = self.review.for_export(self.transform) self.assert_blacklisted_properties_removed(self.review, exported) self.assertEqual( 'transformed_' + self.reviewer_key.name(), exported.reviewer_key.name()) def test_safe_key_makes_key_names_safe(self): safe_review_key = student_work.Review.safe_key( self.review_key, self.transform) # Treat as module-protected. pylint: disable-msg=protected-access _, safe_unit_id, safe_reviewee_key_str, safe_reviewer_key_str = ( student_work.Review._split_key(safe_review_key.name())) safe_reviewee_key = db.Key(encoded=safe_reviewee_key_str) safe_reviewer_key = db.Key(encoded=safe_reviewer_key_str) self.assertEqual( 'transformed_' + self.reviewee_email, safe_reviewee_key.name()) self.assertEqual( 'transformed_' + self.reviewer_email, safe_reviewer_key.name()) self.assertEqual(self.unit_id, safe_unit_id) class SubmissionTest(actions.ExportTestBase): def setUp(self): super(SubmissionTest, self).setUp() self.reviewee_email = 'reviewee@example.com' self.unit_id = 'unit_id' self.reviewee = models.Student(key_name=self.reviewee_email) self.reviewee_key = self.reviewee.put() self.submission = student_work.Submission( reviewee_key=self.reviewee_key, unit_id=self.unit_id) self.submission_key = self.submission.put() def test_constructor_sets_key_name(self): self.assertEqual( student_work.Submission.key_name(self.unit_id, self.reviewee_key), self.submission_key.name()) def test_for_export_transforms_correctly(self): exported = self.submission.for_export(self.transform) self.assert_blacklisted_properties_removed(self.submission, exported) self.assertEqual( 'transformed_' + self.reviewee_key.name(), exported.reviewee_key.name()) def test_safe_key_makes_reviewee_key_name_safe(self): safe_submission_key = student_work.Submission.safe_key( self.submission_key, self.transform) # Treat as module-protected. pylint: disable-msg=protected-access _, safe_unit_id, safe_reviewee_key_name = ( student_work.Submission._split_key(safe_submission_key.name())) self.assertEqual( 'transformed_' + self.reviewee_email, safe_reviewee_key_name) self.assertEqual(self.unit_id, safe_unit_id)
apache-2.0
[ 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 3481, 279, 2295, 367, 1709, 15, 8578, 14, 647, 1041, 199, 199, 363, 2502, 363, 275, 359, 272, 283, 20216, 331, 88, 32, 3098, 14, 957, 334, 12923, 1849, 88, 3196, 199, 61, 199, 199, 504, 1709, 492, 9045, 199, 504, 1709, 492, 1709, 199, 504, 1709, 492, 6474, 63, 800, 199, 504, 1709, 492, 18501, 199, 504, 2295, 14, 15481, 492, 5445, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 421, 199, 3, 7529, 1133, 4409, 20964, 641, 2295, 14, 4287, 26, 3507, 13, 1328, 29, 71, 13, 4752, 13, 12485, 199, 3, 3613, 365, 282, 536, 12414, 701, 1676, 14, 4287, 26, 3507, 13, 1328, 29, 71, 13, 4087, 13, 354, 421, 199, 533, 10944, 68, 1685, 8, 8327, 14, 1563, 7302, 304, 272, 986, 421, 199, 533, 1910, 24372, 5083, 8, 8327, 14, 1563, 7302, 304, 272, 11812, 63, 1238, 63, 498, 275, 6474, 63, 800, 14, 1197, 3697, 342, 421, 199, 533, 4821, 972, 5083, 8, 8327, 14, 1563, 7302, 304, 272, 11812, 63, 1238, 63, 498, 275, 6474, 63, 800, 14, 1197, 3697, 8, 5091, 29, 5083, 68, 1685, 14, 5091, 1012, 421, 199, 533, 2606, 3697, 774, 8, 3723, 14, 14440, 304, 272, 408, 2925, 2606, 3697, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1197, 3697, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 22355, 63, 1238, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 339, 347, 511, 63, 4492, 21360, 63, 15133, 63, 26622, 8, 277, 304, 267, 408, 2925, 626, 18501, 4642, 28, 5118, 807, 28, 5118, 1001, 6168, 3229, 1190, 6657, 1041, 267, 11812, 63, 1238, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 267, 4642, 275, 1910, 24372, 5083, 8, 22355, 63, 1238, 63, 498, 29, 22355, 63, 1238, 63, 498, 9, 267, 4642, 14, 524, 342, 398, 14834, 275, 18501, 14, 4502, 63, 475, 63, 807, 8, 4502, 9, 267, 291, 14, 629, 8, 22355, 63, 1238, 63, 498, 12, 4642, 14, 22355, 63, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 288, 11812, 63, 1238, 63, 498, 12, 14834, 459, 22355, 63, 1238, 63, 498, 1105, 398, 892, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 267, 14834, 459, 22355, 63, 1238, 63, 498, 418, 275, 892, 63, 498, 267, 14429, 275, 18501, 14, 807, 63, 475, 63, 4502, 8, 4502, 12, 14834, 9, 267, 291, 14, 629, 8, 1222, 63, 498, 12, 14429, 14, 22355, 63, 1238, 63, 498, 9, 398, 2022, 275, 18501, 14, 807, 63, 475, 63, 1001, 8, 20209, 12, 488, 9, 267, 291, 14, 629, 8, 495, 8, 1222, 63, 498, 395, 2022, 459, 22355, 63, 1238, 63, 498, 1105, 398, 687, 63, 1001, 275, 18501, 14, 1001, 63, 475, 63, 807, 8, 288, 2022, 12, 791, 3282, 356, 791, 22355, 63, 1238, 63, 498, 356, 791, 466, 356, 283, 875, 18620, 1552, 267, 291, 14, 629, 3252, 22355, 63, 1238, 63, 498, 356, 620, 8, 1222, 63, 498, 16658, 687, 63, 1001, 9, 339, 347, 511, 63, 466, 63, 1397, 63, 24372, 63, 692, 63, 5091, 63, 1397, 63, 12070, 8, 277, 304, 267, 1402, 63, 498, 275, 1592, 14, 1685, 1252, 524, 342, 267, 625, 24372, 275, 1910, 24372, 5083, 8, 22355, 63, 1238, 63, 498, 29, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 1238, 63, 498, 12, 625, 24372, 14, 22355, 63, 1238, 63, 498, 9, 339, 347, 511, 63, 6136, 63, 460, 63, 11450, 63, 2363, 63, 7254, 63, 1618, 63, 1612, 63, 14301, 5923, 8, 277, 304, 267, 408, 2925, 394, 18869, 931, 367, 3865, 6411, 436, 334, 271, 9, 12161, 1041, 267, 1402, 63, 1045, 63, 4443, 275, 4821, 972, 5083, 8, 288, 11812, 63, 1238, 63, 498, 29, 277, 14, 22355, 63, 1238, 63, 498, 9, 267, 1402, 63, 1045, 63, 4443, 63, 498, 275, 1402, 63, 1045, 63, 4443, 14, 524, 342, 267, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 275, 1592, 14, 362, 8, 1238, 63, 1045, 63, 4443, 63, 498, 9, 267, 291, 14, 629, 8, 288, 291, 14, 22355, 63, 1238, 63, 498, 12, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 9, 267, 3537, 63, 1238, 63, 504, 63, 11450, 275, 1592, 14, 362, 8, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 288, 291, 14, 22355, 63, 1238, 63, 498, 12, 3537, 63, 1238, 63, 504, 63, 11450, 14, 498, 1012, 267, 291, 14, 1815, 8, 6074, 8, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 12, 288, 1592, 14, 1197, 430, 339, 347, 511, 63, 6136, 63, 15762, 8, 277, 304, 267, 1402, 63, 498, 275, 1592, 14, 1685, 1252, 524, 342, 267, 291, 14, 1855, 8, 288, 1592, 14, 5725, 3393, 12, 4821, 972, 5083, 12, 288, 11812, 63, 1238, 63, 498, 534, 1397, 63, 65, 63, 498, 358, 267, 291, 14, 1855, 8, 288, 1592, 14, 5725, 3393, 12, 4821, 972, 5083, 12, 288, 11812, 63, 1238, 63, 498, 29, 1238, 63, 498, 9, 421, 199, 533, 26705, 774, 8, 3723, 14, 11399, 14440, 304, 339, 347, 3613, 8, 277, 304, 267, 1613 ]
[ 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 3481, 279, 2295, 367, 1709, 15, 8578, 14, 647, 1041, 199, 199, 363, 2502, 363, 275, 359, 272, 283, 20216, 331, 88, 32, 3098, 14, 957, 334, 12923, 1849, 88, 3196, 199, 61, 199, 199, 504, 1709, 492, 9045, 199, 504, 1709, 492, 1709, 199, 504, 1709, 492, 6474, 63, 800, 199, 504, 1709, 492, 18501, 199, 504, 2295, 14, 15481, 492, 5445, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 421, 199, 3, 7529, 1133, 4409, 20964, 641, 2295, 14, 4287, 26, 3507, 13, 1328, 29, 71, 13, 4752, 13, 12485, 199, 3, 3613, 365, 282, 536, 12414, 701, 1676, 14, 4287, 26, 3507, 13, 1328, 29, 71, 13, 4087, 13, 354, 421, 199, 533, 10944, 68, 1685, 8, 8327, 14, 1563, 7302, 304, 272, 986, 421, 199, 533, 1910, 24372, 5083, 8, 8327, 14, 1563, 7302, 304, 272, 11812, 63, 1238, 63, 498, 275, 6474, 63, 800, 14, 1197, 3697, 342, 421, 199, 533, 4821, 972, 5083, 8, 8327, 14, 1563, 7302, 304, 272, 11812, 63, 1238, 63, 498, 275, 6474, 63, 800, 14, 1197, 3697, 8, 5091, 29, 5083, 68, 1685, 14, 5091, 1012, 421, 199, 533, 2606, 3697, 774, 8, 3723, 14, 14440, 304, 272, 408, 2925, 2606, 3697, 1041, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 1197, 3697, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 22355, 63, 1238, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 339, 347, 511, 63, 4492, 21360, 63, 15133, 63, 26622, 8, 277, 304, 267, 408, 2925, 626, 18501, 4642, 28, 5118, 807, 28, 5118, 1001, 6168, 3229, 1190, 6657, 1041, 267, 11812, 63, 1238, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 267, 4642, 275, 1910, 24372, 5083, 8, 22355, 63, 1238, 63, 498, 29, 22355, 63, 1238, 63, 498, 9, 267, 4642, 14, 524, 342, 398, 14834, 275, 18501, 14, 4502, 63, 475, 63, 807, 8, 4502, 9, 267, 291, 14, 629, 8, 22355, 63, 1238, 63, 498, 12, 4642, 14, 22355, 63, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 288, 11812, 63, 1238, 63, 498, 12, 14834, 459, 22355, 63, 1238, 63, 498, 1105, 398, 892, 63, 498, 275, 10944, 68, 1685, 1252, 524, 342, 267, 14834, 459, 22355, 63, 1238, 63, 498, 418, 275, 892, 63, 498, 267, 14429, 275, 18501, 14, 807, 63, 475, 63, 4502, 8, 4502, 12, 14834, 9, 267, 291, 14, 629, 8, 1222, 63, 498, 12, 14429, 14, 22355, 63, 1238, 63, 498, 9, 398, 2022, 275, 18501, 14, 807, 63, 475, 63, 1001, 8, 20209, 12, 488, 9, 267, 291, 14, 629, 8, 495, 8, 1222, 63, 498, 395, 2022, 459, 22355, 63, 1238, 63, 498, 1105, 398, 687, 63, 1001, 275, 18501, 14, 1001, 63, 475, 63, 807, 8, 288, 2022, 12, 791, 3282, 356, 791, 22355, 63, 1238, 63, 498, 356, 791, 466, 356, 283, 875, 18620, 1552, 267, 291, 14, 629, 3252, 22355, 63, 1238, 63, 498, 356, 620, 8, 1222, 63, 498, 16658, 687, 63, 1001, 9, 339, 347, 511, 63, 466, 63, 1397, 63, 24372, 63, 692, 63, 5091, 63, 1397, 63, 12070, 8, 277, 304, 267, 1402, 63, 498, 275, 1592, 14, 1685, 1252, 524, 342, 267, 625, 24372, 275, 1910, 24372, 5083, 8, 22355, 63, 1238, 63, 498, 29, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 1238, 63, 498, 12, 625, 24372, 14, 22355, 63, 1238, 63, 498, 9, 339, 347, 511, 63, 6136, 63, 460, 63, 11450, 63, 2363, 63, 7254, 63, 1618, 63, 1612, 63, 14301, 5923, 8, 277, 304, 267, 408, 2925, 394, 18869, 931, 367, 3865, 6411, 436, 334, 271, 9, 12161, 1041, 267, 1402, 63, 1045, 63, 4443, 275, 4821, 972, 5083, 8, 288, 11812, 63, 1238, 63, 498, 29, 277, 14, 22355, 63, 1238, 63, 498, 9, 267, 1402, 63, 1045, 63, 4443, 63, 498, 275, 1402, 63, 1045, 63, 4443, 14, 524, 342, 267, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 275, 1592, 14, 362, 8, 1238, 63, 1045, 63, 4443, 63, 498, 9, 267, 291, 14, 629, 8, 288, 291, 14, 22355, 63, 1238, 63, 498, 12, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 9, 267, 3537, 63, 1238, 63, 504, 63, 11450, 275, 1592, 14, 362, 8, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 9, 267, 291, 14, 629, 8, 288, 291, 14, 22355, 63, 1238, 63, 498, 12, 3537, 63, 1238, 63, 504, 63, 11450, 14, 498, 1012, 267, 291, 14, 1815, 8, 6074, 8, 288, 1402, 63, 1045, 63, 4443, 63, 504, 63, 11450, 14, 22355, 63, 1238, 63, 498, 12, 288, 1592, 14, 1197, 430, 339, 347, 511, 63, 6136, 63, 15762, 8, 277, 304, 267, 1402, 63, 498, 275, 1592, 14, 1685, 1252, 524, 342, 267, 291, 14, 1855, 8, 288, 1592, 14, 5725, 3393, 12, 4821, 972, 5083, 12, 288, 11812, 63, 1238, 63, 498, 534, 1397, 63, 65, 63, 498, 358, 267, 291, 14, 1855, 8, 288, 1592, 14, 5725, 3393, 12, 4821, 972, 5083, 12, 288, 11812, 63, 1238, 63, 498, 29, 1238, 63, 498, 9, 421, 199, 533, 26705, 774, 8, 3723, 14, 11399, 14440, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pmylund/haveabit
console/app/pygments/styles/emacs.py
24
2463
# -*- coding: utf-8 -*- """ pygments.styles.emacs ~~~~~~~~~~~~~~~~~~~~~ A highlighting style for Pygments, inspired by Emacs. :copyright: 2006-2007 by Georg Brandl. :license: BSD, see LICENSE for more details. """ from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Whitespace class EmacsStyle(Style): """ The default style (inspired by Emacs 22). """ background_color = "#f8f8f8" default_style = "" styles = { Whitespace: "#bbbbbb", Comment: "italic #008800", Comment.Preproc: "noitalic", Comment.Special: "noitalic bold", Keyword: "bold #AA22FF", Keyword.Pseudo: "nobold", Keyword.Type: "bold #00BB00", Operator: "#666666", Operator.Word: "bold #AA22FF", Name.Builtin: "#AA22FF", Name.Function: "#00A000", Name.Class: "#0000FF", Name.Namespace: "bold #0000FF", Name.Exception: "bold #D2413A", Name.Variable: "#B8860B", Name.Constant: "#880000", Name.Label: "#A0A000", Name.Entity: "bold #999999", Name.Attribute: "#BB4444", Name.Tag: "bold #008000", Name.Decorator: "#AA22FF", String: "#BB4444", String.Doc: "italic", String.Interpol: "bold #BB6688", String.Escape: "bold #BB6622", String.Regex: "#BB6688", String.Symbol: "#B8860B", String.Other: "#008000", Number: "#666666", Generic.Heading: "bold #000080", Generic.Subheading: "bold #800080", Generic.Deleted: "#A00000", Generic.Inserted: "#00A000", Generic.Error: "#FF0000", Generic.Emph: "italic", Generic.Strong: "bold", Generic.Prompt: "bold #000080", Generic.Output: "#888", Generic.Traceback: "#04D", Error: "border:#FF0000" }
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12955, 14, 69, 19309, 272, 18294, 2878, 94, 339, 437, 22437, 3449, 367, 14493, 12, 315, 8721, 581, 701, 662, 19309, 14, 339, 520, 7307, 26, 8315, 13, 9488, 701, 5346, 1308, 699, 3759, 76, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 4860, 12, 11013, 12, 8307, 12, 24403, 421, 199, 533, 662, 19309, 6609, 8, 6609, 304, 272, 408, 272, 710, 849, 3449, 334, 262, 8721, 581, 701, 662, 19309, 6928, 680, 272, 408, 339, 8020, 63, 2326, 275, 5426, 70, 24, 70, 24, 70, 24, 2, 272, 849, 63, 2487, 275, 3087, 339, 15725, 275, 469, 267, 24403, 26, 4483, 5426, 14923, 2501, 401, 267, 6819, 26, 7861, 298, 21843, 327, 31419, 383, 401, 267, 6819, 14, 19285, 26, 3698, 298, 889, 21843, 401, 267, 6819, 14, 12246, 26, 3698, 298, 889, 21843, 17268, 401, 398, 6431, 26, 7861, 298, 9771, 327, 2276, 1081, 1665, 401, 267, 6431, 14, 23414, 26, 3322, 298, 889, 9771, 401, 267, 6431, 14, 804, 26, 4519, 298, 9771, 327, 383, 5342, 383, 401, 398, 11013, 26, 8295, 5426, 6997, 1272, 401, 267, 11013, 14, 10155, 26, 3777, 298, 9771, 327, 2276, 1081, 1665, 401, 398, 2812, 14, 12306, 26, 4519, 5426, 2276, 1081, 1665, 401, 267, 2812, 14, 3481, 26, 3777, 5426, 383, 33, 1493, 401, 267, 2812, 14, 2543, 26, 4483, 5426, 993, 1665, 401, 267, 2812, 14, 8814, 26, 3322, 298, 9771, 327, 993, 1665, 401, 267, 2812, 14, 1726, 26, 3322, 298, 9771, 327, 36, 1194, 969, 33, 401, 267, 2812, 14, 2773, 26, 3777, 5426, 34, 24, 14832, 34, 401, 267, 2812, 14, 9737, 26, 3777, 5426, 1299, 993, 401, 267, 2812, 14, 4314, 26, 4483, 5426, 33, 16, 33, 1493, 401, 267, 2812, 14, 7302, 26, 5185, 298, 9771, 327, 20036, 401, 267, 2812, 14, 1646, 26, 3322, 5426, 5342, 22872, 401, 267, 2812, 14, 1931, 26, 8295, 298, 9771, 327, 8662, 1493, 401, 267, 2812, 14, 14946, 26, 3322, 5426, 2276, 1081, 1665, 401, 398, 2624, 26, 8540, 5426, 5342, 22872, 401, 267, 2624, 14, 3768, 26, 4483, 298, 21843, 401, 267, 2624, 14, 22713, 26, 3698, 298, 9771, 327, 5342, 1272, 1299, 401, 267, 2624, 14, 10260, 26, 3777, 298, 9771, 327, 5342, 1272, 1081, 401, 267, 2624, 14, 5103, 26, 4519, 5426, 5342, 1272, 1299, 401, 267, 2624, 14, 8169, 26, 3777, 5426, 34, 24, 14832, 34, 401, 267, 2624, 14, 8632, 26, 4519, 5426, 8662, 1493, 401, 267, 4860, 26, 8540, 5426, 6997, 1272, 401, 398, 8307, 14, 23818, 26, 3698, 298, 9771, 327, 993, 1257, 401, 267, 8307, 14, 2610, 13983, 26, 263, 298, 9771, 327, 15214, 1257, 401, 267, 8307, 14, 17735, 26, 3698, 5426, 33, 5345, 401, 267, 8307, 14, 607, 9449, 26, 3515, 5426, 383, 33, 1493, 401, 267, 8307, 14, 547, 26, 3777, 5426, 1665, 993, 401, 267, 8307, 14, 37, 311, 72, 26, 4519, 298, 21843, 401, 267, 8307, 14, 2848, 951, 26, 3322, 298, 9771, 401, 267, 8307, 14, 20430, 26, 3322, 298, 9771, 327, 993, 1257, 401, 267, 8307, 14, 2959, 26, 3322, 5426, 13997, 401, 267, 8307, 14, 15905, 26, 260, 5426, 966, 36, 401, 398, 4520, 26, 9326, 298, 8665, 15596, 1665, 993, 2, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12955, 14, 69, 19309, 272, 18294, 2878, 94, 339, 437, 22437, 3449, 367, 14493, 12, 315, 8721, 581, 701, 662, 19309, 14, 339, 520, 7307, 26, 8315, 13, 9488, 701, 5346, 1308, 699, 3759, 76, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 4860, 12, 11013, 12, 8307, 12, 24403, 421, 199, 533, 662, 19309, 6609, 8, 6609, 304, 272, 408, 272, 710, 849, 3449, 334, 262, 8721, 581, 701, 662, 19309, 6928, 680, 272, 408, 339, 8020, 63, 2326, 275, 5426, 70, 24, 70, 24, 70, 24, 2, 272, 849, 63, 2487, 275, 3087, 339, 15725, 275, 469, 267, 24403, 26, 4483, 5426, 14923, 2501, 401, 267, 6819, 26, 7861, 298, 21843, 327, 31419, 383, 401, 267, 6819, 14, 19285, 26, 3698, 298, 889, 21843, 401, 267, 6819, 14, 12246, 26, 3698, 298, 889, 21843, 17268, 401, 398, 6431, 26, 7861, 298, 9771, 327, 2276, 1081, 1665, 401, 267, 6431, 14, 23414, 26, 3322, 298, 889, 9771, 401, 267, 6431, 14, 804, 26, 4519, 298, 9771, 327, 383, 5342, 383, 401, 398, 11013, 26, 8295, 5426, 6997, 1272, 401, 267, 11013, 14, 10155, 26, 3777, 298, 9771, 327, 2276, 1081, 1665, 401, 398, 2812, 14, 12306, 26, 4519, 5426, 2276, 1081, 1665, 401, 267, 2812, 14, 3481, 26, 3777, 5426, 383, 33, 1493, 401, 267, 2812, 14, 2543, 26, 4483, 5426, 993, 1665, 401, 267, 2812, 14, 8814, 26, 3322, 298, 9771, 327, 993, 1665, 401, 267, 2812, 14, 1726, 26, 3322, 298, 9771, 327, 36, 1194, 969, 33, 401, 267, 2812, 14, 2773, 26, 3777, 5426, 34, 24, 14832, 34, 401, 267, 2812, 14, 9737, 26, 3777, 5426, 1299, 993, 401, 267, 2812, 14, 4314, 26, 4483, 5426, 33, 16, 33, 1493, 401, 267, 2812, 14, 7302, 26, 5185, 298, 9771, 327, 20036, 401, 267, 2812, 14, 1646, 26, 3322, 5426, 5342, 22872, 401, 267, 2812, 14, 1931, 26, 8295, 298, 9771, 327, 8662, 1493, 401, 267, 2812, 14, 14946, 26, 3322, 5426, 2276, 1081, 1665, 401, 398, 2624, 26, 8540, 5426, 5342, 22872, 401, 267, 2624, 14, 3768, 26, 4483, 298, 21843, 401, 267, 2624, 14, 22713, 26, 3698, 298, 9771, 327, 5342, 1272, 1299, 401, 267, 2624, 14, 10260, 26, 3777, 298, 9771, 327, 5342, 1272, 1081, 401, 267, 2624, 14, 5103, 26, 4519, 5426, 5342, 1272, 1299, 401, 267, 2624, 14, 8169, 26, 3777, 5426, 34, 24, 14832, 34, 401, 267, 2624, 14, 8632, 26, 4519, 5426, 8662, 1493, 401, 267, 4860, 26, 8540, 5426, 6997, 1272, 401, 398, 8307, 14, 23818, 26, 3698, 298, 9771, 327, 993, 1257, 401, 267, 8307, 14, 2610, 13983, 26, 263, 298, 9771, 327, 15214, 1257, 401, 267, 8307, 14, 17735, 26, 3698, 5426, 33, 5345, 401, 267, 8307, 14, 607, 9449, 26, 3515, 5426, 383, 33, 1493, 401, 267, 8307, 14, 547, 26, 3777, 5426, 1665, 993, 401, 267, 8307, 14, 37, 311, 72, 26, 4519, 298, 21843, 401, 267, 8307, 14, 2848, 951, 26, 3322, 298, 9771, 401, 267, 8307, 14, 20430, 26, 3322, 298, 9771, 327, 993, 1257, 401, 267, 8307, 14, 2959, 26, 3322, 5426, 13997, 401, 267, 8307, 14, 15905, 26, 260, 5426, 966, 36, 401, 398, 4520, 26, 9326, 298, 8665, 15596, 1665, 993, 2, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Akuli/editor
tests/test_settings.py
1
6923
import dataclasses import json import sys import tkinter from tkinter import ttk from tkinter.font import Font from typing import List, Optional import dacite import pytest from porcupine import settings # Could replace some of this with non-global setting objects, but I don't feel # like rewriting the tests just because it would be slightly nicer that way @pytest.fixture def cleared_global_settings(monkeypatch, tmp_path): monkeypatch.setattr(settings._global_settings, '_options', {}) monkeypatch.setattr(settings._global_settings, '_unknown_options', {}) monkeypatch.setattr(settings, '_get_json_path', (lambda: tmp_path / 'settings.json')) def load_from_json_string(json_string: str) -> None: with settings._get_json_path().open('x', encoding='utf-8') as file: file.write(json_string) settings._load_from_file() def save_and_read_file() -> str: settings.save() with settings._get_json_path().open('r', encoding='utf-8') as file: return json.load(file) def test_add_option_and_get_and_set(cleared_global_settings): settings.add_option('how_many_foos', 123) settings.add_option('bar_message', 'hello') assert settings.get('how_many_foos', int) == 123 assert settings.get('bar_message', str) == 'hello' settings.set_('how_many_foos', 456) settings.set_('bar_message', 'bla') assert settings.get('how_many_foos', int) == 456 assert settings.get('bar_message', str) == 'bla' # Consider this situation: # - User installs plugin that adds an option # - User uninstalls plugin, which leaves the option to the settings file # - User restarts porcupine # # Even if the plugin is installed, reading the file happens before add_option() # is called. def test_unknown_option_in_settings_file(cleared_global_settings): load_from_json_string('{"foo": "custom", "unknown": "hello"}') with pytest.raises(KeyError): settings.get('foo', str) settings.add_option('foo', 'default') assert settings.get('foo', str) == 'custom' settings.set_('foo', 'default') assert settings.get('foo', str) == 'default' assert save_and_read_file() == {'unknown': 'hello'} def test_wrong_type(cleared_global_settings): settings.add_option('magic_message', 'bla') with pytest.raises( dacite.exceptions.WrongTypeError, match=r'wrong value type .* should be "int" instead of .* "str"'): settings.get('magic_message', int) with pytest.raises( dacite.exceptions.WrongTypeError, match=r'wrong value type .* should be "str" instead of .* "int"'): settings.set_('magic_message', 123) def test_name_collision(cleared_global_settings): settings.add_option('omg', 'bla') with pytest.raises(RuntimeError, match="^there's already an option named 'omg'$"): settings.add_option('omg', 'bla') settings.add_option('omg', 'bla', exist_ok=True) with pytest.raises(AssertionError): settings.add_option('omg', 123, exist_ok=True) def test_reset(cleared_global_settings): load_from_json_string('{"foo": "custom", "bar": "custom", "unknown": "hello"}') settings.add_option('foo', 'default') settings.add_option('bar', 'default') settings.add_option('baz', 'default') assert settings.get('foo', str) == 'custom' assert settings.get('bar', str) == 'custom' assert settings.get('baz', str) == 'default' settings.reset('bar') assert settings.get('foo', str) == 'custom' assert settings.get('bar', str) == 'default' assert settings.get('baz', str) == 'default' assert save_and_read_file() == {'foo': 'custom', 'unknown': 'hello'} settings.reset_all() assert settings.get('foo', str) == 'default' assert settings.get('bar', str) == 'default' assert settings.get('baz', str) == 'default' assert save_and_read_file() == {} # even unknown options go away def test_no_json_file(cleared_global_settings): assert not settings._get_json_path().exists() settings._load_from_file() settings.add_option('foo', 'default') settings.set_('foo', 'custom') assert not settings._get_json_path().exists() settings.reset_all() assert settings.get('foo', str) == 'default' def test_save(cleared_global_settings): load_from_json_string('{"bar": "custom bar"}') settings.add_option('foo', 'default') settings.add_option('bar', 'default') settings.add_option('baz', 'default') settings.set_('foo', 'custom foo') settings.save() with settings._get_json_path().open('r') as file: assert json.load(file) == {'foo': 'custom foo', 'bar': 'custom bar'} def test_font_gets_updated(): fixedfont = Font(name='TkFixedFont', exists=True) settings.set_('font_family', 'Helvetica') assert fixedfont['family'] == 'Helvetica' settings.set_('font_size', 123) assert fixedfont['size'] == 123 @dataclasses.dataclass class Foo: how_many: int message: str def test_dataclass(): settings_obj = settings.Settings(None, '<<Foo:{}>>') settings_obj.add_option('foo', None, Optional[Foo]) settings_obj.set('foo', {'how_many': 123, 'message': 'hello'}, from_config=True) settings_obj.set('bar', {'how_many': 456, 'message': 'hi'}, from_config=True) settings_obj.add_option('bar', None, Optional[Foo]) assert settings_obj.get('foo', Foo) == Foo(123, 'hello') assert settings_obj.get('bar', Foo) == Foo(456, 'hi') def test_debug_dump(capsys): settings_obj = settings.Settings(None, '<<Foo:{}>>') settings_obj.add_option('foo', None, Optional[str]) settings_obj.set('bar', ['a', 'b', 'c'], from_config=True) settings_obj.debug_dump() output, errors = capsys.readouterr() assert not errors if sys.version_info < (3, 9): output = output.replace('typing.Union[str, NoneType]', 'typing.Optional[str]') assert output == '''\ 1 known options (add_option called) foo = None (type: typing.Optional[str]) 1 unknown options (add_option not called) bar = ['a', 'b', 'c'] ''' def test_font_family_chooser(): families = settings._get_monospace_font_families() assert len(families) == len(set(families)), "duplicates" assert families == sorted(families), "wrong order" @pytest.fixture def toplevel(): toplevel = tkinter.Toplevel() toplevel.geometry('600x100') yield toplevel toplevel.destroy() def test_remember_panedwindow_positions(toplevel): pw = ttk.PanedWindow(toplevel, orient='horizontal') settings.remember_divider_positions(pw, 'pw_dividers', [123]) pw.pack(fill='both', expand=True) pw.add(ttk.Label(pw, text="aaaaaaaaaaa")) pw.add(ttk.Label(pw, text="bbbbbbbbbbb")) pw.update() assert pw.sashpos(0) == 123 pw.sashpos(0, 456) pw.event_generate('<ButtonRelease-1>') # happens after user drags pane assert settings.get('pw_dividers', List[int]) == [456]
mit
[ 646, 666, 2888, 199, 646, 2022, 199, 646, 984, 199, 646, 22171, 199, 504, 22171, 492, 28431, 199, 504, 22171, 14, 4246, 492, 26159, 199, 504, 14090, 492, 3820, 12, 4879, 199, 199, 646, 12927, 25171, 199, 646, 4613, 199, 199, 504, 8706, 17500, 1132, 492, 2202, 421, 199, 3, 18615, 3350, 2005, 402, 642, 543, 2222, 13, 2966, 4260, 2251, 12, 1325, 473, 2793, 1133, 23109, 199, 3, 2839, 295, 14827, 314, 2295, 2951, 2952, 652, 3955, 506, 18023, 30023, 626, 4340, 199, 32, 4462, 14, 5997, 199, 318, 20518, 63, 2966, 63, 1751, 8, 20372, 2068, 12, 3529, 63, 515, 304, 272, 17309, 14, 10202, 8, 1751, 423, 2966, 63, 1751, 12, 2513, 1419, 297, 5009, 272, 17309, 14, 10202, 8, 1751, 423, 2966, 63, 1751, 12, 2513, 5187, 63, 1419, 297, 5009, 272, 17309, 14, 10202, 8, 1751, 12, 2513, 362, 63, 1001, 63, 515, 297, 334, 2734, 26, 3529, 63, 515, 1182, 283, 1751, 14, 1001, 1333, 421, 199, 318, 2248, 63, 504, 63, 1001, 63, 875, 8, 1001, 63, 875, 26, 620, 9, 1035, 488, 26, 272, 543, 2202, 423, 362, 63, 1001, 63, 515, 1252, 1490, 360, 88, 297, 2644, 534, 1624, 13, 24, 358, 465, 570, 26, 267, 570, 14, 952, 8, 1001, 63, 875, 9, 272, 2202, 423, 912, 63, 504, 63, 493, 342, 421, 199, 318, 3354, 63, 460, 63, 739, 63, 493, 342, 1035, 620, 26, 272, 2202, 14, 2117, 342, 272, 543, 2202, 423, 362, 63, 1001, 63, 515, 1252, 1490, 360, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 570, 26, 267, 372, 2022, 14, 912, 8, 493, 9, 421, 199, 318, 511, 63, 525, 63, 1422, 63, 460, 63, 362, 63, 460, 63, 409, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 1917, 63, 3479, 63, 545, 736, 297, 11869, 9, 272, 2202, 14, 525, 63, 1422, 360, 1700, 63, 1188, 297, 283, 5006, 358, 339, 702, 2202, 14, 362, 360, 1917, 63, 3479, 63, 545, 736, 297, 1109, 9, 508, 11869, 272, 702, 2202, 14, 362, 360, 1700, 63, 1188, 297, 620, 9, 508, 283, 5006, 7, 272, 2202, 14, 409, 11252, 1917, 63, 3479, 63, 545, 736, 297, 31944, 9, 272, 2202, 14, 409, 11252, 1700, 63, 1188, 297, 283, 21244, 358, 272, 702, 2202, 14, 362, 360, 1917, 63, 3479, 63, 545, 736, 297, 1109, 9, 508, 31944, 272, 702, 2202, 14, 362, 360, 1700, 63, 1188, 297, 620, 9, 508, 283, 21244, 7, 421, 199, 3, 24413, 642, 25781, 26, 199, 3, 257, 446, 2876, 25801, 3589, 626, 9584, 376, 945, 199, 3, 257, 446, 2876, 22199, 83, 3589, 12, 1314, 16733, 314, 945, 370, 314, 2202, 570, 199, 3, 257, 446, 2876, 11004, 83, 8706, 17500, 1132, 199, 3, 199, 3, 22207, 340, 314, 3589, 365, 4903, 12, 7664, 314, 570, 10986, 2544, 1050, 63, 1422, 342, 199, 3, 365, 2797, 14, 199, 318, 511, 63, 5187, 63, 1422, 63, 262, 63, 1751, 63, 493, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2248, 63, 504, 63, 1001, 63, 875, 360, 6641, 1421, 582, 298, 4229, 401, 298, 5187, 582, 298, 5006, 3570, 358, 272, 543, 4613, 14, 3536, 8, 10230, 304, 267, 2202, 14, 362, 360, 1421, 297, 620, 9, 339, 2202, 14, 525, 63, 1422, 360, 1421, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 2202, 14, 409, 11252, 1421, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 885, 7, 339, 702, 3354, 63, 460, 63, 739, 63, 493, 342, 508, 791, 5187, 356, 283, 5006, 936, 421, 199, 318, 511, 63, 10603, 63, 466, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 11523, 63, 1188, 297, 283, 21244, 358, 339, 543, 4613, 14, 3536, 8, 288, 12927, 25171, 14, 3924, 14, 14858, 4333, 12, 288, 1336, 29, 82, 7, 10603, 574, 730, 23076, 1077, 506, 298, 442, 2, 3140, 402, 23076, 298, 495, 2, 735, 267, 2202, 14, 362, 360, 11523, 63, 1188, 297, 1109, 9, 272, 543, 4613, 14, 3536, 8, 288, 12927, 25171, 14, 3924, 14, 14858, 4333, 12, 288, 1336, 29, 82, 7, 10603, 574, 730, 23076, 1077, 506, 298, 495, 2, 3140, 402, 23076, 298, 442, 2, 735, 267, 2202, 14, 409, 11252, 11523, 63, 1188, 297, 11869, 9, 421, 199, 318, 511, 63, 354, 63, 761, 23656, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 358, 272, 543, 4613, 14, 3536, 8, 13281, 12, 1336, 628, 62, 16990, 1159, 2575, 376, 945, 4310, 283, 676, 71, 7, 4, 2349, 267, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 358, 339, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 297, 2187, 63, 745, 29, 549, 9, 272, 543, 4613, 14, 3536, 8, 14844, 304, 267, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 11869, 12, 2187, 63, 745, 29, 549, 9, 421, 199, 318, 511, 63, 3958, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2248, 63, 504, 63, 1001, 63, 875, 360, 6641, 1421, 582, 298, 4229, 401, 298, 1700, 582, 298, 4229, 401, 298, 5187, 582, 298, 5006, 3570, 358, 272, 2202, 14, 525, 63, 1422, 360, 1421, 297, 283, 885, 358, 272, 2202, 14, 525, 63, 1422, 360, 1700, 297, 283, 885, 358, 272, 2202, 14, 525, 63, 1422, 360, 6185, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202, 14, 362, 360, 1700, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202, 14, 362, 360, 6185, 297, 620, 9, 508, 283, 885, 7, 339, 2202, 14, 3958, 360, 1700, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202, 14, 362, 360, 1700, 297, 620, 9, 508, 283, 885, 7, 272, 702, 2202, 14, 362, 360, 6185, 297, 620, 9, 508, 283, 885, 7, 272, 702, 3354, 63, 460 ]
[ 666, 2888, 199, 646, 2022, 199, 646, 984, 199, 646, 22171, 199, 504, 22171, 492, 28431, 199, 504, 22171, 14, 4246, 492, 26159, 199, 504, 14090, 492, 3820, 12, 4879, 199, 199, 646, 12927, 25171, 199, 646, 4613, 199, 199, 504, 8706, 17500, 1132, 492, 2202, 421, 199, 3, 18615, 3350, 2005, 402, 642, 543, 2222, 13, 2966, 4260, 2251, 12, 1325, 473, 2793, 1133, 23109, 199, 3, 2839, 295, 14827, 314, 2295, 2951, 2952, 652, 3955, 506, 18023, 30023, 626, 4340, 199, 32, 4462, 14, 5997, 199, 318, 20518, 63, 2966, 63, 1751, 8, 20372, 2068, 12, 3529, 63, 515, 304, 272, 17309, 14, 10202, 8, 1751, 423, 2966, 63, 1751, 12, 2513, 1419, 297, 5009, 272, 17309, 14, 10202, 8, 1751, 423, 2966, 63, 1751, 12, 2513, 5187, 63, 1419, 297, 5009, 272, 17309, 14, 10202, 8, 1751, 12, 2513, 362, 63, 1001, 63, 515, 297, 334, 2734, 26, 3529, 63, 515, 1182, 283, 1751, 14, 1001, 1333, 421, 199, 318, 2248, 63, 504, 63, 1001, 63, 875, 8, 1001, 63, 875, 26, 620, 9, 1035, 488, 26, 272, 543, 2202, 423, 362, 63, 1001, 63, 515, 1252, 1490, 360, 88, 297, 2644, 534, 1624, 13, 24, 358, 465, 570, 26, 267, 570, 14, 952, 8, 1001, 63, 875, 9, 272, 2202, 423, 912, 63, 504, 63, 493, 342, 421, 199, 318, 3354, 63, 460, 63, 739, 63, 493, 342, 1035, 620, 26, 272, 2202, 14, 2117, 342, 272, 543, 2202, 423, 362, 63, 1001, 63, 515, 1252, 1490, 360, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 570, 26, 267, 372, 2022, 14, 912, 8, 493, 9, 421, 199, 318, 511, 63, 525, 63, 1422, 63, 460, 63, 362, 63, 460, 63, 409, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 1917, 63, 3479, 63, 545, 736, 297, 11869, 9, 272, 2202, 14, 525, 63, 1422, 360, 1700, 63, 1188, 297, 283, 5006, 358, 339, 702, 2202, 14, 362, 360, 1917, 63, 3479, 63, 545, 736, 297, 1109, 9, 508, 11869, 272, 702, 2202, 14, 362, 360, 1700, 63, 1188, 297, 620, 9, 508, 283, 5006, 7, 272, 2202, 14, 409, 11252, 1917, 63, 3479, 63, 545, 736, 297, 31944, 9, 272, 2202, 14, 409, 11252, 1700, 63, 1188, 297, 283, 21244, 358, 272, 702, 2202, 14, 362, 360, 1917, 63, 3479, 63, 545, 736, 297, 1109, 9, 508, 31944, 272, 702, 2202, 14, 362, 360, 1700, 63, 1188, 297, 620, 9, 508, 283, 21244, 7, 421, 199, 3, 24413, 642, 25781, 26, 199, 3, 257, 446, 2876, 25801, 3589, 626, 9584, 376, 945, 199, 3, 257, 446, 2876, 22199, 83, 3589, 12, 1314, 16733, 314, 945, 370, 314, 2202, 570, 199, 3, 257, 446, 2876, 11004, 83, 8706, 17500, 1132, 199, 3, 199, 3, 22207, 340, 314, 3589, 365, 4903, 12, 7664, 314, 570, 10986, 2544, 1050, 63, 1422, 342, 199, 3, 365, 2797, 14, 199, 318, 511, 63, 5187, 63, 1422, 63, 262, 63, 1751, 63, 493, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2248, 63, 504, 63, 1001, 63, 875, 360, 6641, 1421, 582, 298, 4229, 401, 298, 5187, 582, 298, 5006, 3570, 358, 272, 543, 4613, 14, 3536, 8, 10230, 304, 267, 2202, 14, 362, 360, 1421, 297, 620, 9, 339, 2202, 14, 525, 63, 1422, 360, 1421, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 2202, 14, 409, 11252, 1421, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 885, 7, 339, 702, 3354, 63, 460, 63, 739, 63, 493, 342, 508, 791, 5187, 356, 283, 5006, 936, 421, 199, 318, 511, 63, 10603, 63, 466, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 11523, 63, 1188, 297, 283, 21244, 358, 339, 543, 4613, 14, 3536, 8, 288, 12927, 25171, 14, 3924, 14, 14858, 4333, 12, 288, 1336, 29, 82, 7, 10603, 574, 730, 23076, 1077, 506, 298, 442, 2, 3140, 402, 23076, 298, 495, 2, 735, 267, 2202, 14, 362, 360, 11523, 63, 1188, 297, 1109, 9, 272, 543, 4613, 14, 3536, 8, 288, 12927, 25171, 14, 3924, 14, 14858, 4333, 12, 288, 1336, 29, 82, 7, 10603, 574, 730, 23076, 1077, 506, 298, 495, 2, 3140, 402, 23076, 298, 442, 2, 735, 267, 2202, 14, 409, 11252, 11523, 63, 1188, 297, 11869, 9, 421, 199, 318, 511, 63, 354, 63, 761, 23656, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 358, 272, 543, 4613, 14, 3536, 8, 13281, 12, 1336, 628, 62, 16990, 1159, 2575, 376, 945, 4310, 283, 676, 71, 7, 4, 2349, 267, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 358, 339, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 283, 21244, 297, 2187, 63, 745, 29, 549, 9, 272, 543, 4613, 14, 3536, 8, 14844, 304, 267, 2202, 14, 525, 63, 1422, 360, 676, 71, 297, 11869, 12, 2187, 63, 745, 29, 549, 9, 421, 199, 318, 511, 63, 3958, 8, 2265, 2899, 63, 2966, 63, 1751, 304, 272, 2248, 63, 504, 63, 1001, 63, 875, 360, 6641, 1421, 582, 298, 4229, 401, 298, 1700, 582, 298, 4229, 401, 298, 5187, 582, 298, 5006, 3570, 358, 272, 2202, 14, 525, 63, 1422, 360, 1421, 297, 283, 885, 358, 272, 2202, 14, 525, 63, 1422, 360, 1700, 297, 283, 885, 358, 272, 2202, 14, 525, 63, 1422, 360, 6185, 297, 283, 885, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202, 14, 362, 360, 1700, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202, 14, 362, 360, 6185, 297, 620, 9, 508, 283, 885, 7, 339, 2202, 14, 3958, 360, 1700, 358, 272, 702, 2202, 14, 362, 360, 1421, 297, 620, 9, 508, 283, 4229, 7, 272, 702, 2202,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MikeAmy/django
django/db/models/fields/related.py
6
67331
from __future__ import unicode_literals import warnings from functools import partial from django import forms from django.apps import apps from django.core import checks, exceptions from django.db import connection, router from django.db.backends import utils from django.db.models.deletion import CASCADE, SET_DEFAULT, SET_NULL from django.db.models.query_utils import PathInfo from django.db.models.utils import make_model_tuple from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, smart_text from django.utils.functional import cached_property, curry from django.utils.translation import ugettext_lazy as _ from django.utils.version import get_docs_version from . import Field from .related_descriptors import ( ForwardManyToOneDescriptor, ManyToManyDescriptor, ReverseManyToOneDescriptor, ReverseOneToOneDescriptor, ) from .related_lookups import ( RelatedExact, RelatedGreaterThan, RelatedGreaterThanOrEqual, RelatedIn, RelatedIsNull, RelatedLessThan, RelatedLessThanOrEqual, ) from .reverse_related import ( ForeignObjectRel, ManyToManyRel, ManyToOneRel, OneToOneRel, ) RECURSIVE_RELATIONSHIP_CONSTANT = 'self' def resolve_relation(scope_model, relation): """ Transform relation into a model or fully-qualified model string of the form "app_label.ModelName", relative to scope_model. The relation argument can be: * RECURSIVE_RELATIONSHIP_CONSTANT, i.e. the string "self", in which case the model argument will be returned. * A bare model name without an app_label, in which case scope_model's app_label will be prepended. * An "app_label.ModelName" string. * A model class, which will be returned unchanged. """ # Check for recursive relations if relation == RECURSIVE_RELATIONSHIP_CONSTANT: relation = scope_model # Look for an "app.Model" relation if isinstance(relation, six.string_types): if "." not in relation: relation = "%s.%s" % (scope_model._meta.app_label, relation) return relation def lazy_related_operation(function, model, *related_models, **kwargs): """ Schedule `function` to be called once `model` and all `related_models` have been imported and registered with the app registry. `function` will be called with the newly-loaded model classes as its positional arguments, plus any optional keyword arguments. The `model` argument must be a model class. Each subsequent positional argument is another model, or a reference to another model - see `resolve_relation()` for the various forms these may take. Any relative references will be resolved relative to `model`. This is a convenience wrapper for `Apps.lazy_model_operation` - the app registry model used is the one found in `model._meta.apps`. """ models = [model] + [resolve_relation(model, rel) for rel in related_models] model_keys = (make_model_tuple(m) for m in models) apps = model._meta.apps return apps.lazy_model_operation(partial(function, **kwargs), *model_keys) def add_lazy_relation(cls, field, relation, operation): warnings.warn( "add_lazy_relation() has been superseded by lazy_related_operation() " "and related methods on the Apps class.", RemovedInDjango20Warning, stacklevel=2) # Rearrange args for new Apps.lazy_model_operation function = lambda local, related, field: operation(field, related, local) lazy_related_operation(function, cls, relation, field=field) class RelatedField(Field): """ Base class that all relational fields inherit from. """ # Field flags one_to_many = False one_to_one = False many_to_many = False many_to_one = False @cached_property def related_model(self): # Can't cache this property until all the models are loaded. apps.check_models_ready() return self.remote_field.model def check(self, **kwargs): errors = super(RelatedField, self).check(**kwargs) errors.extend(self._check_related_name_is_valid()) errors.extend(self._check_relation_model_exists()) errors.extend(self._check_referencing_to_swapped_model()) errors.extend(self._check_clashes()) return errors def _check_related_name_is_valid(self): import re import keyword related_name = self.remote_field.related_name if related_name is None: return [] is_valid_id = True if keyword.iskeyword(related_name): is_valid_id = False if six.PY3: if not related_name.isidentifier(): is_valid_id = False else: if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*\Z', related_name): is_valid_id = False if not (is_valid_id or related_name.endswith('+')): return [ checks.Error( "The name '%s' is invalid related_name for field %s.%s" % (self.remote_field.related_name, self.model._meta.object_name, self.name), hint="Related name must be a valid Python identifier or end with a '+'", obj=self, id='fields.E306', ) ] return [] def _check_relation_model_exists(self): rel_is_missing = self.remote_field.model not in self.opts.apps.get_models() rel_is_string = isinstance(self.remote_field.model, six.string_types) model_name = self.remote_field.model if rel_is_string else self.remote_field.model._meta.object_name if rel_is_missing and (rel_is_string or not self.remote_field.model._meta.swapped): return [ checks.Error( ("Field defines a relation with model '%s', which " "is either not installed, or is abstract.") % model_name, hint=None, obj=self, id='fields.E300', ) ] return [] def _check_referencing_to_swapped_model(self): if (self.remote_field.model not in self.opts.apps.get_models() and not isinstance(self.remote_field.model, six.string_types) and self.remote_field.model._meta.swapped): model = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name ) return [ checks.Error( ("Field defines a relation with the model '%s', " "which has been swapped out.") % model, hint="Update the relation to point at 'settings.%s'." % self.remote_field.model._meta.swappable, obj=self, id='fields.E301', ) ] return [] def _check_clashes(self): """ Check accessor and reverse query name clashes. """ from django.db.models.base import ModelBase errors = [] opts = self.model._meta # `f.remote_field.model` may be a string instead of a model. Skip if model name is # not resolved. if not isinstance(self.remote_field.model, ModelBase): return [] # If the field doesn't install backward relation on the target model (so # `is_hidden` returns True), then there are no clashes to check and we # can skip these fields. if self.remote_field.is_hidden(): return [] # Consider that we are checking field `Model.foreign` and the models # are: # # class Target(models.Model): # model = models.IntegerField() # model_set = models.IntegerField() # # class Model(models.Model): # foreign = models.ForeignKey(Target) # m2m = models.ManyToManyField(Target) rel_opts = self.remote_field.model._meta # rel_opts.object_name == "Target" rel_name = self.remote_field.get_accessor_name() # i. e. "model_set" rel_query_name = self.related_query_name() # i. e. "model" field_name = "%s.%s" % (opts.object_name, self.name) # i. e. "Model.field" # Check clashes between accessor or reverse query name of `field` # and any other field name -- i.e. accessor for Model.foreign is # model_set and it clashes with Target.model_set. potential_clashes = rel_opts.fields + rel_opts.many_to_many for clash_field in potential_clashes: clash_name = "%s.%s" % (rel_opts.object_name, clash_field.name) # i. e. "Target.model_set" if clash_field.name == rel_name: errors.append( checks.Error( "Reverse accessor for '%s' clashes with field name '%s'." % (field_name, clash_name), hint=("Rename field '%s', or add/change a related_name " "argument to the definition for field '%s'.") % (clash_name, field_name), obj=self, id='fields.E302', ) ) if clash_field.name == rel_query_name: errors.append( checks.Error( "Reverse query name for '%s' clashes with field name '%s'." % (field_name, clash_name), hint=("Rename field '%s', or add/change a related_name " "argument to the definition for field '%s'.") % (clash_name, field_name), obj=self, id='fields.E303', ) ) # Check clashes between accessors/reverse query names of `field` and # any other field accessor -- i. e. Model.foreign accessor clashes with # Model.m2m accessor. potential_clashes = (r for r in rel_opts.related_objects if r.field is not self) for clash_field in potential_clashes: clash_name = "%s.%s" % ( # i. e. "Model.m2m" clash_field.related_model._meta.object_name, clash_field.field.name) if clash_field.get_accessor_name() == rel_name: errors.append( checks.Error( "Reverse accessor for '%s' clashes with reverse accessor for '%s'." % (field_name, clash_name), hint=("Add or change a related_name argument " "to the definition for '%s' or '%s'.") % (field_name, clash_name), obj=self, id='fields.E304', ) ) if clash_field.get_accessor_name() == rel_query_name: errors.append( checks.Error( "Reverse query name for '%s' clashes with reverse query name for '%s'." % (field_name, clash_name), hint=("Add or change a related_name argument " "to the definition for '%s' or '%s'.") % (field_name, clash_name), obj=self, id='fields.E305', ) ) return errors def db_type(self, connection): # By default related field will not have a column as it relates to # columns from another table. return None def contribute_to_class(self, cls, name, virtual_only=False): super(RelatedField, self).contribute_to_class(cls, name, virtual_only=virtual_only) self.opts = cls._meta if not cls._meta.abstract: if self.remote_field.related_name: related_name = force_text(self.remote_field.related_name) % { 'class': cls.__name__.lower(), 'app_label': cls._meta.app_label.lower() } self.remote_field.related_name = related_name def resolve_related_class(model, related, field): field.remote_field.model = related field.do_related_class(related, model) lazy_related_operation(resolve_related_class, cls, self.remote_field.model, field=self) def get_forward_related_filter(self, obj): """ Return the keyword arguments that when supplied to self.model.object.filter(), would select all instances related through this field to the remote obj. This is used to build the querysets returned by related descriptors. obj is an instance of self.related_field.model. """ return { '%s__%s' % (self.name, rh_field.name): getattr(obj, rh_field.attname) for _, rh_field in self.related_fields } def get_reverse_related_filter(self, obj): """ Complement to get_forward_related_filter(). Return the keyword arguments that when passed to self.related_field.model.object.filter() select all instances of self.related_field.model related through this field to obj. obj is an instance of self.model. """ base_filter = { rh_field.attname: getattr(obj, lh_field.attname) for lh_field, rh_field in self.related_fields } base_filter.update(self.get_extra_descriptor_filter(obj) or {}) return base_filter @property def swappable_setting(self): """ Get the setting that this is powered from for swapping, or None if it's not swapped in / marked with swappable=False. """ if self.swappable: # Work out string form of "to" if isinstance(self.remote_field.model, six.string_types): to_string = self.remote_field.model else: to_string = self.remote_field.model._meta.label return apps.get_swappable_settings_name(to_string) return None def set_attributes_from_rel(self): self.name = ( self.name or (self.remote_field.model._meta.model_name + '_' + self.remote_field.model._meta.pk.name) ) if self.verbose_name is None: self.verbose_name = self.remote_field.model._meta.verbose_name self.remote_field.set_field_name() def do_related_class(self, other, cls): self.set_attributes_from_rel() self.contribute_to_related_class(other, self.remote_field) def get_limit_choices_to(self): """ Return ``limit_choices_to`` for this model field. If it is a callable, it will be invoked and the result will be returned. """ if callable(self.remote_field.limit_choices_to): return self.remote_field.limit_choices_to() return self.remote_field.limit_choices_to def formfield(self, **kwargs): """ Pass ``limit_choices_to`` to the field being constructed. Only passes it if there is a type that supports related fields. This is a similar strategy used to pass the ``queryset`` to the field being constructed. """ defaults = {} if hasattr(self.remote_field, 'get_related_field'): # If this is a callable, do not invoke it here. Just pass # it in the defaults for when the form class will later be # instantiated. limit_choices_to = self.remote_field.limit_choices_to defaults.update({ 'limit_choices_to': limit_choices_to, }) defaults.update(kwargs) return super(RelatedField, self).formfield(**defaults) def related_query_name(self): """ Define the name that can be used to identify this related object in a table-spanning query. """ return self.remote_field.related_query_name or self.remote_field.related_name or self.opts.model_name @property def target_field(self): """ When filtering against this relation, returns the field on the remote model against which the filtering should happen. """ target_fields = self.get_path_info()[-1].target_fields if len(target_fields) > 1: raise exceptions.FieldError( "The relation has multiple target fields, but only single target field was asked for") return target_fields[0] class ForeignObject(RelatedField): """ Abstraction of the ForeignKey relation, supports multi-column relations. """ # Field flags many_to_many = False many_to_one = True one_to_many = False one_to_one = False requires_unique_target = True related_accessor_class = ReverseManyToOneDescriptor rel_class = ForeignObjectRel def __init__(self, to, on_delete, from_fields, to_fields, rel=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, swappable=True, **kwargs): if rel is None: rel = self.rel_class( self, to, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, parent_link=parent_link, on_delete=on_delete, ) super(ForeignObject, self).__init__(rel=rel, **kwargs) self.from_fields = from_fields self.to_fields = to_fields self.swappable = swappable def check(self, **kwargs): errors = super(ForeignObject, self).check(**kwargs) errors.extend(self._check_unique_target()) return errors def _check_unique_target(self): rel_is_string = isinstance(self.remote_field.model, six.string_types) if rel_is_string or not self.requires_unique_target: return [] try: self.foreign_related_fields except exceptions.FieldDoesNotExist: return [] if not self.foreign_related_fields: return [] unique_foreign_fields = { frozenset([f.name]) for f in self.remote_field.model._meta.get_fields() if getattr(f, 'unique', False) } unique_foreign_fields.update({ frozenset(ut) for ut in self.remote_field.model._meta.unique_together }) foreign_fields = {f.name for f in self.foreign_related_fields} has_unique_constraint = any(u <= foreign_fields for u in unique_foreign_fields) if not has_unique_constraint and len(self.foreign_related_fields) > 1: field_combination = ', '.join("'%s'" % rel_field.name for rel_field in self.foreign_related_fields) model_name = self.remote_field.model.__name__ return [ checks.Error( "No subset of the fields %s on model '%s' is unique." % (field_combination, model_name), hint=( "Add unique=True on any of those fields or add at " "least a subset of them to a unique_together constraint." ), obj=self, id='fields.E310', ) ] elif not has_unique_constraint: field_name = self.foreign_related_fields[0].name model_name = self.remote_field.model.__name__ return [ checks.Error( ("'%s.%s' must set unique=True " "because it is referenced by a foreign key.") % (model_name, field_name), hint=None, obj=self, id='fields.E311', ) ] else: return [] def deconstruct(self): name, path, args, kwargs = super(ForeignObject, self).deconstruct() kwargs['on_delete'] = self.remote_field.on_delete kwargs['from_fields'] = self.from_fields kwargs['to_fields'] = self.to_fields if self.remote_field.related_name is not None: kwargs['related_name'] = self.remote_field.related_name if self.remote_field.related_query_name is not None: kwargs['related_query_name'] = self.remote_field.related_query_name if self.remote_field.parent_link: kwargs['parent_link'] = self.remote_field.parent_link # Work out string form of "to" if isinstance(self.remote_field.model, six.string_types): kwargs['to'] = self.remote_field.model else: kwargs['to'] = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name, ) # If swappable is True, then see if we're actually pointing to the target # of a swap. swappable_setting = self.swappable_setting if swappable_setting is not None: # If it's already a settings reference, error if hasattr(kwargs['to'], "setting_name"): if kwargs['to'].setting_name != swappable_setting: raise ValueError( "Cannot deconstruct a ForeignKey pointing to a model " "that is swapped in place of more than one model (%s and %s)" % (kwargs['to'].setting_name, swappable_setting) ) # Set it from django.db.migrations.writer import SettingsReference kwargs['to'] = SettingsReference( kwargs['to'], swappable_setting, ) return name, path, args, kwargs def resolve_related_fields(self): if len(self.from_fields) < 1 or len(self.from_fields) != len(self.to_fields): raise ValueError('Foreign Object from and to fields must be the same non-zero length') if isinstance(self.remote_field.model, six.string_types): raise ValueError('Related model %r cannot be resolved' % self.remote_field.model) related_fields = [] for index in range(len(self.from_fields)): from_field_name = self.from_fields[index] to_field_name = self.to_fields[index] from_field = (self if from_field_name == 'self' else self.opts.get_field(from_field_name)) to_field = (self.remote_field.model._meta.pk if to_field_name is None else self.remote_field.model._meta.get_field(to_field_name)) related_fields.append((from_field, to_field)) return related_fields @property def related_fields(self): if not hasattr(self, '_related_fields'): self._related_fields = self.resolve_related_fields() return self._related_fields @property def reverse_related_fields(self): return [(rhs_field, lhs_field) for lhs_field, rhs_field in self.related_fields] @property def local_related_fields(self): return tuple(lhs_field for lhs_field, rhs_field in self.related_fields) @property def foreign_related_fields(self): return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field) def get_local_related_value(self, instance): return self.get_instance_value_for_fields(instance, self.local_related_fields) def get_foreign_related_value(self, instance): return self.get_instance_value_for_fields(instance, self.foreign_related_fields) @staticmethod def get_instance_value_for_fields(instance, fields): ret = [] opts = instance._meta for field in fields: # Gotcha: in some cases (like fixture loading) a model can have # different values in parent_ptr_id and parent's id. So, use # instance.pk (that is, parent_ptr_id) when asked for instance.id. if field.primary_key: possible_parent_link = opts.get_ancestor_link(field.model) if (not possible_parent_link or possible_parent_link.primary_key or possible_parent_link.model._meta.abstract): ret.append(instance.pk) continue ret.append(getattr(instance, field.attname)) return tuple(ret) def get_attname_column(self): attname, column = super(ForeignObject, self).get_attname_column() return attname, None def get_joining_columns(self, reverse_join=False): source = self.reverse_related_fields if reverse_join else self.related_fields return tuple((lhs_field.column, rhs_field.column) for lhs_field, rhs_field in source) def get_reverse_joining_columns(self): return self.get_joining_columns(reverse_join=True) def get_extra_descriptor_filter(self, instance): """ Return an extra filter condition for related object fetching when user does 'instance.fieldname', that is the extra filter is used in the descriptor of the field. The filter should be either a dict usable in .filter(**kwargs) call or a Q-object. The condition will be ANDed together with the relation's joining columns. A parallel method is get_extra_restriction() which is used in JOIN and subquery conditions. """ return {} def get_extra_restriction(self, where_class, alias, related_alias): """ Return a pair condition used for joining and subquery pushdown. The condition is something that responds to as_sql(compiler, connection) method. Note that currently referring both the 'alias' and 'related_alias' will not work in some conditions, like subquery pushdown. A parallel method is get_extra_descriptor_filter() which is used in instance.fieldname related object fetching. """ return None def get_path_info(self): """ Get path from this field to the related model. """ opts = self.remote_field.model._meta from_opts = self.model._meta return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] def get_reverse_path_info(self): """ Get path from the related model to this field's model. """ opts = self.model._meta from_opts = self.remote_field.model._meta pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)] return pathinfos def get_lookup(self, lookup_name): if lookup_name == 'in': return RelatedIn elif lookup_name == 'exact': return RelatedExact elif lookup_name == 'gt': return RelatedGreaterThan elif lookup_name == 'gte': return RelatedGreaterThanOrEqual elif lookup_name == 'lt': return RelatedLessThan elif lookup_name == 'lte': return RelatedLessThanOrEqual elif lookup_name == 'isnull': return RelatedIsNull else: raise TypeError('Related Field got invalid lookup: %s' % lookup_name) def get_transform(self, *args, **kwargs): raise NotImplementedError('Relational fields do not support transforms.') @property def attnames(self): return tuple(field.attname for field in self.local_related_fields) def get_defaults(self): return tuple(field.get_default() for field in self.local_related_fields) def contribute_to_class(self, cls, name, virtual_only=False): super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only) setattr(cls, self.name, ForwardManyToOneDescriptor(self)) def contribute_to_related_class(self, cls, related): # Internal FK's - i.e., those with a related name ending with '+' - # and swapped models don't get a related descriptor. if not self.remote_field.is_hidden() and not related.related_model._meta.swapped: setattr(cls._meta.concrete_model, related.get_accessor_name(), self.related_accessor_class(related)) # While 'limit_choices_to' might be a callable, simply pass # it along for later - this is too early because it's still # model load time. if self.remote_field.limit_choices_to: cls._meta.related_fkey_lookups.append(self.remote_field.limit_choices_to) class ForeignKey(ForeignObject): """ Provide a many-to-one relation by adding a column to the local model to hold the remote value. By default ForeignKey will target the pk of the remote model but this behavior can be changed by using the ``to_field`` argument. """ # Field flags many_to_many = False many_to_one = True one_to_many = False one_to_one = False rel_class = ManyToOneRel empty_strings_allowed = False default_error_messages = { 'invalid': _('%(model)s instance with %(field)s %(value)r does not exist.') } description = _("Foreign Key (type determined by related field)") def __init__(self, to, on_delete=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, to_field=None, db_constraint=True, **kwargs): try: to._meta.model_name except AttributeError: assert isinstance(to, six.string_types), ( "%s(%r) is invalid. First parameter to ForeignKey must be " "either a model, a model name, or the string %r" % ( self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT, ) ) else: # For backwards compatibility purposes, we need to *try* and set # the to_field during FK construction. It won't be guaranteed to # be correct until contribute_to_class is called. Refs #12190. to_field = to_field or (to._meta.pk and to._meta.pk.name) if on_delete is None: warnings.warn( "on_delete will be a required arg for %s in Django 2.0. Set " "it to models.CASCADE on models and in existing migrations " "if you want to maintain the current default behavior. " "See https://docs.djangoproject.com/en/%s/ref/models/fields/" "#django.db.models.ForeignKey.on_delete" % ( self.__class__.__name__, get_docs_version(), ), RemovedInDjango20Warning, 2) on_delete = CASCADE elif not callable(on_delete): warnings.warn( "The signature for {0} will change in Django 2.0. " "Pass to_field='{1}' as a kwarg instead of as an arg.".format( self.__class__.__name__, on_delete, ), RemovedInDjango20Warning, 2) on_delete, to_field = to_field, on_delete kwargs['rel'] = self.rel_class( self, to, to_field, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, parent_link=parent_link, on_delete=on_delete, ) kwargs['db_index'] = kwargs.get('db_index', True) super(ForeignKey, self).__init__( to, on_delete, from_fields=['self'], to_fields=[to_field], **kwargs) self.db_constraint = db_constraint def check(self, **kwargs): errors = super(ForeignKey, self).check(**kwargs) errors.extend(self._check_on_delete()) errors.extend(self._check_unique()) return errors def _check_on_delete(self): on_delete = getattr(self.remote_field, 'on_delete', None) if on_delete == SET_NULL and not self.null: return [ checks.Error( 'Field specifies on_delete=SET_NULL, but cannot be null.', hint='Set null=True argument on the field, or change the on_delete rule.', obj=self, id='fields.E320', ) ] elif on_delete == SET_DEFAULT and not self.has_default(): return [ checks.Error( 'Field specifies on_delete=SET_DEFAULT, but has no default value.', hint='Set a default value, or change the on_delete rule.', obj=self, id='fields.E321', ) ] else: return [] def _check_unique(self, **kwargs): return [ checks.Warning( 'Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.', hint='ForeignKey(unique=True) is usually better served by a OneToOneField.', obj=self, id='fields.W342', ) ] if self.unique else [] def deconstruct(self): name, path, args, kwargs = super(ForeignKey, self).deconstruct() del kwargs['to_fields'] del kwargs['from_fields'] # Handle the simpler arguments if self.db_index: del kwargs['db_index'] else: kwargs['db_index'] = False if self.db_constraint is not True: kwargs['db_constraint'] = self.db_constraint # Rel needs more work. to_meta = getattr(self.remote_field.model, "_meta", None) if self.remote_field.field_name and ( not to_meta or (to_meta.pk and self.remote_field.field_name != to_meta.pk.name)): kwargs['to_field'] = self.remote_field.field_name return name, path, args, kwargs @property def target_field(self): return self.foreign_related_fields[0] def get_reverse_path_info(self): """ Get path from the related model to this field's model. """ opts = self.model._meta from_opts = self.remote_field.model._meta pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)] return pathinfos def validate(self, value, model_instance): if self.remote_field.parent_link: return super(ForeignKey, self).validate(value, model_instance) if value is None: return using = router.db_for_read(model_instance.__class__, instance=model_instance) qs = self.remote_field.model._default_manager.using(using).filter( **{self.remote_field.field_name: value} ) qs = qs.complex_filter(self.get_limit_choices_to()) if not qs.exists(): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={ 'model': self.remote_field.model._meta.verbose_name, 'pk': value, 'field': self.remote_field.field_name, 'value': value, }, # 'pk' is included for backwards compatibility ) def get_attname(self): return '%s_id' % self.name def get_attname_column(self): attname = self.get_attname() column = self.db_column or attname return attname, column def get_default(self): "Here we check if the default value is an object and return the to_field if so." field_default = super(ForeignKey, self).get_default() if isinstance(field_default, self.remote_field.model): return getattr(field_default, self.target_field.attname) return field_default def get_db_prep_save(self, value, connection): if value is None or (value == '' and (not self.target_field.empty_strings_allowed or connection.features.interprets_empty_strings_as_nulls)): return None else: return self.target_field.get_db_prep_save(value, connection=connection) def get_db_prep_value(self, value, connection, prepared=False): return self.target_field.get_db_prep_value(value, connection, prepared) def value_to_string(self, obj): if not obj: # In required many-to-one fields with only one available choice, # select that one available choice. Note: For SelectFields # we have to check that the length of choices is *2*, not 1, # because SelectFields always have an initial "blank" value. if not self.blank and self.choices: choice_list = self.get_choices_default() if len(choice_list) == 2: return smart_text(choice_list[1][0]) return super(ForeignKey, self).value_to_string(obj) def contribute_to_related_class(self, cls, related): super(ForeignKey, self).contribute_to_related_class(cls, related) if self.remote_field.field_name is None: self.remote_field.field_name = cls._meta.pk.name def formfield(self, **kwargs): db = kwargs.pop('using', None) if isinstance(self.remote_field.model, six.string_types): raise ValueError("Cannot create form field for %r yet, because " "its related model %r has not been loaded yet" % (self.name, self.remote_field.model)) defaults = { 'form_class': forms.ModelChoiceField, 'queryset': self.remote_field.model._default_manager.using(db), 'to_field_name': self.remote_field.field_name, } defaults.update(kwargs) return super(ForeignKey, self).formfield(**defaults) def db_type(self, connection): return self.target_field.rel_db_type(connection=connection) def db_parameters(self, connection): return {"type": self.db_type(connection), "check": []} def convert_empty_strings(self, value, expression, connection, context): if (not value) and isinstance(value, six.string_types): return None return value def get_db_converters(self, connection): converters = super(ForeignKey, self).get_db_converters(connection) if connection.features.interprets_empty_strings_as_nulls: converters += [self.convert_empty_strings] return converters def get_col(self, alias, output_field=None): return super(ForeignKey, self).get_col(alias, output_field or self.target_field) class OneToOneField(ForeignKey): """ A OneToOneField is essentially the same as a ForeignKey, with the exception that it always carries a "unique" constraint with it and the reverse relation always returns the object pointed to (since there will only ever be one), rather than returning a list. """ # Field flags many_to_many = False many_to_one = False one_to_many = False one_to_one = True related_accessor_class = ReverseOneToOneDescriptor rel_class = OneToOneRel description = _("One-to-one relationship") def __init__(self, to, on_delete=None, to_field=None, **kwargs): kwargs['unique'] = True if on_delete is None: warnings.warn( "on_delete will be a required arg for %s in Django 2.0. Set " "it to models.CASCADE on models and in existing migrations " "if you want to maintain the current default behavior. " "See https://docs.djangoproject.com/en/%s/ref/models/fields/" "#django.db.models.ForeignKey.on_delete" % ( self.__class__.__name__, get_docs_version(), ), RemovedInDjango20Warning, 2) on_delete = CASCADE elif not callable(on_delete): warnings.warn( "The signature for {0} will change in Django 2.0. " "Pass to_field='{1}' as a kwarg instead of as an arg.".format( self.__class__.__name__, on_delete, ), RemovedInDjango20Warning, 2) to_field = on_delete on_delete = CASCADE # Avoid warning in superclass super(OneToOneField, self).__init__(to, on_delete, to_field=to_field, **kwargs) def deconstruct(self): name, path, args, kwargs = super(OneToOneField, self).deconstruct() if "unique" in kwargs: del kwargs['unique'] return name, path, args, kwargs def formfield(self, **kwargs): if self.remote_field.parent_link: return None return super(OneToOneField, self).formfield(**kwargs) def save_form_data(self, instance, data): if isinstance(data, self.remote_field.model): setattr(instance, self.name, data) else: setattr(instance, self.attname, data) def _check_unique(self, **kwargs): # Override ForeignKey since check isn't applicable here. return [] def create_many_to_many_intermediary_model(field, klass): from django.db import models def set_managed(model, related, through): through._meta.managed = model._meta.managed or related._meta.managed to_model = resolve_relation(klass, field.remote_field.model) name = '%s_%s' % (klass._meta.object_name, field.name) lazy_related_operation(set_managed, klass, to_model, name) to = make_model_tuple(to_model)[1] from_ = klass._meta.model_name if to == from_: to = 'to_%s' % to from_ = 'from_%s' % from_ meta = type(str('Meta'), (object,), { 'db_table': field._get_m2m_db_table(klass._meta), 'auto_created': klass, 'app_label': klass._meta.app_label, 'db_tablespace': klass._meta.db_tablespace, 'unique_together': (from_, to), 'verbose_name': _('%(from)s-%(to)s relationship') % {'from': from_, 'to': to}, 'verbose_name_plural': _('%(from)s-%(to)s relationships') % {'from': from_, 'to': to}, 'apps': field.model._meta.apps, }) # Construct and return the new class. return type(str(name), (models.Model,), { 'Meta': meta, '__module__': klass.__module__, from_: models.ForeignKey( klass, related_name='%s+' % name, db_tablespace=field.db_tablespace, db_constraint=field.remote_field.db_constraint, on_delete=CASCADE, ), to: models.ForeignKey( to_model, related_name='%s+' % name, db_tablespace=field.db_tablespace, db_constraint=field.remote_field.db_constraint, on_delete=CASCADE, ) }) class ManyToManyField(RelatedField): """ Provide a many-to-many relation by using an intermediary model that holds two ForeignKey fields pointed at the two sides of the relation. Unless a ``through`` model was provided, ManyToManyField will use the create_many_to_many_intermediary_model factory to automatically generate the intermediary model. """ # Field flags many_to_many = True many_to_one = False one_to_many = False one_to_one = False rel_class = ManyToManyRel description = _("Many-to-many relationship") def __init__(self, to, related_name=None, related_query_name=None, limit_choices_to=None, symmetrical=None, through=None, through_fields=None, db_constraint=True, db_table=None, swappable=True, **kwargs): try: to._meta except AttributeError: assert isinstance(to, six.string_types), ( "%s(%r) is invalid. First parameter to ManyToManyField must be " "either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT) ) # Class names must be ASCII in Python 2.x, so we forcibly coerce it # here to break early if there's a problem. to = str(to) if symmetrical is None: symmetrical = (to == RECURSIVE_RELATIONSHIP_CONSTANT) if through is not None: assert db_table is None, ( "Cannot specify a db_table if an intermediary model is used." ) kwargs['rel'] = self.rel_class( self, to, related_name=related_name, related_query_name=related_query_name, limit_choices_to=limit_choices_to, symmetrical=symmetrical, through=through, through_fields=through_fields, db_constraint=db_constraint, ) self.has_null_arg = 'null' in kwargs super(ManyToManyField, self).__init__(**kwargs) self.db_table = db_table self.swappable = swappable def check(self, **kwargs): errors = super(ManyToManyField, self).check(**kwargs) errors.extend(self._check_unique(**kwargs)) errors.extend(self._check_relationship_model(**kwargs)) errors.extend(self._check_ignored_options(**kwargs)) return errors def _check_unique(self, **kwargs): if self.unique: return [ checks.Error( 'ManyToManyFields cannot be unique.', hint=None, obj=self, id='fields.E330', ) ] return [] def _check_ignored_options(self, **kwargs): warnings = [] if self.has_null_arg: warnings.append( checks.Warning( 'null has no effect on ManyToManyField.', hint=None, obj=self, id='fields.W340', ) ) if len(self._validators) > 0: warnings.append( checks.Warning( 'ManyToManyField does not support validators.', hint=None, obj=self, id='fields.W341', ) ) return warnings def _check_relationship_model(self, from_model=None, **kwargs): if hasattr(self.remote_field.through, '_meta'): qualified_model_name = "%s.%s" % ( self.remote_field.through._meta.app_label, self.remote_field.through.__name__) else: qualified_model_name = self.remote_field.through errors = [] if self.remote_field.through not in self.opts.apps.get_models(include_auto_created=True): # The relationship model is not installed. errors.append( checks.Error( ("Field specifies a many-to-many relation through model " "'%s', which has not been installed.") % qualified_model_name, hint=None, obj=self, id='fields.E331', ) ) else: assert from_model is not None, ( "ManyToManyField with intermediate " "tables cannot be checked if you don't pass the model " "where the field is attached to." ) # Set some useful local variables to_model = resolve_relation(from_model, self.remote_field.model) from_model_name = from_model._meta.object_name if isinstance(to_model, six.string_types): to_model_name = to_model else: to_model_name = to_model._meta.object_name relationship_model_name = self.remote_field.through._meta.object_name self_referential = from_model == to_model # Check symmetrical attribute. if (self_referential and self.remote_field.symmetrical and not self.remote_field.through._meta.auto_created): errors.append( checks.Error( 'Many-to-many fields with intermediate tables must not be symmetrical.', hint=None, obj=self, id='fields.E332', ) ) # Count foreign keys in intermediate model if self_referential: seen_self = sum(from_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields) if seen_self > 2 and not self.remote_field.through_fields: errors.append( checks.Error( ("The model is used as an intermediate model by " "'%s', but it has more than two foreign keys " "to '%s', which is ambiguous. You must specify " "which two foreign keys Django should use via the " "through_fields keyword argument.") % (self, from_model_name), hint=("Use through_fields to specify which two " "foreign keys Django should use."), obj=self.remote_field.through, id='fields.E333', ) ) else: # Count foreign keys in relationship model seen_from = sum(from_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields) seen_to = sum(to_model == getattr(field.remote_field, 'model', None) for field in self.remote_field.through._meta.fields) if seen_from > 1 and not self.remote_field.through_fields: errors.append( checks.Error( ("The model is used as an intermediate model by " "'%s', but it has more than one foreign key " "from '%s', which is ambiguous. You must specify " "which foreign key Django should use via the " "through_fields keyword argument.") % (self, from_model_name), hint=('If you want to create a recursive relationship, ' 'use ForeignKey("self", symmetrical=False, ' 'through="%s").') % relationship_model_name, obj=self, id='fields.E334', ) ) if seen_to > 1 and not self.remote_field.through_fields: errors.append( checks.Error( ("The model is used as an intermediate model by " "'%s', but it has more than one foreign key " "to '%s', which is ambiguous. You must specify " "which foreign key Django should use via the " "through_fields keyword argument.") % (self, to_model_name), hint=('If you want to create a recursive ' 'relationship, use ForeignKey("self", ' 'symmetrical=False, through="%s").') % relationship_model_name, obj=self, id='fields.E335', ) ) if seen_from == 0 or seen_to == 0: errors.append( checks.Error( ("The model is used as an intermediate model by " "'%s', but it does not have a foreign key to '%s' or '%s'.") % ( self, from_model_name, to_model_name ), hint=None, obj=self.remote_field.through, id='fields.E336', ) ) # Validate `through_fields`. if self.remote_field.through_fields is not None: # Validate that we're given an iterable of at least two items # and that none of them is "falsy". if not (len(self.remote_field.through_fields) >= 2 and self.remote_field.through_fields[0] and self.remote_field.through_fields[1]): errors.append( checks.Error( ("Field specifies 'through_fields' but does not " "provide the names of the two link fields that should be " "used for the relation through model " "'%s'.") % qualified_model_name, hint=("Make sure you specify 'through_fields' as " "through_fields=('field1', 'field2')"), obj=self, id='fields.E337', ) ) # Validate the given through fields -- they should be actual # fields on the through model, and also be foreign keys to the # expected models. else: assert from_model is not None, ( "ManyToManyField with intermediate " "tables cannot be checked if you don't pass the model " "where the field is attached to." ) source, through, target = from_model, self.remote_field.through, self.remote_field.model source_field_name, target_field_name = self.remote_field.through_fields[:2] for field_name, related_model in ((source_field_name, source), (target_field_name, target)): possible_field_names = [] for f in through._meta.fields: if hasattr(f, 'remote_field') and getattr(f.remote_field, 'model', None) == related_model: possible_field_names.append(f.name) if possible_field_names: hint = ("Did you mean one of the following foreign " "keys to '%s': %s?") % (related_model._meta.object_name, ', '.join(possible_field_names)) else: hint = None try: field = through._meta.get_field(field_name) except exceptions.FieldDoesNotExist: errors.append( checks.Error( ("The intermediary model '%s' has no field '%s'.") % ( qualified_model_name, field_name), hint=hint, obj=self, id='fields.E338', ) ) else: if not (hasattr(field, 'remote_field') and getattr(field.remote_field, 'model', None) == related_model): errors.append( checks.Error( "'%s.%s' is not a foreign key to '%s'." % ( through._meta.object_name, field_name, related_model._meta.object_name), hint=hint, obj=self, id='fields.E339', ) ) return errors def deconstruct(self): name, path, args, kwargs = super(ManyToManyField, self).deconstruct() # Handle the simpler arguments. if self.db_table is not None: kwargs['db_table'] = self.db_table if self.remote_field.db_constraint is not True: kwargs['db_constraint'] = self.remote_field.db_constraint if self.remote_field.related_name is not None: kwargs['related_name'] = self.remote_field.related_name if self.remote_field.related_query_name is not None: kwargs['related_query_name'] = self.remote_field.related_query_name # Rel needs more work. if isinstance(self.remote_field.model, six.string_types): kwargs['to'] = self.remote_field.model else: kwargs['to'] = "%s.%s" % ( self.remote_field.model._meta.app_label, self.remote_field.model._meta.object_name, ) if getattr(self.remote_field, 'through', None) is not None: if isinstance(self.remote_field.through, six.string_types): kwargs['through'] = self.remote_field.through elif not self.remote_field.through._meta.auto_created: kwargs['through'] = "%s.%s" % ( self.remote_field.through._meta.app_label, self.remote_field.through._meta.object_name, ) # If swappable is True, then see if we're actually pointing to the target # of a swap. swappable_setting = self.swappable_setting if swappable_setting is not None: # If it's already a settings reference, error. if hasattr(kwargs['to'], "setting_name"): if kwargs['to'].setting_name != swappable_setting: raise ValueError( "Cannot deconstruct a ManyToManyField pointing to a " "model that is swapped in place of more than one model " "(%s and %s)" % (kwargs['to'].setting_name, swappable_setting) ) from django.db.migrations.writer import SettingsReference kwargs['to'] = SettingsReference( kwargs['to'], swappable_setting, ) return name, path, args, kwargs def _get_path_info(self, direct=False): """ Called by both direct and indirect m2m traversal. """ pathinfos = [] int_model = self.remote_field.through linkfield1 = int_model._meta.get_field(self.m2m_field_name()) linkfield2 = int_model._meta.get_field(self.m2m_reverse_field_name()) if direct: join1infos = linkfield1.get_reverse_path_info() join2infos = linkfield2.get_path_info() else: join1infos = linkfield2.get_reverse_path_info() join2infos = linkfield1.get_path_info() pathinfos.extend(join1infos) pathinfos.extend(join2infos) return pathinfos def get_path_info(self): return self._get_path_info(direct=True) def get_reverse_path_info(self): return self._get_path_info(direct=False) def get_choices_default(self): return Field.get_choices(self, include_blank=False) def _get_m2m_db_table(self, opts): """ Function that can be curried to provide the m2m table name for this relation. """ if self.remote_field.through is not None: return self.remote_field.through._meta.db_table elif self.db_table: return self.db_table else: return utils.truncate_name('%s_%s' % (opts.db_table, self.name), connection.ops.max_name_length()) def _get_m2m_attr(self, related, attr): """ Function that can be curried to provide the source accessor or DB column name for the m2m table. """ cache_attr = '_m2m_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) if self.remote_field.through_fields is not None: link_field_name = self.remote_field.through_fields[0] else: link_field_name = None for f in self.remote_field.through._meta.fields: if (f.is_relation and f.remote_field.model == related.related_model and (link_field_name is None or link_field_name == f.name)): setattr(self, cache_attr, getattr(f, attr)) return getattr(self, cache_attr) def _get_m2m_reverse_attr(self, related, attr): """ Function that can be curried to provide the related accessor or DB column name for the m2m table. """ cache_attr = '_m2m_reverse_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) found = False if self.remote_field.through_fields is not None: link_field_name = self.remote_field.through_fields[1] else: link_field_name = None for f in self.remote_field.through._meta.fields: if f.is_relation and f.remote_field.model == related.model: if link_field_name is None and related.related_model == related.model: # If this is an m2m-intermediate to self, # the first foreign key you find will be # the source column. Keep searching for # the second foreign key. if found: setattr(self, cache_attr, getattr(f, attr)) break else: found = True elif link_field_name is None or link_field_name == f.name: setattr(self, cache_attr, getattr(f, attr)) break return getattr(self, cache_attr) def value_to_string(self, obj): data = '' if obj: qs = getattr(obj, self.name).all() data = [instance._get_pk_val() for instance in qs] else: # In required many-to-many fields with only one available choice, # select that one available choice. if not self.blank: choices_list = self.get_choices_default() if len(choices_list) == 1: data = [choices_list[0][0]] return smart_text(data) def contribute_to_class(self, cls, name, **kwargs): # To support multiple relations to self, it's useful to have a non-None # related name on symmetrical relations for internal reasons. The # concept doesn't make a lot of sense externally ("you want me to # specify *what* on my non-reversible relation?!"), so we set it up # automatically. The funky name reduces the chance of an accidental # clash. if self.remote_field.symmetrical and ( self.remote_field.model == "self" or self.remote_field.model == cls._meta.object_name): self.remote_field.related_name = "%s_rel_+" % name elif self.remote_field.is_hidden(): # If the backwards relation is disabled, replace the original # related_name with one generated from the m2m field name. Django # still uses backwards relations internally and we need to avoid # clashes between multiple m2m fields with related_name == '+'. self.remote_field.related_name = "_%s_%s_+" % (cls.__name__.lower(), name) super(ManyToManyField, self).contribute_to_class(cls, name, **kwargs) # The intermediate m2m model is not auto created if: # 1) There is a manually specified intermediate, or # 2) The class owning the m2m field is abstract. # 3) The class owning the m2m field has been swapped out. if not cls._meta.abstract: if self.remote_field.through: def resolve_through_model(_, model, field): field.remote_field.through = model lazy_related_operation(resolve_through_model, cls, self.remote_field.through, field=self) elif not cls._meta.swapped: self.remote_field.through = create_many_to_many_intermediary_model(self, cls) # Add the descriptor for the m2m relation. setattr(cls, self.name, ManyToManyDescriptor(self.remote_field, reverse=False)) # Set up the accessor for the m2m table name for the relation. self.m2m_db_table = curry(self._get_m2m_db_table, cls._meta) def contribute_to_related_class(self, cls, related): # Internal M2Ms (i.e., those with a related name ending with '+') # and swapped models don't get a related descriptor. if not self.remote_field.is_hidden() and not related.related_model._meta.swapped: setattr(cls, related.get_accessor_name(), ManyToManyDescriptor(self.remote_field, reverse=True)) # Set up the accessors for the column names on the m2m table. self.m2m_column_name = curry(self._get_m2m_attr, related, 'column') self.m2m_reverse_name = curry(self._get_m2m_reverse_attr, related, 'column') self.m2m_field_name = curry(self._get_m2m_attr, related, 'name') self.m2m_reverse_field_name = curry(self._get_m2m_reverse_attr, related, 'name') get_m2m_rel = curry(self._get_m2m_attr, related, 'remote_field') self.m2m_target_field_name = lambda: get_m2m_rel().field_name get_m2m_reverse_rel = curry(self._get_m2m_reverse_attr, related, 'remote_field') self.m2m_reverse_target_field_name = lambda: get_m2m_reverse_rel().field_name def set_attributes_from_rel(self): pass def value_from_object(self, obj): """ Return the value of this field in the given model instance. """ return getattr(obj, self.attname).all() def save_form_data(self, instance, data): getattr(instance, self.attname).set(data) def formfield(self, **kwargs): db = kwargs.pop('using', None) defaults = { 'form_class': forms.ModelMultipleChoiceField, 'queryset': self.remote_field.model._default_manager.using(db), } defaults.update(kwargs) # If initial is passed in, it's a list of related objects, but the # MultipleChoiceField takes a list of IDs. if defaults.get('initial') is not None: initial = defaults['initial'] if callable(initial): initial = initial() defaults['initial'] = [i._get_pk_val() for i in initial] return super(ManyToManyField, self).formfield(**defaults) def db_type(self, connection): # A ManyToManyField is not represented by a single column, # so return None. return None def db_parameters(self, connection): return {"type": None, "check": None}
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 7765, 492, 3778, 199, 504, 1639, 14, 697, 14, 992, 14, 14281, 492, 27751, 9947, 12, 11543, 63, 3472, 12, 11543, 63, 8084, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 6912, 2354, 199, 504, 1639, 14, 697, 14, 992, 14, 1208, 492, 1852, 63, 1238, 63, 2960, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1165, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 1023, 492, 664, 63, 4757, 63, 1023, 199, 199, 504, 1275, 492, 5024, 199, 504, 1275, 2407, 63, 17752, 492, 334, 272, 22536, 4089, 10939, 4311, 12, 15517, 6749, 4311, 12, 272, 22734, 4089, 10939, 4311, 12, 22734, 4395, 10939, 4311, 12, 199, 9, 199, 504, 1275, 2407, 63, 17438, 492, 334, 272, 20116, 29751, 12, 20116, 11891, 19760, 12, 20116, 11891, 19760, 2844, 591, 12, 20116, 607, 12, 272, 20116, 1831, 8849, 12, 20116, 32693, 12, 20116, 32693, 2844, 591, 12, 199, 9, 199, 504, 1275, 4471, 63, 2407, 492, 334, 272, 481, 2692, 1692, 5640, 12, 15517, 6749, 5640, 12, 15517, 10939, 5640, 12, 7309, 10939, 5640, 12, 199, 9, 199, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 421, 199, 318, 7512, 63, 5690, 8, 2645, 63, 1238, 12, 5850, 304, 272, 408, 272, 19463, 5850, 1901, 282, 1402, 503, 9999, 13, 11661, 1402, 1059, 402, 314, 1824, 272, 298, 571, 63, 1302, 14, 1685, 985, 401, 3847, 370, 4194, 63, 1238, 14, 339, 710, 5850, 1423, 883, 506, 26, 489, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 12, 284, 14, 69, 14, 314, 1059, 298, 277, 401, 315, 1314, 1930, 267, 314, 1402, 1423, 911, 506, 2138, 14, 489, 627, 437, 18753, 1402, 536, 1928, 376, 1145, 63, 1302, 12, 315, 1314, 1930, 4194, 63, 1238, 1159, 267, 1145, 63, 1302, 911, 506, 20247, 14, 489, 627, 1626, 298, 571, 63, 1302, 14, 1685, 985, 2, 1059, 14, 489, 627, 437, 1402, 1021, 12, 1314, 911, 506, 2138, 14874, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 5850, 275, 4194, 63, 1238, 339, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 272, 340, 1228, 8, 5690, 12, 3816, 14, 875, 63, 1313, 304, 267, 340, 14530, 440, 315, 5850, 26, 288, 5850, 275, 2071, 83, 4111, 83, 2, 450, 334, 2645, 63, 1238, 423, 2024, 14, 571, 63, 1302, 12, 5850, 9, 339, 372, 5850, 421, 199, 318, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 1402, 12, 627, 2407, 63, 992, 12, 1011, 958, 304, 272, 408, 272, 24317, 658, 1593, 64, 370, 506, 2797, 5403, 658, 1238, 64, 436, 1006, 658, 2407, 63, 992, 64, 272, 1172, 2757, 8439, 436, 7264, 543, 314, 1145, 7086, 14, 658, 1593, 64, 911, 272, 506, 2797, 543, 314, 13903, 13, 4591, 1402, 3992, 465, 2399, 11333, 2368, 12, 272, 12254, 1263, 2716, 4252, 2368, 14, 339, 710, 658, 1238, 64, 1423, 1471, 506, 282, 1402, 1021, 14, 7048, 13372, 11333, 272, 1423, 365, 4573, 1402, 12, 503, 282, 3659, 370, 4573, 1402, 446, 1937, 272, 658, 6983, 63, 5690, 11995, 367, 314, 7750, 4513, 3520, 1443, 5452, 14, 6184, 3847, 272, 6941, 911, 506, 12152, 3847, 370, 658, 1238, 2313, 339, 961, 365, 282, 16777, 4975, 367, 658, 2640, 83, 14, 6395, 63, 1238, 63, 5735, 64, 446, 314, 1145, 272, 7086, 1402, 1202, 365, 314, 1373, 1911, 315, 658, 1238, 423, 2024, 14, 5181, 2313, 272, 408, 272, 1709, 275, 359, 1238, 61, 435, 359, 6983, 63, 5690, 8, 1238, 12, 4668, 9, 367, 4668, 315, 4048, 63, 992, 61, 272, 1402, 63, 1612, 275, 334, 1875, 63, 1238, 63, 2960, 8, 77, 9, 367, 333, 315, 1709, 9, 272, 8686, 275, 1402, 423, 2024, 14, 5181, 272, 372, 8686, 14, 6395, 63, 1238, 63, 5735, 8, 6672, 8, 1593, 12, 1011, 958, 395, 627, 1238, 63, 1612, 9, 421, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 3598, 14, 4050, 8, 267, 298, 525, 63, 6395, 63, 5690, 342, 965, 2757, 1613, 261, 770, 701, 9617, 63, 2407, 63, 5735, 342, 298, 267, 298, 460, 4048, 3102, 641, 314, 4693, 83, 1021, 4765, 267, 23687, 1165, 3849, 12, 13232, 29, 18, 9, 272, 327, 799, 285, 1842, 1249, 367, 892, 4693, 83, 14, 6395, 63, 1238, 63, 5735, 272, 805, 275, 2400, 2257, 12, 4048, 12, 901, 26, 3439, 8, 698, 12, 4048, 12, 2257, 9, 272, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 843, 12, 5850, 12, 901, 29, 698, 9, 421, 199, 533, 20116, 792, 8, 792, 304, 272, 408, 272, 3523, 1021, 626, 1006, 5850, 279, 1504, 8287, 687, 14, 272, 408, 339, 327, 5024, 3285, 272, 1373, 63, 475, 63, 3479, 275, 756, 272, 1373, 63, 475, 63, 368, 275, 756, 272, 5002, 63, 475, 63, 3479, 275, 756, 272, 5002, 63, 475, 63, 368, 275, 756, 339, 768, 5245, 63, 1829, 272, 347, 4048, 63, 1238, 8, 277, 304, 267, 327, 6855, 1133, 2581, 642, 3324, 5133, 1006, 314, 1709, 787, 6511, 14, 267, 8686, 14, 1074, 63, 992, 63, 2179, 342, 267, 372, 291, 14, 3846, 63, 698, 14, 1238, 339, 347, 1104, 8, 277, 12, 1011, 958, 304, 267, 2552, 275, 1613, 8, 13885, 792, 12, 291, 680, 1074, 3682, 958, 9, 267, 2552, 14, 2880, 8, 277, 423, 1074, 63, 2407, 63, 354, 63, 374, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 3598, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 199, 504, 1639, 14, 697, 14, 7765, 492, 3778, 199, 504, 1639, 14, 697, 14, 992, 14, 14281, 492, 27751, 9947, 12, 11543, 63, 3472, 12, 11543, 63, 8084, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 6912, 2354, 199, 504, 1639, 14, 697, 14, 992, 14, 1208, 492, 1852, 63, 1238, 63, 2960, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1165, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1208, 14, 1023, 492, 664, 63, 4757, 63, 1023, 199, 199, 504, 1275, 492, 5024, 199, 504, 1275, 2407, 63, 17752, 492, 334, 272, 22536, 4089, 10939, 4311, 12, 15517, 6749, 4311, 12, 272, 22734, 4089, 10939, 4311, 12, 22734, 4395, 10939, 4311, 12, 199, 9, 199, 504, 1275, 2407, 63, 17438, 492, 334, 272, 20116, 29751, 12, 20116, 11891, 19760, 12, 20116, 11891, 19760, 2844, 591, 12, 20116, 607, 12, 272, 20116, 1831, 8849, 12, 20116, 32693, 12, 20116, 32693, 2844, 591, 12, 199, 9, 199, 504, 1275, 4471, 63, 2407, 492, 334, 272, 481, 2692, 1692, 5640, 12, 15517, 6749, 5640, 12, 15517, 10939, 5640, 12, 7309, 10939, 5640, 12, 199, 9, 199, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 421, 199, 318, 7512, 63, 5690, 8, 2645, 63, 1238, 12, 5850, 304, 272, 408, 272, 19463, 5850, 1901, 282, 1402, 503, 9999, 13, 11661, 1402, 1059, 402, 314, 1824, 272, 298, 571, 63, 1302, 14, 1685, 985, 401, 3847, 370, 4194, 63, 1238, 14, 339, 710, 5850, 1423, 883, 506, 26, 489, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 12, 284, 14, 69, 14, 314, 1059, 298, 277, 401, 315, 1314, 1930, 267, 314, 1402, 1423, 911, 506, 2138, 14, 489, 627, 437, 18753, 1402, 536, 1928, 376, 1145, 63, 1302, 12, 315, 1314, 1930, 4194, 63, 1238, 1159, 267, 1145, 63, 1302, 911, 506, 20247, 14, 489, 627, 1626, 298, 571, 63, 1302, 14, 1685, 985, 2, 1059, 14, 489, 627, 437, 1402, 1021, 12, 1314, 911, 506, 2138, 14874, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 5850, 275, 4194, 63, 1238, 339, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 272, 340, 1228, 8, 5690, 12, 3816, 14, 875, 63, 1313, 304, 267, 340, 14530, 440, 315, 5850, 26, 288, 5850, 275, 2071, 83, 4111, 83, 2, 450, 334, 2645, 63, 1238, 423, 2024, 14, 571, 63, 1302, 12, 5850, 9, 339, 372, 5850, 421, 199, 318, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 1402, 12, 627, 2407, 63, 992, 12, 1011, 958, 304, 272, 408, 272, 24317, 658, 1593, 64, 370, 506, 2797, 5403, 658, 1238, 64, 436, 1006, 658, 2407, 63, 992, 64, 272, 1172, 2757, 8439, 436, 7264, 543, 314, 1145, 7086, 14, 658, 1593, 64, 911, 272, 506, 2797, 543, 314, 13903, 13, 4591, 1402, 3992, 465, 2399, 11333, 2368, 12, 272, 12254, 1263, 2716, 4252, 2368, 14, 339, 710, 658, 1238, 64, 1423, 1471, 506, 282, 1402, 1021, 14, 7048, 13372, 11333, 272, 1423, 365, 4573, 1402, 12, 503, 282, 3659, 370, 4573, 1402, 446, 1937, 272, 658, 6983, 63, 5690, 11995, 367, 314, 7750, 4513, 3520, 1443, 5452, 14, 6184, 3847, 272, 6941, 911, 506, 12152, 3847, 370, 658, 1238, 2313, 339, 961, 365, 282, 16777, 4975, 367, 658, 2640, 83, 14, 6395, 63, 1238, 63, 5735, 64, 446, 314, 1145, 272, 7086, 1402, 1202, 365, 314, 1373, 1911, 315, 658, 1238, 423, 2024, 14, 5181, 2313, 272, 408, 272, 1709, 275, 359, 1238, 61, 435, 359, 6983, 63, 5690, 8, 1238, 12, 4668, 9, 367, 4668, 315, 4048, 63, 992, 61, 272, 1402, 63, 1612, 275, 334, 1875, 63, 1238, 63, 2960, 8, 77, 9, 367, 333, 315, 1709, 9, 272, 8686, 275, 1402, 423, 2024, 14, 5181, 272, 372, 8686, 14, 6395, 63, 1238, 63, 5735, 8, 6672, 8, 1593, 12, 1011, 958, 395, 627, 1238, 63, 1612, 9, 421, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 3598, 14, 4050, 8, 267, 298, 525, 63, 6395, 63, 5690, 342, 965, 2757, 1613, 261, 770, 701, 9617, 63, 2407, 63, 5735, 342, 298, 267, 298, 460, 4048, 3102, 641, 314, 4693, 83, 1021, 4765, 267, 23687, 1165, 3849, 12, 13232, 29, 18, 9, 272, 327, 799, 285, 1842, 1249, 367, 892, 4693, 83, 14, 6395, 63, 1238, 63, 5735, 272, 805, 275, 2400, 2257, 12, 4048, 12, 901, 26, 3439, 8, 698, 12, 4048, 12, 2257, 9, 272, 9617, 63, 2407, 63, 5735, 8, 1593, 12, 843, 12, 5850, 12, 901, 29, 698, 9, 421, 199, 533, 20116, 792, 8, 792, 304, 272, 408, 272, 3523, 1021, 626, 1006, 5850, 279, 1504, 8287, 687, 14, 272, 408, 339, 327, 5024, 3285, 272, 1373, 63, 475, 63, 3479, 275, 756, 272, 1373, 63, 475, 63, 368, 275, 756, 272, 5002, 63, 475, 63, 3479, 275, 756, 272, 5002, 63, 475, 63, 368, 275, 756, 339, 768, 5245, 63, 1829, 272, 347, 4048, 63, 1238, 8, 277, 304, 267, 327, 6855, 1133, 2581, 642, 3324, 5133, 1006, 314, 1709, 787, 6511, 14, 267, 8686, 14, 1074, 63, 992, 63, 2179, 342, 267, 372, 291, 14, 3846, 63, 698, 14, 1238, 339, 347, 1104, 8, 277, 12, 1011, 958, 304, 267, 2552, 275, 1613, 8, 13885, 792, 12, 291, 680, 1074, 3682, 958, 9, 267, 2552, 14, 2880, 8, 277, 423, 1074, 63, 2407, 63, 354, 63, 374, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
yeming233/rally
tests/unit/plugins/common/context/test_dummy.py
21
1361
# All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from rally import exceptions from rally.plugins.common.context import dummy from tests.unit import test class DummyContextTestCase(test.TestCase): def test_setup(self): dummy.DummyContext({"task": "some_task"}).setup() config = {"dummy_context": {"fail_setup": True}} self.assertRaises( exceptions.RallyException, dummy.DummyContext({"task": "some_task", "config": config}).setup) def test_cleanup(self): dummy.DummyContext({"task": "some_task"}).cleanup() config = {"dummy_context": {"fail_cleanup": True}} self.assertRaises( exceptions.RallyException, dummy.DummyContext({"task": "some_task", "config": config}).cleanup)
apache-2.0
[ 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, 421, 199, 504, 519, 1183, 492, 4967, 199, 504, 519, 1183, 14, 5265, 14, 2330, 14, 1100, 492, 7283, 199, 504, 2295, 14, 3248, 492, 511, 421, 199, 533, 9762, 2998, 1746, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 2758, 8, 277, 304, 267, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 3570, 680, 2758, 342, 267, 1101, 275, 2420, 5869, 63, 1100, 582, 2420, 1633, 63, 2758, 582, 715, 4863, 267, 291, 14, 1855, 8, 288, 4967, 14, 50, 1183, 1726, 12, 288, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 401, 298, 888, 582, 1101, 21385, 2758, 9, 339, 347, 511, 63, 7661, 8, 277, 304, 267, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 3570, 680, 7661, 342, 267, 1101, 275, 2420, 5869, 63, 1100, 582, 2420, 1633, 63, 7661, 582, 715, 4863, 267, 291, 14, 1855, 8, 288, 4967, 14, 50, 1183, 1726, 12, 288, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 401, 1816, 298, 888, 582, 1101, 21385, 7661, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 421, 199, 504, 519, 1183, 492, 4967, 199, 504, 519, 1183, 14, 5265, 14, 2330, 14, 1100, 492, 7283, 199, 504, 2295, 14, 3248, 492, 511, 421, 199, 533, 9762, 2998, 1746, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 2758, 8, 277, 304, 267, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 3570, 680, 2758, 342, 267, 1101, 275, 2420, 5869, 63, 1100, 582, 2420, 1633, 63, 2758, 582, 715, 4863, 267, 291, 14, 1855, 8, 288, 4967, 14, 50, 1183, 1726, 12, 288, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 401, 298, 888, 582, 1101, 21385, 2758, 9, 339, 347, 511, 63, 7661, 8, 277, 304, 267, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 3570, 680, 7661, 342, 267, 1101, 275, 2420, 5869, 63, 1100, 582, 2420, 1633, 63, 7661, 582, 715, 4863, 267, 291, 14, 1855, 8, 288, 4967, 14, 50, 1183, 1726, 12, 288, 7283, 14, 11324, 2998, 6333, 1765, 582, 298, 3972, 63, 1765, 401, 1816, 298, 888, 582, 1101, 21385, 7661, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Southpaw-TACTIC/Team
src/python/Lib/site-packages/PySide/examples/hyperui/hyperuilib/phoneview.py
1
21585
""" /* * This file is part of PySide: Python for Qt * * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). * * Contact: PySide team <contact@pyside.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * 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 * */ """ from PySide.QtCore import * from PySide.QtGui import * from hyperuilib.shared.dataresource import * from hyperuilib.shared.label import * from hyperuilib.qt_global import * from hyperuilib.shared.button import * from hyperuilib.contactlist import * from hyperuilib.contactresource import * from hyperuilib.view import * def resourceButtonFont(): font = QFont(Resource.stringValue("default/font-family")) font.setBold(True) font.setPixelSize(Resource.intValue("button/font-size")) return font class Overlay(QObject, QGraphicsRectItem): def __init__(self, parent=None): QObject.__init__(self, parent) QGraphicsRectItem.__init__(self) self.setProperty("opacity", 0.0); self.setProperty("visible", True); def mousePressEvent(self, e): pass class DialerWidget(QGraphicsWidget): def __init__(self, parent=None): QGraphicsWidget.__init__(self, parent) background = QGraphicsPixmapItem(Resource.pixmap("dialer/background.png"), self) background.setPos(0, 0) background.setShapeMode(QGraphicsPixmapItem.BoundingRectShape) margin = Resource.intValue("dialer-widget/margin") spacing = Resource.intValue("dialer-widget/spacing") self._layout = QGraphicsGridLayout() self._layout.setSpacing(spacing) self._layout.setContentsMargins(margin, margin, margin, margin) self.addButton("1", 0, 0, "dialer/top_left_key") self.addButton("2", 0, 1, "dialer/middle_key") self.addButton("3", 0, 2, "dialer/top_right_key") self.addButton("4", 1, 0, "dialer/middle_key") self.addButton("5", 1, 1, "dialer/middle_key") self.addButton("6", 1, 2, "dialer/middle_key") self.addButton("7", 2, 0, "dialer/middle_key") self.addButton("8", 2, 1, "dialer/middle_key") self.addButton("9", 2, 2, "dialer/middle_key") self.addButton("*", 3, 0, "dialer/bottom_left_key") self.addButton("0", 3, 1, "dialer/middle_key") self.addButton("#", 3, 2, "dialer/bottom_right_key") self.setLayout(self._layout) def addButton(self, label, row, col, imagePrefix): normalPath = "%s.png" % imagePrefix pressedPath = "%s_pressed.png" % imagePrefix button = Button(Resource.pixmap(normalPath), Resource.pixmap(pressedPath), None, None) button.setText(label) button.setFont(resourceButtonFont()) self.connect(button, SIGNAL("clicked()"), SLOT("onButtonClicked()")) self._layout.addItem(button, row, col) def onButtonClicked(self): button = self.sender() if button: self.emit(SIGNAL("buttonClicked(QString)"), button.text()) class CallBoard(QGraphicsWidget): def __init__(self, parent=None): QGraphicsWidget.__init__(self, parent) self._top = Resource.pixmap("dialer_bk_top.png") self._bottom = Resource.pixmap("dialer_bk_bottom.png") self._middleline = Resource.pixmap("dialer_bk_lineexpand.png") # read settings self._font = QFont(Resource.stringValue("default/font-family")) self._margin = Resource.intValue("call-board/margin") self._phoneColor = Resource.stringValue("call-board/phone-font-color") self._subPanelRect = Resource.value("call-board/sub-panel-rect") self._dialPos = Resource.value("call-board/dial-button-pos") self._mutePos = Resource.value("call-board/mute-button-pos") self._speakerPos = Resource.value("call-board/speaker-button-pos") self._dialIconPos = Resource.value("call-board/dial-icon-pos") self._callLabelRect = Resource.value("call-board/call-label-rect") self._nameLabelRect = Resource.value("call-board/name-label-rect") self._phoneLabelRect = Resource.value("call-board/phone-label-rect") self._bigNameLabelRect = Resource.value("call-board/big-name-label-rect") # initialize interface self.setMinimumSize(self._top.size().width(), self._top.size().height() + self._bottom.size().height() + self._middleline.size().height()) # create main panel and photo self._contents = QGraphicsWidget(self) self._contents.setFlag(QGraphicsItem.ItemHasNoContents) self._contents.setGeometry(self.geometry()) self._photo = QGraphicsPixmapItem(self._contents) self._photo.setPos(self._margin, self._margin) self._photo.setShapeMode(QGraphicsPixmapItem.BoundingRectShape) self._icon = QGraphicsPixmapItem(self._contents) self._icon.setPixmap(Resource.pixmap("dialer_bullet_phone.png")) self._icon.setPos(QPointF(self._dialIconPos)) self._icon.setShapeMode(QGraphicsPixmapItem.BoundingRectShape) # create 'wait' sub-panel self._panelWait = QGraphicsWidget(self._contents) self._panelWait.setFlag(QGraphicsItem.ItemHasNoContents) self._panelWait.setGeometry(QRectF(self._subPanelRect)) self._font.setPixelSize(Resource.intValue("call-board/small-font-size")) self._callLabel = Label(self._panelWait) self._callLabel.setFont(self._font) self._callLabel.setText(self.tr("Calling...")) self._callLabel.setGeometry(QRectF(self._callLabelRect)) self._font.setPixelSize(Resource.intValue("call-board/font-size")) self._nameLabel = Label(self._panelWait) self._nameLabel.setFont(self._font) self._nameLabel.setGeometry(QRectF(self._nameLabelRect)) self._phoneLabel = Label(self._panelWait) self._phoneLabel.setFont(self._font) self._phoneLabel.setFontColor(QColor(self._phoneColor)) self._phoneLabel.setGeometry(QRectF(self._phoneLabelRect)) # create 'in-call' sub-panel self._panelInCall = QGraphicsWidget(self._contents) self._panelInCall.setFlag(QGraphicsItem.ItemHasNoContents) self._panelInCall.setGeometry(QRectF(self._subPanelRect)) self._bigNameLabel = Label(self._panelInCall) self._bigNameLabel.setFont(self._font) self._bigNameLabel.setGeometry(QRectF(self._bigNameLabelRect)) dialButton = Button(Resource.pixmap("dialer_bt_dialer.png"), None, None, self._panelInCall) dialButton.setPos(QPointF(self._dialPos)) muteButton = Button(Resource.pixmap("dialer_bt_mute.png"), None, None, self._panelInCall) muteButton.setPos(QPointF(self._mutePos)) speakerButton = Button(Resource.pixmap("dialer_bt_speaker.png"), None, None, self._panelInCall) speakerButton.setPos(QPointF(self._speakerPos)) def setName(self, name): self._nameLabel.setText(name) self._bigNameLabel.setText(name) def setPhone(self, phone): self._phoneLabel.setText(phone) def setPhoto(self, photo): self._photo.setPixmap(photo) def paint(self, painter, style, widget): tw = self._top.width() th = self._top.height() by = self.size().height() - self._bottom.height() painter.drawPixmap(0, 0, self._top) painter.drawTiledPixmap(0, int(th), int(tw), int(by - th), self._middleline) painter.drawPixmap(0, int(by), self._bottom) class DialerDisplay(QGraphicsWidget): def __init__(self, parent): QGraphicsWidget.__init__(self, parent) self._background = Resource.pixmap("dialer_display_background.png") self.setMinimumSize(QSizeF(self._background.size())) self._label = Label(self) self._label.setElideMode(Qt.ElideLeft) self._label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) font = self._label.font() font.setPixelSize(Resource.intValue("phone-view/display-font-size")) self._label.setFont(font) self._cancel = Button(Resource.pixmap("dialer_display_bt_cancel.png"), None, None) self.connect(self._cancel, SIGNAL("clicked()"), SLOT("clear()")) layout = QGraphicsLinearLayout(Qt.Horizontal) layout.addItem(self._label) layout.addItem(self._cancel) self.setLayout(layout) layout.setAlignment(self._cancel, Qt.AlignBottom) def text(self): return self._label.text() def append(self, value): old = self._label.text() if old is None: old = "" self._label.setText(old + value) def clear(self): value = self._label.text() if value: self._label.setText(value[:-1]) def paint(self, painter, style, widget): painter.drawPixmap(0, 0, self._background) class PhoneView(View): def __init__(self, parent=None): View.__init__(self, parent) self.setTitle(self.tr("CONTACTS")) # read settings callTimeout = Resource.intValue("phone-view/call-timeout") displayPos = Resource.value("phone-view/display-pos") dialerBackPos = Resource.value("phone-view/dialer-back-pos") callButtonPos = Resource.value("phone-view/call-button-pos") contactsButtonPos = Resource.value("phone-view/contacts-button-pos") # initialize interface self.setFlag(QGraphicsItem.ItemHasNoContents) self._frame = QGraphicsWidget(self) self._display = DialerDisplay(self._frame) self._display.setPos(QPointF(displayPos)) self._contactsButton = Button(Resource.pixmap("dialer_bt_contacts.png"), Resource.pixmap("dialer_bt_contacts_over.png"), None, self._frame) self._contactsButton.setPos(QPointF(contactsButtonPos)) self._contactsButton.setFont(resourceButtonFont()) self._overlay = Overlay(self._frame) self._overlay.setBrush(QBrush(Qt.black)) self._overlay.setRect(QRectF(Resource.value("phone-view/overlay-rect"))) self._callButton = Button(Resource.pixmap("dialer_bt_call.png"), Resource.pixmap("dialer_bt_call_over.png"), None, self._frame) self._callButton.setText(self.tr("CALL")) self._callButton.setPos(QPointF(callButtonPos)) self._callButton.setFont(resourceButtonFont()) self._endCallButton = Button(Resource.pixmap("dialer_bt_endcall.png"), Resource.pixmap("dialer_bt_endcall_over.png"), None, self._frame) self._endCallButton.setText(self.tr("END CALL")) self._endCallButton.setPos(QPointF(callButtonPos)) self._endCallButton.setFont(resourceButtonFont()) self._board = CallBoard(self._frame) self._board.setPos(QPointF(dialerBackPos)) self._board.setPhoto(Resource.pixmap("call_photo_nobody.png")) self._dialer = DialerWidget(self._frame) self._dialer.setPos(QPointF(dialerBackPos)) self.connect(self._dialer, SIGNAL("buttonClicked(const QString &)"), SLOT("dialButtonClicked(const QString &)")) self._contactList = ContactList(self) self._contactList.setGeometry(QRectF(Resource.value("phone-view/contactlist-rect"))) self._contactList.hide() self.connect(self._contactList, SIGNAL("contactClicked(int)"), self.contactClicked) self._callTimer = QTimer() self._callTimer.setInterval(callTimeout) self._callTimer.setSingleShot(True) self.setOpacity(0.0) self.createStateMachine() self.connect(self._callButton, SIGNAL("clicked()"), SLOT("callClicked()")) def callClicked(self): # update phone number self._board.setName(self._display.text()) self._board.setPhone("") self._board.setPhoto(Resource.pixmap("call_photo_nobody.png")) # simulate call wait self._callTimer.start() def contactClicked(self, index): self._board.setName(ContactResource.name(index)) self._board.setPhone(ContactResource.phone(index)) photo = ContactResource.photo(index, ContactResource.LargePhoto) if photo: self._board.setPhoto(Resource.pixmap(photo)) else: self._board.setPhoto(Resource.pixmap("call_photo_nobody.png")) self.emit(SIGNAL("callContact()")) # simulate call wait self._callTimer.start() def dialButtonClicked(self, value): self._display.append(value) def createStateMachine(self): self._machine = QStateMachine(self) state0 = QState() state0.assignProperty(self, "opacity", 0.0) # create default state state1 = QState() state1.assignProperty(self, "opacity", 1.0) state1.assignProperty(self._frame, "opacity", 1.0) state1.assignProperty(self._frame, "visible", True) state1.assignProperty(self._dialer, "opacity", 1.0) state1.assignProperty(self._display, "visible", True) state1.assignProperty(self._board, "visible", False) state1.assignProperty(self._callButton, "visible", True) state1.assignProperty(self._endCallButton, "visible", False) state1.assignProperty(self._board._contents, "opacity", 0.0) state1.assignProperty(self._board, "geometry", self._board.geometry()) state1.assignProperty(self._overlay, "opacity", 0.0) state1.assignProperty(self._overlay, "visible", False) state1.assignProperty(self._contactList, "y", self._contactList.size().height() * 1.5) state1.assignProperty(self._contactList, "visible", False) # create calling state state2 = QState() state2.assignProperty(self._frame, "opacity", 1.0) state2.assignProperty(self._frame, "visible", True) state2.assignProperty(self._dialer, "opacity", 0.0) state2.assignProperty(self._display, "visible", False) state2.assignProperty(self._board, "visible", True) state2.assignProperty(self._callButton, "visible", False) state2.assignProperty(self._endCallButton, "visible", True) state2.assignProperty(self._board._contents, "opacity", 1.0) offsetY = -(self._board.pos().y() - self._display.pos().y()) state2.assignProperty(self._board, "geometry", self._board.geometry().adjusted(0, offsetY, 0, 0)) state2.assignProperty(self._board._panelWait, "opacity", 1.0) state2.assignProperty(self._board._panelInCall, "opacity", 0.0) state2.assignProperty(self._board._panelWait, "visible", True) state2.assignProperty(self._board._panelInCall, "visible", False) state2.assignProperty(self._overlay, "opacity", 0.5) state2.assignProperty(self._overlay, "visible", True) state2.assignProperty(self._contactList, "y", self._contactList.size().height() * 1.5) state2.assignProperty(self._contactList, "visible", False) #create in-call state state3 = QState() state3.assignProperty(self._board._panelWait, "opacity", 0.0) state3.assignProperty(self._board._panelInCall, "opacity", 1.0) state3.assignProperty(self._board._panelWait, "visible", False) state3.assignProperty(self._board._panelInCall, "visible", True) state3.assignProperty(self._overlay, "opacity", 0.5) state3.assignProperty(self._overlay, "visible", True) # create contact list state state4 = QState() state4.assignProperty(self._frame, "opacity", 0.0) state4.assignProperty(self._frame, "visible", False) state4.assignProperty(self._contactList, "y", 0) state4.assignProperty(self._contactList, "visible", True) # associates state1-state2 transition transition1 = state1.addTransition(self._callButton, SIGNAL("clicked()"), state2) transition1.addAnimation(self.createCallAnimation()) #associates state2-state1 transition transition2 = state2.addTransition(self._endCallButton, SIGNAL("clicked()"), state1) transition2.addAnimation(self.createEndCallAnimation()) # associates state3-state1 transition transition3 = state3.addTransition(self._endCallButton, SIGNAL("clicked()"), state1) transition3.addAnimation(self.createEndCallAnimation()) # associates state2-state3 transition transition4 = state2.addTransition(self._callTimer, SIGNAL("timeout()"), state3) transition4.addAnimation(self.createInCallAnimation()) # associates state0-state1 transition transition5 = state0.addTransition(self, SIGNAL("transitionInStarted()"), state1) transition5.addAnimation(self.createInOutAnimation(False)) # associates state1-state0 transition transition6 = state1.addTransition(self, SIGNAL("transitionOutStarted()"), state0) transition6.addAnimation(self.createInOutAnimation(True)) #associates state1-state4 transition transition7 = state1.addTransition(self._contactsButton, SIGNAL("clicked()"), state4) transition7.addAnimation(self.createContactAnimation(False)) # associates state4-state2 transition transition8 = state4.addTransition(self, SIGNAL("callContact()"), state2) transition8.addAnimation(self.createContactAnimation(True)) # associates state4-state0 transition transition9 = state4.addTransition(self, SIGNAL("transitionOutStarted()"), state0) transition9.addAnimation(self.createInOutAnimation(True)) self._machine.addState(state0) self._machine.addState(state1) self._machine.addState(state2) self._machine.addState(state3) self._machine.addState(state4) self._machine.setInitialState(state0) self._machine.start() def createInOutAnimation(self, out): result = QSequentialAnimationGroup() result.addAnimation(propertyAnimation(self, "opacity", 400)) if not out: self.connect(result, SIGNAL("finished()"), SIGNAL("transitionInFinished()")) else: self.connect(result, SIGNAL("finished()"), SIGNAL("transitionOutFinished()")) return result def createContactAnimation(self, close): result = QSequentialAnimationGroup() if close: result.addAnimation(propertyAnimation(self._contactList, "y", 600, QEasingCurve.InQuart)) result.addAnimation(propertyAnimation(self._contactList, "visible", 0)) result.addAnimation(propertyAnimation(self._frame, "visible", 0)) result.addAnimation(propertyAnimation(self._frame, "opacity", 400)) else: result.addAnimation(propertyAnimation(self._contactList, "visible", 0)) result.addAnimation(propertyAnimation(self._frame, "opacity", 400)) result.addAnimation(propertyAnimation(self._contactList, "y", 600, QEasingCurve.OutQuart)) result.addAnimation(propertyAnimation(self._frame, "visible", 0)) return result def createCallAnimation(self): result = QSequentialAnimationGroup() result.addAnimation(propertyAnimation(self._dialer, "opacity", 200)) result.addAnimation(propertyAnimation(self._board, "geometry", 300)) result.addAnimation(propertyAnimation(self._board._contents, "opacity", 200)) result.addAnimation(propertyAnimation(self._overlay, "opacity", 200)) return result def createInCallAnimation(self): result = QSequentialAnimationGroup() result.addAnimation(propertyAnimation(self._overlay, "opacity", 200)) result.addAnimation(propertyAnimation(self._board._panelWait, "opacity", 300)) result.addAnimation(propertyAnimation(self._board._panelWait, "visible", 0)) result.addAnimation(propertyAnimation(self._board._panelInCall, "opacity", 300)) result.addAnimation(propertyAnimation(self._overlay, "visible", 0)) return result def createEndCallAnimation(self): result = QSequentialAnimationGroup() result.addAnimation(propertyAnimation(self._overlay, "opacity", 200)) result.addAnimation(propertyAnimation(self._board._contents, "opacity", 200)) result.addAnimation(propertyAnimation(self._board, "geometry", 300)) result.addAnimation(propertyAnimation(self._dialer, "opacity", 200)) result.addAnimation(propertyAnimation(self._board, "visible", False)) result.addAnimation(propertyAnimation(self._display, "visible", False)) result.addAnimation(propertyAnimation(self._overlay, "visible", False)) return result
epl-1.0
[ 624, 199, 6331, 199, 627, 961, 570, 365, 1777, 402, 1611, 15414, 26, 2018, 367, 3959, 199, 627, 199, 627, 1898, 334, 35, 9, 8937, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 627, 199, 627, 18684, 26, 1611, 15414, 8099, 665, 7811, 32, 647, 2441, 14, 1308, 30, 199, 627, 199, 627, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 627, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 627, 1015, 499, 14, 17, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 627, 199, 627, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 627, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 627, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 627, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 627, 199, 627, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 627, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 627, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 627, 11315, 13, 10067, 8217, 199, 627, 199, 11589, 199, 624, 199, 199, 504, 1611, 15414, 14, 10901, 492, 627, 199, 504, 1611, 15414, 14, 10604, 492, 627, 199, 199, 504, 10342, 1907, 773, 14, 5555, 14, 576, 1927, 492, 627, 199, 504, 10342, 1907, 773, 14, 5555, 14, 1302, 492, 627, 199, 504, 10342, 1907, 773, 14, 8440, 63, 2966, 492, 627, 199, 504, 10342, 1907, 773, 14, 5555, 14, 3887, 492, 627, 199, 504, 10342, 1907, 773, 14, 7811, 513, 492, 627, 199, 504, 10342, 1907, 773, 14, 7811, 1927, 492, 627, 199, 504, 10342, 1907, 773, 14, 1345, 492, 627, 421, 199, 318, 2073, 4259, 6986, 837, 272, 5023, 275, 1413, 6986, 8, 4031, 14, 875, 1110, 480, 885, 15, 4246, 13, 6606, 2237, 272, 5023, 14, 409, 26395, 8, 549, 9, 272, 5023, 14, 409, 14383, 2320, 8, 4031, 14, 442, 1110, 480, 3887, 15, 4246, 13, 890, 2237, 272, 372, 5023, 421, 199, 533, 7259, 817, 8, 32260, 12, 1413, 18859, 8252, 2081, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 1692, 855, 826, 721, 277, 12, 1676, 9, 267, 1413, 18859, 8252, 2081, 855, 826, 721, 277, 9, 267, 291, 14, 21173, 480, 21861, 401, 378, 14, 16, 2736, 267, 291, 14, 21173, 480, 6604, 401, 715, 2736, 339, 347, 12817, 14414, 2390, 8, 277, 12, 325, 304, 267, 986, 199, 199, 533, 3757, 29706, 3339, 8, 49, 18859, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 18859, 3339, 855, 826, 721, 277, 12, 1676, 9, 267, 8020, 275, 1413, 18859, 16049, 2081, 8, 4031, 14, 6644, 1130, 480, 2391, 1435, 15, 7451, 14, 4524, 1288, 291, 9, 267, 8020, 14, 409, 6981, 8, 16, 12, 378, 9, 267, 8020, 14, 409, 7238, 1385, 8, 49, 18859, 16049, 2081, 14, 8934, 316, 8252, 7238, 9, 398, 11042, 275, 7337, 14, 442, 1110, 480, 2391, 1435, 13, 3440, 15, 9650, 531, 267, 19621, 275, 7337, 14, 442, 1110, 480, 2391, 1435, 13, 3440, 15, 15880, 531, 398, 291, 423, 4209, 275, 1413, 18859, 7900, 4798, 342, 267, 291, 423, 4209, 14, 409, 24052, 8, 15880, 9, 267, 291, 423, 4209, 14, 409, 11383, 15182, 83, 8, 9650, 12, 11042, 12, 11042, 12, 11042, 9, 398, 291, 14, 525, 4259, 480, 17, 401, 378, 12, 378, 12, 298, 2391, 1435, 15, 2119, 63, 3039, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 18, 401, 378, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 19, 401, 378, 12, 499, 12, 298, 2391, 1435, 15, 2119, 63, 1019, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 20, 401, 413, 12, 378, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 21, 401, 413, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 22, 401, 413, 12, 499, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 23, 401, 499, 12, 378, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 24, 401, 499, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 25, 401, 499, 12, 499, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 14421, 650, 12, 378, 12, 298, 2391, 1435, 15, 8305, 63, 3039, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 16, 401, 650, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 10064, 401, 650, 12, 499, 12, 298, 2391, 1435, 15, 8305, 63, 1019, 63, 498, 531, 398, 291, 14, 409, 4798, 8, 277, 423, 4209, 9, 339, 347, 1050, 4259, 8, 277, 12, 1768, 12, 1962, 12, 1048, 12, 1834, 4793, 304, 267, 3293, 2042, 275, 2071, 83, 14, 4524, 2, 450, 1834, 4793, 267, 25167, 2042, 275, 2071, 83, 63, 30455, 14, 4524, 2, 450, 1834, 4793, 398, 5528, 275, 16005, 8, 4031, 14, 6644, 1130, 8, 3302, 2042, 395, 717, 7337, 14, 6644, 1130, 8, 30455, 2042, 395, 488, 12, 488, 9, 267, 5528, 14, 8341, 8, 1302, 9, 267, 5528, 14, 24432, 8, 1927, 4259, 6986, 1012, 398, 291, 14, 2242, 8, 3887, 12, 24360, 480, 11276, 26322, 428, 21444, 480, 265, 4259, 31483, 342, 2237, 267, 291, 423, 4209, 14, 19798, 8, 3887, 12, 1962, 12, 1048, 9, 339, 347, 641, 4259, 31483, 8, 277, 304, 267, 5528, 275, 291, 14, 8114, 342, 398, 340, 5528, 26, 288, 291, 14, 8159, 8, 16496, 480, 3887, 31483, 8, 49, 1558, 13185, 5528, 14, 505, 1012, 421, 199, 533, 6523, 18995, 8, 49, 18859, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 18859, 3339, 855, 826, 721, 277, 12 ]
[ 199, 6331, 199, 627, 961, 570, 365, 1777, 402, 1611, 15414, 26, 2018, 367, 3959, 199, 627, 199, 627, 1898, 334, 35, 9, 8937, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 627, 199, 627, 18684, 26, 1611, 15414, 8099, 665, 7811, 32, 647, 2441, 14, 1308, 30, 199, 627, 199, 627, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 627, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 627, 1015, 499, 14, 17, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 627, 199, 627, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 627, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 627, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 627, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 627, 199, 627, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 627, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 627, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 627, 11315, 13, 10067, 8217, 199, 627, 199, 11589, 199, 624, 199, 199, 504, 1611, 15414, 14, 10901, 492, 627, 199, 504, 1611, 15414, 14, 10604, 492, 627, 199, 199, 504, 10342, 1907, 773, 14, 5555, 14, 576, 1927, 492, 627, 199, 504, 10342, 1907, 773, 14, 5555, 14, 1302, 492, 627, 199, 504, 10342, 1907, 773, 14, 8440, 63, 2966, 492, 627, 199, 504, 10342, 1907, 773, 14, 5555, 14, 3887, 492, 627, 199, 504, 10342, 1907, 773, 14, 7811, 513, 492, 627, 199, 504, 10342, 1907, 773, 14, 7811, 1927, 492, 627, 199, 504, 10342, 1907, 773, 14, 1345, 492, 627, 421, 199, 318, 2073, 4259, 6986, 837, 272, 5023, 275, 1413, 6986, 8, 4031, 14, 875, 1110, 480, 885, 15, 4246, 13, 6606, 2237, 272, 5023, 14, 409, 26395, 8, 549, 9, 272, 5023, 14, 409, 14383, 2320, 8, 4031, 14, 442, 1110, 480, 3887, 15, 4246, 13, 890, 2237, 272, 372, 5023, 421, 199, 533, 7259, 817, 8, 32260, 12, 1413, 18859, 8252, 2081, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 1692, 855, 826, 721, 277, 12, 1676, 9, 267, 1413, 18859, 8252, 2081, 855, 826, 721, 277, 9, 267, 291, 14, 21173, 480, 21861, 401, 378, 14, 16, 2736, 267, 291, 14, 21173, 480, 6604, 401, 715, 2736, 339, 347, 12817, 14414, 2390, 8, 277, 12, 325, 304, 267, 986, 199, 199, 533, 3757, 29706, 3339, 8, 49, 18859, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 18859, 3339, 855, 826, 721, 277, 12, 1676, 9, 267, 8020, 275, 1413, 18859, 16049, 2081, 8, 4031, 14, 6644, 1130, 480, 2391, 1435, 15, 7451, 14, 4524, 1288, 291, 9, 267, 8020, 14, 409, 6981, 8, 16, 12, 378, 9, 267, 8020, 14, 409, 7238, 1385, 8, 49, 18859, 16049, 2081, 14, 8934, 316, 8252, 7238, 9, 398, 11042, 275, 7337, 14, 442, 1110, 480, 2391, 1435, 13, 3440, 15, 9650, 531, 267, 19621, 275, 7337, 14, 442, 1110, 480, 2391, 1435, 13, 3440, 15, 15880, 531, 398, 291, 423, 4209, 275, 1413, 18859, 7900, 4798, 342, 267, 291, 423, 4209, 14, 409, 24052, 8, 15880, 9, 267, 291, 423, 4209, 14, 409, 11383, 15182, 83, 8, 9650, 12, 11042, 12, 11042, 12, 11042, 9, 398, 291, 14, 525, 4259, 480, 17, 401, 378, 12, 378, 12, 298, 2391, 1435, 15, 2119, 63, 3039, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 18, 401, 378, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 19, 401, 378, 12, 499, 12, 298, 2391, 1435, 15, 2119, 63, 1019, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 20, 401, 413, 12, 378, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 21, 401, 413, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 22, 401, 413, 12, 499, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 23, 401, 499, 12, 378, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 24, 401, 499, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 25, 401, 499, 12, 499, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 14421, 650, 12, 378, 12, 298, 2391, 1435, 15, 8305, 63, 3039, 63, 498, 531, 267, 291, 14, 525, 4259, 480, 16, 401, 650, 12, 413, 12, 298, 2391, 1435, 15, 14885, 63, 498, 531, 267, 291, 14, 525, 4259, 10064, 401, 650, 12, 499, 12, 298, 2391, 1435, 15, 8305, 63, 1019, 63, 498, 531, 398, 291, 14, 409, 4798, 8, 277, 423, 4209, 9, 339, 347, 1050, 4259, 8, 277, 12, 1768, 12, 1962, 12, 1048, 12, 1834, 4793, 304, 267, 3293, 2042, 275, 2071, 83, 14, 4524, 2, 450, 1834, 4793, 267, 25167, 2042, 275, 2071, 83, 63, 30455, 14, 4524, 2, 450, 1834, 4793, 398, 5528, 275, 16005, 8, 4031, 14, 6644, 1130, 8, 3302, 2042, 395, 717, 7337, 14, 6644, 1130, 8, 30455, 2042, 395, 488, 12, 488, 9, 267, 5528, 14, 8341, 8, 1302, 9, 267, 5528, 14, 24432, 8, 1927, 4259, 6986, 1012, 398, 291, 14, 2242, 8, 3887, 12, 24360, 480, 11276, 26322, 428, 21444, 480, 265, 4259, 31483, 342, 2237, 267, 291, 423, 4209, 14, 19798, 8, 3887, 12, 1962, 12, 1048, 9, 339, 347, 641, 4259, 31483, 8, 277, 304, 267, 5528, 275, 291, 14, 8114, 342, 398, 340, 5528, 26, 288, 291, 14, 8159, 8, 16496, 480, 3887, 31483, 8, 49, 1558, 13185, 5528, 14, 505, 1012, 421, 199, 533, 6523, 18995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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alexandrujuncu/sos
sos/plugins/soundcard.py
12
1475
# 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., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin class Soundcard(Plugin): """ Sound devices """ plugin_name = "soundcard" profiles = ('desktop', 'hardware') def setup(self): self.add_copy_spec("/proc/asound/*") self.add_cmd_output([ "aplay -l", "aplay -L", "amixer" ]) class RedHatSoundcard(Soundcard, RedHatPlugin): def setup(self): super(RedHatSoundcard, self).setup() self.add_copy_spec([ "/etc/alsa/*", "/etc/asound.*" ]) class DebianSoundcard(Soundcard, DebianPlugin, UbuntuPlugin): def setup(self): super(DebianSoundcard, self).setup() self.add_copy_spec("/etc/pulse/*") # vim: set et ts=4 sw=4 :
gpl-2.0
[ 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 504, 308, 736, 14, 5265, 492, 11349, 12, 9572, 40, 292, 5061, 12, 30445, 5061, 12, 31631, 5061, 421, 199, 533, 428, 1034, 5841, 8, 5061, 304, 272, 408, 428, 1034, 7256, 272, 408, 339, 3589, 63, 354, 275, 298, 14990, 5841, 2, 272, 17390, 275, 661, 14487, 297, 283, 16529, 358, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 525, 63, 1574, 63, 1650, 4769, 4687, 15, 305, 1034, 6331, 531, 267, 291, 14, 525, 63, 1760, 63, 1199, 779, 288, 298, 439, 817, 446, 76, 401, 288, 298, 439, 817, 446, 44, 401, 288, 298, 455, 1148, 281, 2, 267, 4794, 421, 199, 533, 9572, 40, 292, 18670, 5841, 8, 18670, 5841, 12, 9572, 40, 292, 5061, 304, 339, 347, 3272, 8, 277, 304, 267, 1613, 8, 10858, 40, 292, 18670, 5841, 12, 291, 680, 2758, 342, 398, 291, 14, 525, 63, 1574, 63, 1650, 779, 288, 3286, 6839, 15, 279, 2231, 6331, 401, 288, 3286, 6839, 15, 305, 1034, 2795, 2, 267, 4794, 421, 199, 533, 30445, 18670, 5841, 8, 18670, 5841, 12, 30445, 5061, 12, 31631, 5061, 304, 339, 347, 3272, 8, 277, 304, 267, 1613, 8, 872, 9662, 18670, 5841, 12, 291, 680, 2758, 342, 398, 291, 14, 525, 63, 1574, 63, 1650, 4769, 6839, 15, 19538, 6331, 531, 199, 199, 3, 6695, 26, 663, 10844, 6714, 29, 20, 5584, 29, 20, 520, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 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, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 504, 308, 736, 14, 5265, 492, 11349, 12, 9572, 40, 292, 5061, 12, 30445, 5061, 12, 31631, 5061, 421, 199, 533, 428, 1034, 5841, 8, 5061, 304, 272, 408, 428, 1034, 7256, 272, 408, 339, 3589, 63, 354, 275, 298, 14990, 5841, 2, 272, 17390, 275, 661, 14487, 297, 283, 16529, 358, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 525, 63, 1574, 63, 1650, 4769, 4687, 15, 305, 1034, 6331, 531, 267, 291, 14, 525, 63, 1760, 63, 1199, 779, 288, 298, 439, 817, 446, 76, 401, 288, 298, 439, 817, 446, 44, 401, 288, 298, 455, 1148, 281, 2, 267, 4794, 421, 199, 533, 9572, 40, 292, 18670, 5841, 8, 18670, 5841, 12, 9572, 40, 292, 5061, 304, 339, 347, 3272, 8, 277, 304, 267, 1613, 8, 10858, 40, 292, 18670, 5841, 12, 291, 680, 2758, 342, 398, 291, 14, 525, 63, 1574, 63, 1650, 779, 288, 3286, 6839, 15, 279, 2231, 6331, 401, 288, 3286, 6839, 15, 305, 1034, 2795, 2, 267, 4794, 421, 199, 533, 30445, 18670, 5841, 8, 18670, 5841, 12, 30445, 5061, 12, 31631, 5061, 304, 339, 347, 3272, 8, 277, 304, 267, 1613, 8, 872, 9662, 18670, 5841, 12, 291, 680, 2758, 342, 398, 291, 14, 525, 63, 1574, 63, 1650, 4769, 6839, 15, 19538, 6331, 531, 199, 199, 3, 6695, 26, 663, 10844, 6714, 29, 20, 5584, 29, 20, 520, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tszym/ansible
test/utils/shippable/tools/run.py
136
3570
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK # (c) 2016 Red Hat, Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. """CLI tool for starting new Shippable CI runs.""" from __future__ import print_function # noinspection PyCompatibility import argparse import json import os import requests try: import argcomplete except ImportError: argcomplete = None def main(): """Main program body.""" api_key = get_api_key() parser = argparse.ArgumentParser(description='Start a new Shippable run.') parser.add_argument('project', metavar='account/project', help='Shippable account/project') target = parser.add_mutually_exclusive_group() target.add_argument('--branch', help='branch name') target.add_argument('--run', metavar='ID', help='Shippable run ID') parser.add_argument('--key', metavar='KEY', default=api_key, required=not api_key, help='Shippable API key') parser.add_argument('--env', nargs=2, metavar=('KEY', 'VALUE'), action='append', help='environment variable to pass') if argcomplete: argcomplete.autocomplete(parser) args = parser.parse_args() headers = dict( Authorization='apiToken %s' % args.key, ) # get project ID data = dict( projectFullNames=args.project, ) url = 'https://api.shippable.com/projects' response = requests.get(url, data, headers=headers) if response.status_code != 200: raise Exception(response.content) result = response.json() if len(result) != 1: raise Exception( 'Received %d items instead of 1 looking for %s in:\n%s' % ( len(result), args.project, json.dumps(result, indent=4, sort_keys=True))) project_id = response.json()[0]['id'] # new build data = dict( globalEnv=['%s=%s' % (kp[0], kp[1]) for kp in args.env or []] ) if args.branch: data['branch'] = args.branch elif args.run: data['runId'] = args.run url = 'https://api.shippable.com/projects/%s/newBuild' % project_id response = requests.post(url, data, headers=headers) if response.status_code != 200: raise Exception(response.content) print(json.dumps(response.json(), indent=4, sort_keys=True)) def get_api_key(): """ rtype: str """ key = os.environ.get('SHIPPABLE_KEY', None) if key: return key path = os.path.join(os.environ['HOME'], '.shippable.key') try: with open(path, 'r') as key_fd: return key_fd.read().strip() except IOError: return None if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 18280, 63, 11611, 15558, 63, 3593, 199, 199, 3, 334, 67, 9, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 7802, 4744, 367, 6617, 892, 5244, 31112, 461, 445, 41, 7858, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 30870, 1611, 2404, 5880, 199, 646, 7534, 199, 646, 2022, 199, 646, 747, 199, 646, 4145, 199, 199, 893, 26, 272, 492, 1680, 4883, 199, 2590, 3545, 26, 272, 1680, 4883, 275, 488, 421, 199, 318, 2446, 837, 272, 408, 6756, 2240, 2396, 1041, 272, 2986, 63, 498, 275, 664, 63, 1246, 63, 498, 342, 339, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 3162, 282, 892, 5244, 31112, 461, 1255, 2659, 339, 1798, 14, 525, 63, 2094, 360, 1715, 297, 717, 8214, 534, 2048, 15, 1715, 297, 717, 1720, 534, 30707, 80, 461, 2933, 15, 1715, 358, 339, 1347, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 339, 1347, 14, 525, 63, 2094, 4517, 4694, 297, 717, 1720, 534, 4694, 536, 358, 339, 1347, 14, 525, 63, 2094, 4517, 1065, 297, 717, 8214, 534, 998, 297, 717, 1720, 534, 30707, 80, 461, 1255, 2870, 358, 339, 1798, 14, 525, 63, 2094, 4517, 498, 297, 717, 8214, 534, 3078, 297, 717, 849, 29, 1246, 63, 498, 12, 717, 1415, 29, 1397, 2986, 63, 498, 12, 717, 1720, 534, 30707, 80, 461, 3261, 790, 358, 339, 1798, 14, 525, 63, 2094, 4517, 1813, 297, 717, 9237, 29, 18, 12, 717, 8214, 7782, 3078, 297, 283, 7041, 659, 717, 1595, 534, 740, 297, 717, 1720, 534, 5418, 1750, 370, 986, 358, 339, 340, 1680, 4883, 26, 267, 1680, 4883, 14, 29695, 8, 2087, 9, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 2323, 275, 1211, 8, 267, 21527, 534, 1246, 3264, 450, 83, 7, 450, 1249, 14, 498, 12, 272, 776, 339, 327, 664, 2199, 2870, 339, 666, 275, 1211, 8, 267, 2199, 9042, 5866, 29, 589, 14, 1715, 12, 272, 776, 339, 1166, 275, 283, 2859, 921, 1246, 14, 3319, 80, 461, 14, 957, 15, 6776, 7, 272, 1177, 275, 4145, 14, 362, 8, 633, 12, 666, 12, 2323, 29, 2139, 9, 339, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 746, 2186, 8, 1310, 14, 1317, 9, 339, 754, 275, 1177, 14, 1001, 342, 339, 340, 822, 8, 1099, 9, 1137, 413, 26, 267, 746, 2186, 8, 288, 283, 9392, 450, 68, 2974, 3140, 402, 413, 10023, 367, 450, 83, 315, 3427, 78, 5, 83, 7, 450, 334, 355, 822, 8, 1099, 395, 355, 1249, 14, 1715, 12, 355, 2022, 14, 4180, 8, 1099, 12, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 1724, 339, 2199, 63, 344, 275, 1177, 14, 1001, 3430, 16, 2733, 344, 418, 339, 327, 892, 1900, 339, 666, 275, 1211, 8, 267, 2288, 7744, 2968, 5, 83, 2458, 83, 7, 450, 334, 25017, 59, 16, 467, 1022, 80, 59, 17, 566, 367, 1022, 80, 315, 1249, 14, 1813, 503, 942, 61, 272, 776, 339, 340, 1249, 14, 4694, 26, 267, 666, 459, 4694, 418, 275, 1249, 14, 4694, 272, 916, 1249, 14, 1065, 26, 267, 666, 459, 1065, 1304, 418, 275, 1249, 14, 1065, 339, 1166, 275, 283, 2859, 921, 1246, 14, 3319, 80, 461, 14, 957, 15, 6776, 3149, 83, 15, 1222, 3425, 7, 450, 2199, 63, 344, 272, 1177, 275, 4145, 14, 1932, 8, 633, 12, 666, 12, 2323, 29, 2139, 9, 339, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 746, 2186, 8, 1310, 14, 1317, 9, 339, 870, 8, 1001, 14, 4180, 8, 1310, 14, 1001, 1062, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 430, 421, 199, 318, 664, 63, 1246, 63, 498, 837, 272, 408, 272, 519, 466, 26, 620, 272, 408, 272, 790, 275, 747, 14, 2314, 14, 362, 360, 3234, 1772, 48, 2617, 63, 3078, 297, 488, 9, 339, 340, 790, 26, 267, 372, 790, 339, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 2314, 459, 9524, 995, 1987, 3319, 80, 461, 14, 498, 358, 339, 862, 26, 267, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 790, 63, 2592, 26, 288, 372, 790, 63, 2592, 14, 739, 1252, 1913, 342, 272, 871, 5925, 26, 267, 372, 488, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 18280, 63, 11611, 15558, 63, 3593, 199, 199, 3, 334, 67, 9, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 7802, 4744, 367, 6617, 892, 5244, 31112, 461, 445, 41, 7858, 1041, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 30870, 1611, 2404, 5880, 199, 646, 7534, 199, 646, 2022, 199, 646, 747, 199, 646, 4145, 199, 199, 893, 26, 272, 492, 1680, 4883, 199, 2590, 3545, 26, 272, 1680, 4883, 275, 488, 421, 199, 318, 2446, 837, 272, 408, 6756, 2240, 2396, 1041, 272, 2986, 63, 498, 275, 664, 63, 1246, 63, 498, 342, 339, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 3162, 282, 892, 5244, 31112, 461, 1255, 2659, 339, 1798, 14, 525, 63, 2094, 360, 1715, 297, 717, 8214, 534, 2048, 15, 1715, 297, 717, 1720, 534, 30707, 80, 461, 2933, 15, 1715, 358, 339, 1347, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 339, 1347, 14, 525, 63, 2094, 4517, 4694, 297, 717, 1720, 534, 4694, 536, 358, 339, 1347, 14, 525, 63, 2094, 4517, 1065, 297, 717, 8214, 534, 998, 297, 717, 1720, 534, 30707, 80, 461, 1255, 2870, 358, 339, 1798, 14, 525, 63, 2094, 4517, 498, 297, 717, 8214, 534, 3078, 297, 717, 849, 29, 1246, 63, 498, 12, 717, 1415, 29, 1397, 2986, 63, 498, 12, 717, 1720, 534, 30707, 80, 461, 3261, 790, 358, 339, 1798, 14, 525, 63, 2094, 4517, 1813, 297, 717, 9237, 29, 18, 12, 717, 8214, 7782, 3078, 297, 283, 7041, 659, 717, 1595, 534, 740, 297, 717, 1720, 534, 5418, 1750, 370, 986, 358, 339, 340, 1680, 4883, 26, 267, 1680, 4883, 14, 29695, 8, 2087, 9, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 2323, 275, 1211, 8, 267, 21527, 534, 1246, 3264, 450, 83, 7, 450, 1249, 14, 498, 12, 272, 776, 339, 327, 664, 2199, 2870, 339, 666, 275, 1211, 8, 267, 2199, 9042, 5866, 29, 589, 14, 1715, 12, 272, 776, 339, 1166, 275, 283, 2859, 921, 1246, 14, 3319, 80, 461, 14, 957, 15, 6776, 7, 272, 1177, 275, 4145, 14, 362, 8, 633, 12, 666, 12, 2323, 29, 2139, 9, 339, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 746, 2186, 8, 1310, 14, 1317, 9, 339, 754, 275, 1177, 14, 1001, 342, 339, 340, 822, 8, 1099, 9, 1137, 413, 26, 267, 746, 2186, 8, 288, 283, 9392, 450, 68, 2974, 3140, 402, 413, 10023, 367, 450, 83, 315, 3427, 78, 5, 83, 7, 450, 334, 355, 822, 8, 1099, 395, 355, 1249, 14, 1715, 12, 355, 2022, 14, 4180, 8, 1099, 12, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 1724, 339, 2199, 63, 344, 275, 1177, 14, 1001, 3430, 16, 2733, 344, 418, 339, 327, 892, 1900, 339, 666, 275, 1211, 8, 267, 2288, 7744, 2968, 5, 83, 2458, 83, 7, 450, 334, 25017, 59, 16, 467, 1022, 80, 59, 17, 566, 367, 1022, 80, 315, 1249, 14, 1813, 503, 942, 61, 272, 776, 339, 340, 1249, 14, 4694, 26, 267, 666, 459, 4694, 418, 275, 1249, 14, 4694, 272, 916, 1249, 14, 1065, 26, 267, 666, 459, 1065, 1304, 418, 275, 1249, 14, 1065, 339, 1166, 275, 283, 2859, 921, 1246, 14, 3319, 80, 461, 14, 957, 15, 6776, 3149, 83, 15, 1222, 3425, 7, 450, 2199, 63, 344, 272, 1177, 275, 4145, 14, 1932, 8, 633, 12, 666, 12, 2323, 29, 2139, 9, 339, 340, 1177, 14, 1205, 63, 600, 1137, 1926, 26, 267, 746, 2186, 8, 1310, 14, 1317, 9, 339, 870, 8, 1001, 14, 4180, 8, 1310, 14, 1001, 1062, 4363, 29, 20, 12, 4069, 63, 1612, 29, 549, 430, 421, 199, 318, 664, 63, 1246, 63, 498, 837, 272, 408, 272, 519, 466, 26, 620, 272, 408, 272, 790, 275, 747, 14, 2314, 14, 362, 360, 3234, 1772, 48, 2617, 63, 3078, 297, 488, 9, 339, 340, 790, 26, 267, 372, 790, 339, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 2314, 459, 9524, 995, 1987, 3319, 80, 461, 14, 498, 358, 339, 862, 26, 267, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 790, 63, 2592, 26, 288, 372, 790, 63, 2592, 14, 739, 1252, 1913, 342, 272, 871, 5925, 26, 267, 372, 488, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
abhishekgahlot/or-tools
examples/python/fill_a_pix.py
34
4969
# Copyright 2010 Hakan Kjellerstrand hakank@bonetmail.com # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an 'AS IS' BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Fill-a-Pix problem in Google CP Solver. From http://www.conceptispuzzles.com/index.aspx?uri=puzzle/fill-a-pix/basiclogic ''' Each puzzle consists of a grid containing clues in various places. The object is to reveal a hidden picture by painting the squares around each clue so that the number of painted squares, including the square with the clue, matches the value of the clue. ''' http://www.conceptispuzzles.com/index.aspx?uri=puzzle/fill-a-pix/rules ''' Fill-a-Pix is a Minesweeper-like puzzle based on a grid with a pixilated picture hidden inside. Using logic alone, the solver determines which squares are painted and which should remain empty until the hidden picture is completely exposed. ''' Fill-a-pix History: http://www.conceptispuzzles.com/index.aspx?uri=puzzle/fill-a-pix/history Compare with the following models: * MiniZinc: http://www.hakank.org/minizinc/fill_a_pix.mzn * SICStus Prolog: http://www.hakank.org/sicstus/fill_a_pix.pl * ECLiPSe: http://hakank.org/eclipse/fill_a_pix.ecl * Gecode: http://hakank.org/gecode/fill_a_pix.cpp And see the Minesweeper model: * http://www.hakank.org/google_or_tools/minesweeper.py This model was created by Hakan Kjellerstrand (hakank@bonetmail.com) Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/ """ import sys from ortools.constraint_solver import pywrapcp # Puzzle 1 from # http://www.conceptispuzzles.com/index.aspx?uri=puzzle/fill-a-pix/rules default_n = 10 X = -1 default_puzzle = [ [X, X, X, X, X, X, X, X, 0, X], [X, 8, 8, X, 2, X, 0, X, X, X], [5, X, 8, X, X, X, X, X, X, X], [X, X, X, X, X, 2, X, X, X, 2], [1, X, X, X, 4, 5, 6, X, X, X], [X, 0, X, X, X, 7, 9, X, X, 6], [X, X, X, 6, X, X, 9, X, X, 6], [X, X, 6, 6, 8, 7, 8, 7, X, 5], [X, 4, X, 6, 6, 6, X, 6, X, 4], [X, X, X, X, X, X, 3, X, X, X] ] def main(puzzle='', n=''): # Create the solver. solver = pywrapcp.Solver('Fill-a-Pix') # # data # # Set default problem if puzzle == '': puzzle = default_puzzle n = default_n else: print 'n:', n # for the neighbors of 'this' cell S = [-1, 0, 1] # print problem instance print 'Problem:' for i in range(n): for j in range(n): if puzzle[i][j] == X: sys.stdout.write('.') else: sys.stdout.write(str(puzzle[i][j])) print print # # declare variables # pict = {} for i in range(n): for j in range(n): pict[(i, j)] = solver.IntVar(0, 1, 'pict %i %i' % (i, j)) pict_flat = [pict[i, j] for i in range(n) for j in range(n)] # # constraints # for i in range(n): for j in range(n): if puzzle[i][j] > X: # this cell is the sum of all the surrounding cells solver.Add( puzzle[i][j] == solver.Sum([pict[i + a, j + b] for a in S for b in S if i + a >= 0 and j + b >= 0 and i + a < n and j + b < n]) ) # # solution and search # db = solver.Phase(pict_flat, solver.INT_VAR_DEFAULT, solver.INT_VALUE_DEFAULT) solver.NewSearch(db) num_solutions = 0 print 'Solution:' while solver.NextSolution(): num_solutions += 1 for i in range(n): row = [str(pict[i, j].Value()) for j in range(n)] for j in range(n): if row[j] == '0': row[j] = ' ' else: row[j] = '#' print ''.join(row) print print 'num_solutions:', num_solutions print 'failures:', solver.Failures() print 'branches:', solver.Branches() print 'WallTime:', solver.WallTime(), 'ms' # # Read a problem instance from a file # def read_problem(file): f = open(file, 'r') n = int(f.readline()) puzzle = [] for i in range(n): x = f.readline() row = [0] * n for j in range(n): if x[j] == '.': tmp = -1 else: tmp = int(x[j]) row[j] = tmp puzzle.append(row) return [puzzle, n] if __name__ == '__main__': if len(sys.argv) > 1: file = sys.argv[1] print 'Problem instance from', file [puzzle, n] = read_problem(file) main(puzzle, n) else: main()
apache-2.0
[ 3, 1898, 7129, 869, 1151, 290, 1804, 74, 352, 1435, 30964, 394, 1151, 3580, 32, 21134, 84, 1198, 14, 957, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 283, 3761, 11339, 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, 283, 1179, 2281, 7, 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, 819, 24797, 13, 65, 13, 25747, 5160, 315, 4475, 19701, 428, 3725, 14, 819, 11606, 523, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4316, 15370, 523, 1449, 523, 7048, 18848, 17622, 18581, 402, 282, 6068, 3035, 824, 10138, 315, 7750, 9825, 14, 710, 523, 909, 365, 370, 295, 432, 279, 282, 8752, 24945, 701, 32055, 316, 314, 26170, 6818, 1924, 523, 824, 310, 880, 626, 314, 1329, 402, 691, 9082, 26170, 12, 5893, 314, 12386, 543, 523, 314, 824, 310, 12, 4450, 314, 574, 402, 314, 824, 310, 14, 523, 1449, 819, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4423, 523, 1449, 523, 24797, 13, 65, 13, 25747, 365, 282, 603, 3746, 25515, 529, 13, 2930, 18848, 17622, 4079, 641, 282, 6068, 543, 282, 25505, 382, 972, 523, 24945, 8752, 6272, 14, 11719, 9661, 23016, 12, 314, 10196, 16756, 1314, 523, 26170, 787, 691, 9082, 436, 1314, 1077, 5706, 2701, 5133, 314, 8752, 24945, 523, 365, 14793, 19282, 14, 523, 1449, 819, 24797, 13, 65, 13, 6644, 27829, 26, 523, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 5570, 8330, 18955, 543, 314, 2569, 1709, 26, 523, 627, 24954, 58, 6559, 26, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 827, 565, 6559, 15, 4498, 63, 65, 63, 6644, 14, 28808, 78, 523, 627, 428, 948, 933, 527, 2165, 793, 26, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 9916, 270, 527, 15, 4498, 63, 65, 63, 6644, 14, 1168, 523, 627, 662, 1981, 73, 48, 1513, 26, 1455, 921, 72, 1151, 3580, 14, 1308, 15, 825, 3587, 261, 15, 4498, 63, 65, 63, 6644, 14, 69, 429, 523, 627, 5346, 600, 26, 1455, 921, 72, 1151, 3580, 14, 1308, 15, 303, 600, 15, 4498, 63, 65, 63, 6644, 14, 5910, 819, 6061, 1937, 314, 603, 3746, 25515, 529, 1402, 26, 523, 627, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 3098, 63, 269, 63, 2537, 15, 827, 397, 25515, 529, 14, 647, 8330, 961, 1402, 1990, 2737, 701, 869, 1151, 290, 1804, 74, 352, 1435, 30964, 334, 72, 1151, 3580, 32, 21134, 84, 1198, 14, 957, 9, 523, 6121, 1937, 3002, 1163, 4475, 19701, 428, 3725, 1709, 26, 523, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 3098, 63, 269, 63, 2537, 15, 199, 624, 199, 646, 984, 199, 504, 221, 361, 5998, 14, 5631, 63, 11263, 492, 1134, 3823, 1850, 421, 199, 3, 510, 85, 17622, 413, 687, 199, 3, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4423, 199, 885, 63, 78, 275, 1616, 199, 56, 275, 446, 17, 199, 885, 63, 3165, 17622, 275, 359, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 378, 12, 1323, 467, 272, 359, 56, 12, 1695, 12, 1695, 12, 1323, 12, 499, 12, 1323, 12, 378, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 21, 12, 1323, 12, 1695, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 499, 12, 1323, 12, 1323, 12, 1323, 12, 499, 467, 272, 359, 17, 12, 1323, 12, 1323, 12, 1323, 12, 841, 12, 959, 12, 1227, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 56, 12, 378, 12, 1323, 12, 1323, 12, 1323, 12, 1520, 12, 1749, 12, 1323, 12, 1323, 12, 1227, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1227, 12, 1323, 12, 1323, 12, 1749, 12, 1323, 12, 1323, 12, 1227, 467, 272, 359, 56, 12, 1323, 12, 1227, 12, 1227, 12, 1695, 12, 1520, 12, 1695, 12, 1520, 12, 1323, 12, 959, 467, 272, 359, 56, 12, 841, 12, 1323, 12, 1227, 12, 1227, 12, 1227, 12, 1323, 12, 1227, 12, 1323, 12, 841, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 650, 12, 1323, 12, 1323, 12, 1323, 61, 199, 61, 421, 199, 318, 2446, 8, 3165, 17622, 4581, 302, 9280, 819, 327, 2790, 314, 10196, 14, 523, 10196, 275, 1134, 3823, 1850, 14, 24755, 360, 12914, 13, 65, 13, 25747, 358, 819, 327, 523, 327, 666, 523, 327, 819, 327, 2494, 849, 5160, 523, 340, 18848, 17622, 508, 8061, 272, 18848, 17622, 275, 849, 63, 3165, 17622, 272, 302, 275, 849, 63, 78, 523, 587, 26, 272, 870, 283, 78, 6536, 302, 819, 327, 367, 314, 15845, 402, 283, 3749, 7, 4917, 523, 428, 275, 5243, 17, 12, 378, 12, 413, 61, 819, 327, 870, 5160, 1256, 523, 870, 283, 16467, 4881, 523, 367, 284, 315, 1425, 8, 78, 304, 272, 367, 1335, 315, 1425, 8, 78, 304, 489, 340, 18848, 17622, 59, 73, 1527 ]
[ 1898, 7129, 869, 1151, 290, 1804, 74, 352, 1435, 30964, 394, 1151, 3580, 32, 21134, 84, 1198, 14, 957, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 283, 3761, 11339, 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, 283, 1179, 2281, 7, 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, 819, 24797, 13, 65, 13, 25747, 5160, 315, 4475, 19701, 428, 3725, 14, 819, 11606, 523, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4316, 15370, 523, 1449, 523, 7048, 18848, 17622, 18581, 402, 282, 6068, 3035, 824, 10138, 315, 7750, 9825, 14, 710, 523, 909, 365, 370, 295, 432, 279, 282, 8752, 24945, 701, 32055, 316, 314, 26170, 6818, 1924, 523, 824, 310, 880, 626, 314, 1329, 402, 691, 9082, 26170, 12, 5893, 314, 12386, 543, 523, 314, 824, 310, 12, 4450, 314, 574, 402, 314, 824, 310, 14, 523, 1449, 819, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4423, 523, 1449, 523, 24797, 13, 65, 13, 25747, 365, 282, 603, 3746, 25515, 529, 13, 2930, 18848, 17622, 4079, 641, 282, 6068, 543, 282, 25505, 382, 972, 523, 24945, 8752, 6272, 14, 11719, 9661, 23016, 12, 314, 10196, 16756, 1314, 523, 26170, 787, 691, 9082, 436, 1314, 1077, 5706, 2701, 5133, 314, 8752, 24945, 523, 365, 14793, 19282, 14, 523, 1449, 819, 24797, 13, 65, 13, 6644, 27829, 26, 523, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 5570, 8330, 18955, 543, 314, 2569, 1709, 26, 523, 627, 24954, 58, 6559, 26, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 827, 565, 6559, 15, 4498, 63, 65, 63, 6644, 14, 28808, 78, 523, 627, 428, 948, 933, 527, 2165, 793, 26, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 9916, 270, 527, 15, 4498, 63, 65, 63, 6644, 14, 1168, 523, 627, 662, 1981, 73, 48, 1513, 26, 1455, 921, 72, 1151, 3580, 14, 1308, 15, 825, 3587, 261, 15, 4498, 63, 65, 63, 6644, 14, 69, 429, 523, 627, 5346, 600, 26, 1455, 921, 72, 1151, 3580, 14, 1308, 15, 303, 600, 15, 4498, 63, 65, 63, 6644, 14, 5910, 819, 6061, 1937, 314, 603, 3746, 25515, 529, 1402, 26, 523, 627, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 3098, 63, 269, 63, 2537, 15, 827, 397, 25515, 529, 14, 647, 8330, 961, 1402, 1990, 2737, 701, 869, 1151, 290, 1804, 74, 352, 1435, 30964, 334, 72, 1151, 3580, 32, 21134, 84, 1198, 14, 957, 9, 523, 6121, 1937, 3002, 1163, 4475, 19701, 428, 3725, 1709, 26, 523, 1455, 921, 1544, 14, 72, 1151, 3580, 14, 1308, 15, 3098, 63, 269, 63, 2537, 15, 199, 624, 199, 646, 984, 199, 504, 221, 361, 5998, 14, 5631, 63, 11263, 492, 1134, 3823, 1850, 421, 199, 3, 510, 85, 17622, 413, 687, 199, 3, 1455, 921, 1544, 14, 388, 28448, 280, 681, 85, 4348, 2978, 14, 957, 15, 1080, 14, 26146, 31, 2302, 29, 3165, 17622, 15, 4498, 13, 65, 13, 6644, 15, 4423, 199, 885, 63, 78, 275, 1616, 199, 56, 275, 446, 17, 199, 885, 63, 3165, 17622, 275, 359, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 378, 12, 1323, 467, 272, 359, 56, 12, 1695, 12, 1695, 12, 1323, 12, 499, 12, 1323, 12, 378, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 21, 12, 1323, 12, 1695, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 499, 12, 1323, 12, 1323, 12, 1323, 12, 499, 467, 272, 359, 17, 12, 1323, 12, 1323, 12, 1323, 12, 841, 12, 959, 12, 1227, 12, 1323, 12, 1323, 12, 1323, 467, 272, 359, 56, 12, 378, 12, 1323, 12, 1323, 12, 1323, 12, 1520, 12, 1749, 12, 1323, 12, 1323, 12, 1227, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1227, 12, 1323, 12, 1323, 12, 1749, 12, 1323, 12, 1323, 12, 1227, 467, 272, 359, 56, 12, 1323, 12, 1227, 12, 1227, 12, 1695, 12, 1520, 12, 1695, 12, 1520, 12, 1323, 12, 959, 467, 272, 359, 56, 12, 841, 12, 1323, 12, 1227, 12, 1227, 12, 1227, 12, 1323, 12, 1227, 12, 1323, 12, 841, 467, 272, 359, 56, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 1323, 12, 650, 12, 1323, 12, 1323, 12, 1323, 61, 199, 61, 421, 199, 318, 2446, 8, 3165, 17622, 4581, 302, 9280, 819, 327, 2790, 314, 10196, 14, 523, 10196, 275, 1134, 3823, 1850, 14, 24755, 360, 12914, 13, 65, 13, 25747, 358, 819, 327, 523, 327, 666, 523, 327, 819, 327, 2494, 849, 5160, 523, 340, 18848, 17622, 508, 8061, 272, 18848, 17622, 275, 849, 63, 3165, 17622, 272, 302, 275, 849, 63, 78, 523, 587, 26, 272, 870, 283, 78, 6536, 302, 819, 327, 367, 314, 15845, 402, 283, 3749, 7, 4917, 523, 428, 275, 5243, 17, 12, 378, 12, 413, 61, 819, 327, 870, 5160, 1256, 523, 870, 283, 16467, 4881, 523, 367, 284, 315, 1425, 8, 78, 304, 272, 367, 1335, 315, 1425, 8, 78, 304, 489, 340, 18848, 17622, 59, 73, 1527, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jorvis/biocode
gff/convert_fasta_contigs_to_gff3.py
2
2260
#!/usr/bin/env python3 """ This script assumes that the input FASTA represents genomic sequence and creates a GFF3 file for these, devoid of anything other than placeholder rows for each molecule. It is assumed other processes will add to this. Input example (fake): >AL009126.2 Bacillus subtilis contig 2 ATCTTTTTCGGCTTTTTTTAGTATCCACAGAGGTTATCGACAACATTTTCACATTACCAACCCCTGTGGACAAGGTTTTT TCAACAGGTTGTCCGCTTTGTGGATAAGATTGTGA >AL009126.3 Bacillus subtilis contig 3 ATCTTTTTCGGCTTTTTTTAGTATCCACAGAGGTTATCGACAACATTTTCACATTACCAACCCCTGTGGACAAGGTTTTT TCAACAGGTTGTCCGCTTTGTGGATAAGATTGTGACAACCATTGCAAGCTCTCGTTTATTTTGGTATTATATTTGTGTTT TAACTCTTGATTACTAATCCTACCTTTCCTCTTTATCCACAAAGTGTGGATAAGTTGTGGATTGATTTCACACAGCTTGT Output: AL009126.2 IGS contig 1 100613 . . . ID=AL009126.2;Name=Bacillus subtilis contig 2 AL009126.3 IGS contig 1 230218 . . . ID=AL009126.3;Name=Bacillus subtilis contig 3 The value of the 2nd column is up to you and defined using the --source parameter. """ import argparse from biocode import utils def main(): parser = argparse.ArgumentParser( description='Creates a GFF3 file from a genomic FASTA') ## output file to be written parser.add_argument('-i', '--input_fasta', type=str, required=True, help='Path to an input file to be read' ) parser.add_argument('-o', '--output_gff3', type=str, required=True, help='Path to an output file to be created' ) parser.add_argument('-s', '--source', type=str, required=True, help='Source, fills column 2 of the output GFF3 file' ) parser.add_argument('-t', '--molecule_term', type=str, required=False, default='contig', help='SO term to represent genomic sequence type') args = parser.parse_args() ofh = open(args.output_gff3, 'wt') seqs = utils.fasta_dict_from_file(args.input_fasta) # header ofh.write("##gff-version 3\n") for seq_id in seqs: ofh.write("{0}\t{1}\t{2}\t1\t{3}\t.\t.\t.\tID={0}".format(seq_id, args.source, args.molecule_term, len(seqs[seq_id]['s']))) if len(seqs[seq_id]['h']) > 0: ofh.write(";Name={0}".format(seqs[seq_id]['h'])) ofh.write("\n") if __name__ == '__main__': main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 199, 199, 2765, 2884, 15194, 626, 314, 1324, 481, 11307, 33, 8469, 3805, 676, 530, 3414, 436, 8491, 199, 65, 598, 1665, 19, 570, 367, 3520, 12, 477, 1647, 402, 7003, 1163, 2419, 10069, 4730, 367, 1924, 199, 26310, 14, 221, 2779, 365, 10826, 1163, 10358, 911, 1050, 370, 642, 14, 199, 199, 3205, 2893, 334, 3183, 304, 199, 199, 30, 748, 8581, 7957, 14, 18, 699, 645, 778, 527, 1007, 280, 14392, 406, 17277, 499, 199, 619, 19640, 1481, 12756, 19640, 21939, 31721, 619, 2571, 23589, 14083, 1481, 19859, 1348, 20768, 17789, 5708, 1348, 11712, 1348, 3263, 1348, 2571, 1028, 8391, 2916, 32295, 14083, 21939, 52, 199, 52, 3263, 1348, 14083, 1481, 8391, 18636, 19640, 8391, 2916, 2751, 1254, 21585, 6332, 33, 199, 30, 748, 8581, 7957, 14, 19, 699, 645, 778, 527, 1007, 280, 14392, 406, 17277, 650, 199, 619, 19640, 1481, 12756, 19640, 21939, 31721, 619, 2571, 23589, 14083, 1481, 19859, 1348, 20768, 17789, 5708, 1348, 11712, 1348, 3263, 1348, 2571, 1028, 8391, 2916, 32295, 14083, 21939, 52, 199, 52, 3263, 1348, 14083, 1481, 8391, 18636, 19640, 8391, 2916, 2751, 1254, 21585, 6332, 32295, 7372, 21585, 3263, 1254, 1028, 1028, 4064, 30545, 17789, 17569, 52, 11712, 619, 17789, 39, 6332, 30545, 199, 52, 2276, 1028, 1028, 6332, 11712, 3036, 33, 24355, 1028, 1348, 19640, 27911, 19640, 619, 2571, 1348, 19899, 6332, 17569, 2751, 1254, 1481, 8391, 2916, 21585, 17789, 29154, 23589, 1028, 26422, 199, 199, 2959, 26, 199, 748, 8581, 7957, 14, 18, 259, 473, 8021, 258, 406, 17277, 420, 413, 755, 2948, 30896, 221, 1275, 755, 1275, 755, 1275, 755, 2870, 29, 748, 8581, 7957, 14, 18, 27, 985, 29, 30584, 778, 527, 1007, 280, 14392, 406, 17277, 499, 199, 748, 8581, 7957, 14, 19, 259, 473, 8021, 258, 406, 17277, 420, 413, 755, 6546, 996, 1085, 221, 1275, 755, 1275, 755, 1275, 755, 2870, 29, 748, 8581, 7957, 14, 19, 27, 985, 29, 30584, 778, 527, 1007, 280, 14392, 406, 17277, 650, 199, 199, 1918, 574, 402, 314, 499, 977, 2763, 365, 1536, 370, 1265, 436, 3247, 1808, 314, 1553, 1365, 2725, 14, 199, 199, 624, 199, 199, 646, 7534, 199, 199, 504, 28897, 600, 492, 3778, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1369, 534, 10607, 282, 598, 1665, 19, 570, 687, 282, 3805, 676, 530, 481, 11307, 33, 358, 339, 925, 1072, 570, 370, 506, 5313, 272, 1798, 14, 525, 63, 2094, 3654, 73, 297, 2850, 1210, 63, 20309, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2042, 370, 376, 1324, 570, 370, 506, 1586, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 63, 71, 556, 19, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2042, 370, 376, 1072, 570, 370, 506, 2737, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 1365, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2980, 12, 1794, 478, 2763, 499, 402, 314, 1072, 598, 1665, 19, 570, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 26310, 63, 5125, 297, 730, 29, 495, 12, 1415, 29, 797, 12, 849, 534, 27952, 297, 1720, 534, 4118, 6707, 370, 2954, 3805, 676, 530, 3414, 730, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 402, 72, 275, 1551, 8, 589, 14, 1199, 63, 71, 556, 19, 12, 283, 9115, 358, 272, 5412, 83, 275, 3778, 14, 20309, 63, 807, 63, 504, 63, 493, 8, 589, 14, 1210, 63, 20309, 9, 339, 327, 1406, 272, 402, 72, 14, 952, 480, 309, 71, 556, 13, 1023, 650, 60, 78, 531, 339, 367, 5412, 63, 344, 315, 5412, 83, 26, 267, 402, 72, 14, 952, 13076, 16, 4988, 84, 91, 17, 4988, 84, 91, 18, 4988, 84, 17, 60, 84, 91, 19, 4988, 84, 3134, 84, 3134, 84, 3134, 84, 998, 3126, 16, 5469, 908, 8, 3610, 63, 344, 12, 1249, 14, 1365, 12, 1249, 14, 26310, 63, 5125, 12, 822, 8, 19467, 59, 3610, 63, 344, 2733, 83, 26991, 2728, 340, 822, 8, 19467, 59, 3610, 63, 344, 2733, 72, 1105, 690, 378, 26, 288, 402, 72, 14, 952, 480, 27, 985, 3126, 16, 5469, 908, 8, 19467, 59, 3610, 63, 344, 2733, 72, 5156, 398, 402, 72, 14, 952, 4582, 78, 531, 1467, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 17344, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 199, 199, 2765, 2884, 15194, 626, 314, 1324, 481, 11307, 33, 8469, 3805, 676, 530, 3414, 436, 8491, 199, 65, 598, 1665, 19, 570, 367, 3520, 12, 477, 1647, 402, 7003, 1163, 2419, 10069, 4730, 367, 1924, 199, 26310, 14, 221, 2779, 365, 10826, 1163, 10358, 911, 1050, 370, 642, 14, 199, 199, 3205, 2893, 334, 3183, 304, 199, 199, 30, 748, 8581, 7957, 14, 18, 699, 645, 778, 527, 1007, 280, 14392, 406, 17277, 499, 199, 619, 19640, 1481, 12756, 19640, 21939, 31721, 619, 2571, 23589, 14083, 1481, 19859, 1348, 20768, 17789, 5708, 1348, 11712, 1348, 3263, 1348, 2571, 1028, 8391, 2916, 32295, 14083, 21939, 52, 199, 52, 3263, 1348, 14083, 1481, 8391, 18636, 19640, 8391, 2916, 2751, 1254, 21585, 6332, 33, 199, 30, 748, 8581, 7957, 14, 19, 699, 645, 778, 527, 1007, 280, 14392, 406, 17277, 650, 199, 619, 19640, 1481, 12756, 19640, 21939, 31721, 619, 2571, 23589, 14083, 1481, 19859, 1348, 20768, 17789, 5708, 1348, 11712, 1348, 3263, 1348, 2571, 1028, 8391, 2916, 32295, 14083, 21939, 52, 199, 52, 3263, 1348, 14083, 1481, 8391, 18636, 19640, 8391, 2916, 2751, 1254, 21585, 6332, 32295, 7372, 21585, 3263, 1254, 1028, 1028, 4064, 30545, 17789, 17569, 52, 11712, 619, 17789, 39, 6332, 30545, 199, 52, 2276, 1028, 1028, 6332, 11712, 3036, 33, 24355, 1028, 1348, 19640, 27911, 19640, 619, 2571, 1348, 19899, 6332, 17569, 2751, 1254, 1481, 8391, 2916, 21585, 17789, 29154, 23589, 1028, 26422, 199, 199, 2959, 26, 199, 748, 8581, 7957, 14, 18, 259, 473, 8021, 258, 406, 17277, 420, 413, 755, 2948, 30896, 221, 1275, 755, 1275, 755, 1275, 755, 2870, 29, 748, 8581, 7957, 14, 18, 27, 985, 29, 30584, 778, 527, 1007, 280, 14392, 406, 17277, 499, 199, 748, 8581, 7957, 14, 19, 259, 473, 8021, 258, 406, 17277, 420, 413, 755, 6546, 996, 1085, 221, 1275, 755, 1275, 755, 1275, 755, 2870, 29, 748, 8581, 7957, 14, 19, 27, 985, 29, 30584, 778, 527, 1007, 280, 14392, 406, 17277, 650, 199, 199, 1918, 574, 402, 314, 499, 977, 2763, 365, 1536, 370, 1265, 436, 3247, 1808, 314, 1553, 1365, 2725, 14, 199, 199, 624, 199, 199, 646, 7534, 199, 199, 504, 28897, 600, 492, 3778, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1369, 534, 10607, 282, 598, 1665, 19, 570, 687, 282, 3805, 676, 530, 481, 11307, 33, 358, 339, 925, 1072, 570, 370, 506, 5313, 272, 1798, 14, 525, 63, 2094, 3654, 73, 297, 2850, 1210, 63, 20309, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2042, 370, 376, 1324, 570, 370, 506, 1586, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 63, 71, 556, 19, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2042, 370, 376, 1072, 570, 370, 506, 2737, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 83, 297, 2850, 1365, 297, 730, 29, 495, 12, 1415, 29, 549, 12, 1720, 534, 2980, 12, 1794, 478, 2763, 499, 402, 314, 1072, 598, 1665, 19, 570, 7, 776, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 26310, 63, 5125, 297, 730, 29, 495, 12, 1415, 29, 797, 12, 849, 534, 27952, 297, 1720, 534, 4118, 6707, 370, 2954, 3805, 676, 530, 3414, 730, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 402, 72, 275, 1551, 8, 589, 14, 1199, 63, 71, 556, 19, 12, 283, 9115, 358, 272, 5412, 83, 275, 3778, 14, 20309, 63, 807, 63, 504, 63, 493, 8, 589, 14, 1210, 63, 20309, 9, 339, 327, 1406, 272, 402, 72, 14, 952, 480, 309, 71, 556, 13, 1023, 650, 60, 78, 531, 339, 367, 5412, 63, 344, 315, 5412, 83, 26, 267, 402, 72, 14, 952, 13076, 16, 4988, 84, 91, 17, 4988, 84, 91, 18, 4988, 84, 17, 60, 84, 91, 19, 4988, 84, 3134, 84, 3134, 84, 3134, 84, 998, 3126, 16, 5469, 908, 8, 3610, 63, 344, 12, 1249, 14, 1365, 12, 1249, 14, 26310, 63, 5125, 12, 822, 8, 19467, 59, 3610, 63, 344, 2733, 83, 26991, 2728, 340, 822, 8, 19467, 59, 3610, 63, 344, 2733, 72, 1105, 690, 378, 26, 288, 402, 72, 14, 952, 480, 27, 985, 3126, 16, 5469, 908, 8, 19467, 59, 3610, 63, 344, 2733, 72, 5156, 398, 402, 72, 14, 952, 4582, 78, 531, 1467, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 17344, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0 ]
VitalPet/8-addonsddrap
project_scrum/report/task_burndown.py
15
3549
# -*- 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 StringIO from report.render import render from report.interface import report_int from datetime import datetime import time from pychart import * import pychart.legend import _burndown class report_tasks(report_int): def create(self, cr, uid, ids, datas, context=None): if context is None: context = {} io = StringIO.StringIO() if 'date_start' not in datas: cr.execute('select min(date_start) from project_task where id IN %s',(tuple(ids),)) dt = cr.fetchone()[0] if dt: datas['date_start'] = dt[:10] else: datas['date_start'] = time.strftime('%Y-%m-%d') if 'date_stop' not in datas: cr.execute('select max(date_start),max(date_end) from project_task where id IN %s',(tuple(ids),)) res = cr.fetchone() datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d') if res[1] and datas['date_stop']<res[1]: datas['date_stop'] = res[1][:10] datas = _burndown.compute_burndown(cr, uid, ids, datas['date_start'], datas['date_stop']) canv = canvas.init(fname=io, format='pdf') canv.set_author("OpenERP") max_hour = reduce(lambda x,y: max(y[1],x), datas, 0) int_to_date = lambda x: '/a60{}' + datetime(time.localtime(x).tm_year, time.localtime(x).tm_mon, time.localtime(x).tm_mday).strftime('%d %m %Y') def _interval_get(*args): result = set() for i in range(20): d = time.localtime(datas[0][0] + (((datas[-1][0]-datas[0][0])/20)*(i+1))) res = time.mktime(d) result.add(res) return list(result) if datas[-1][0] == datas[0][0]: x_range = (datas[0][0],datas[-1][0]+1) else: x_range = (datas[0][0],datas[-1][0]) ar = area.T(x_grid_style=line_style.gray50_dash1, x_axis=axis.X(label="Date", format=int_to_date), y_axis=axis.Y(label="Burndown Chart - Planned Hours"), x_grid_interval=_interval_get, x_range = x_range, y_range = (0,max_hour), legend = None, size = (680,450)) ar.add_plot(line_plot.T(data=datas)) ar.draw(canv) canv.close() self.obj = _burndown.external_pdf(io.getvalue()) self.obj.render() return (self.obj.pdf,'pdf') report_tasks('report.project.tasks.burndown') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
gpl-2.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, 5228, 199, 504, 3622, 14, 3352, 492, 3795, 199, 504, 3622, 14, 3266, 492, 3622, 63, 442, 199, 504, 2197, 492, 2197, 199, 646, 900, 199, 504, 1134, 9019, 492, 627, 199, 646, 1134, 9019, 14, 10231, 199, 646, 485, 30736, 2110, 199, 199, 533, 3622, 63, 5054, 8, 3070, 63, 442, 304, 272, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 5890, 275, 5228, 14, 6424, 342, 398, 340, 283, 602, 63, 928, 7, 440, 315, 15012, 26, 288, 2467, 14, 2526, 360, 2416, 1748, 8, 602, 63, 928, 9, 687, 2199, 63, 1765, 2382, 1305, 1621, 450, 83, 297, 8, 2960, 8, 1580, 18399, 288, 4487, 275, 2467, 14, 11591, 3430, 16, 61, 288, 340, 4487, 26, 355, 15012, 459, 602, 63, 928, 418, 275, 4487, 1491, 709, 61, 288, 587, 26, 355, 15012, 459, 602, 63, 928, 418, 275, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 267, 340, 283, 602, 63, 2379, 7, 440, 315, 15012, 26, 288, 2467, 14, 2526, 360, 2416, 1390, 8, 602, 63, 928, 395, 988, 8, 602, 63, 500, 9, 687, 2199, 63, 1765, 2382, 1305, 1621, 450, 83, 297, 8, 2960, 8, 1580, 18399, 288, 522, 275, 2467, 14, 11591, 342, 288, 15012, 459, 602, 63, 2379, 418, 275, 334, 470, 59, 16, 61, 436, 522, 59, 16, 19663, 709, 566, 503, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 288, 340, 522, 59, 17, 61, 436, 15012, 459, 602, 63, 2379, 418, 28, 470, 59, 17, 2189, 355, 15012, 459, 602, 63, 2379, 418, 275, 522, 59, 17, 19663, 709, 61, 398, 15012, 275, 485, 30736, 2110, 14, 3357, 63, 30736, 2110, 8, 1556, 12, 1747, 12, 2762, 12, 15012, 459, 602, 63, 928, 995, 15012, 459, 602, 63, 2379, 1105, 267, 883, 86, 275, 10218, 14, 826, 8, 5252, 29, 2308, 12, 1475, 534, 5607, 358, 267, 883, 86, 14, 409, 63, 2502, 480, 25347, 531, 398, 1390, 63, 5180, 275, 7114, 8, 2734, 671, 12, 89, 26, 1390, 8, 89, 59, 17, 467, 88, 395, 15012, 12, 378, 9, 398, 1109, 63, 475, 63, 602, 275, 2400, 671, 26, 1994, 65, 2259, 2440, 7, 435, 2197, 8, 521, 14, 15198, 8, 88, 680, 7574, 63, 3403, 12, 900, 14, 15198, 8, 88, 680, 7574, 63, 2106, 12, 900, 14, 15198, 8, 88, 680, 7574, 63, 77, 2977, 680, 6205, 3508, 68, 450, 77, 450, 57, 358, 398, 347, 485, 4284, 63, 362, 2031, 589, 304, 288, 754, 275, 663, 342, 288, 367, 284, 315, 1425, 8, 1165, 304, 355, 366, 275, 900, 14, 15198, 8, 11563, 59, 16, 1527, 16, 61, 435, 20337, 11563, 1988, 17, 1527, 16, 11285, 11563, 59, 16, 1527, 16, 23067, 1165, 14397, 73, 11, 17, 1724, 355, 522, 275, 900, 14, 23456, 8, 68, 9, 355, 754, 14, 525, 8, 470, 9, 953, 372, 769, 8, 1099, 9, 398, 340, 15012, 1988, 17, 1527, 16, 61, 508, 15012, 59, 16, 1527, 16, 2189, 288, 671, 63, 1842, 275, 334, 11563, 59, 16, 1527, 16, 467, 11563, 1988, 17, 1527, 16, 2807, 17, 9, 267, 587, 26, 288, 671, 63, 1842, 275, 334, 11563, 59, 16, 1527, 16, 467, 11563, 1988, 17, 1527, 16, 566, 398, 601, 275, 9150, 14, 52, 8, 88, 63, 3825, 63, 2487, 29, 604, 63, 2487, 14, 12150, 1400, 63, 6760, 17, 12, 288, 671, 63, 3127, 29, 3127, 14, 56, 8, 1302, 628, 2506, 401, 1475, 29, 442, 63, 475, 63, 602, 395, 288, 612, 63, 3127, 29, 3127, 14, 57, 8, 1302, 628, 34, 349, 2110, 24874, 446, 7497, 9386, 869, 16363, 1288, 288, 671, 63, 3825, 63, 4284, 3699, 4284, 63, 362, 12, 288, 671, 63, 1842, 275, 671, 63, 1842, 12, 288, 612, 63, 1842, 275, 334, 16, 12, 988, 63, 5180, 395, 288, 15906, 275, 488, 12, 288, 1568, 275, 334, 29766, 12, 24223, 430, 267, 601, 14, 525, 63, 2798, 8, 604, 63, 2798, 14, 52, 8, 576, 29, 11563, 430, 267, 601, 14, 5485, 8, 29185, 9, 267, 883, 86, 14, 1600, 342, 398, 291, 14, 1113, 275, 485, 30736, 2110, 14, 5159, 63, 5607, 8, 2308, 14, 7150, 1012, 267, 291, 14, 1113, 14, 3352, 342, 267, 372, 334, 277, 14, 1113, 14, 5607, 2584, 5607, 358, 199, 3070, 63, 5054, 360, 3070, 14, 1715, 14, 5054, 14, 30736, 2110, 358, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 5228, 199, 504, 3622, 14, 3352, 492, 3795, 199, 504, 3622, 14, 3266, 492, 3622, 63, 442, 199, 504, 2197, 492, 2197, 199, 646, 900, 199, 504, 1134, 9019, 492, 627, 199, 646, 1134, 9019, 14, 10231, 199, 646, 485, 30736, 2110, 199, 199, 533, 3622, 63, 5054, 8, 3070, 63, 442, 304, 272, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 5890, 275, 5228, 14, 6424, 342, 398, 340, 283, 602, 63, 928, 7, 440, 315, 15012, 26, 288, 2467, 14, 2526, 360, 2416, 1748, 8, 602, 63, 928, 9, 687, 2199, 63, 1765, 2382, 1305, 1621, 450, 83, 297, 8, 2960, 8, 1580, 18399, 288, 4487, 275, 2467, 14, 11591, 3430, 16, 61, 288, 340, 4487, 26, 355, 15012, 459, 602, 63, 928, 418, 275, 4487, 1491, 709, 61, 288, 587, 26, 355, 15012, 459, 602, 63, 928, 418, 275, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 267, 340, 283, 602, 63, 2379, 7, 440, 315, 15012, 26, 288, 2467, 14, 2526, 360, 2416, 1390, 8, 602, 63, 928, 395, 988, 8, 602, 63, 500, 9, 687, 2199, 63, 1765, 2382, 1305, 1621, 450, 83, 297, 8, 2960, 8, 1580, 18399, 288, 522, 275, 2467, 14, 11591, 342, 288, 15012, 459, 602, 63, 2379, 418, 275, 334, 470, 59, 16, 61, 436, 522, 59, 16, 19663, 709, 566, 503, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 288, 340, 522, 59, 17, 61, 436, 15012, 459, 602, 63, 2379, 418, 28, 470, 59, 17, 2189, 355, 15012, 459, 602, 63, 2379, 418, 275, 522, 59, 17, 19663, 709, 61, 398, 15012, 275, 485, 30736, 2110, 14, 3357, 63, 30736, 2110, 8, 1556, 12, 1747, 12, 2762, 12, 15012, 459, 602, 63, 928, 995, 15012, 459, 602, 63, 2379, 1105, 267, 883, 86, 275, 10218, 14, 826, 8, 5252, 29, 2308, 12, 1475, 534, 5607, 358, 267, 883, 86, 14, 409, 63, 2502, 480, 25347, 531, 398, 1390, 63, 5180, 275, 7114, 8, 2734, 671, 12, 89, 26, 1390, 8, 89, 59, 17, 467, 88, 395, 15012, 12, 378, 9, 398, 1109, 63, 475, 63, 602, 275, 2400, 671, 26, 1994, 65, 2259, 2440, 7, 435, 2197, 8, 521, 14, 15198, 8, 88, 680, 7574, 63, 3403, 12, 900, 14, 15198, 8, 88, 680, 7574, 63, 2106, 12, 900, 14, 15198, 8, 88, 680, 7574, 63, 77, 2977, 680, 6205, 3508, 68, 450, 77, 450, 57, 358, 398, 347, 485, 4284, 63, 362, 2031, 589, 304, 288, 754, 275, 663, 342, 288, 367, 284, 315, 1425, 8, 1165, 304, 355, 366, 275, 900, 14, 15198, 8, 11563, 59, 16, 1527, 16, 61, 435, 20337, 11563, 1988, 17, 1527, 16, 11285, 11563, 59, 16, 1527, 16, 23067, 1165, 14397, 73, 11, 17, 1724, 355, 522, 275, 900, 14, 23456, 8, 68, 9, 355, 754, 14, 525, 8, 470, 9, 953, 372, 769, 8, 1099, 9, 398, 340, 15012, 1988, 17, 1527, 16, 61, 508, 15012, 59, 16, 1527, 16, 2189, 288, 671, 63, 1842, 275, 334, 11563, 59, 16, 1527, 16, 467, 11563, 1988, 17, 1527, 16, 2807, 17, 9, 267, 587, 26, 288, 671, 63, 1842, 275, 334, 11563, 59, 16, 1527, 16, 467, 11563, 1988, 17, 1527, 16, 566, 398, 601, 275, 9150, 14, 52, 8, 88, 63, 3825, 63, 2487, 29, 604, 63, 2487, 14, 12150, 1400, 63, 6760, 17, 12, 288, 671, 63, 3127, 29, 3127, 14, 56, 8, 1302, 628, 2506, 401, 1475, 29, 442, 63, 475, 63, 602, 395, 288, 612, 63, 3127, 29, 3127, 14, 57, 8, 1302, 628, 34, 349, 2110, 24874, 446, 7497, 9386, 869, 16363, 1288, 288, 671, 63, 3825, 63, 4284, 3699, 4284, 63, 362, 12, 288, 671, 63, 1842, 275, 671, 63, 1842, 12, 288, 612, 63, 1842, 275, 334, 16, 12, 988, 63, 5180, 395, 288, 15906, 275, 488, 12, 288, 1568, 275, 334, 29766, 12, 24223, 430, 267, 601, 14, 525, 63, 2798, 8, 604, 63, 2798, 14, 52, 8, 576, 29, 11563, 430, 267, 601, 14, 5485, 8, 29185, 9, 267, 883, 86, 14, 1600, 342, 398, 291, 14, 1113, 275, 485, 30736, 2110, 14, 5159, 63, 5607, 8, 2308, 14, 7150, 1012, 267, 291, 14, 1113, 14, 3352, 342, 267, 372, 334, 277, 14, 1113, 14, 5607, 2584, 5607, 358, 199, 3070, 63, 5054, 360, 3070, 14, 1715, 14, 5054, 14, 30736, 2110, 358, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
barachka/odoo
addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py
382
1726
########################################################################## # # Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com # Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>). # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # See: http://www.gnu.org/licenses/lgpl.html # ############################################################################## if __name__<>"package": from gui import * class ErrorDialog: def __init__(self, sErrorMsg, sErrorHelpMsg="", sTitle="Error Message"): self.win = DBModalDialog(50, 50, 150, 90, sTitle) self.win.addFixedText("lblErrMsg", 5, 5, 190, 25, sErrorMsg) self.win.addFixedText("lblErrHelpMsg", 5, 30, 190, 25, sErrorHelpMsg) self.win.addButton('btnOK', 55,-5,40,15,'Ok' ,actionListenerProc = self.btnOkOrCancel_clicked ) self.win.doModalDialog("",None) def btnOkOrCancel_clicked( self, oActionEvent ): self.win.endExecute() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 26863, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 257, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 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, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 4605, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 582, 272, 687, 11621, 492, 627, 199, 533, 4520, 5619, 26, 272, 347, 636, 826, 721, 277, 12, 308, 547, 6173, 12, 308, 547, 8673, 6173, 8772, 308, 6888, 628, 547, 6430, 2349, 267, 291, 14, 2676, 275, 6249, 23689, 5619, 8, 1400, 12, 5238, 12, 14711, 12, 9137, 12, 308, 6888, 9, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5432, 6173, 401, 959, 12, 959, 12, 29682, 12, 5661, 12, 308, 547, 6173, 9, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5432, 8673, 6173, 401, 959, 12, 4233, 12, 29682, 12, 5661, 12, 308, 547, 8673, 6173, 9, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 3593, 297, 12766, 3057, 21, 12, 2167, 12, 1046, 2584, 11622, 7, 2151, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 11622, 2844, 9083, 63, 11276, 776, 267, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 272, 347, 19368, 11622, 2844, 9083, 63, 11276, 8, 291, 12, 312, 3310, 2390, 3461, 267, 291, 14, 2676, 14, 500, 12049, 342, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 3, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 257, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 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, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 4605, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 582, 272, 687, 11621, 492, 627, 199, 533, 4520, 5619, 26, 272, 347, 636, 826, 721, 277, 12, 308, 547, 6173, 12, 308, 547, 8673, 6173, 8772, 308, 6888, 628, 547, 6430, 2349, 267, 291, 14, 2676, 275, 6249, 23689, 5619, 8, 1400, 12, 5238, 12, 14711, 12, 9137, 12, 308, 6888, 9, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5432, 6173, 401, 959, 12, 959, 12, 29682, 12, 5661, 12, 308, 547, 6173, 9, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5432, 8673, 6173, 401, 959, 12, 4233, 12, 29682, 12, 5661, 12, 308, 547, 8673, 6173, 9, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 3593, 297, 12766, 3057, 21, 12, 2167, 12, 1046, 2584, 11622, 7, 2151, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 11622, 2844, 9083, 63, 11276, 776, 267, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 272, 347, 19368, 11622, 2844, 9083, 63, 11276, 8, 291, 12, 312, 3310, 2390, 3461, 267, 291, 14, 2676, 14, 500, 12049, 342, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
TreeNote/TreeNote
treenote/util.py
1
2097
# source: http://daringfireball.net/2010/07/improved_regex_for_matching_urls url_regex = r"""(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\-][a-z0-9]+)*[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b/?(?!@)))"""
gpl-3.0
[ 3, 1350, 26, 1455, 921, 4460, 316, 8935, 8571, 14, 846, 15, 6542, 15, 1780, 15, 3236, 26429, 63, 3821, 63, 509, 63, 9467, 63, 3603, 199, 633, 63, 3821, 275, 519, 624, 2229, 73, 2862, 66, 17304, 26, 2859, 31, 26, 5169, 5321, 17, 12, 19, 93, 17884, 65, 13, 90, 16, 13, 25, 5, 566, 17884, 65, 13, 90, 16, 13, 25, 3134, 20253, 59, 19784, 5169, 957, 92, 846, 92, 1308, 92, 8654, 92, 16294, 92, 77, 382, 92, 65, 3478, 92, 305, 4674, 92, 66, 565, 92, 3385, 92, 331, 411, 92, 815, 92, 442, 92, 6920, 92, 573, 4492, 92, 77, 1180, 453, 92, 354, 92, 1932, 92, 496, 92, 14146, 92, 1239, 1090, 92, 10013, 92, 645, 92, 350, 92, 3624, 92, 2756, 92, 643, 92, 5789, 92, 279, 92, 455, 92, 290, 92, 8035, 92, 30030, 92, 285, 92, 305, 92, 292, 92, 3844, 92, 10084, 92, 1219, 92, 4651, 92, 2470, 92, 2501, 92, 3691, 92, 1235, 92, 4361, 92, 6856, 92, 26397, 92, 4492, 92, 468, 92, 12648, 92, 10472, 92, 656, 92, 3289, 92, 1533, 92, 13061, 92, 23064, 92, 12415, 92, 991, 92, 10582, 92, 696, 92, 2055, 92, 2866, 92, 2177, 92, 12595, 92, 335, 92, 559, 92, 346, 92, 429, 92, 4400, 92, 6413, 92, 331, 92, 1556, 92, 1259, 92, 15140, 92, 5107, 92, 11859, 92, 1480, 92, 16823, 92, 617, 92, 271, 92, 18256, 92, 6341, 92, 6428, 92, 1117, 92, 17019, 92, 825, 92, 1024, 92, 5902, 92, 24528, 92, 281, 92, 397, 92, 386, 92, 16913, 92, 329, 92, 70, 74, 92, 9010, 92, 10886, 92, 545, 92, 4391, 92, 5294, 92, 4908, 92, 7136, 92, 303, 92, 7102, 92, 2721, 92, 3561, 92, 6153, 92, 3528, 92, 13844, 92, 784, 92, 4927, 92, 71, 81, 92, 2587, 92, 458, 92, 3308, 92, 6051, 92, 8392, 92, 4312, 92, 21557, 92, 14038, 92, 6164, 92, 6271, 92, 517, 92, 10616, 92, 344, 92, 1873, 92, 382, 92, 1017, 92, 262, 92, 2308, 92, 9962, 92, 723, 92, 374, 92, 390, 92, 6532, 92, 74, 77, 92, 743, 92, 11538, 92, 415, 92, 9761, 92, 21889, 92, 8810, 92, 14595, 92, 18974, 92, 25017, 92, 16779, 92, 829, 92, 10562, 92, 75, 90, 92, 416, 92, 6374, 92, 10181, 92, 317, 92, 23333, 92, 7493, 92, 478, 92, 4116, 92, 10836, 92, 6371, 92, 590, 92, 391, 92, 5466, 92, 1064, 92, 278, 92, 6649, 92, 17077, 92, 3880, 92, 757, 92, 596, 92, 10344, 92, 573, 92, 311, 92, 8334, 92, 13118, 92, 706, 92, 2037, 92, 6553, 92, 12393, 92, 14716, 92, 9457, 92, 1662, 92, 28808, 92, 3540, 92, 7966, 92, 685, 92, 9914, 92, 2753, 92, 8445, 92, 7530, 92, 889, 92, 1590, 92, 7865, 92, 4850, 92, 15291, 92, 676, 92, 387, 92, 321, 92, 9928, 92, 4198, 92, 838, 92, 2051, 92, 1168, 92, 7073, 92, 4812, 92, 2700, 92, 1190, 92, 541, 92, 8796, 92, 647, 92, 7096, 92, 264, 92, 293, 92, 2393, 92, 6558, 92, 13057, 92, 2231, 92, 9264, 92, 551, 92, 3893, 92, 261, 92, 1226, 92, 609, 92, 338, 92, 83, 74, 92, 42, 65, 92, 1339, 92, 2482, 92, 3300, 92, 5167, 92, 1152, 92, 5474, 92, 385, 92, 270, 92, 9648, 92, 2772, 92, 12915, 92, 1786, 92, 11803, 92, 3641, 92, 2076, 92, 3249, 92, 17699, 92, 273, 92, 84, 74, 92, 2663, 92, 5019, 92, 7574, 92, 5889, 92, 475, 92, 683, 92, 454, 92, 6215, 92, 6993, 92, 8122, 92, 3903, 92, 1458, 92, 1518, 92, 3210, 92, 527, 92, 29514, 92, 9494, 92, 3042, 92, 6737, 92, 432, 92, 10929, 92, 433, 92, 6002, 92, 86, 85, 92, 14114, 92, 3569, 92, 8048, 92, 24264, 92, 16366, 92, 8076, 92, 90, 77, 92, 90, 87, 2447, 9, 5169, 16045, 83, 342, 16137, 24423, 7023, 2677, 11, 6113, 21690, 83, 342, 3672, 8995, 21690, 83, 342, 24621, 2788, 12773, 83, 342, 3672, 8995, 9, 6113, 21690, 83, 2807, 8995, 430, 11, 15840, 21690, 83, 342, 3672, 8995, 21690, 83, 342, 24621, 2788, 12773, 83, 342, 3672, 8995, 9, 6113, 21690, 83, 2807, 8995, 8636, 16045, 83, 64, 1, 17158, 7023, 61, 2440, 27, 4881, 1674, 12, 16137, 31, 127, 105, 127, 120, 8477, 251, 8477, 252, 8477, 247, 21045, 566, 92, 5169, 2229, 11230, 32, 2788, 65, 13, 90, 16, 13, 25, 2807, 25060, 3134, 13, 1527, 65, 13, 90, 16, 13, 25, 2807, 3342, 59, 19784, 5169, 957, 92, 846, 92, 1308, 92, 8654, 92, 16294, 92, 77, 382, 92, 65, 3478, 92, 305, 4674, 92, 66, 565, 92, 3385, 92, 331, 411, 92, 815, 92, 442, 92, 6920, 92, 573, 4492, 92, 77, 1180, 453, 92, 354, 92, 1932, 92, 496, 92, 14146, 92, 1239, 1090, 92, 10013, 92, 645, 92, 350, 92, 3624, 92, 2756, 92, 643, 92, 5789, 92, 279, 92, 455, 92, 290, 92, 8035, 92, 30030, 92, 285, 92, 305, 92, 292, 92, 3844, 92, 10084, 92, 1219, 92, 4651, 92, 2470, 92, 2501, 92, 3691, 92, 1235, 92, 4361, 92, 6856, 92, 26397, 92, 4492, 92, 468, 92, 12648, 92, 10472, 92, 656, 92, 3289, 92, 1533, 92, 13061, 92, 23064, 92, 12415, 92, 991, 92, 10582, 92, 696, 92, 2055, 92, 2866, 92, 2177, 92, 12595, 92, 335, 92, 559, 92, 346, 92, 429, 92, 4400, 92, 6413, 92, 331, 92, 1556, 92, 1259, 92, 15140, 92, 5107, 92, 11859, 92, 1480, 92, 16823, 92, 617, 92, 271, 92, 18256, 92, 6341, 92, 6428, 92, 1117, 92, 17019, 92, 825, 92, 1024, 92, 5902, 92, 24528, 92, 281, 92, 397, 92, 386, 92, 16913, 92, 329, 92, 70, 74, 92, 9010, 92, 10886, 92, 545, 92, 4391, 92, 5294, 92, 4908, 92, 7136, 92, 303, 92, 7102, 92, 2721, 92, 3561, 92, 6153, 92, 3528, 92, 13844, 92, 784, 92, 4927, 92, 71, 81, 92, 2587, 92, 458, 92, 3308, 92, 6051, 92, 8392, 92, 4312, 92, 21557, 92, 14038, 92, 6164, 92, 6271, 92, 517, 92, 10616, 92, 344, 92, 1873, 92, 382, 92, 1017, 92, 262, 92, 2308, 92, 9962, 92 ]
[ 1350, 26, 1455, 921, 4460, 316, 8935, 8571, 14, 846, 15, 6542, 15, 1780, 15, 3236, 26429, 63, 3821, 63, 509, 63, 9467, 63, 3603, 199, 633, 63, 3821, 275, 519, 624, 2229, 73, 2862, 66, 17304, 26, 2859, 31, 26, 5169, 5321, 17, 12, 19, 93, 17884, 65, 13, 90, 16, 13, 25, 5, 566, 17884, 65, 13, 90, 16, 13, 25, 3134, 20253, 59, 19784, 5169, 957, 92, 846, 92, 1308, 92, 8654, 92, 16294, 92, 77, 382, 92, 65, 3478, 92, 305, 4674, 92, 66, 565, 92, 3385, 92, 331, 411, 92, 815, 92, 442, 92, 6920, 92, 573, 4492, 92, 77, 1180, 453, 92, 354, 92, 1932, 92, 496, 92, 14146, 92, 1239, 1090, 92, 10013, 92, 645, 92, 350, 92, 3624, 92, 2756, 92, 643, 92, 5789, 92, 279, 92, 455, 92, 290, 92, 8035, 92, 30030, 92, 285, 92, 305, 92, 292, 92, 3844, 92, 10084, 92, 1219, 92, 4651, 92, 2470, 92, 2501, 92, 3691, 92, 1235, 92, 4361, 92, 6856, 92, 26397, 92, 4492, 92, 468, 92, 12648, 92, 10472, 92, 656, 92, 3289, 92, 1533, 92, 13061, 92, 23064, 92, 12415, 92, 991, 92, 10582, 92, 696, 92, 2055, 92, 2866, 92, 2177, 92, 12595, 92, 335, 92, 559, 92, 346, 92, 429, 92, 4400, 92, 6413, 92, 331, 92, 1556, 92, 1259, 92, 15140, 92, 5107, 92, 11859, 92, 1480, 92, 16823, 92, 617, 92, 271, 92, 18256, 92, 6341, 92, 6428, 92, 1117, 92, 17019, 92, 825, 92, 1024, 92, 5902, 92, 24528, 92, 281, 92, 397, 92, 386, 92, 16913, 92, 329, 92, 70, 74, 92, 9010, 92, 10886, 92, 545, 92, 4391, 92, 5294, 92, 4908, 92, 7136, 92, 303, 92, 7102, 92, 2721, 92, 3561, 92, 6153, 92, 3528, 92, 13844, 92, 784, 92, 4927, 92, 71, 81, 92, 2587, 92, 458, 92, 3308, 92, 6051, 92, 8392, 92, 4312, 92, 21557, 92, 14038, 92, 6164, 92, 6271, 92, 517, 92, 10616, 92, 344, 92, 1873, 92, 382, 92, 1017, 92, 262, 92, 2308, 92, 9962, 92, 723, 92, 374, 92, 390, 92, 6532, 92, 74, 77, 92, 743, 92, 11538, 92, 415, 92, 9761, 92, 21889, 92, 8810, 92, 14595, 92, 18974, 92, 25017, 92, 16779, 92, 829, 92, 10562, 92, 75, 90, 92, 416, 92, 6374, 92, 10181, 92, 317, 92, 23333, 92, 7493, 92, 478, 92, 4116, 92, 10836, 92, 6371, 92, 590, 92, 391, 92, 5466, 92, 1064, 92, 278, 92, 6649, 92, 17077, 92, 3880, 92, 757, 92, 596, 92, 10344, 92, 573, 92, 311, 92, 8334, 92, 13118, 92, 706, 92, 2037, 92, 6553, 92, 12393, 92, 14716, 92, 9457, 92, 1662, 92, 28808, 92, 3540, 92, 7966, 92, 685, 92, 9914, 92, 2753, 92, 8445, 92, 7530, 92, 889, 92, 1590, 92, 7865, 92, 4850, 92, 15291, 92, 676, 92, 387, 92, 321, 92, 9928, 92, 4198, 92, 838, 92, 2051, 92, 1168, 92, 7073, 92, 4812, 92, 2700, 92, 1190, 92, 541, 92, 8796, 92, 647, 92, 7096, 92, 264, 92, 293, 92, 2393, 92, 6558, 92, 13057, 92, 2231, 92, 9264, 92, 551, 92, 3893, 92, 261, 92, 1226, 92, 609, 92, 338, 92, 83, 74, 92, 42, 65, 92, 1339, 92, 2482, 92, 3300, 92, 5167, 92, 1152, 92, 5474, 92, 385, 92, 270, 92, 9648, 92, 2772, 92, 12915, 92, 1786, 92, 11803, 92, 3641, 92, 2076, 92, 3249, 92, 17699, 92, 273, 92, 84, 74, 92, 2663, 92, 5019, 92, 7574, 92, 5889, 92, 475, 92, 683, 92, 454, 92, 6215, 92, 6993, 92, 8122, 92, 3903, 92, 1458, 92, 1518, 92, 3210, 92, 527, 92, 29514, 92, 9494, 92, 3042, 92, 6737, 92, 432, 92, 10929, 92, 433, 92, 6002, 92, 86, 85, 92, 14114, 92, 3569, 92, 8048, 92, 24264, 92, 16366, 92, 8076, 92, 90, 77, 92, 90, 87, 2447, 9, 5169, 16045, 83, 342, 16137, 24423, 7023, 2677, 11, 6113, 21690, 83, 342, 3672, 8995, 21690, 83, 342, 24621, 2788, 12773, 83, 342, 3672, 8995, 9, 6113, 21690, 83, 2807, 8995, 430, 11, 15840, 21690, 83, 342, 3672, 8995, 21690, 83, 342, 24621, 2788, 12773, 83, 342, 3672, 8995, 9, 6113, 21690, 83, 2807, 8995, 8636, 16045, 83, 64, 1, 17158, 7023, 61, 2440, 27, 4881, 1674, 12, 16137, 31, 127, 105, 127, 120, 8477, 251, 8477, 252, 8477, 247, 21045, 566, 92, 5169, 2229, 11230, 32, 2788, 65, 13, 90, 16, 13, 25, 2807, 25060, 3134, 13, 1527, 65, 13, 90, 16, 13, 25, 2807, 3342, 59, 19784, 5169, 957, 92, 846, 92, 1308, 92, 8654, 92, 16294, 92, 77, 382, 92, 65, 3478, 92, 305, 4674, 92, 66, 565, 92, 3385, 92, 331, 411, 92, 815, 92, 442, 92, 6920, 92, 573, 4492, 92, 77, 1180, 453, 92, 354, 92, 1932, 92, 496, 92, 14146, 92, 1239, 1090, 92, 10013, 92, 645, 92, 350, 92, 3624, 92, 2756, 92, 643, 92, 5789, 92, 279, 92, 455, 92, 290, 92, 8035, 92, 30030, 92, 285, 92, 305, 92, 292, 92, 3844, 92, 10084, 92, 1219, 92, 4651, 92, 2470, 92, 2501, 92, 3691, 92, 1235, 92, 4361, 92, 6856, 92, 26397, 92, 4492, 92, 468, 92, 12648, 92, 10472, 92, 656, 92, 3289, 92, 1533, 92, 13061, 92, 23064, 92, 12415, 92, 991, 92, 10582, 92, 696, 92, 2055, 92, 2866, 92, 2177, 92, 12595, 92, 335, 92, 559, 92, 346, 92, 429, 92, 4400, 92, 6413, 92, 331, 92, 1556, 92, 1259, 92, 15140, 92, 5107, 92, 11859, 92, 1480, 92, 16823, 92, 617, 92, 271, 92, 18256, 92, 6341, 92, 6428, 92, 1117, 92, 17019, 92, 825, 92, 1024, 92, 5902, 92, 24528, 92, 281, 92, 397, 92, 386, 92, 16913, 92, 329, 92, 70, 74, 92, 9010, 92, 10886, 92, 545, 92, 4391, 92, 5294, 92, 4908, 92, 7136, 92, 303, 92, 7102, 92, 2721, 92, 3561, 92, 6153, 92, 3528, 92, 13844, 92, 784, 92, 4927, 92, 71, 81, 92, 2587, 92, 458, 92, 3308, 92, 6051, 92, 8392, 92, 4312, 92, 21557, 92, 14038, 92, 6164, 92, 6271, 92, 517, 92, 10616, 92, 344, 92, 1873, 92, 382, 92, 1017, 92, 262, 92, 2308, 92, 9962, 92, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fzsens/zookeeper
src/contrib/zkpython/src/test/create_test.py
164
4170
#!/usr/bin/python # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import zookeeper, zktestbase, unittest, threading ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"} class CreationTest(zktestbase.TestBase): """Test whether we can create znodes""" # to do: startup and teardown via scripts? def setUp(self): zktestbase.TestBase.setUp(self) try: zookeeper.delete(self.handle, "/zk-python-createtest") zookeeper.delete(self.handle, "/zk-python-acreatetest") except: pass def test_sync_create(self): self.assertEqual(self.connected, True) ret = zookeeper.create(self.handle, "/zk-python-createtest", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL) self.assertEqual(ret, "/zk-python-createtest") self.assertRaises(zookeeper.NoChildrenForEphemeralsException, zookeeper.create, self.handle, "/zk-python-createtest/invalid-child", "", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL) def test_sync_create_existing(self): self.assertEqual(self.connected, True) ret = zookeeper.create(self.handle, "/zk-python-createtest-existing", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL) self.assertEqual(ret, "/zk-python-createtest-existing") self.assertRaises(zookeeper.NodeExistsException, zookeeper.create, self.handle, "/zk-python-createtest-existing", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL) def test_exception_paths(self): """ Make sure common exceptions due to API misuse are correctly propogated """ self.assertRaises(zookeeper.BadArgumentsException, zookeeper.create, self.handle, "/zk-python-badargs-test", "", [ZOO_OPEN_ACL_UNSAFE], -1) self.assertRaises(zookeeper.InvalidACLException, zookeeper.create, self.handle, "/zk-python-invalidacl-test", "", ZOO_OPEN_ACL_UNSAFE) # Error - not a list def test_async_create(self): self.cv = threading.Condition() def callback(handle, rc, value): self.cv.acquire() self.callback_flag = True self.rc = rc self.cv.notify() self.cv.release() self.assertEqual(self.connected, True, "Not connected!") self.cv.acquire() ret = zookeeper.acreate(self.handle, "/zk-python-acreatetest", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL, callback ) self.assertEqual(ret, zookeeper.OK, "acreate failed") while not self.callback_flag: self.cv.wait(15) self.cv.release() self.assertEqual(self.callback_flag, True, "acreate timed out") self.assertEqual(self.rc, zookeeper.OK) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 221, 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, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 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, 1315, 23479, 12, 1315, 75, 396, 1095, 12, 2882, 12, 5796, 199, 199, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 275, 2420, 12068, 582, 16, 88, 17, 70, 12, 298, 5512, 5122, 7617, 401, 298, 344, 2, 26673, 1629, 368, 3570, 199, 199, 533, 9750, 425, 774, 8, 20344, 396, 1095, 14, 14440, 304, 272, 408, 774, 3775, 781, 883, 1218, 1315, 2415, 624, 272, 327, 370, 886, 26, 14210, 436, 17558, 4799, 10554, 31, 272, 347, 3613, 8, 277, 304, 267, 1315, 75, 396, 1095, 14, 14440, 14, 5996, 8, 277, 9, 267, 862, 26, 288, 1315, 23479, 14, 1807, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 531, 288, 1315, 23479, 14, 1807, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 645, 622, 396, 531, 267, 871, 26, 288, 986, 339, 347, 511, 63, 5186, 63, 981, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 9, 267, 2203, 275, 1315, 23479, 14, 981, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 401, 298, 932, 4407, 401, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 267, 291, 14, 629, 8, 3292, 12, 3286, 20344, 13, 1548, 13, 981, 396, 531, 267, 291, 14, 1855, 8, 90, 23479, 14, 1944, 7139, 1858, 14057, 13616, 2551, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 981, 396, 15, 3197, 13, 1739, 401, 2079, 4873, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 339, 347, 511, 63, 5186, 63, 981, 63, 5952, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 9, 267, 2203, 275, 1315, 23479, 14, 981, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 401, 298, 932, 4407, 401, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 267, 291, 14, 629, 8, 3292, 12, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 531, 398, 291, 14, 1855, 8, 90, 23479, 14, 1716, 7965, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 401, 2079, 298, 932, 4407, 401, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 2378, 347, 511, 63, 1971, 63, 3771, 8, 277, 304, 267, 408, 267, 4155, 3238, 2863, 4967, 7037, 370, 3261, 3201, 1180, 787, 6657, 557, 555, 71, 972, 267, 408, 267, 291, 14, 1855, 8, 90, 23479, 14, 5725, 14517, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 4087, 589, 13, 396, 401, 2079, 4873, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 446, 17, 9, 267, 291, 14, 1855, 8, 90, 23479, 14, 3364, 1348, 906, 16010, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 3197, 5853, 13, 396, 401, 2079, 4873, 2079, 3107, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 9, 327, 4520, 446, 440, 282, 769, 2378, 347, 511, 63, 4146, 63, 981, 8, 277, 304, 267, 291, 14, 5107, 275, 5796, 14, 9558, 342, 267, 347, 3233, 8, 2479, 12, 4819, 12, 574, 304, 288, 291, 14, 5107, 14, 8174, 342, 288, 291, 14, 3058, 63, 4173, 275, 715, 288, 291, 14, 1195, 275, 4819, 288, 291, 14, 5107, 14, 6814, 342, 288, 291, 14, 5107, 14, 3221, 342, 398, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 12, 298, 1763, 8539, 9124, 267, 291, 14, 5107, 14, 8174, 342, 398, 2203, 275, 1315, 23479, 14, 645, 622, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 645, 622, 396, 401, 298, 932, 4407, 401, 1816, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 12, 1816, 3233, 776, 267, 291, 14, 629, 8, 3292, 12, 1315, 23479, 14, 3593, 12, 298, 645, 622, 3405, 531, 267, 1830, 440, 291, 14, 3058, 63, 4173, 26, 288, 291, 14, 5107, 14, 2573, 8, 1046, 9, 267, 291, 14, 5107, 14, 3221, 342, 398, 291, 14, 629, 8, 277, 14, 3058, 63, 4173, 12, 715, 12, 298, 645, 622, 18590, 734, 531, 267, 291, 14, 629, 8, 277, 14, 1195, 12, 1315, 23479, 14, 3593, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 221, 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, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 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, 1315, 23479, 12, 1315, 75, 396, 1095, 12, 2882, 12, 5796, 199, 199, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 275, 2420, 12068, 582, 16, 88, 17, 70, 12, 298, 5512, 5122, 7617, 401, 298, 344, 2, 26673, 1629, 368, 3570, 199, 199, 533, 9750, 425, 774, 8, 20344, 396, 1095, 14, 14440, 304, 272, 408, 774, 3775, 781, 883, 1218, 1315, 2415, 624, 272, 327, 370, 886, 26, 14210, 436, 17558, 4799, 10554, 31, 272, 347, 3613, 8, 277, 304, 267, 1315, 75, 396, 1095, 14, 14440, 14, 5996, 8, 277, 9, 267, 862, 26, 288, 1315, 23479, 14, 1807, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 531, 288, 1315, 23479, 14, 1807, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 645, 622, 396, 531, 267, 871, 26, 288, 986, 339, 347, 511, 63, 5186, 63, 981, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 9, 267, 2203, 275, 1315, 23479, 14, 981, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 401, 298, 932, 4407, 401, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 267, 291, 14, 629, 8, 3292, 12, 3286, 20344, 13, 1548, 13, 981, 396, 531, 267, 291, 14, 1855, 8, 90, 23479, 14, 1944, 7139, 1858, 14057, 13616, 2551, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 981, 396, 15, 3197, 13, 1739, 401, 2079, 4873, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 339, 347, 511, 63, 5186, 63, 981, 63, 5952, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 9, 267, 2203, 275, 1315, 23479, 14, 981, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 401, 298, 932, 4407, 401, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 267, 291, 14, 629, 8, 3292, 12, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 531, 398, 291, 14, 1855, 8, 90, 23479, 14, 1716, 7965, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 981, 396, 13, 5952, 401, 2079, 298, 932, 4407, 401, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 1315, 23479, 14, 6102, 1645, 20263, 748, 9, 2378, 347, 511, 63, 1971, 63, 3771, 8, 277, 304, 267, 408, 267, 4155, 3238, 2863, 4967, 7037, 370, 3261, 3201, 1180, 787, 6657, 557, 555, 71, 972, 267, 408, 267, 291, 14, 1855, 8, 90, 23479, 14, 5725, 14517, 1726, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 4087, 589, 13, 396, 401, 2079, 4873, 2079, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 2079, 446, 17, 9, 267, 291, 14, 1855, 8, 90, 23479, 14, 3364, 1348, 906, 16010, 12, 2079, 1315, 23479, 14, 981, 12, 2079, 291, 14, 2479, 12, 2079, 3286, 20344, 13, 1548, 13, 3197, 5853, 13, 396, 401, 2079, 4873, 2079, 3107, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 9, 327, 4520, 446, 440, 282, 769, 2378, 347, 511, 63, 4146, 63, 981, 8, 277, 304, 267, 291, 14, 5107, 275, 5796, 14, 9558, 342, 267, 347, 3233, 8, 2479, 12, 4819, 12, 574, 304, 288, 291, 14, 5107, 14, 8174, 342, 288, 291, 14, 3058, 63, 4173, 275, 715, 288, 291, 14, 1195, 275, 4819, 288, 291, 14, 5107, 14, 6814, 342, 288, 291, 14, 5107, 14, 3221, 342, 398, 291, 14, 629, 8, 277, 14, 7113, 12, 715, 12, 298, 1763, 8539, 9124, 267, 291, 14, 5107, 14, 8174, 342, 398, 2203, 275, 1315, 23479, 14, 645, 622, 8, 277, 14, 2479, 12, 3286, 20344, 13, 1548, 13, 645, 622, 396, 401, 298, 932, 4407, 401, 1816, 359, 58, 5757, 63, 9935, 63, 18765, 63, 1734, 27657, 467, 1315, 23479, 14, 6102, 1645, 20263, 748, 12, 1816, 3233, 776, 267, 291, 14, 629, 8, 3292, 12, 1315, 23479, 14, 3593, 12, 298, 645, 622, 3405, 531, 267, 1830, 440, 291, 14, 3058, 63, 4173, 26, 288, 291, 14, 5107, 14, 2573, 8, 1046, 9, 267, 291, 14, 5107, 14, 3221, 342, 398, 291, 14, 629, 8, 277, 14, 3058, 63, 4173, 12, 715, 12, 298, 645, 622, 18590, 734, 531, 267, 291, 14, 629, 8, 277, 14, 1195, 12, 1315, 23479, 14, 3593, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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, 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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 ]
Gr1ph00n/staticwebanalyzer
SDK/dnspython-1.11.1/dns/node.py
49
6028
# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation 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 NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM 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. """DNS nodes. A node is a set of rdatasets.""" import StringIO import dns.rdataset import dns.rdatatype import dns.renderer class Node(object): """A DNS node. A node is a set of rdatasets @ivar rdatasets: the node's rdatasets @type rdatasets: list of dns.rdataset.Rdataset objects""" __slots__ = ['rdatasets'] def __init__(self): """Initialize a DNS node. """ self.rdatasets = []; def to_text(self, name, **kw): """Convert a node to text format. Each rdataset at the node is printed. Any keyword arguments to this method are passed on to the rdataset's to_text() method. @param name: the owner name of the rdatasets @type name: dns.name.Name object @rtype: string """ s = StringIO.StringIO() for rds in self.rdatasets: if len(rds) > 0: print >> s, rds.to_text(name, **kw) return s.getvalue()[:-1] def __repr__(self): return '<DNS node ' + str(id(self)) + '>' def __eq__(self, other): """Two nodes are equal if they have the same rdatasets. @rtype: bool """ # # This is inefficient. Good thing we don't need to do it much. # for rd in self.rdatasets: if rd not in other.rdatasets: return False for rd in other.rdatasets: if rd not in self.rdatasets: return False return True def __ne__(self, other): return not self.__eq__(other) def __len__(self): return len(self.rdatasets) def __iter__(self): return iter(self.rdatasets) def find_rdataset(self, rdclass, rdtype, covers=dns.rdatatype.NONE, create=False): """Find an rdataset matching the specified properties in the current node. @param rdclass: The class of the rdataset @type rdclass: int @param rdtype: The type of the rdataset @type rdtype: int @param covers: The covered type. Usually this value is dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or dns.rdatatype.RRSIG, then the covers value will be the rdata type the SIG/RRSIG covers. The library treats the SIG and RRSIG types as if they were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much easier to work with than if RRSIGs covering different rdata types were aggregated into a single RRSIG rdataset. @type covers: int @param create: If True, create the rdataset if it is not found. @type create: bool @raises KeyError: An rdataset of the desired type and class does not exist and I{create} is not True. @rtype: dns.rdataset.Rdataset object """ for rds in self.rdatasets: if rds.match(rdclass, rdtype, covers): return rds if not create: raise KeyError rds = dns.rdataset.Rdataset(rdclass, rdtype) self.rdatasets.append(rds) return rds def get_rdataset(self, rdclass, rdtype, covers=dns.rdatatype.NONE, create=False): """Get an rdataset matching the specified properties in the current node. None is returned if an rdataset of the specified type and class does not exist and I{create} is not True. @param rdclass: The class of the rdataset @type rdclass: int @param rdtype: The type of the rdataset @type rdtype: int @param covers: The covered type. @type covers: int @param create: If True, create the rdataset if it is not found. @type create: bool @rtype: dns.rdataset.Rdataset object or None """ try: rds = self.find_rdataset(rdclass, rdtype, covers, create) except KeyError: rds = None return rds def delete_rdataset(self, rdclass, rdtype, covers=dns.rdatatype.NONE): """Delete the rdataset matching the specified properties in the current node. If a matching rdataset does not exist, it is not an error. @param rdclass: The class of the rdataset @type rdclass: int @param rdtype: The type of the rdataset @type rdtype: int @param covers: The covered type. @type covers: int """ rds = self.get_rdataset(rdclass, rdtype, covers) if not rds is None: self.rdatasets.remove(rds) def replace_rdataset(self, replacement): """Replace an rdataset. It is not an error if there is no rdataset matching I{replacement}. Ownership of the I{replacement} object is transferred to the node; in other words, this method does not store a copy of I{replacement} at the node, it stores I{replacement} itself. """ if not isinstance(replacement, dns.rdataset.Rdataset): raise ValueError, 'replacement is not an rdataset' self.delete_rdataset(replacement.rdclass, replacement.rdtype, replacement.covers) self.rdatasets.append(replacement)
mit
[ 3, 1898, 334, 35, 9, 12521, 13, 9488, 12, 8937, 13, 8128, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 12323, 3380, 14, 221, 437, 1031, 365, 282, 663, 402, 519, 12281, 1041, 199, 199, 646, 5228, 199, 199, 646, 6715, 14, 82, 5214, 199, 646, 6715, 14, 82, 14184, 199, 646, 6715, 14, 12471, 199, 199, 533, 5013, 8, 785, 304, 272, 408, 33, 10237, 1031, 14, 339, 437, 1031, 365, 282, 663, 402, 519, 12281, 339, 768, 7725, 519, 12281, 26, 314, 1031, 1159, 519, 12281, 272, 768, 466, 519, 12281, 26, 769, 402, 6715, 14, 82, 5214, 14, 50, 5214, 2251, 624, 339, 636, 7257, 363, 275, 788, 82, 12281, 418, 339, 347, 636, 826, 721, 277, 304, 267, 408, 9345, 282, 10237, 1031, 14, 267, 408, 398, 291, 14, 82, 12281, 275, 22750, 339, 347, 370, 63, 505, 8, 277, 12, 536, 12, 1011, 829, 304, 267, 408, 7306, 282, 1031, 370, 1318, 1475, 14, 398, 7048, 519, 5214, 737, 314, 1031, 365, 12487, 14, 221, 6184, 4252, 2368, 267, 370, 642, 1083, 787, 3032, 641, 370, 314, 519, 5214, 1159, 370, 63, 505, 342, 1083, 14, 267, 768, 635, 536, 26, 314, 5771, 536, 402, 314, 519, 12281, 267, 768, 466, 536, 26, 6715, 14, 354, 14, 985, 909, 267, 768, 4500, 26, 1059, 267, 408, 398, 308, 275, 5228, 14, 6424, 342, 267, 367, 519, 795, 315, 291, 14, 82, 12281, 26, 288, 340, 822, 8, 23098, 9, 690, 378, 26, 355, 870, 4331, 308, 12, 519, 795, 14, 475, 63, 505, 8, 354, 12, 1011, 829, 9, 267, 372, 308, 14, 7150, 342, 4439, 17, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 12323, 1031, 283, 435, 620, 8, 344, 8, 277, 430, 435, 21770, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 11467, 3380, 787, 4472, 340, 2985, 1172, 314, 2011, 519, 12281, 14, 398, 768, 4500, 26, 2155, 267, 408, 267, 327, 267, 327, 961, 365, 315, 21069, 14, 221, 22311, 8377, 781, 2793, 1133, 1929, 370, 886, 652, 8298, 14, 267, 327, 267, 367, 11517, 315, 291, 14, 82, 12281, 26, 288, 340, 11517, 440, 315, 1163, 14, 82, 12281, 26, 355, 372, 756, 267, 367, 11517, 315, 1163, 14, 82, 12281, 26, 288, 340, 11517, 440, 315, 291, 14, 82, 12281, 26, 355, 372, 756, 267, 372, 715, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 82, 12281, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 82, 12281, 9, 339, 347, 2342, 63, 82, 5214, 8, 277, 12, 29320, 12, 22764, 12, 25858, 29, 5797, 14, 82, 14184, 14, 9185, 12, 1993, 1218, 29, 797, 304, 267, 408, 6591, 376, 519, 5214, 4877, 314, 2013, 4382, 315, 314, 267, 1453, 1031, 14, 398, 768, 635, 29320, 26, 710, 1021, 402, 314, 519, 5214, 267, 768, 466, 29320, 26, 1109, 267, 768, 635, 22764, 26, 710, 730, 402, 314, 519, 5214, 267, 768, 466, 22764, 26, 1109, 267, 768, 635, 25858, 26, 710, 24295, 730, 14, 221, 24612, 642, 574, 365, 267, 6715, 14, 82, 14184, 14, 9185, 12, 1325, 340, 314, 22764, 365, 6715, 14, 82, 14184, 14, 7864, 503, 267, 6715, 14, 82, 14184, 14, 13381, 7864, 12, 2066, 314, 25858, 574, 911, 506, 314, 27020, 267, 730, 314, 15522, 15, 13381, 7864, 25858, 14, 221, 710, 3555, 20991, 1956, 314, 15522, 436, 27222, 7864, 267, 2943, 465, 340, 2985, 4898, 282, 9614, 402, 267, 2943, 12, 325, 14, 71, 14, 27222, 7864, 8, 33, 395, 27222, 7864, 8, 2709, 395, 27222, 7864, 8, 4118, 33, 680, 221, 961, 7704, 27222, 7864, 83, 8298, 267, 14905, 370, 1736, 543, 2419, 340, 27222, 7864, 83, 8486, 316, 3365, 27020, 267, 2943, 4898, 26913, 1901, 282, 2849, 27222, 7864, 519, 5214, 14, 267, 768, 466, 25858, 26, 1109, 267, 768, 635, 1218, 26, 982, 715, 12, 1218, 314, 519, 5214, 340, 652, 365, 440, 1911, 14, 267, 768, 466, 1218, 26, 2155, 267, 768, 3536, 4067, 26, 1626, 519, 5214, 402, 314, 6387, 730, 436, 1021, 1630, 267, 440, 2187, 436, 473, 91, 981, 93, 365, 440, 715, 14, 267, 768, 4500, 26, 6715, 14, 82, 5214, 14, 50, 5214, 909, 267, 408, 398, 367, 519, 795, 315, 291, 14, 82, 12281, 26, 288, 340, 519, 795, 14, 1431, 8, 30186, 12, 22764, 12, 25858, 304, 355, 372, 519, 795, 267, 340, 440, 1218, 26, 288, 746, 4067, 267, 519, 795, 275, 6715, 14, 82, 5214, 14, 50, 5214, 8, 30186, 12, 22764, 9, 267, 291, 14, 82, 12281, 14, 740, 8, 23098, 9, 267, 372, 519, 795, 339, 347, 664, 63, 82, 5214, 8, 277, 12, 29320, 12, 22764, 12, 25858, 29, 5797, 14, 82, 14184, 14, 9185, 12, 2151, 1218, 29, 797, 304, 267, 408, 1002, 376, 519, 5214, 4877, 314, 2013, 4382, 315, 314, 267, 1453, 1031, 14, 398, 488, 365, 2138, 340, 376, 519, 5214, 402, 314, 2013, 730, 436, 267, 1021, 1630, 440, 2187, 436, 473, 91 ]
[ 1898, 334, 35, 9, 12521, 13, 9488, 12, 8937, 13, 8128, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 12323, 3380, 14, 221, 437, 1031, 365, 282, 663, 402, 519, 12281, 1041, 199, 199, 646, 5228, 199, 199, 646, 6715, 14, 82, 5214, 199, 646, 6715, 14, 82, 14184, 199, 646, 6715, 14, 12471, 199, 199, 533, 5013, 8, 785, 304, 272, 408, 33, 10237, 1031, 14, 339, 437, 1031, 365, 282, 663, 402, 519, 12281, 339, 768, 7725, 519, 12281, 26, 314, 1031, 1159, 519, 12281, 272, 768, 466, 519, 12281, 26, 769, 402, 6715, 14, 82, 5214, 14, 50, 5214, 2251, 624, 339, 636, 7257, 363, 275, 788, 82, 12281, 418, 339, 347, 636, 826, 721, 277, 304, 267, 408, 9345, 282, 10237, 1031, 14, 267, 408, 398, 291, 14, 82, 12281, 275, 22750, 339, 347, 370, 63, 505, 8, 277, 12, 536, 12, 1011, 829, 304, 267, 408, 7306, 282, 1031, 370, 1318, 1475, 14, 398, 7048, 519, 5214, 737, 314, 1031, 365, 12487, 14, 221, 6184, 4252, 2368, 267, 370, 642, 1083, 787, 3032, 641, 370, 314, 519, 5214, 1159, 370, 63, 505, 342, 1083, 14, 267, 768, 635, 536, 26, 314, 5771, 536, 402, 314, 519, 12281, 267, 768, 466, 536, 26, 6715, 14, 354, 14, 985, 909, 267, 768, 4500, 26, 1059, 267, 408, 398, 308, 275, 5228, 14, 6424, 342, 267, 367, 519, 795, 315, 291, 14, 82, 12281, 26, 288, 340, 822, 8, 23098, 9, 690, 378, 26, 355, 870, 4331, 308, 12, 519, 795, 14, 475, 63, 505, 8, 354, 12, 1011, 829, 9, 267, 372, 308, 14, 7150, 342, 4439, 17, 61, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 12323, 1031, 283, 435, 620, 8, 344, 8, 277, 430, 435, 21770, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 11467, 3380, 787, 4472, 340, 2985, 1172, 314, 2011, 519, 12281, 14, 398, 768, 4500, 26, 2155, 267, 408, 267, 327, 267, 327, 961, 365, 315, 21069, 14, 221, 22311, 8377, 781, 2793, 1133, 1929, 370, 886, 652, 8298, 14, 267, 327, 267, 367, 11517, 315, 291, 14, 82, 12281, 26, 288, 340, 11517, 440, 315, 1163, 14, 82, 12281, 26, 355, 372, 756, 267, 367, 11517, 315, 1163, 14, 82, 12281, 26, 288, 340, 11517, 440, 315, 291, 14, 82, 12281, 26, 355, 372, 756, 267, 372, 715, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 82, 12281, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 14, 82, 12281, 9, 339, 347, 2342, 63, 82, 5214, 8, 277, 12, 29320, 12, 22764, 12, 25858, 29, 5797, 14, 82, 14184, 14, 9185, 12, 1993, 1218, 29, 797, 304, 267, 408, 6591, 376, 519, 5214, 4877, 314, 2013, 4382, 315, 314, 267, 1453, 1031, 14, 398, 768, 635, 29320, 26, 710, 1021, 402, 314, 519, 5214, 267, 768, 466, 29320, 26, 1109, 267, 768, 635, 22764, 26, 710, 730, 402, 314, 519, 5214, 267, 768, 466, 22764, 26, 1109, 267, 768, 635, 25858, 26, 710, 24295, 730, 14, 221, 24612, 642, 574, 365, 267, 6715, 14, 82, 14184, 14, 9185, 12, 1325, 340, 314, 22764, 365, 6715, 14, 82, 14184, 14, 7864, 503, 267, 6715, 14, 82, 14184, 14, 13381, 7864, 12, 2066, 314, 25858, 574, 911, 506, 314, 27020, 267, 730, 314, 15522, 15, 13381, 7864, 25858, 14, 221, 710, 3555, 20991, 1956, 314, 15522, 436, 27222, 7864, 267, 2943, 465, 340, 2985, 4898, 282, 9614, 402, 267, 2943, 12, 325, 14, 71, 14, 27222, 7864, 8, 33, 395, 27222, 7864, 8, 2709, 395, 27222, 7864, 8, 4118, 33, 680, 221, 961, 7704, 27222, 7864, 83, 8298, 267, 14905, 370, 1736, 543, 2419, 340, 27222, 7864, 83, 8486, 316, 3365, 27020, 267, 2943, 4898, 26913, 1901, 282, 2849, 27222, 7864, 519, 5214, 14, 267, 768, 466, 25858, 26, 1109, 267, 768, 635, 1218, 26, 982, 715, 12, 1218, 314, 519, 5214, 340, 652, 365, 440, 1911, 14, 267, 768, 466, 1218, 26, 2155, 267, 768, 3536, 4067, 26, 1626, 519, 5214, 402, 314, 6387, 730, 436, 1021, 1630, 267, 440, 2187, 436, 473, 91, 981, 93, 365, 440, 715, 14, 267, 768, 4500, 26, 6715, 14, 82, 5214, 14, 50, 5214, 909, 267, 408, 398, 367, 519, 795, 315, 291, 14, 82, 12281, 26, 288, 340, 519, 795, 14, 1431, 8, 30186, 12, 22764, 12, 25858, 304, 355, 372, 519, 795, 267, 340, 440, 1218, 26, 288, 746, 4067, 267, 519, 795, 275, 6715, 14, 82, 5214, 14, 50, 5214, 8, 30186, 12, 22764, 9, 267, 291, 14, 82, 12281, 14, 740, 8, 23098, 9, 267, 372, 519, 795, 339, 347, 664, 63, 82, 5214, 8, 277, 12, 29320, 12, 22764, 12, 25858, 29, 5797, 14, 82, 14184, 14, 9185, 12, 2151, 1218, 29, 797, 304, 267, 408, 1002, 376, 519, 5214, 4877, 314, 2013, 4382, 315, 314, 267, 1453, 1031, 14, 398, 488, 365, 2138, 340, 376, 519, 5214, 402, 314, 2013, 730, 436, 267, 1021, 1630, 440, 2187, 436, 473, 91, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
grandquista/rethinkdb
test/common/http_support/jinja2/defaults.py
659
1068
# -*- coding: utf-8 -*- """ jinja2.defaults ~~~~~~~~~~~~~~~ Jinja default filters and tags. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ from jinja2._compat import range_type from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner # defaults for the parser / lexer BLOCK_START_STRING = '{%' BLOCK_END_STRING = '%}' VARIABLE_START_STRING = '{{' VARIABLE_END_STRING = '}}' COMMENT_START_STRING = '{#' COMMENT_END_STRING = '#}' LINE_STATEMENT_PREFIX = None LINE_COMMENT_PREFIX = None TRIM_BLOCKS = False LSTRIP_BLOCKS = False NEWLINE_SEQUENCE = '\n' KEEP_TRAILING_NEWLINE = False # default filters, tests and namespace from jinja2.filters import FILTERS as DEFAULT_FILTERS from jinja2.tests import TESTS as DEFAULT_TESTS DEFAULT_NAMESPACE = { 'range': range_type, 'dict': lambda **kw: kw, 'lipsum': generate_lorem_ipsum, 'cycler': Cycler, 'joiner': Joiner } # export all constants __all__ = tuple(x for x in locals().keys() if x.isupper())
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 4322, 272, 32202, 23597, 339, 17300, 849, 4766, 436, 3762, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10321, 18, 423, 5819, 492, 1425, 63, 466, 199, 504, 10321, 18, 14, 1208, 492, 3550, 63, 320, 13179, 63, 711, 1838, 12, 18461, 32046, 12, 7135, 16187, 421, 199, 3, 4243, 367, 314, 1798, 1182, 10426, 199, 8475, 63, 7363, 63, 5353, 275, 12100, 7, 199, 8475, 63, 3902, 63, 5353, 275, 1543, 6834, 199, 23129, 63, 7363, 63, 5353, 275, 5041, 1445, 199, 23129, 63, 3902, 63, 5353, 275, 283, 4863, 7, 199, 10973, 63, 7363, 63, 5353, 275, 5041, 19367, 199, 10973, 63, 3902, 63, 5353, 275, 3943, 6834, 199, 6174, 63, 6689, 4479, 63, 6351, 275, 488, 199, 6174, 63, 10973, 63, 6351, 275, 488, 199, 1766, 1469, 63, 8475, 51, 275, 756, 199, 44, 31296, 63, 8475, 51, 275, 756, 199, 28758, 63, 16585, 275, 1557, 78, 7, 199, 32162, 63, 1766, 6593, 1206, 63, 28758, 275, 756, 421, 199, 3, 849, 4766, 12, 2295, 436, 3231, 199, 504, 10321, 18, 14, 4273, 492, 23244, 51, 465, 6186, 63, 9905, 51, 199, 504, 10321, 18, 14, 2219, 492, 7393, 51, 465, 6186, 63, 7569, 199, 3472, 63, 13001, 275, 469, 272, 283, 1842, 356, 263, 1425, 63, 466, 12, 272, 283, 807, 356, 260, 2400, 1011, 829, 26, 4775, 12, 272, 283, 317, 1190, 453, 356, 755, 3550, 63, 320, 13179, 63, 711, 1838, 12, 272, 283, 1480, 32046, 356, 755, 18461, 32046, 12, 272, 283, 904, 281, 356, 755, 7135, 16187, 199, 93, 421, 199, 3, 4843, 1006, 5262, 199, 363, 452, 363, 275, 2008, 8, 88, 367, 671, 315, 9480, 1252, 1612, 342, 340, 671, 14, 374, 4142, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 4322, 272, 32202, 23597, 339, 17300, 849, 4766, 436, 3762, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10321, 18, 423, 5819, 492, 1425, 63, 466, 199, 504, 10321, 18, 14, 1208, 492, 3550, 63, 320, 13179, 63, 711, 1838, 12, 18461, 32046, 12, 7135, 16187, 421, 199, 3, 4243, 367, 314, 1798, 1182, 10426, 199, 8475, 63, 7363, 63, 5353, 275, 12100, 7, 199, 8475, 63, 3902, 63, 5353, 275, 1543, 6834, 199, 23129, 63, 7363, 63, 5353, 275, 5041, 1445, 199, 23129, 63, 3902, 63, 5353, 275, 283, 4863, 7, 199, 10973, 63, 7363, 63, 5353, 275, 5041, 19367, 199, 10973, 63, 3902, 63, 5353, 275, 3943, 6834, 199, 6174, 63, 6689, 4479, 63, 6351, 275, 488, 199, 6174, 63, 10973, 63, 6351, 275, 488, 199, 1766, 1469, 63, 8475, 51, 275, 756, 199, 44, 31296, 63, 8475, 51, 275, 756, 199, 28758, 63, 16585, 275, 1557, 78, 7, 199, 32162, 63, 1766, 6593, 1206, 63, 28758, 275, 756, 421, 199, 3, 849, 4766, 12, 2295, 436, 3231, 199, 504, 10321, 18, 14, 4273, 492, 23244, 51, 465, 6186, 63, 9905, 51, 199, 504, 10321, 18, 14, 2219, 492, 7393, 51, 465, 6186, 63, 7569, 199, 3472, 63, 13001, 275, 469, 272, 283, 1842, 356, 263, 1425, 63, 466, 12, 272, 283, 807, 356, 260, 2400, 1011, 829, 26, 4775, 12, 272, 283, 317, 1190, 453, 356, 755, 3550, 63, 320, 13179, 63, 711, 1838, 12, 272, 283, 1480, 32046, 356, 755, 18461, 32046, 12, 272, 283, 904, 281, 356, 755, 7135, 16187, 199, 93, 421, 199, 3, 4843, 1006, 5262, 199, 363, 452, 363, 275, 2008, 8, 88, 367, 671, 315, 9480, 1252, 1612, 342, 340, 671, 14, 374, 4142, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cchurch/ansible
lib/ansible/module_utils/azure_rm_common_rest.py
67
3696
# Copyright (c) 2018 Zim Kalinowski, <zikalino@microsoft.com> # # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from ansible.module_utils.ansible_release import __version__ as ANSIBLE_VERSION try: from msrestazure.azure_exceptions import CloudError from msrestazure.azure_configuration import AzureConfiguration from msrest.service_client import ServiceClient from msrest.pipeline import ClientRawResponse from msrest.polling import LROPoller from msrestazure.polling.arm_polling import ARMPolling import uuid import json except ImportError: # This is handled in azure_rm_common AzureConfiguration = object ANSIBLE_USER_AGENT = 'Ansible/{0}'.format(ANSIBLE_VERSION) class GenericRestClientConfiguration(AzureConfiguration): def __init__(self, credentials, subscription_id, base_url=None): if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") if not base_url: base_url = 'https://management.azure.com' super(GenericRestClientConfiguration, self).__init__(base_url) self.add_user_agent(ANSIBLE_USER_AGENT) self.credentials = credentials self.subscription_id = subscription_id class GenericRestClient(object): def __init__(self, credentials, subscription_id, base_url=None): self.config = GenericRestClientConfiguration(credentials, subscription_id, base_url) self._client = ServiceClient(self.config.credentials, self.config) self.models = None def query(self, url, method, query_parameters, header_parameters, body, expected_status_codes, polling_timeout, polling_interval): # Construct and send request operation_config = {} request = None if header_parameters is None: header_parameters = {} header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if method == 'GET': request = self._client.get(url, query_parameters) elif method == 'PUT': request = self._client.put(url, query_parameters) elif method == 'POST': request = self._client.post(url, query_parameters) elif method == 'HEAD': request = self._client.head(url, query_parameters) elif method == 'PATCH': request = self._client.patch(url, query_parameters) elif method == 'DELETE': request = self._client.delete(url, query_parameters) elif method == 'MERGE': request = self._client.merge(url, query_parameters) response = self._client.send(request, header_parameters, body, **operation_config) if response.status_code not in expected_status_codes: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp elif response.status_code == 202 and polling_timeout > 0: def get_long_running_output(response): return response poller = LROPoller(self._client, ClientRawResponse(None, response), get_long_running_output, ARMPolling(polling_interval, **operation_config)) response = self.get_poller_result(poller, polling_timeout) return response def get_poller_result(self, poller, timeout): try: poller.wait(timeout=timeout) return poller.result() except Exception as exc: raise
gpl-3.0
[ 3, 1898, 334, 67, 9, 14894, 3107, 1017, 1804, 279, 262, 19844, 12, 665, 90, 3258, 279, 10175, 32, 17040, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4853, 63, 3221, 492, 636, 1023, 363, 465, 32271, 7187, 63, 4612, 199, 199, 893, 26, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 4758, 492, 15474, 5688, 272, 687, 6605, 3911, 14, 1364, 63, 1258, 492, 7591, 3041, 272, 687, 6605, 3911, 14, 7379, 492, 6810, 28973, 272, 687, 6605, 3911, 14, 17154, 492, 491, 26898, 272, 687, 6605, 264, 1207, 7895, 14, 17154, 14, 5362, 63, 17154, 492, 4160, 1658, 393, 2983, 272, 492, 5377, 272, 492, 2022, 199, 2590, 3545, 26, 272, 327, 961, 365, 8860, 315, 13601, 63, 5682, 63, 2330, 272, 15474, 5688, 275, 909, 199, 199, 8490, 63, 3791, 63, 14565, 275, 283, 10047, 5321, 16, 5285, 908, 8, 8490, 63, 4612, 9, 421, 199, 533, 8307, 13726, 3041, 5688, 8, 22386, 5688, 304, 339, 347, 636, 826, 721, 277, 12, 6235, 12, 9966, 63, 344, 12, 1300, 63, 633, 29, 403, 304, 398, 340, 6235, 365, 488, 26, 288, 746, 1722, 480, 4720, 283, 6942, 7, 1471, 440, 506, 488, 2685, 267, 340, 9966, 63, 344, 365, 488, 26, 288, 746, 1722, 480, 4720, 283, 6645, 63, 344, 7, 1471, 440, 506, 488, 2685, 267, 340, 440, 1300, 63, 633, 26, 288, 1300, 63, 633, 275, 283, 2859, 921, 8110, 14, 9078, 14, 957, 7, 398, 1613, 8, 9417, 13726, 3041, 5688, 12, 291, 2843, 826, 721, 1095, 63, 633, 9, 398, 291, 14, 525, 63, 751, 63, 4054, 8, 8490, 63, 3791, 63, 14565, 9, 398, 291, 14, 6942, 275, 6235, 267, 291, 14, 6645, 63, 344, 275, 9966, 63, 344, 421, 199, 533, 8307, 13726, 3041, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 6235, 12, 9966, 63, 344, 12, 1300, 63, 633, 29, 403, 304, 267, 291, 14, 888, 275, 8307, 13726, 3041, 5688, 8, 6942, 12, 9966, 63, 344, 12, 1300, 63, 633, 9, 267, 291, 423, 1258, 275, 7591, 3041, 8, 277, 14, 888, 14, 6942, 12, 291, 14, 888, 9, 267, 291, 14, 992, 275, 488, 339, 347, 1827, 8, 277, 12, 1166, 12, 1083, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 12, 2396, 12, 1420, 63, 1205, 63, 6021, 12, 12353, 63, 2593, 12, 12353, 63, 4284, 304, 267, 327, 9215, 436, 3222, 1056, 267, 3439, 63, 888, 275, 1052, 398, 1056, 275, 488, 398, 340, 1406, 63, 3214, 365, 488, 26, 288, 1406, 63, 3214, 275, 1052, 398, 1406, 63, 3214, 459, 88, 13, 706, 13, 1258, 13, 1069, 13, 344, 418, 275, 620, 8, 2580, 14, 2580, 17, 1012, 398, 340, 1083, 508, 283, 2970, 356, 288, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 4013, 356, 288, 1056, 275, 291, 423, 1258, 14, 524, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 4030, 356, 288, 1056, 275, 291, 423, 1258, 14, 1932, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 5211, 356, 288, 1056, 275, 291, 423, 1258, 14, 2993, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 17073, 356, 288, 1056, 275, 291, 423, 1258, 14, 2068, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 7014, 356, 288, 1056, 275, 291, 423, 1258, 14, 1807, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 25619, 356, 288, 1056, 275, 291, 423, 1258, 14, 5628, 8, 633, 12, 1827, 63, 3214, 9, 398, 1177, 275, 291, 423, 1258, 14, 2254, 8, 1069, 12, 1406, 63, 3214, 12, 2396, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 1420, 63, 1205, 63, 6021, 26, 288, 1437, 275, 30059, 8, 1310, 9, 288, 1437, 14, 1069, 63, 344, 275, 1177, 14, 2139, 14, 362, 360, 88, 13, 706, 13, 1069, 13, 344, 358, 288, 746, 1437, 267, 916, 1177, 14, 1205, 63, 600, 508, 19328, 436, 12353, 63, 2593, 690, 378, 26, 288, 347, 664, 63, 2809, 63, 5720, 63, 1199, 8, 1310, 304, 355, 372, 1177, 288, 28073, 275, 491, 26898, 8, 277, 423, 1258, 12, 3044, 6810, 28973, 8, 403, 12, 1177, 395, 3044, 664, 63, 2809, 63, 5720, 63, 1199, 12, 3044, 4160, 1658, 393, 2983, 8, 17154, 63, 4284, 12, 1011, 5735, 63, 888, 430, 288, 1177, 275, 291, 14, 362, 63, 26746, 63, 1099, 8, 26746, 12, 12353, 63, 2593, 9, 398, 372, 1177, 339, 347, 664, 63, 26746, 63, 1099, 8, 277, 12, 28073, 12, 2653, 304, 267, 862, 26, 288, 28073, 14, 2573, 8, 2593, 29, 2593, 9, 288, 372, 28073, 14, 1099, 342, 267, 871, 2186, 465, 3178, 26, 288, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 14894, 3107, 1017, 1804, 279, 262, 19844, 12, 665, 90, 3258, 279, 10175, 32, 17040, 14, 957, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4853, 63, 3221, 492, 636, 1023, 363, 465, 32271, 7187, 63, 4612, 199, 199, 893, 26, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 272, 687, 6605, 264, 1207, 7895, 14, 9078, 63, 4758, 492, 15474, 5688, 272, 687, 6605, 3911, 14, 1364, 63, 1258, 492, 7591, 3041, 272, 687, 6605, 3911, 14, 7379, 492, 6810, 28973, 272, 687, 6605, 3911, 14, 17154, 492, 491, 26898, 272, 687, 6605, 264, 1207, 7895, 14, 17154, 14, 5362, 63, 17154, 492, 4160, 1658, 393, 2983, 272, 492, 5377, 272, 492, 2022, 199, 2590, 3545, 26, 272, 327, 961, 365, 8860, 315, 13601, 63, 5682, 63, 2330, 272, 15474, 5688, 275, 909, 199, 199, 8490, 63, 3791, 63, 14565, 275, 283, 10047, 5321, 16, 5285, 908, 8, 8490, 63, 4612, 9, 421, 199, 533, 8307, 13726, 3041, 5688, 8, 22386, 5688, 304, 339, 347, 636, 826, 721, 277, 12, 6235, 12, 9966, 63, 344, 12, 1300, 63, 633, 29, 403, 304, 398, 340, 6235, 365, 488, 26, 288, 746, 1722, 480, 4720, 283, 6942, 7, 1471, 440, 506, 488, 2685, 267, 340, 9966, 63, 344, 365, 488, 26, 288, 746, 1722, 480, 4720, 283, 6645, 63, 344, 7, 1471, 440, 506, 488, 2685, 267, 340, 440, 1300, 63, 633, 26, 288, 1300, 63, 633, 275, 283, 2859, 921, 8110, 14, 9078, 14, 957, 7, 398, 1613, 8, 9417, 13726, 3041, 5688, 12, 291, 2843, 826, 721, 1095, 63, 633, 9, 398, 291, 14, 525, 63, 751, 63, 4054, 8, 8490, 63, 3791, 63, 14565, 9, 398, 291, 14, 6942, 275, 6235, 267, 291, 14, 6645, 63, 344, 275, 9966, 63, 344, 421, 199, 533, 8307, 13726, 3041, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 6235, 12, 9966, 63, 344, 12, 1300, 63, 633, 29, 403, 304, 267, 291, 14, 888, 275, 8307, 13726, 3041, 5688, 8, 6942, 12, 9966, 63, 344, 12, 1300, 63, 633, 9, 267, 291, 423, 1258, 275, 7591, 3041, 8, 277, 14, 888, 14, 6942, 12, 291, 14, 888, 9, 267, 291, 14, 992, 275, 488, 339, 347, 1827, 8, 277, 12, 1166, 12, 1083, 12, 1827, 63, 3214, 12, 1406, 63, 3214, 12, 2396, 12, 1420, 63, 1205, 63, 6021, 12, 12353, 63, 2593, 12, 12353, 63, 4284, 304, 267, 327, 9215, 436, 3222, 1056, 267, 3439, 63, 888, 275, 1052, 398, 1056, 275, 488, 398, 340, 1406, 63, 3214, 365, 488, 26, 288, 1406, 63, 3214, 275, 1052, 398, 1406, 63, 3214, 459, 88, 13, 706, 13, 1258, 13, 1069, 13, 344, 418, 275, 620, 8, 2580, 14, 2580, 17, 1012, 398, 340, 1083, 508, 283, 2970, 356, 288, 1056, 275, 291, 423, 1258, 14, 362, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 4013, 356, 288, 1056, 275, 291, 423, 1258, 14, 524, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 4030, 356, 288, 1056, 275, 291, 423, 1258, 14, 1932, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 5211, 356, 288, 1056, 275, 291, 423, 1258, 14, 2993, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 17073, 356, 288, 1056, 275, 291, 423, 1258, 14, 2068, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 7014, 356, 288, 1056, 275, 291, 423, 1258, 14, 1807, 8, 633, 12, 1827, 63, 3214, 9, 267, 916, 1083, 508, 283, 25619, 356, 288, 1056, 275, 291, 423, 1258, 14, 5628, 8, 633, 12, 1827, 63, 3214, 9, 398, 1177, 275, 291, 423, 1258, 14, 2254, 8, 1069, 12, 1406, 63, 3214, 12, 2396, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 1420, 63, 1205, 63, 6021, 26, 288, 1437, 275, 30059, 8, 1310, 9, 288, 1437, 14, 1069, 63, 344, 275, 1177, 14, 2139, 14, 362, 360, 88, 13, 706, 13, 1069, 13, 344, 358, 288, 746, 1437, 267, 916, 1177, 14, 1205, 63, 600, 508, 19328, 436, 12353, 63, 2593, 690, 378, 26, 288, 347, 664, 63, 2809, 63, 5720, 63, 1199, 8, 1310, 304, 355, 372, 1177, 288, 28073, 275, 491, 26898, 8, 277, 423, 1258, 12, 3044, 6810, 28973, 8, 403, 12, 1177, 395, 3044, 664, 63, 2809, 63, 5720, 63, 1199, 12, 3044, 4160, 1658, 393, 2983, 8, 17154, 63, 4284, 12, 1011, 5735, 63, 888, 430, 288, 1177, 275, 291, 14, 362, 63, 26746, 63, 1099, 8, 26746, 12, 12353, 63, 2593, 9, 398, 372, 1177, 339, 347, 664, 63, 26746, 63, 1099, 8, 277, 12, 28073, 12, 2653, 304, 267, 862, 26, 288, 28073, 14, 2573, 8, 2593, 29, 2593, 9, 288, 372, 28073, 14, 1099, 342, 267, 871, 2186, 465, 3178, 26, 288, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
Tejal011089/trufil-erpnext
erpnext/accounts/doctype/shipping_rule/shipping_rule.py
38
3213
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt # For license information, please see license.txt from __future__ import unicode_literals import frappe from frappe import _, msgprint, throw from frappe.utils import flt, fmt_money from frappe.model.document import Document from erpnext.setup.utils import get_company_currency class OverlappingConditionError(frappe.ValidationError): pass class FromGreaterThanToError(frappe.ValidationError): pass class ManyBlankToValuesError(frappe.ValidationError): pass class ShippingRule(Document): def validate(self): self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"]) self.conditions = self.get("conditions") self.validate_from_to_values() self.sort_shipping_rule_conditions() self.validate_overlapping_shipping_rule_conditions() def validate_from_to_values(self): zero_to_values = [] for d in self.get("conditions"): self.round_floats_in(d) # values cannot be negative self.validate_value("from_value", ">=", 0.0, d) self.validate_value("to_value", ">=", 0.0, d) if not d.to_value: zero_to_values.append(d) elif d.from_value >= d.to_value: throw(_("From value must be less than to value in row {0}").format(d.idx), FromGreaterThanToError) # check if more than two or more rows has To Value = 0 if len(zero_to_values) >= 2: throw(_('There can only be one Shipping Rule Condition with 0 or blank value for "To Value"'), ManyBlankToValuesError) def sort_shipping_rule_conditions(self): """Sort Shipping Rule Conditions based on increasing From Value""" self.shipping_rules_conditions = sorted(self.conditions, key=lambda d: flt(d.from_value)) for i, d in enumerate(self.conditions): d.idx = i + 1 def validate_overlapping_shipping_rule_conditions(self): def overlap_exists_between((x1, x2), (y1, y2)): """ (x1, x2) and (y1, y2) are two ranges if condition x = 100 to 300 then condition y can only be like 50 to 99 or 301 to 400 hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2) """ separate = (x1 <= x2 <= y1 <= y2) or (y1 <= y2 <= x1 <= x2) return (not separate) overlaps = [] for i in xrange(0, len(self.conditions)): for j in xrange(i+1, len(self.conditions)): d1, d2 = self.conditions[i], self.conditions[j] if d1.as_dict() != d2.as_dict(): # in our case, to_value can be zero, hence pass the from_value if so range_a = (d1.from_value, d1.to_value or d1.from_value) range_b = (d2.from_value, d2.to_value or d2.from_value) if overlap_exists_between(range_a, range_b): overlaps.append([d1, d2]) if overlaps: company_currency = get_company_currency(self.company) msgprint(_("Overlapping conditions found between:")) messages = [] for d1, d2 in overlaps: messages.append("%s-%s = %s " % (d1.from_value, d1.to_value, fmt_money(d1.shipping_amount, currency=company_currency)) + _("and") + " %s-%s = %s" % (d2.from_value, d2.to_value, fmt_money(d2.shipping_amount, currency=company_currency))) msgprint("\n".join(messages), raise_exception=OverlappingConditionError)
agpl-3.0
[ 3, 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 6950, 492, 5501, 1499, 1361, 12, 7978, 199, 504, 6950, 14, 1208, 492, 17166, 12, 7104, 63, 27468, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 29106, 14, 2758, 14, 1208, 492, 664, 63, 4627, 63, 4968, 199, 199, 533, 7259, 18352, 9558, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 11606, 11891, 19760, 1378, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 15517, 28083, 1378, 6550, 547, 8, 9098, 14, 8172, 304, 986, 199, 199, 533, 5244, 711, 4073, 5065, 8, 5564, 304, 199, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 585, 480, 12063, 63, 6788, 63, 265, 401, 298, 262, 401, 2097, 2480, 19271, 401, 298, 2480, 2136, 1070, 3135, 507, 198, 277, 14, 9855, 275, 291, 14, 362, 480, 9855, 531, 507, 198, 277, 14, 3502, 63, 504, 63, 475, 63, 1459, 342, 507, 198, 277, 14, 3191, 63, 17801, 63, 2200, 63, 9855, 342, 507, 198, 277, 14, 3502, 63, 31034, 63, 17801, 63, 2200, 63, 9855, 342, 421, 198, 318, 4107, 63, 504, 63, 475, 63, 1459, 8, 277, 304, 507, 198, 4262, 63, 475, 63, 1459, 275, 942, 2742, 198, 509, 366, 315, 291, 14, 362, 480, 9855, 2349, 686, 198, 277, 14, 2363, 63, 1609, 83, 63, 262, 8, 68, 9, 6319, 198, 3, 1338, 3913, 506, 6946, 686, 198, 277, 14, 3502, 63, 585, 480, 504, 63, 585, 401, 298, 8119, 401, 378, 14, 16, 12, 366, 9, 686, 198, 277, 14, 3502, 63, 585, 480, 475, 63, 585, 401, 298, 8119, 401, 378, 14, 16, 12, 366, 9, 6319, 198, 692, 440, 366, 14, 475, 63, 585, 26, 1585, 198, 4262, 63, 475, 63, 1459, 14, 740, 8, 68, 9, 686, 198, 4164, 366, 14, 504, 63, 585, 2356, 366, 14, 475, 63, 585, 26, 1585, 198, 11964, 6115, 2532, 574, 1471, 506, 6656, 2419, 370, 574, 315, 1962, 469, 16, 30273, 908, 8, 68, 14, 2996, 395, 11606, 11891, 19760, 1378, 547, 9, 2742, 198, 3, 1104, 340, 1655, 2419, 2877, 503, 1655, 4730, 965, 4005, 1594, 275, 378, 507, 198, 692, 822, 8, 4262, 63, 475, 63, 1459, 9, 2356, 499, 26, 686, 198, 11964, 6723, 10924, 883, 1454, 506, 1373, 5244, 711, 4073, 11949, 28401, 543, 378, 503, 4596, 574, 367, 298, 1378, 1594, 32574, 1585, 198, 4089, 28083, 1378, 6550, 547, 9, 421, 198, 318, 4069, 63, 17801, 63, 2200, 63, 9855, 8, 277, 304, 507, 198, 624, 14376, 5244, 711, 4073, 11949, 1448, 3138, 4079, 641, 22255, 11606, 1594, 624, 507, 198, 277, 14, 17801, 63, 4423, 63, 9855, 275, 3355, 8, 277, 14, 9855, 12, 790, 29, 2734, 366, 26, 17166, 8, 68, 14, 504, 63, 585, 430, 507, 198, 509, 284, 12, 366, 315, 3874, 8, 277, 14, 9855, 304, 686, 198, 68, 14, 2996, 275, 284, 435, 413, 421, 198, 318, 4107, 63, 31034, 63, 17801, 63, 2200, 63, 9855, 8, 277, 304, 507, 198, 318, 15145, 63, 2444, 63, 13007, 1332, 88, 17, 12, 671, 18, 395, 334, 89, 17, 12, 612, 18, 2298, 686, 198, 624, 1585, 198, 8, 88, 17, 12, 671, 18, 9, 436, 334, 89, 17, 12, 612, 18, 9, 787, 2877, 12271, 1585, 198, 692, 5558, 671, 275, 2948, 370, 9601, 1585, 198, 12726, 5558, 612, 883, 1454, 506, 2839, 5238, 370, 8806, 503, 19660, 370, 8290, 1585, 198, 72, 4894, 12, 2222, 13, 31034, 5558, 275, 334, 88, 17, 2695, 671, 18, 665, 612, 17, 2695, 612, 18, 9, 503, 334, 89, 17, 2695, 612, 18, 665, 671, 17, 2695, 671, 18, 9, 686, 198, 624, 686, 198, 24904, 275, 334, 88, 17, 2695, 671, 18, 2695, 612, 17, 2695, 612, 18, 9, 503, 334, 89, 17, 2695, 612, 18, 2695, 671, 17, 2695, 671, 18, 9, 686, 198, 1107, 334, 1397, 7396, 9, 2742, 198, 20798, 275, 942, 507, 198, 509, 284, 315, 4945, 8, 16, 12, 822, 8, 277, 14, 9855, 2298, 686, 198, 509, 1335, 315, 4945, 8, 73, 11, 17, 12, 822, 8, 277, 14, 9855, 2298, 1585, 198, 68, 17, 12, 366, 18, 275, 291, 14, 9855, 59, 73, 467, 291, 14, 9855, 59, 74, 61, 1585, 198, 692, 366, 17, 14, 305, 63, 807, 342, 1137, 366, 18, 14, 305, 63, 807, 837, 1871, 198, 3, 315, 4154, 1930, 12, 370, 63, 585, 883, 506, 4697, 12, 19407, 986, 314, 687, 63, 585, 340, 880, 1871, 198, 1842, 63, 65, 275, 334, 68, 17, 14, 504, 63, 585, 12, 366, 17, 14, 475, 63, 585, 503, 366, 17, 14, 504, 63, 585, 9, 1871, 198, 1842, 63, 66, 275, 334, 68, 18, 14, 504, 63, 585, 12, 366, 18, 14, 475, 63, 585, 503, 366, 18, 14, 504, 63, 585, 9, 1871, 198, 692, 15145, 63, 2444, 63, 13007, 8, 1842, 63, 65, 12, 1425, 63, 66, 304, 4671, 198, 20798, 14, 740, 779, 68, 17, 12, 366, 18, 566, 2742, 198, 692, 29755, 26, 686, 198, 4627, 63, 4968, 275, 664, 63, 4627, 63, 4968, 8, 277, 14, 4627, 9, 686, 198, 1328, 1361, 6115, 5674, 18352, 3704, 1911, 3382, 26, 2237, 686, 198, 3431, 275, 942, 686, 198, 509, 366, 17, 12, 366, 18, 315, 29755, 26, 1585, 198, 3431, 14, 740, 3647, 83, 3295, 83, 275, 450, 83, 298, 450, 334, 68, 17, 14, 504, 63, 585, 12, 366, 17, 14, 475, 63, 585, 12, 7104, 63, 27468, 8, 68, 17, 14, 17801, 63, 4606, 12, 9952, 29, 4627, 63, 4968, 430, 435, 1871, 198, 14332, 460, 531, 435, 298, 450, 83, 3295, 83, 275, 450, 83, 2, 450, 334, 68, 18, 14, 504, 63, 585, 12, 366, 18, 14, 475, 63, 585, 12, 7104, 63, 27468, 8, 68, 18, 14, 17801, 63, 4606, 12, 9952, 29, 4627, 63, 4968, 1724, 6319, 198 ]
[ 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 6950, 492, 5501, 1499, 1361, 12, 7978, 199, 504, 6950, 14, 1208, 492, 17166, 12, 7104, 63, 27468, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 29106, 14, 2758, 14, 1208, 492, 664, 63, 4627, 63, 4968, 199, 199, 533, 7259, 18352, 9558, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 11606, 11891, 19760, 1378, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 15517, 28083, 1378, 6550, 547, 8, 9098, 14, 8172, 304, 986, 199, 199, 533, 5244, 711, 4073, 5065, 8, 5564, 304, 199, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 585, 480, 12063, 63, 6788, 63, 265, 401, 298, 262, 401, 2097, 2480, 19271, 401, 298, 2480, 2136, 1070, 3135, 507, 198, 277, 14, 9855, 275, 291, 14, 362, 480, 9855, 531, 507, 198, 277, 14, 3502, 63, 504, 63, 475, 63, 1459, 342, 507, 198, 277, 14, 3191, 63, 17801, 63, 2200, 63, 9855, 342, 507, 198, 277, 14, 3502, 63, 31034, 63, 17801, 63, 2200, 63, 9855, 342, 421, 198, 318, 4107, 63, 504, 63, 475, 63, 1459, 8, 277, 304, 507, 198, 4262, 63, 475, 63, 1459, 275, 942, 2742, 198, 509, 366, 315, 291, 14, 362, 480, 9855, 2349, 686, 198, 277, 14, 2363, 63, 1609, 83, 63, 262, 8, 68, 9, 6319, 198, 3, 1338, 3913, 506, 6946, 686, 198, 277, 14, 3502, 63, 585, 480, 504, 63, 585, 401, 298, 8119, 401, 378, 14, 16, 12, 366, 9, 686, 198, 277, 14, 3502, 63, 585, 480, 475, 63, 585, 401, 298, 8119, 401, 378, 14, 16, 12, 366, 9, 6319, 198, 692, 440, 366, 14, 475, 63, 585, 26, 1585, 198, 4262, 63, 475, 63, 1459, 14, 740, 8, 68, 9, 686, 198, 4164, 366, 14, 504, 63, 585, 2356, 366, 14, 475, 63, 585, 26, 1585, 198, 11964, 6115, 2532, 574, 1471, 506, 6656, 2419, 370, 574, 315, 1962, 469, 16, 30273, 908, 8, 68, 14, 2996, 395, 11606, 11891, 19760, 1378, 547, 9, 2742, 198, 3, 1104, 340, 1655, 2419, 2877, 503, 1655, 4730, 965, 4005, 1594, 275, 378, 507, 198, 692, 822, 8, 4262, 63, 475, 63, 1459, 9, 2356, 499, 26, 686, 198, 11964, 6723, 10924, 883, 1454, 506, 1373, 5244, 711, 4073, 11949, 28401, 543, 378, 503, 4596, 574, 367, 298, 1378, 1594, 32574, 1585, 198, 4089, 28083, 1378, 6550, 547, 9, 421, 198, 318, 4069, 63, 17801, 63, 2200, 63, 9855, 8, 277, 304, 507, 198, 624, 14376, 5244, 711, 4073, 11949, 1448, 3138, 4079, 641, 22255, 11606, 1594, 624, 507, 198, 277, 14, 17801, 63, 4423, 63, 9855, 275, 3355, 8, 277, 14, 9855, 12, 790, 29, 2734, 366, 26, 17166, 8, 68, 14, 504, 63, 585, 430, 507, 198, 509, 284, 12, 366, 315, 3874, 8, 277, 14, 9855, 304, 686, 198, 68, 14, 2996, 275, 284, 435, 413, 421, 198, 318, 4107, 63, 31034, 63, 17801, 63, 2200, 63, 9855, 8, 277, 304, 507, 198, 318, 15145, 63, 2444, 63, 13007, 1332, 88, 17, 12, 671, 18, 395, 334, 89, 17, 12, 612, 18, 2298, 686, 198, 624, 1585, 198, 8, 88, 17, 12, 671, 18, 9, 436, 334, 89, 17, 12, 612, 18, 9, 787, 2877, 12271, 1585, 198, 692, 5558, 671, 275, 2948, 370, 9601, 1585, 198, 12726, 5558, 612, 883, 1454, 506, 2839, 5238, 370, 8806, 503, 19660, 370, 8290, 1585, 198, 72, 4894, 12, 2222, 13, 31034, 5558, 275, 334, 88, 17, 2695, 671, 18, 665, 612, 17, 2695, 612, 18, 9, 503, 334, 89, 17, 2695, 612, 18, 665, 671, 17, 2695, 671, 18, 9, 686, 198, 624, 686, 198, 24904, 275, 334, 88, 17, 2695, 671, 18, 2695, 612, 17, 2695, 612, 18, 9, 503, 334, 89, 17, 2695, 612, 18, 2695, 671, 17, 2695, 671, 18, 9, 686, 198, 1107, 334, 1397, 7396, 9, 2742, 198, 20798, 275, 942, 507, 198, 509, 284, 315, 4945, 8, 16, 12, 822, 8, 277, 14, 9855, 2298, 686, 198, 509, 1335, 315, 4945, 8, 73, 11, 17, 12, 822, 8, 277, 14, 9855, 2298, 1585, 198, 68, 17, 12, 366, 18, 275, 291, 14, 9855, 59, 73, 467, 291, 14, 9855, 59, 74, 61, 1585, 198, 692, 366, 17, 14, 305, 63, 807, 342, 1137, 366, 18, 14, 305, 63, 807, 837, 1871, 198, 3, 315, 4154, 1930, 12, 370, 63, 585, 883, 506, 4697, 12, 19407, 986, 314, 687, 63, 585, 340, 880, 1871, 198, 1842, 63, 65, 275, 334, 68, 17, 14, 504, 63, 585, 12, 366, 17, 14, 475, 63, 585, 503, 366, 17, 14, 504, 63, 585, 9, 1871, 198, 1842, 63, 66, 275, 334, 68, 18, 14, 504, 63, 585, 12, 366, 18, 14, 475, 63, 585, 503, 366, 18, 14, 504, 63, 585, 9, 1871, 198, 692, 15145, 63, 2444, 63, 13007, 8, 1842, 63, 65, 12, 1425, 63, 66, 304, 4671, 198, 20798, 14, 740, 779, 68, 17, 12, 366, 18, 566, 2742, 198, 692, 29755, 26, 686, 198, 4627, 63, 4968, 275, 664, 63, 4627, 63, 4968, 8, 277, 14, 4627, 9, 686, 198, 1328, 1361, 6115, 5674, 18352, 3704, 1911, 3382, 26, 2237, 686, 198, 3431, 275, 942, 686, 198, 509, 366, 17, 12, 366, 18, 315, 29755, 26, 1585, 198, 3431, 14, 740, 3647, 83, 3295, 83, 275, 450, 83, 298, 450, 334, 68, 17, 14, 504, 63, 585, 12, 366, 17, 14, 475, 63, 585, 12, 7104, 63, 27468, 8, 68, 17, 14, 17801, 63, 4606, 12, 9952, 29, 4627, 63, 4968, 430, 435, 1871, 198, 14332, 460, 531, 435, 298, 450, 83, 3295, 83, 275, 450, 83, 2, 450, 334, 68, 18, 14, 504, 63, 585, 12, 366, 18, 14, 475, 63, 585, 12, 7104, 63, 27468, 8, 68, 18, 14, 17801, 63, 4606, 12, 9952, 29, 4627,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1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Mixser/django
django/core/checks/registry.py
53
3058
# -*- coding: utf-8 -*- from __future__ import unicode_literals from itertools import chain from django.utils.itercompat import is_iterable class Tags(object): """ Built-in tags for internal checks. """ admin = 'admin' compatibility = 'compatibility' models = 'models' security = 'security' signals = 'signals' templates = 'templates' class CheckRegistry(object): def __init__(self): self.registered_checks = [] self.deployment_checks = [] def register(self, check=None, *tags, **kwargs): """ Can be used as a function or a decorator. Register given function `f` labeled with given `tags`. The function should receive **kwargs and return list of Errors and Warnings. Example:: registry = CheckRegistry() @registry.register('mytag', 'anothertag') def my_check(apps, **kwargs): # ... perform checks and collect `errors` ... return errors # or registry.register(my_check, 'mytag', 'anothertag') """ kwargs.setdefault('deploy', False) def inner(check): check.tags = tags if kwargs['deploy']: if check not in self.deployment_checks: self.deployment_checks.append(check) elif check not in self.registered_checks: self.registered_checks.append(check) return check if callable(check): return inner(check) else: if check: tags += (check, ) return inner def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False): """ Run all registered checks and return list of Errors and Warnings. """ errors = [] checks = self.get_checks(include_deployment_checks) if tags is not None: checks = [check for check in checks if hasattr(check, 'tags') and set(check.tags) & set(tags)] for check in checks: new_errors = check(app_configs=app_configs) assert is_iterable(new_errors), ( "The function %r did not return a list. All functions registered " "with the checks registry must return a list." % check) errors.extend(new_errors) return errors def tag_exists(self, tag, include_deployment_checks=False): return tag in self.tags_available(include_deployment_checks) def tags_available(self, deployment_checks=False): return set(chain(*[check.tags for check in self.get_checks(deployment_checks) if hasattr(check, 'tags')])) def get_checks(self, include_deployment_checks=False): checks = list(self.registered_checks) if include_deployment_checks: checks.extend(self.deployment_checks) return checks registry = CheckRegistry() register = registry.register run_checks = registry.run_checks tag_exists = registry.tag_exists
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 7975, 492, 6036, 199, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 421, 199, 533, 25204, 8, 785, 304, 272, 408, 272, 4779, 4803, 13, 262, 3762, 367, 5007, 5920, 14, 272, 408, 272, 4628, 275, 283, 2113, 7, 272, 7163, 275, 283, 15390, 7, 272, 1709, 275, 283, 992, 7, 272, 6391, 275, 283, 4416, 7, 272, 10166, 275, 283, 10458, 7, 272, 7009, 275, 283, 5876, 7, 421, 199, 533, 2670, 10899, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11616, 63, 8625, 275, 942, 267, 291, 14, 13605, 63, 8625, 275, 942, 339, 347, 2274, 8, 277, 12, 1104, 29, 403, 12, 627, 2969, 12, 1011, 958, 304, 267, 408, 267, 6855, 506, 1202, 465, 282, 805, 503, 282, 7531, 14, 11828, 1627, 805, 267, 658, 70, 64, 23677, 543, 1627, 658, 2969, 2313, 710, 805, 1077, 9128, 1011, 958, 267, 436, 372, 769, 402, 20456, 436, 644, 2627, 14, 398, 5679, 447, 953, 7086, 275, 2670, 10899, 342, 288, 768, 5189, 14, 2683, 360, 1662, 1450, 297, 283, 13565, 1450, 358, 288, 347, 3002, 63, 1074, 8, 5181, 12, 1011, 958, 304, 355, 327, 2263, 5147, 5920, 436, 8775, 658, 2550, 64, 2263, 355, 372, 2552, 288, 327, 503, 288, 7086, 14, 2683, 8, 1662, 63, 1074, 12, 283, 1662, 1450, 297, 283, 13565, 1450, 358, 267, 408, 267, 2074, 14, 5486, 360, 11060, 297, 756, 9, 398, 347, 6506, 8, 1074, 304, 288, 1104, 14, 2969, 275, 3762, 288, 340, 2074, 459, 11060, 2565, 355, 340, 1104, 440, 315, 291, 14, 13605, 63, 8625, 26, 490, 291, 14, 13605, 63, 8625, 14, 740, 8, 1074, 9, 288, 916, 1104, 440, 315, 291, 14, 11616, 63, 8625, 26, 355, 291, 14, 11616, 63, 8625, 14, 740, 8, 1074, 9, 288, 372, 1104, 398, 340, 4550, 8, 1074, 304, 288, 372, 6506, 8, 1074, 9, 267, 587, 26, 288, 340, 1104, 26, 355, 3762, 847, 334, 1074, 12, 776, 288, 372, 6506, 339, 347, 1255, 63, 8625, 8, 277, 12, 1145, 63, 7532, 29, 403, 12, 3762, 29, 403, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 408, 267, 3378, 1006, 7264, 5920, 436, 372, 769, 402, 20456, 436, 644, 2627, 14, 267, 408, 267, 2552, 275, 942, 267, 5920, 275, 291, 14, 362, 63, 8625, 8, 2613, 63, 13605, 63, 8625, 9, 398, 340, 3762, 365, 440, 488, 26, 288, 5920, 275, 359, 1074, 367, 1104, 315, 5920, 1993, 340, 2688, 8, 1074, 12, 283, 2969, 358, 436, 663, 8, 1074, 14, 2969, 9, 1253, 663, 8, 2969, 1874, 398, 367, 1104, 315, 5920, 26, 288, 892, 63, 2550, 275, 1104, 8, 571, 63, 7532, 29, 571, 63, 7532, 9, 288, 702, 365, 63, 8147, 8, 1222, 63, 2550, 395, 334, 355, 298, 1918, 805, 450, 82, 8103, 440, 372, 282, 769, 14, 2900, 3423, 7264, 298, 355, 298, 1045, 314, 5920, 7086, 1471, 372, 282, 769, 2122, 450, 1104, 9, 288, 2552, 14, 2880, 8, 1222, 63, 2550, 9, 267, 372, 2552, 339, 347, 1947, 63, 2444, 8, 277, 12, 1947, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 372, 1947, 315, 291, 14, 2969, 63, 4561, 8, 2613, 63, 13605, 63, 8625, 9, 339, 347, 3762, 63, 4561, 8, 277, 12, 14295, 63, 8625, 29, 797, 304, 267, 372, 663, 8, 4429, 23151, 1074, 14, 2969, 367, 1104, 315, 291, 14, 362, 63, 8625, 8, 13605, 63, 8625, 9, 340, 2688, 8, 1074, 12, 283, 2969, 358, 2459, 339, 347, 664, 63, 8625, 8, 277, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 5920, 275, 769, 8, 277, 14, 11616, 63, 8625, 9, 267, 340, 2387, 63, 13605, 63, 8625, 26, 288, 5920, 14, 2880, 8, 277, 14, 13605, 63, 8625, 9, 267, 372, 5920, 421, 199, 5189, 275, 2670, 10899, 342, 199, 2683, 275, 7086, 14, 2683, 199, 1065, 63, 8625, 275, 7086, 14, 1065, 63, 8625, 199, 1450, 63, 2444, 275, 7086, 14, 1450, 63, 2444, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 7975, 492, 6036, 199, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 421, 199, 533, 25204, 8, 785, 304, 272, 408, 272, 4779, 4803, 13, 262, 3762, 367, 5007, 5920, 14, 272, 408, 272, 4628, 275, 283, 2113, 7, 272, 7163, 275, 283, 15390, 7, 272, 1709, 275, 283, 992, 7, 272, 6391, 275, 283, 4416, 7, 272, 10166, 275, 283, 10458, 7, 272, 7009, 275, 283, 5876, 7, 421, 199, 533, 2670, 10899, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 11616, 63, 8625, 275, 942, 267, 291, 14, 13605, 63, 8625, 275, 942, 339, 347, 2274, 8, 277, 12, 1104, 29, 403, 12, 627, 2969, 12, 1011, 958, 304, 267, 408, 267, 6855, 506, 1202, 465, 282, 805, 503, 282, 7531, 14, 11828, 1627, 805, 267, 658, 70, 64, 23677, 543, 1627, 658, 2969, 2313, 710, 805, 1077, 9128, 1011, 958, 267, 436, 372, 769, 402, 20456, 436, 644, 2627, 14, 398, 5679, 447, 953, 7086, 275, 2670, 10899, 342, 288, 768, 5189, 14, 2683, 360, 1662, 1450, 297, 283, 13565, 1450, 358, 288, 347, 3002, 63, 1074, 8, 5181, 12, 1011, 958, 304, 355, 327, 2263, 5147, 5920, 436, 8775, 658, 2550, 64, 2263, 355, 372, 2552, 288, 327, 503, 288, 7086, 14, 2683, 8, 1662, 63, 1074, 12, 283, 1662, 1450, 297, 283, 13565, 1450, 358, 267, 408, 267, 2074, 14, 5486, 360, 11060, 297, 756, 9, 398, 347, 6506, 8, 1074, 304, 288, 1104, 14, 2969, 275, 3762, 288, 340, 2074, 459, 11060, 2565, 355, 340, 1104, 440, 315, 291, 14, 13605, 63, 8625, 26, 490, 291, 14, 13605, 63, 8625, 14, 740, 8, 1074, 9, 288, 916, 1104, 440, 315, 291, 14, 11616, 63, 8625, 26, 355, 291, 14, 11616, 63, 8625, 14, 740, 8, 1074, 9, 288, 372, 1104, 398, 340, 4550, 8, 1074, 304, 288, 372, 6506, 8, 1074, 9, 267, 587, 26, 288, 340, 1104, 26, 355, 3762, 847, 334, 1074, 12, 776, 288, 372, 6506, 339, 347, 1255, 63, 8625, 8, 277, 12, 1145, 63, 7532, 29, 403, 12, 3762, 29, 403, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 408, 267, 3378, 1006, 7264, 5920, 436, 372, 769, 402, 20456, 436, 644, 2627, 14, 267, 408, 267, 2552, 275, 942, 267, 5920, 275, 291, 14, 362, 63, 8625, 8, 2613, 63, 13605, 63, 8625, 9, 398, 340, 3762, 365, 440, 488, 26, 288, 5920, 275, 359, 1074, 367, 1104, 315, 5920, 1993, 340, 2688, 8, 1074, 12, 283, 2969, 358, 436, 663, 8, 1074, 14, 2969, 9, 1253, 663, 8, 2969, 1874, 398, 367, 1104, 315, 5920, 26, 288, 892, 63, 2550, 275, 1104, 8, 571, 63, 7532, 29, 571, 63, 7532, 9, 288, 702, 365, 63, 8147, 8, 1222, 63, 2550, 395, 334, 355, 298, 1918, 805, 450, 82, 8103, 440, 372, 282, 769, 14, 2900, 3423, 7264, 298, 355, 298, 1045, 314, 5920, 7086, 1471, 372, 282, 769, 2122, 450, 1104, 9, 288, 2552, 14, 2880, 8, 1222, 63, 2550, 9, 267, 372, 2552, 339, 347, 1947, 63, 2444, 8, 277, 12, 1947, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 372, 1947, 315, 291, 14, 2969, 63, 4561, 8, 2613, 63, 13605, 63, 8625, 9, 339, 347, 3762, 63, 4561, 8, 277, 12, 14295, 63, 8625, 29, 797, 304, 267, 372, 663, 8, 4429, 23151, 1074, 14, 2969, 367, 1104, 315, 291, 14, 362, 63, 8625, 8, 13605, 63, 8625, 9, 340, 2688, 8, 1074, 12, 283, 2969, 358, 2459, 339, 347, 664, 63, 8625, 8, 277, 12, 2387, 63, 13605, 63, 8625, 29, 797, 304, 267, 5920, 275, 769, 8, 277, 14, 11616, 63, 8625, 9, 267, 340, 2387, 63, 13605, 63, 8625, 26, 288, 5920, 14, 2880, 8, 277, 14, 13605, 63, 8625, 9, 267, 372, 5920, 421, 199, 5189, 275, 2670, 10899, 342, 199, 2683, 275, 7086, 14, 2683, 199, 1065, 63, 8625, 275, 7086, 14, 1065, 63, 8625, 199, 1450, 63, 2444, 275, 7086, 14, 1450, 63, 2444, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
endlessm/chromium-browser
ui/file_manager/base/gn/js_test_gen_html.py
3
5074
# Copyright 2019 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Generates HTML file with all dependencies from a js_unittest build target.""" import os import sys from argparse import ArgumentParser _HTML_FILE = r"""<!DOCTYPE html> <html> <script> // Basic include checker. window.addEventListener('error', function(e) { if ((e.target instanceof HTMLScriptElement)) { console.log('ERROR loading <script> element (does it exist?):\n\t' + e.srcElement.src + '\n\tIncluded from: ' + e.srcElement.baseURI); } }, true /* useCapture */); </script> <body> """ _SCRIPT = r'<script src="%s"></script>' _IMPORT = r'<link rel="import" href="%s">' _HTML_FOOTER = r""" </body> </html> """ def _process_deps(unique_deps, html_import, target_name): """Processes all deps strings, yielding each HTML tag to include the dep. Args: unique_deps: Iterator of strings, for all deps to be processed. html_import: Boolean: Enables the use of HTMLImport for the main Polymer element being tested. target_name: Current test target name, used to infer the main Polymer element for HTMLImport. element_unitest => element.js/element.html. Returns: Iterator of strings, each string is a HTML tag <script> or <link>. """ for dep in unique_deps: # Special case for jstemplate which has multiple files but we server all of # them combined from chrome://resources/js/jstemplate_compiled.js if '/jstemplate/' in dep: if '/jstemplate.js' in dep: yield ('<script src=' '"chrome://resources/js/jstemplate_compiled.js"></script>') # just ignore other files files from /jstemplate/ continue # Map file_manager files: dep = dep.replace('ui/file_manager/', 'chrome://file_manager_test/ui/file_manager/', 1) # WebUI files (both Polymer and non-Polymer): dep = dep.replace('ui/webui/resources/', 'chrome://resources/', 1) # Polymer Files: dep = dep.replace('third_party/polymer/', 'chrome://resources/polymer/', 1) dep = dep.replace('components-chromium/', '', 1) # Remove the relative because all replaces above map to an absolute path in # chrome://* and this URL scheme doesn't allow "..". dep = dep.replace('../', '') # Find the file being tested eg: element_unittest => element.js implementation_file = target_name.replace('_unittest', '.js') # If it should use HTMLImport the main element JS file shouldn't be # included, instead we <link rel=import> its HTML file which in turn # includes the JS file. Note that all other JS deps are included as # <script>. if html_import and dep.endswith(implementation_file): dep = dep.replace('.js', '.html') yield _IMPORT % (dep) else: # Normal dep, just return the <script src="dep.js"> yield _SCRIPT % (dep) def _process(deps, output_filename, mocks, html_import, target_name): """Generates the HTML file with all JS dependencies for JS unittest. Args: deps: List of strings for each dependency path. output_filename: String, HTML file name that will be generated. mocks: List of strings, JS file names that will be included in the bottom to overwrite JS implementation from deps. html_import: Boolean, indicate if HTMLImport should be used for testing Polymer elements. target_name: Current test target name, used to infer the main Polymer element for HTMLImport. element_unitest => element.js/element.html. """ with open(output_filename, 'w') as out: out.write(_HTML_FILE) for dep in _process_deps(mocks, html_import, target_name): out.write(dep + '\n') for dep in _process_deps(deps, html_import, target_name): out.write(dep + '\n') out.write(_HTML_FOOTER) def main(): parser = ArgumentParser() parser.add_argument( '-s', '--src_path', help='Path to //src/ directory', required=True) parser.add_argument( '-i', '--input', help='Input dependency file generated by js_library.py', required=True) parser.add_argument( '-o', '--output', help='Generated html output with flattened dependencies', required=True) parser.add_argument( '-m', '--mocks', nargs='*', default=[], help='List of additional js files to load before others') parser.add_argument('-t', '--target_name', help='Test target name') parser.add_argument( '--html_import', action='store_true', help='Enable HTMLImports, used for Polymer elements') args = parser.parse_args() # Append closure path to sys.path to be able to import js_unit_test. sys.path.append(os.path.join(args.src_path, 'third_party/closure_compiler')) from js_binary import CrawlDepsTree deps, _ = CrawlDepsTree([args.input]) return _process(deps, args.output, args.mocks, args.html_import, args.target_name) if __name__ == '__main__': main()
bsd-3-clause
[ 3, 1898, 20312, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 624, 20551, 4163, 570, 543, 1006, 5124, 687, 282, 8586, 63, 2796, 1900, 1347, 1041, 199, 199, 646, 747, 199, 646, 984, 199, 504, 7534, 492, 27615, 199, 199, 63, 4943, 63, 3817, 275, 519, 624, 11230, 16556, 3517, 30, 199, 28, 1360, 30, 199, 28, 1579, 30, 199, 501, 10082, 2387, 7739, 14, 199, 3806, 14, 525, 2390, 10464, 360, 705, 297, 805, 8, 69, 9, 469, 523, 340, 3666, 69, 14, 1375, 1256, 1618, 4163, 5229, 2162, 430, 469, 272, 8559, 14, 793, 360, 3170, 8697, 665, 1579, 30, 1819, 334, 9105, 652, 2187, 31, 17211, 78, 60, 84, 7, 435, 355, 325, 14, 2164, 2162, 14, 2164, 435, 1557, 78, 60, 84, 607, 3331, 687, 26, 283, 435, 355, 325, 14, 2164, 2162, 14, 1095, 7639, 2736, 523, 789, 199, 1386, 2549, 13505, 675, 16640, 11589, 2736, 199, 1108, 1579, 30, 199, 28, 2030, 30, 199, 624, 199, 199, 63, 10484, 275, 519, 7601, 1579, 2928, 5961, 83, 10070, 1579, 3524, 199, 63, 17576, 275, 519, 7601, 1073, 4668, 628, 646, 2, 4369, 5961, 83, 15603, 199, 199, 63, 4943, 63, 13046, 1157, 275, 519, 624, 199, 1108, 2030, 30, 199, 1108, 1360, 30, 199, 624, 421, 199, 318, 485, 1412, 63, 5846, 8, 3235, 63, 5846, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 523, 408, 25857, 1006, 10140, 3326, 12, 32035, 1924, 4163, 1947, 370, 2387, 314, 2657, 14, 819, 3033, 26, 272, 3747, 63, 5846, 26, 25769, 402, 3326, 12, 367, 1006, 10140, 370, 506, 7686, 14, 272, 3517, 63, 646, 26, 9411, 26, 3447, 5921, 314, 675, 402, 4163, 6295, 367, 314, 2446, 16869, 2626, 489, 1819, 3769, 12470, 14, 272, 1347, 63, 354, 26, 9338, 511, 1347, 536, 12, 1202, 370, 18538, 314, 2446, 16869, 2626, 489, 1819, 367, 4163, 6295, 14, 1819, 63, 5411, 396, 9265, 1819, 14, 3596, 15, 2108, 14, 1360, 14, 819, 1803, 26, 272, 25769, 402, 3326, 12, 1924, 1059, 365, 282, 4163, 1947, 665, 1579, 30, 503, 665, 1073, 10827, 523, 408, 523, 367, 2657, 315, 3747, 63, 5846, 26, 272, 327, 12568, 1930, 367, 8586, 1160, 1314, 965, 3663, 1584, 1325, 781, 1654, 1006, 402, 272, 327, 3062, 12149, 687, 18221, 921, 4435, 15, 3596, 15, 3596, 1160, 63, 8427, 14, 3596, 272, 340, 1994, 3596, 1160, 4805, 315, 2657, 26, 489, 340, 1994, 3596, 1160, 14, 3596, 7, 315, 2657, 26, 267, 1995, 19990, 1579, 2928, 534, 2049, 5522, 9887, 921, 4435, 15, 3596, 15, 3596, 1160, 63, 8427, 14, 3596, 10070, 1579, 5971, 489, 327, 2951, 3686, 1163, 1584, 1584, 687, 1182, 3596, 1160, 15, 489, 1980, 339, 327, 9672, 570, 63, 2609, 1584, 26, 272, 2657, 275, 2657, 14, 1814, 360, 1907, 15, 493, 63, 2609, 3678, 1993, 283, 9887, 921, 493, 63, 2609, 63, 396, 15, 1907, 15, 493, 63, 2609, 3678, 413, 9, 272, 327, 6001, 6379, 1584, 334, 10727, 16869, 2626, 436, 2222, 13, 12747, 2626, 304, 272, 2657, 275, 2657, 14, 1814, 360, 1907, 15, 31991, 73, 15, 4435, 3678, 283, 9887, 921, 4435, 3678, 413, 9, 339, 327, 16869, 2626, 16920, 26, 272, 2657, 275, 2657, 14, 1814, 360, 11470, 63, 7522, 15, 6023, 2626, 3678, 283, 9887, 921, 4435, 15, 6023, 2626, 3678, 413, 9, 272, 2657, 275, 2657, 14, 1814, 360, 4608, 13, 13211, 3678, 3260, 413, 9, 339, 327, 5852, 314, 3847, 2952, 1006, 19058, 3432, 2341, 370, 376, 3679, 931, 315, 272, 327, 18221, 921, 10, 436, 642, 2851, 5687, 3181, 1133, 2040, 21777, 1674, 272, 2657, 275, 2657, 14, 1814, 24893, 3678, 4074, 339, 327, 6668, 314, 570, 3769, 12470, 11837, 26, 1819, 63, 2796, 9265, 1819, 14, 3596, 272, 4514, 63, 493, 275, 1347, 63, 354, 14, 1814, 6412, 2796, 297, 1987, 3596, 358, 339, 327, 982, 652, 1077, 675, 4163, 6295, 314, 2446, 1819, 18001, 570, 9296, 1133, 506, 272, 327, 5120, 12, 3140, 781, 665, 1073, 4668, 29, 646, 30, 2399, 4163, 570, 1314, 315, 7485, 272, 327, 6952, 314, 18001, 570, 14, 3390, 626, 1006, 1163, 18001, 10140, 787, 5120, 465, 272, 327, 665, 1579, 10827, 272, 340, 3517, 63, 646, 436, 2657, 14, 4130, 8, 12236, 63, 493, 304, 489, 2657, 275, 2657, 14, 1814, 5175, 3596, 297, 1987, 1360, 358, 489, 1995, 485, 17576, 450, 334, 2601, 9, 272, 587, 26, 489, 327, 11514, 2657, 12, 2951, 372, 314, 665, 1579, 2928, 628, 2601, 14, 3596, 1743, 489, 1995, 485, 10484, 450, 334, 2601, 9, 421, 199, 318, 485, 1412, 8, 5846, 12, 1072, 63, 1501, 12, 26500, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 523, 408, 20551, 314, 4163, 570, 543, 1006, 18001, 5124, 367, 18001, 2882, 14, 819, 3033, 26, 272, 10140, 26, 3820, 402, 3326, 367, 1924, 5936, 931, 14, 272, 1072, 63, 1501, 26, 2624, 12, 4163, 570, 536, 626, 911, 506, 4046, 14, 272, 26500, 26, 3820, 402, 3326, 12, 18001, 570, 1561, 626, 911, 506, 5120, 315, 314, 9048, 370, 489, 8970, 18001, 4514, 687, 10140, 14, 272, 3517, 63, 646, 26, 9411, 12, 6623, 340, 4163, 6295, 1077, 506, 1202, 367, 5343, 489, 16869, 2626, 4008, 14, 272, 1347, 63, 354, 26, 9338, 511, 1347, 536, 12, 1202, 370, 18538, 314, 2446, 16869, 2626, 489, 1819, 367, 4163, 6295, 14, 1819, 63, 5411, 396, 9265, 1819, 14, 3596, 15, 2108, 14, 1360, 14, 523, 408, 819, 543, 1551, 8, 1199, 63, 1501, 12, 283, 87, 358, 465, 734, 26, 272, 734, 14, 952, 1547, 4943, 63, 3817, 9, 272, 367, 2657, 315, 485, 1412, 63, 5846, 8, 25191, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 489, 734, 14, 952, 8, 2601, 435, 1557, 78, 358, 272, 367, 2657, 315, 485, 1412, 63, 5846, 8, 5846, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 489, 734, 14, 952, 8, 2601, 435, 1557, 78, 358, 339, 734, 14, 952, 1547, 4943, 63, 13046, 1157, 9, 421, 199, 318, 2446, 837, 523 ]
[ 1898, 20312, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 624, 20551, 4163, 570, 543, 1006, 5124, 687, 282, 8586, 63, 2796, 1900, 1347, 1041, 199, 199, 646, 747, 199, 646, 984, 199, 504, 7534, 492, 27615, 199, 199, 63, 4943, 63, 3817, 275, 519, 624, 11230, 16556, 3517, 30, 199, 28, 1360, 30, 199, 28, 1579, 30, 199, 501, 10082, 2387, 7739, 14, 199, 3806, 14, 525, 2390, 10464, 360, 705, 297, 805, 8, 69, 9, 469, 523, 340, 3666, 69, 14, 1375, 1256, 1618, 4163, 5229, 2162, 430, 469, 272, 8559, 14, 793, 360, 3170, 8697, 665, 1579, 30, 1819, 334, 9105, 652, 2187, 31, 17211, 78, 60, 84, 7, 435, 355, 325, 14, 2164, 2162, 14, 2164, 435, 1557, 78, 60, 84, 607, 3331, 687, 26, 283, 435, 355, 325, 14, 2164, 2162, 14, 1095, 7639, 2736, 523, 789, 199, 1386, 2549, 13505, 675, 16640, 11589, 2736, 199, 1108, 1579, 30, 199, 28, 2030, 30, 199, 624, 199, 199, 63, 10484, 275, 519, 7601, 1579, 2928, 5961, 83, 10070, 1579, 3524, 199, 63, 17576, 275, 519, 7601, 1073, 4668, 628, 646, 2, 4369, 5961, 83, 15603, 199, 199, 63, 4943, 63, 13046, 1157, 275, 519, 624, 199, 1108, 2030, 30, 199, 1108, 1360, 30, 199, 624, 421, 199, 318, 485, 1412, 63, 5846, 8, 3235, 63, 5846, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 523, 408, 25857, 1006, 10140, 3326, 12, 32035, 1924, 4163, 1947, 370, 2387, 314, 2657, 14, 819, 3033, 26, 272, 3747, 63, 5846, 26, 25769, 402, 3326, 12, 367, 1006, 10140, 370, 506, 7686, 14, 272, 3517, 63, 646, 26, 9411, 26, 3447, 5921, 314, 675, 402, 4163, 6295, 367, 314, 2446, 16869, 2626, 489, 1819, 3769, 12470, 14, 272, 1347, 63, 354, 26, 9338, 511, 1347, 536, 12, 1202, 370, 18538, 314, 2446, 16869, 2626, 489, 1819, 367, 4163, 6295, 14, 1819, 63, 5411, 396, 9265, 1819, 14, 3596, 15, 2108, 14, 1360, 14, 819, 1803, 26, 272, 25769, 402, 3326, 12, 1924, 1059, 365, 282, 4163, 1947, 665, 1579, 30, 503, 665, 1073, 10827, 523, 408, 523, 367, 2657, 315, 3747, 63, 5846, 26, 272, 327, 12568, 1930, 367, 8586, 1160, 1314, 965, 3663, 1584, 1325, 781, 1654, 1006, 402, 272, 327, 3062, 12149, 687, 18221, 921, 4435, 15, 3596, 15, 3596, 1160, 63, 8427, 14, 3596, 272, 340, 1994, 3596, 1160, 4805, 315, 2657, 26, 489, 340, 1994, 3596, 1160, 14, 3596, 7, 315, 2657, 26, 267, 1995, 19990, 1579, 2928, 534, 2049, 5522, 9887, 921, 4435, 15, 3596, 15, 3596, 1160, 63, 8427, 14, 3596, 10070, 1579, 5971, 489, 327, 2951, 3686, 1163, 1584, 1584, 687, 1182, 3596, 1160, 15, 489, 1980, 339, 327, 9672, 570, 63, 2609, 1584, 26, 272, 2657, 275, 2657, 14, 1814, 360, 1907, 15, 493, 63, 2609, 3678, 1993, 283, 9887, 921, 493, 63, 2609, 63, 396, 15, 1907, 15, 493, 63, 2609, 3678, 413, 9, 272, 327, 6001, 6379, 1584, 334, 10727, 16869, 2626, 436, 2222, 13, 12747, 2626, 304, 272, 2657, 275, 2657, 14, 1814, 360, 1907, 15, 31991, 73, 15, 4435, 3678, 283, 9887, 921, 4435, 3678, 413, 9, 339, 327, 16869, 2626, 16920, 26, 272, 2657, 275, 2657, 14, 1814, 360, 11470, 63, 7522, 15, 6023, 2626, 3678, 283, 9887, 921, 4435, 15, 6023, 2626, 3678, 413, 9, 272, 2657, 275, 2657, 14, 1814, 360, 4608, 13, 13211, 3678, 3260, 413, 9, 339, 327, 5852, 314, 3847, 2952, 1006, 19058, 3432, 2341, 370, 376, 3679, 931, 315, 272, 327, 18221, 921, 10, 436, 642, 2851, 5687, 3181, 1133, 2040, 21777, 1674, 272, 2657, 275, 2657, 14, 1814, 24893, 3678, 4074, 339, 327, 6668, 314, 570, 3769, 12470, 11837, 26, 1819, 63, 2796, 9265, 1819, 14, 3596, 272, 4514, 63, 493, 275, 1347, 63, 354, 14, 1814, 6412, 2796, 297, 1987, 3596, 358, 339, 327, 982, 652, 1077, 675, 4163, 6295, 314, 2446, 1819, 18001, 570, 9296, 1133, 506, 272, 327, 5120, 12, 3140, 781, 665, 1073, 4668, 29, 646, 30, 2399, 4163, 570, 1314, 315, 7485, 272, 327, 6952, 314, 18001, 570, 14, 3390, 626, 1006, 1163, 18001, 10140, 787, 5120, 465, 272, 327, 665, 1579, 10827, 272, 340, 3517, 63, 646, 436, 2657, 14, 4130, 8, 12236, 63, 493, 304, 489, 2657, 275, 2657, 14, 1814, 5175, 3596, 297, 1987, 1360, 358, 489, 1995, 485, 17576, 450, 334, 2601, 9, 272, 587, 26, 489, 327, 11514, 2657, 12, 2951, 372, 314, 665, 1579, 2928, 628, 2601, 14, 3596, 1743, 489, 1995, 485, 10484, 450, 334, 2601, 9, 421, 199, 318, 485, 1412, 8, 5846, 12, 1072, 63, 1501, 12, 26500, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 523, 408, 20551, 314, 4163, 570, 543, 1006, 18001, 5124, 367, 18001, 2882, 14, 819, 3033, 26, 272, 10140, 26, 3820, 402, 3326, 367, 1924, 5936, 931, 14, 272, 1072, 63, 1501, 26, 2624, 12, 4163, 570, 536, 626, 911, 506, 4046, 14, 272, 26500, 26, 3820, 402, 3326, 12, 18001, 570, 1561, 626, 911, 506, 5120, 315, 314, 9048, 370, 489, 8970, 18001, 4514, 687, 10140, 14, 272, 3517, 63, 646, 26, 9411, 12, 6623, 340, 4163, 6295, 1077, 506, 1202, 367, 5343, 489, 16869, 2626, 4008, 14, 272, 1347, 63, 354, 26, 9338, 511, 1347, 536, 12, 1202, 370, 18538, 314, 2446, 16869, 2626, 489, 1819, 367, 4163, 6295, 14, 1819, 63, 5411, 396, 9265, 1819, 14, 3596, 15, 2108, 14, 1360, 14, 523, 408, 819, 543, 1551, 8, 1199, 63, 1501, 12, 283, 87, 358, 465, 734, 26, 272, 734, 14, 952, 1547, 4943, 63, 3817, 9, 272, 367, 2657, 315, 485, 1412, 63, 5846, 8, 25191, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 489, 734, 14, 952, 8, 2601, 435, 1557, 78, 358, 272, 367, 2657, 315, 485, 1412, 63, 5846, 8, 5846, 12, 3517, 63, 646, 12, 1347, 63, 354, 304, 489, 734, 14, 952, 8, 2601, 435, 1557, 78, 358, 339, 734, 14, 952, 1547, 4943, 63, 13046, 1157, 9, 421, 199, 318, 2446, 837, 523, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
odicraig/kodi2odi
addons/plugin.video.roggerstream-5.0.2/securi.py
82
3059
debug=False def printdebug(ss): if debug: print ss def getval(strval): strval=strval.strip() if 'slice' in strval: strval=strval.split(".slice(")#.replace(',',':')+']' strval=strval[0]+"["+strval[1].split(')')[0].replace(',',':')+"]" elif 'String.fromCharCode' in strval: strval=strval.replace('String.fromCharCode','chr') elif 'charAt' in strval: strval=strval.replace('.charAt','[').replace('(','').replace(')','')+']' if 'substr' in strval: strval=strval.split(".substr(")#.replace(',',':')+']' f,t=strval[1].split(')')[0].split(',') strval=strval[0]+"["+f+":"+f+'+'+t +"]" printdebug( strval) return eval(strval) def getSecuriCookie(html): import re puts=re.findall("S='(.*?)';",html)[0] puts= puts.decode("base64") printdebug( puts) val=re.findall("[a-z]=([\"'].*?);",puts,re.DOTALL)[0] vals=re.findall('(.*?)[ ]?\+',val) v="" for vv in vals: v+=getval(vv) e=v val=re.findall("cookie=(.*?);",puts,re.DOTALL)[0] vals=re.findall('(.*?)[ ]?\+',val) printdebug( vals) c="" for vv in vals: c+=getval(vv) c+=v return c #print getSecuriCookie("<html><title>You are being redirected...</title><noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript><script>var s={},u,c,U,r,i,l=0,a,e=eval,w=String.fromCharCode,sucuri_cloudproxy_js='',S='cD0iOSIuc2xpY2UoMCwxKSArIFN0cmluZy5mcm9tQ2hhckNvZGUoNTEpICsgIjkiLnNsaWNlKDAsMSkgKyAnTDUnLnNsaWNlKDEsMikrIjBzdSIuc2xpY2UoMCwxKSArICAnJyArIjlzdWN1ciIuY2hhckF0KDApKyJlIiArICIiICsiOSIgKyAgJycgKyJlIi5zbGljZSgwLDEpICsgICcnICsiMXN1Ii5zbGljZSgwLDEpICsgJz8zJy5zbGljZSgxLDIpKyAnJyArJycrJ3hPZCcuY2hhckF0KDIpKyJkc3UiLnNsaWNlKDAsMSkgKyBTdHJpbmcuZnJvbUNoYXJDb2RlKDU3KSArICIiICsnMXM0YScuc3Vic3RyKDMsIDEpICsnMScgKyAgU3RyaW5nLmZyb21DaGFyQ29kZSg1MCkgKyAnNGhaNycuc3Vic3RyKDMsIDEpICsnNScgKyAgICcnICsgCiJkIiArIFN0cmluZy5mcm9tQ2hhckNvZGUoMHg2MSkgKyBTdHJpbmcuZnJvbUNoYXJDb2RlKDU2KSArICIiICsnUmZXYicuc3Vic3RyKDMsIDEpICsgJycgKyAKJzYnICsgICAnJyArU3RyaW5nLmZyb21DaGFyQ29kZSgweDYzKSArICc+NCcuc2xpY2UoMSwyKSsnRXVPMicuc3Vic3RyKDMsIDEpICsgJycgKyJlIiArICIyc3UiLnNsaWNlKDAsMSkgKyAiNnN1Ii5zbGljZSgwLDEpICsgIiIgKydyWzcnLmNoYXJBdCgyKSsnRmw4ZScuc3Vic3RyKDMsIDEpICsgJycgKycnO2RvY3VtZW50LmNvb2tpZT0ncycrJ3UnKydjcycuY2hhckF0KDApKyd1JysncicrJ2lzJy5jaGFyQXQoMCkrJ18nKycnKydjJysnbHN1Jy5jaGFyQXQoMCkgKydvJysnc3VjdXJ1Jy5jaGFyQXQoNSkgKyAnZCcrJ3BzdWN1cmknLmNoYXJBdCgwKSArICdyJysnbycrJ3gnKyd5JysnX3N1Y3UnLmNoYXJBdCgwKSAgKyd1JysnJysndScrJ2lzJy5jaGFyQXQoMCkrJ2QnKydfJysnc3VhJy5jaGFyQXQoMikrJzEnKycnKydzdWN1cmlhJy5jaGFyQXQoNikrJzNzdWN1cmknLmNoYXJBdCgwKSArICdic3VjdScuY2hhckF0KDApICArJzQnKycnKycyJysnJysnOCcrJ2RzdScuY2hhckF0KDApICsiPSIgKyBwOyBsb2NhdGlvbi5yZWxvYWQoKTs=';L=S.length;U=0;r='';var A='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(u=0;u<64;u++){s[A.charAt(u)]=u;}for(i=0;i<L;i++){c=s[S.charAt(i)];U=(U<<6)+c;l+=6;while(l>=8){((a=(U>>>(l-=8))&0xff)||(i<(L-2)))&&(r+=w(a));}}e(r);</script></html>")
gpl-3.0
[ 1757, 29, 797, 199, 318, 870, 1757, 8, 385, 304, 272, 340, 3105, 26, 267, 870, 10110, 199, 318, 664, 637, 8, 495, 637, 304, 272, 620, 637, 29, 495, 637, 14, 1913, 342, 272, 340, 283, 5224, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1294, 9520, 5224, 480, 28017, 14, 1814, 32718, 356, 358, 11, 418, 7, 267, 620, 637, 29, 495, 637, 59, 16, 2807, 2, 905, 11, 495, 637, 59, 17, 1055, 1294, 15938, 5832, 16, 1055, 1814, 32718, 356, 358, 11, 937, 2, 272, 916, 283, 1558, 14, 504, 1610, 3034, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1814, 360, 1558, 14, 504, 1610, 3034, 1673, 10194, 358, 272, 916, 283, 1560, 1271, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1814, 5175, 1560, 1271, 1673, 59, 1959, 1814, 14097, 26516, 1814, 15938, 20944, 11, 418, 7, 272, 340, 283, 22668, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1294, 9520, 22668, 480, 28017, 14, 1814, 32718, 356, 358, 11, 418, 7, 267, 289, 12, 84, 29, 495, 637, 59, 17, 1055, 1294, 15938, 5832, 16, 1055, 1294, 11917, 2728, 620, 637, 29, 495, 637, 59, 16, 2807, 2, 905, 11, 70, 11, 5122, 11, 70, 4786, 4786, 11, 84, 435, 937, 2, 267, 870, 1757, 8, 620, 637, 9, 272, 372, 3468, 8, 495, 637, 9, 199, 318, 664, 4933, 2302, 7810, 8, 1360, 304, 272, 492, 295, 272, 27000, 29, 264, 14, 6452, 480, 51, 534, 17140, 3171, 17259, 1360, 2788, 16, 61, 272, 27000, 29, 27000, 14, 2708, 480, 1095, 772, 531, 272, 870, 1757, 8, 27000, 9, 272, 1139, 29, 264, 14, 6452, 10994, 65, 13, 90, 10404, 779, 4451, 2278, 15279, 2736, 401, 524, 83, 12, 264, 14, 16504, 2788, 16, 61, 272, 5322, 29, 264, 14, 6452, 14097, 6697, 2788, 1622, 8995, 7386, 637, 9, 272, 373, 9287, 272, 367, 373, 86, 315, 5322, 26, 267, 373, 10365, 362, 637, 8, 8958, 9, 272, 325, 29, 86, 272, 1139, 29, 264, 14, 6452, 480, 5306, 2687, 6697, 2736, 401, 524, 83, 12, 264, 14, 16504, 2788, 16, 61, 272, 5322, 29, 264, 14, 6452, 14097, 6697, 2788, 1622, 8995, 7386, 637, 9, 272, 870, 1757, 8, 5322, 9, 272, 286, 9287, 272, 367, 373, 86, 315, 5322, 26, 267, 286, 10365, 362, 637, 8, 8958, 9, 272, 286, 10365, 86, 272, 372, 286, 199, 3, 1361, 664, 4933, 2302, 7810, 6757, 1360, 2535, 1213, 30, 5556, 787, 3769, 20884, 1396, 1108, 1213, 2535, 889, 1579, 30, 31708, 365, 1415, 14, 7754, 4756, 18910, 2544, 1265, 787, 4370, 370, 1937, 642, 2034, 9758, 889, 1579, 2535, 1579, 30, 1391, 308, 10324, 85, 12, 67, 12, 53, 12, 82, 12, 73, 12, 76, 29, 16, 12, 65, 12, 69, 29, 2579, 12, 87, 29, 1558, 14, 504, 1610, 3034, 12, 9648, 895, 73, 63, 4091, 3280, 63, 3596, 4581, 51, 534, 67, 36, 16, 73, 47, 2684, 947, 18, 9290, 57, 18, 53, 79, 7608, 6323, 19982, 1596, 4656, 46, 16, 67, 757, 30127, 89, 21, 77, 4400, 25, 84, 49, 18, 12156, 346, 46, 86, 58, 17188, 79, 46, 3727, 80, 948, 1226, 41, 74, 8810, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 2493, 13449, 1358, 8940, 46, 2231, 3705, 76, 43, 1093, 83, 45, 3258, 82, 41, 74, 34, 23670, 2684, 947, 18, 9290, 57, 18, 53, 79, 7608, 6323, 19982, 1596, 948, 2493, 16608, 1596, 41, 74, 76, 23670, 3705, 17, 559, 41, 85, 57, 18, 12156, 346, 38, 16, 43, 8980, 80, 43, 89, 31182, 31105, 1596, 948, 31105, 948, 338, 47, 2684, 71, 43, 89, 5676, 16608, 12595, 43, 89, 31182, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 948, 6413, 948, 338, 17401, 46, 17, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 25620, 24, 90, 16608, 21, 20176, 17541, 74, 26697, 20777, 44, 1914, 80, 43, 89, 2493, 16608, 1596, 16608, 1556, 42, 19, 72, 48, 58, 35, 15140, 57, 18, 12156, 346, 38, 16, 43, 1914, 80, 43, 89, 42, 75, 67, 19, 18203, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 19162, 68, 22313, 3317, 5466, 85, 26713, 42, 18708, 1734, 79, 16936, 42, 8882, 18, 50, 76, 43, 4980, 19, 19982, 1596, 948, 31105, 948, 5167, 45, 13901, 16, 57, 7181, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 5167, 3053, 12595, 43, 89, 5676, 53, 19, 50, 11552, 55, 21, 78, 23041, 58, 28564, 2025, 25014, 17395, 89, 49, 1398, 75, 26697, 71, 17, 7608, 9761, 43, 89, 2493, 12259, 2411, 22781, 67, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 5167, 2709, 12595, 43, 89, 5676, 948, 6413, 948, 1226, 28665, 42, 75, 31105, 1596, 4656, 46, 16, 67, 757, 30127, 89, 21, 77, 4400, 25, 84, 49, 18, 12156, 346, 46, 86, 58, 17188, 79, 30668, 71, 18, 3053, 9761, 43, 89, 19162, 68, 22313, 3317, 5466, 85, 26713, 42, 18708, 1734, 79, 16936, 42, 8882, 18, 50, 76, 43, 4980, 18, 19982, 1596, 948, 31105, 948, 5167, 53, 77, 58, 8195, 530, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 1226, 16608, 12595, 43, 89, 7872, 25620, 57, 78, 948, 1226, 948, 2493, 16608, 1596, 53, 19, 50, 11552, 55, 21, 78, 23041, 58, 28564, 2025, 25014, 17395, 89, 49, 1398, 75, 26697, 71, 1129, 11446, 90, 19982, 1596, 948, 67, 11, 6389, 67, 947, 18, 9290, 57, 18, 53, 79, 3053, 87, 89, 19982, 5167, 15361, 54, 10793, 530, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 1226, 16608, 12595, 43, 89, 31182, 31105, 1596, 948, 41, 29874, 19, 18203, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 28960, 46, 78, 46, 17, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 31105, 27061, 43, 89, 8161, 55, 90, 6413, 23041, 1944, 16936, 42, 34, 68, 35, 4312, 19982, 5167, 50, 14716, 20, 58, 7181, 947 ]
[ 29, 797, 199, 318, 870, 1757, 8, 385, 304, 272, 340, 3105, 26, 267, 870, 10110, 199, 318, 664, 637, 8, 495, 637, 304, 272, 620, 637, 29, 495, 637, 14, 1913, 342, 272, 340, 283, 5224, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1294, 9520, 5224, 480, 28017, 14, 1814, 32718, 356, 358, 11, 418, 7, 267, 620, 637, 29, 495, 637, 59, 16, 2807, 2, 905, 11, 495, 637, 59, 17, 1055, 1294, 15938, 5832, 16, 1055, 1814, 32718, 356, 358, 11, 937, 2, 272, 916, 283, 1558, 14, 504, 1610, 3034, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1814, 360, 1558, 14, 504, 1610, 3034, 1673, 10194, 358, 272, 916, 283, 1560, 1271, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1814, 5175, 1560, 1271, 1673, 59, 1959, 1814, 14097, 26516, 1814, 15938, 20944, 11, 418, 7, 272, 340, 283, 22668, 7, 315, 620, 637, 26, 267, 620, 637, 29, 495, 637, 14, 1294, 9520, 22668, 480, 28017, 14, 1814, 32718, 356, 358, 11, 418, 7, 267, 289, 12, 84, 29, 495, 637, 59, 17, 1055, 1294, 15938, 5832, 16, 1055, 1294, 11917, 2728, 620, 637, 29, 495, 637, 59, 16, 2807, 2, 905, 11, 70, 11, 5122, 11, 70, 4786, 4786, 11, 84, 435, 937, 2, 267, 870, 1757, 8, 620, 637, 9, 272, 372, 3468, 8, 495, 637, 9, 199, 318, 664, 4933, 2302, 7810, 8, 1360, 304, 272, 492, 295, 272, 27000, 29, 264, 14, 6452, 480, 51, 534, 17140, 3171, 17259, 1360, 2788, 16, 61, 272, 27000, 29, 27000, 14, 2708, 480, 1095, 772, 531, 272, 870, 1757, 8, 27000, 9, 272, 1139, 29, 264, 14, 6452, 10994, 65, 13, 90, 10404, 779, 4451, 2278, 15279, 2736, 401, 524, 83, 12, 264, 14, 16504, 2788, 16, 61, 272, 5322, 29, 264, 14, 6452, 14097, 6697, 2788, 1622, 8995, 7386, 637, 9, 272, 373, 9287, 272, 367, 373, 86, 315, 5322, 26, 267, 373, 10365, 362, 637, 8, 8958, 9, 272, 325, 29, 86, 272, 1139, 29, 264, 14, 6452, 480, 5306, 2687, 6697, 2736, 401, 524, 83, 12, 264, 14, 16504, 2788, 16, 61, 272, 5322, 29, 264, 14, 6452, 14097, 6697, 2788, 1622, 8995, 7386, 637, 9, 272, 870, 1757, 8, 5322, 9, 272, 286, 9287, 272, 367, 373, 86, 315, 5322, 26, 267, 286, 10365, 362, 637, 8, 8958, 9, 272, 286, 10365, 86, 272, 372, 286, 199, 3, 1361, 664, 4933, 2302, 7810, 6757, 1360, 2535, 1213, 30, 5556, 787, 3769, 20884, 1396, 1108, 1213, 2535, 889, 1579, 30, 31708, 365, 1415, 14, 7754, 4756, 18910, 2544, 1265, 787, 4370, 370, 1937, 642, 2034, 9758, 889, 1579, 2535, 1579, 30, 1391, 308, 10324, 85, 12, 67, 12, 53, 12, 82, 12, 73, 12, 76, 29, 16, 12, 65, 12, 69, 29, 2579, 12, 87, 29, 1558, 14, 504, 1610, 3034, 12, 9648, 895, 73, 63, 4091, 3280, 63, 3596, 4581, 51, 534, 67, 36, 16, 73, 47, 2684, 947, 18, 9290, 57, 18, 53, 79, 7608, 6323, 19982, 1596, 4656, 46, 16, 67, 757, 30127, 89, 21, 77, 4400, 25, 84, 49, 18, 12156, 346, 46, 86, 58, 17188, 79, 46, 3727, 80, 948, 1226, 41, 74, 8810, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 2493, 13449, 1358, 8940, 46, 2231, 3705, 76, 43, 1093, 83, 45, 3258, 82, 41, 74, 34, 23670, 2684, 947, 18, 9290, 57, 18, 53, 79, 7608, 6323, 19982, 1596, 948, 2493, 16608, 1596, 41, 74, 76, 23670, 3705, 17, 559, 41, 85, 57, 18, 12156, 346, 38, 16, 43, 8980, 80, 43, 89, 31182, 31105, 1596, 948, 31105, 948, 338, 47, 2684, 71, 43, 89, 5676, 16608, 12595, 43, 89, 31182, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 948, 6413, 948, 338, 17401, 46, 17, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 25620, 24, 90, 16608, 21, 20176, 17541, 74, 26697, 20777, 44, 1914, 80, 43, 89, 2493, 16608, 1596, 16608, 1556, 42, 19, 72, 48, 58, 35, 15140, 57, 18, 12156, 346, 38, 16, 43, 1914, 80, 43, 89, 42, 75, 67, 19, 18203, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 19162, 68, 22313, 3317, 5466, 85, 26713, 42, 18708, 1734, 79, 16936, 42, 8882, 18, 50, 76, 43, 4980, 19, 19982, 1596, 948, 31105, 948, 5167, 45, 13901, 16, 57, 7181, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 5167, 3053, 12595, 43, 89, 5676, 53, 19, 50, 11552, 55, 21, 78, 23041, 58, 28564, 2025, 25014, 17395, 89, 49, 1398, 75, 26697, 71, 17, 7608, 9761, 43, 89, 2493, 12259, 2411, 22781, 67, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 5167, 2709, 12595, 43, 89, 5676, 948, 6413, 948, 1226, 28665, 42, 75, 31105, 1596, 4656, 46, 16, 67, 757, 30127, 89, 21, 77, 4400, 25, 84, 49, 18, 12156, 346, 46, 86, 58, 17188, 79, 30668, 71, 18, 3053, 9761, 43, 89, 19162, 68, 22313, 3317, 5466, 85, 26713, 42, 18708, 1734, 79, 16936, 42, 8882, 18, 50, 76, 43, 4980, 18, 19982, 1596, 948, 31105, 948, 5167, 53, 77, 58, 8195, 530, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 1226, 16608, 12595, 43, 89, 7872, 25620, 57, 78, 948, 1226, 948, 2493, 16608, 1596, 53, 19, 50, 11552, 55, 21, 78, 23041, 58, 28564, 2025, 25014, 17395, 89, 49, 1398, 75, 26697, 71, 1129, 11446, 90, 19982, 1596, 948, 67, 11, 6389, 67, 947, 18, 9290, 57, 18, 53, 79, 3053, 87, 89, 19982, 5167, 15361, 54, 10793, 530, 947, 19, 54, 530, 19, 50, 89, 13368, 13586, 11259, 80, 948, 1226, 16608, 12595, 43, 89, 31182, 31105, 1596, 948, 41, 29874, 19, 18203, 8940, 46, 2231, 3705, 76, 13368, 2822, 3053, 9761, 43, 89, 28960, 46, 78, 46, 17, 31105, 21, 20176, 17541, 74, 26697, 8392, 44, 1093, 80, 948, 1226, 31105, 27061, 43, 89, 8161, 55, 90, 6413, 23041, 1944, 16936, 42, 34, 68, 35, 4312, 19982, 5167, 50, 14716, 20, 58, 7181, 947, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jvrsantacruz/XlsxWriter
xlsxwriter/test/comparison/test_chart_blank05.py
8
1689
############################################################################### # # Tests for XlsxWriter. # # Copyright (c), 2013-2015, John McNamara, jmcnamara@cpan.org # from ..excel_comparsion_test import ExcelComparisonTest from ...workbook import Workbook class TestCompareXLSXFiles(ExcelComparisonTest): """ Test file created by XlsxWriter against a file created by Excel. """ def setUp(self): self.maxDiff = None filename = 'chart_blank05.xlsx' test_dir = 'xlsxwriter/test/comparison/' self.got_filename = test_dir + '_test_' + filename self.exp_filename = test_dir + 'xlsx_files/' + filename self.ignore_files = [] self.ignore_elements = {'xl/drawings/drawing1.xml': ['<xdr:ext']} def test_create_file(self): """Test the worksheet properties of an XlsxWriter chartsheet file.""" workbook = Workbook(self.got_filename) worksheet = workbook.add_worksheet() chartsheet = workbook.add_chartsheet() chart = workbook.add_chart({'type': 'line'}) chart.axis_ids = [57619968, 57621504] data = [ [1, 2, 3, 4, 5], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], ] worksheet.write_column('A1', data[0]) worksheet.write_column('B1', data[1]) worksheet.write_column('C1', data[2]) chart.add_series({'values': '=Sheet1!$A$1:$A$5'}) chart.add_series({'values': '=Sheet1!$B$1:$B$5'}) chart.add_series({'values': '=Sheet1!$C$1:$C$5'}) chart.show_blanks_as('span') chartsheet.set_chart(chart) workbook.close() self.assertExcelEqual()
bsd-2-clause
[ 11490, 199, 3, 199, 3, 6496, 367, 1323, 478, 88, 6261, 14, 199, 3, 199, 3, 1898, 334, 67, 395, 6171, 13, 7806, 12, 17815, 22895, 46, 455, 17956, 12, 1335, 5466, 17811, 17956, 32, 1850, 290, 14, 1308, 199, 3, 199, 199, 504, 2508, 28330, 63, 863, 285, 438, 63, 396, 492, 27832, 25834, 774, 199, 504, 2263, 30765, 492, 9361, 2706, 421, 199, 533, 1379, 16051, 56, 5296, 56, 5535, 8, 920, 6067, 25834, 774, 304, 272, 408, 272, 1379, 570, 2737, 701, 1323, 478, 88, 6261, 6169, 282, 570, 2737, 701, 27832, 14, 339, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 988, 10746, 275, 488, 398, 1788, 275, 283, 9019, 63, 2500, 1717, 14, 19023, 88, 7, 398, 511, 63, 694, 275, 283, 19023, 88, 5491, 15, 396, 15, 8547, 4805, 267, 291, 14, 7808, 63, 1501, 275, 511, 63, 694, 435, 2513, 396, 8650, 435, 1788, 267, 291, 14, 1474, 63, 1501, 275, 511, 63, 694, 435, 283, 19023, 88, 63, 1725, 4805, 435, 1788, 398, 291, 14, 4247, 63, 1725, 275, 942, 267, 291, 14, 4247, 63, 5527, 275, 791, 15455, 15, 5485, 780, 15, 25195, 17, 14, 1652, 356, 12329, 2207, 82, 26, 832, 12074, 339, 347, 511, 63, 981, 63, 493, 8, 277, 304, 267, 408, 774, 314, 21127, 4382, 402, 376, 1323, 478, 88, 6261, 10943, 5069, 570, 1041, 398, 1736, 2706, 275, 9361, 2706, 8, 277, 14, 7808, 63, 1501, 9, 398, 21127, 275, 1736, 2706, 14, 525, 63, 29776, 342, 267, 10943, 5069, 275, 1736, 2706, 14, 525, 63, 9019, 5069, 342, 398, 10943, 275, 1736, 2706, 14, 525, 63, 9019, 3252, 466, 356, 283, 604, 3071, 398, 10943, 14, 3127, 63, 1580, 275, 359, 1641, 2976, 1020, 2333, 12, 959, 2114, 7842, 966, 61, 398, 666, 275, 359, 288, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 467, 288, 359, 18, 12, 841, 12, 1227, 12, 1695, 12, 1616, 467, 288, 359, 19, 12, 1227, 12, 1749, 12, 3144, 12, 4114, 467, 398, 1622, 398, 21127, 14, 952, 63, 2301, 360, 33, 17, 297, 666, 59, 16, 566, 267, 21127, 14, 952, 63, 2301, 360, 34, 17, 297, 666, 59, 17, 566, 267, 21127, 14, 952, 63, 2301, 360, 35, 17, 297, 666, 59, 18, 566, 398, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 33, 4, 17, 26, 4, 33, 4, 21, 3071, 267, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 34, 4, 17, 26, 4, 34, 4, 21, 3071, 267, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 35, 4, 17, 26, 4, 35, 4, 21, 3071, 398, 10943, 14, 2384, 63, 2500, 83, 63, 305, 360, 3751, 358, 398, 10943, 5069, 14, 409, 63, 9019, 8, 9019, 9, 398, 1736, 2706, 14, 1600, 342, 398, 291, 14, 479, 920, 6067, 591, 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 ]
[ 199, 3, 199, 3, 6496, 367, 1323, 478, 88, 6261, 14, 199, 3, 199, 3, 1898, 334, 67, 395, 6171, 13, 7806, 12, 17815, 22895, 46, 455, 17956, 12, 1335, 5466, 17811, 17956, 32, 1850, 290, 14, 1308, 199, 3, 199, 199, 504, 2508, 28330, 63, 863, 285, 438, 63, 396, 492, 27832, 25834, 774, 199, 504, 2263, 30765, 492, 9361, 2706, 421, 199, 533, 1379, 16051, 56, 5296, 56, 5535, 8, 920, 6067, 25834, 774, 304, 272, 408, 272, 1379, 570, 2737, 701, 1323, 478, 88, 6261, 6169, 282, 570, 2737, 701, 27832, 14, 339, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 988, 10746, 275, 488, 398, 1788, 275, 283, 9019, 63, 2500, 1717, 14, 19023, 88, 7, 398, 511, 63, 694, 275, 283, 19023, 88, 5491, 15, 396, 15, 8547, 4805, 267, 291, 14, 7808, 63, 1501, 275, 511, 63, 694, 435, 2513, 396, 8650, 435, 1788, 267, 291, 14, 1474, 63, 1501, 275, 511, 63, 694, 435, 283, 19023, 88, 63, 1725, 4805, 435, 1788, 398, 291, 14, 4247, 63, 1725, 275, 942, 267, 291, 14, 4247, 63, 5527, 275, 791, 15455, 15, 5485, 780, 15, 25195, 17, 14, 1652, 356, 12329, 2207, 82, 26, 832, 12074, 339, 347, 511, 63, 981, 63, 493, 8, 277, 304, 267, 408, 774, 314, 21127, 4382, 402, 376, 1323, 478, 88, 6261, 10943, 5069, 570, 1041, 398, 1736, 2706, 275, 9361, 2706, 8, 277, 14, 7808, 63, 1501, 9, 398, 21127, 275, 1736, 2706, 14, 525, 63, 29776, 342, 267, 10943, 5069, 275, 1736, 2706, 14, 525, 63, 9019, 5069, 342, 398, 10943, 275, 1736, 2706, 14, 525, 63, 9019, 3252, 466, 356, 283, 604, 3071, 398, 10943, 14, 3127, 63, 1580, 275, 359, 1641, 2976, 1020, 2333, 12, 959, 2114, 7842, 966, 61, 398, 666, 275, 359, 288, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 467, 288, 359, 18, 12, 841, 12, 1227, 12, 1695, 12, 1616, 467, 288, 359, 19, 12, 1227, 12, 1749, 12, 3144, 12, 4114, 467, 398, 1622, 398, 21127, 14, 952, 63, 2301, 360, 33, 17, 297, 666, 59, 16, 566, 267, 21127, 14, 952, 63, 2301, 360, 34, 17, 297, 666, 59, 17, 566, 267, 21127, 14, 952, 63, 2301, 360, 35, 17, 297, 666, 59, 18, 566, 398, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 33, 4, 17, 26, 4, 33, 4, 21, 3071, 267, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 34, 4, 17, 26, 4, 34, 4, 21, 3071, 267, 10943, 14, 525, 63, 5602, 3252, 1459, 356, 26143, 16715, 17, 1, 4, 35, 4, 17, 26, 4, 35, 4, 21, 3071, 398, 10943, 14, 2384, 63, 2500, 83, 63, 305, 360, 3751, 358, 398, 10943, 5069, 14, 409, 63, 9019, 8, 9019, 9, 398, 1736, 2706, 14, 1600, 342, 398, 291, 14, 479, 920, 6067, 591, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bepitulaz/huntingdimana
env/Lib/site-packages/werkzeug/datastructures.py
54
87447
# -*- coding: utf-8 -*- """ werkzeug.datastructures ~~~~~~~~~~~~~~~~~~~~~~~ This module provides mixins and classes with an immutable interface. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re import codecs import mimetypes from copy import deepcopy from itertools import repeat from werkzeug._internal import _missing, _empty_stream from werkzeug._compat import iterkeys, itervalues, iteritems, iterlists, \ PY2, text_type, integer_types, string_types, make_literal_wrapper, \ to_native from werkzeug.filesystem import get_filesystem_encoding _locale_delim_re = re.compile(r'[_-]') def is_immutable(self): raise TypeError('%r objects are immutable' % self.__class__.__name__) def iter_multi_items(mapping): """Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures. """ if isinstance(mapping, MultiDict): for item in iteritems(mapping, multi=True): yield item elif isinstance(mapping, dict): for key, value in iteritems(mapping): if isinstance(value, (tuple, list)): for value in value: yield key, value else: yield key, value else: for item in mapping: yield item def native_itermethods(names): if not PY2: return lambda x: x def setmethod(cls, name): itermethod = getattr(cls, name) setattr(cls, 'iter%s' % name, itermethod) listmethod = lambda self, *a, **kw: list(itermethod(self, *a, **kw)) listmethod.__doc__ = \ 'Like :py:meth:`iter%s`, but returns a list.' % name setattr(cls, name, listmethod) def wrap(cls): for name in names: setmethod(cls, name) return cls return wrap class ImmutableListMixin(object): """Makes a :class:`list` immutable. .. versionadded:: 0.5 :private: """ _hash_cache = None def __hash__(self): if self._hash_cache is not None: return self._hash_cache rv = self._hash_cache = hash(tuple(self)) return rv def __reduce_ex__(self, protocol): return type(self), (list(self),) def __delitem__(self, key): is_immutable(self) def __delslice__(self, i, j): is_immutable(self) def __iadd__(self, other): is_immutable(self) __imul__ = __iadd__ def __setitem__(self, key, value): is_immutable(self) def __setslice__(self, i, j, value): is_immutable(self) def append(self, item): is_immutable(self) remove = append def extend(self, iterable): is_immutable(self) def insert(self, pos, value): is_immutable(self) def pop(self, index=-1): is_immutable(self) def reverse(self): is_immutable(self) def sort(self, cmp=None, key=None, reverse=None): is_immutable(self) class ImmutableList(ImmutableListMixin, list): """An immutable :class:`list`. .. versionadded:: 0.5 :private: """ def __repr__(self): return '%s(%s)' % ( self.__class__.__name__, list.__repr__(self), ) class ImmutableDictMixin(object): """Makes a :class:`dict` immutable. .. versionadded:: 0.5 :private: """ _hash_cache = None @classmethod def fromkeys(cls, keys, value=None): instance = super(cls, cls).__new__(cls) instance.__init__(zip(keys, repeat(value))) return instance def __reduce_ex__(self, protocol): return type(self), (dict(self),) def _iter_hashitems(self): return iteritems(self) def __hash__(self): if self._hash_cache is not None: return self._hash_cache rv = self._hash_cache = hash(frozenset(self._iter_hashitems())) return rv def setdefault(self, key, default=None): is_immutable(self) def update(self, *args, **kwargs): is_immutable(self) def pop(self, key, default=None): is_immutable(self) def popitem(self): is_immutable(self) def __setitem__(self, key, value): is_immutable(self) def __delitem__(self, key): is_immutable(self) def clear(self): is_immutable(self) class ImmutableMultiDictMixin(ImmutableDictMixin): """Makes a :class:`MultiDict` immutable. .. versionadded:: 0.5 :private: """ def __reduce_ex__(self, protocol): return type(self), (list(iteritems(self, multi=True)),) def _iter_hashitems(self): return iteritems(self, multi=True) def add(self, key, value): is_immutable(self) def popitemlist(self): is_immutable(self) def poplist(self, key): is_immutable(self) def setlist(self, key, new_list): is_immutable(self) def setlistdefault(self, key, default_list=None): is_immutable(self) class UpdateDictMixin(object): """Makes dicts call `self.on_update` on modifications. .. versionadded:: 0.5 :private: """ on_update = None def calls_update(name): def oncall(self, *args, **kw): rv = getattr(super(UpdateDictMixin, self), name)(*args, **kw) if self.on_update is not None: self.on_update(self) return rv oncall.__name__ = name return oncall def setdefault(self, key, default=None): modified = key not in self rv = super(UpdateDictMixin, self).setdefault(key, default) if modified and self.on_update is not None: self.on_update(self) return rv def pop(self, key, default=_missing): modified = key in self if default is _missing: rv = super(UpdateDictMixin, self).pop(key) else: rv = super(UpdateDictMixin, self).pop(key, default) if modified and self.on_update is not None: self.on_update(self) return rv __setitem__ = calls_update('__setitem__') __delitem__ = calls_update('__delitem__') clear = calls_update('clear') popitem = calls_update('popitem') update = calls_update('update') del calls_update class TypeConversionDict(dict): """Works like a regular dict but the :meth:`get` method can perform type conversions. :class:`MultiDict` and :class:`CombinedMultiDict` are subclasses of this class and provide the same feature. .. versionadded:: 0.5 """ def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>> d = TypeConversionDict(foo='42', bar='blub') >>> d.get('foo', type=int) 42 >>> d.get('bar', -1, type=int) -1 :param key: The key to be looked up. :param default: The default value to be returned if the key can't be looked up. If not further specified `None` is returned. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` is raised by this callable the default value is returned. """ try: rv = self[key] if type is not None: rv = type(rv) except (KeyError, ValueError): rv = default return rv class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict): """Works like a :class:`TypeConversionDict` but does not support modifications. .. versionadded:: 0.5 """ def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return TypeConversionDict(self) def __copy__(self): return self @native_itermethods(['keys', 'values', 'items', 'lists', 'listvalues']) class MultiDict(TypeConversionDict): """A :class:`MultiDict` is a dictionary subclass customized to deal with multiple values for the same key which is for example used by the parsing functions in the wrappers. This is necessary because some HTML form elements pass multiple values for the same key. :class:`MultiDict` implements all standard dictionary methods. Internally, it saves all values for a key as a list, but the standard dict access methods will only return the first value for a key. If you want to gain access to the other values, too, you have to use the `list` methods as explained below. Basic Usage: >>> d = MultiDict([('a', 'b'), ('a', 'c')]) >>> d MultiDict([('a', 'b'), ('a', 'c')]) >>> d['a'] 'b' >>> d.getlist('a') ['b', 'c'] >>> 'a' in d True It behaves like a normal dict thus all dict functions will only return the first value when multiple values for one key are found. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. A :class:`MultiDict` can be constructed from an iterable of ``(key, value)`` tuples, a dict, a :class:`MultiDict` or from Werkzeug 0.2 onwards some keyword parameters. :param mapping: the initial value for the :class:`MultiDict`. Either a regular dict, an iterable of ``(key, value)`` tuples or `None`. """ def __init__(self, mapping=None): if isinstance(mapping, MultiDict): dict.__init__(self, ((k, l[:]) for k, l in iterlists(mapping))) elif isinstance(mapping, dict): tmp = {} for key, value in iteritems(mapping): if isinstance(value, (tuple, list)): value = list(value) else: value = [value] tmp[key] = value dict.__init__(self, tmp) else: tmp = {} for key, value in mapping or (): tmp.setdefault(key, []).append(value) dict.__init__(self, tmp) def __getstate__(self): return dict(self.lists()) def __setstate__(self, value): dict.clear(self) dict.update(self, value) def __getitem__(self, key): """Return the first data value for this key; raises KeyError if not found. :param key: The key to be looked up. :raise KeyError: if the key does not exist. """ if key in self: return dict.__getitem__(self, key)[0] raise exceptions.BadRequestKeyError(key) def __setitem__(self, key, value): """Like :meth:`add` but removes an existing key first. :param key: the key for the value. :param value: the value to set. """ dict.__setitem__(self, key, [value]) def add(self, key, value): """Adds a new value for the key. .. versionadded:: 0.6 :param key: the key for the value. :param value: the value to add. """ dict.setdefault(self, key, []).append(value) def getlist(self, key, type=None): """Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be converted with the callable defined there. :param key: The key to be looked up. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` is raised by this callable the value will be removed from the list. :return: a :class:`list` of all the values for the key. """ try: rv = dict.__getitem__(self, key) except KeyError: return [] if type is None: return list(rv) result = [] for item in rv: try: result.append(type(item)) except ValueError: pass return result def setlist(self, key, new_list): """Remove the old values for a key and add new ones. Note that the list you pass the values in will be shallow-copied before it is inserted in the dictionary. >>> d = MultiDict() >>> d.setlist('foo', ['1', '2']) >>> d['foo'] '1' >>> d.getlist('foo') ['1', '2'] :param key: The key for which the values are set. :param new_list: An iterable with the new values for the key. Old values are removed first. """ dict.__setitem__(self, key, list(new_list)) def setdefault(self, key, default=None): """Returns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`. :param key: The key to be looked up. :param default: The default value to be returned if the key is not in the dict. If not further specified it's `None`. """ if key not in self: self[key] = default else: default = self[key] return default def setlistdefault(self, key, default_list=None): """Like `setdefault` but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list: >>> d = MultiDict({"foo": 1}) >>> d.setlistdefault("foo").extend([2, 3]) >>> d.getlist("foo") [1, 2, 3] :param key: The key to be looked up. :param default: An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned. :return: a :class:`list` """ if key not in self: default_list = list(default_list or ()) dict.__setitem__(self, key, default_list) else: default_list = dict.__getitem__(self, key) return default_list def items(self, multi=False): """Return an iterator of ``(key, value)`` pairs. :param multi: If set to `True` the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key. """ for key, values in iteritems(dict, self): if multi: for value in values: yield key, value else: yield key, values[0] def lists(self): """Return a list of ``(key, values)`` pairs, where values is the list of all values associated with the key.""" for key, values in iteritems(dict, self): yield key, list(values) def keys(self): return iterkeys(dict, self) __iter__ = keys def values(self): """Returns an iterator of the first value on every key's value list.""" for values in itervalues(dict, self): yield values[0] def listvalues(self): """Return an iterator of all values associated with a key. Zipping :meth:`keys` and this is the same as calling :meth:`lists`: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> zip(d.keys(), d.listvalues()) == d.lists() True """ return itervalues(dict, self) def copy(self): """Return a shallow copy of this object.""" return self.__class__(self) def deepcopy(self, memo=None): """Return a deep copy of this object.""" return self.__class__(deepcopy(self.to_dict(flat=False), memo)) def to_dict(self, flat=True): """Return the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists. :param flat: If set to `False` the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key. :return: a :class:`dict` """ if flat: return dict(iteritems(self)) return dict(self.lists()) def update(self, other_dict): """update() extends rather than replaces existing key lists: >>> a = MultiDict({'x': 1}) >>> b = MultiDict({'x': 2, 'y': 3}) >>> a.update(b) >>> a MultiDict([('y', 3), ('x', 1), ('x', 2)]) If the value list for a key in ``other_dict`` is empty, no new values will be added to the dict and the key will not be created: >>> x = {'empty_list': []} >>> y = MultiDict() >>> y.update(x) >>> y MultiDict([]) """ for key, value in iter_multi_items(other_dict): MultiDict.add(self, key, value) def pop(self, key, default=_missing): """Pop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> d.pop("foo") 1 >>> "foo" in d False :param key: the key to pop. :param default: if provided the value to return if the key was not in the dictionary. """ try: return dict.pop(self, key)[0] except KeyError as e: if default is not _missing: return default raise exceptions.BadRequestKeyError(str(e)) def popitem(self): """Pop an item from the dict.""" try: item = dict.popitem(self) return (item[0], item[1][0]) except KeyError as e: raise exceptions.BadRequestKeyError(str(e)) def poplist(self, key): """Pop the list for a key from the dict. If the key is not in the dict an empty list is returned. .. versionchanged:: 0.5 If the key does no longer exist a list is returned instead of raising an error. """ return dict.pop(self, key, []) def popitemlist(self): """Pop a ``(key, list)`` tuple from the dict.""" try: return dict.popitem(self) except KeyError as e: raise exceptions.BadRequestKeyError(str(e)) def __copy__(self): return self.copy() def __deepcopy__(self, memo): return self.deepcopy(memo=memo) def __repr__(self): return '%s(%r)' % (self.__class__.__name__, list(iteritems(self, multi=True))) class _omd_bucket(object): """Wraps values in the :class:`OrderedMultiDict`. This makes it possible to keep an order over multiple different keys. It requires a lot of extra memory and slows down access a lot, but makes it possible to access elements in O(1) and iterate in O(n). """ __slots__ = ('prev', 'key', 'value', 'next') def __init__(self, omd, key, value): self.prev = omd._last_bucket self.key = key self.value = value self.next = None if omd._first_bucket is None: omd._first_bucket = self if omd._last_bucket is not None: omd._last_bucket.next = self omd._last_bucket = self def unlink(self, omd): if self.prev: self.prev.next = self.next if self.next: self.next.prev = self.prev if omd._first_bucket is self: omd._first_bucket = self.next if omd._last_bucket is self: omd._last_bucket = self.prev @native_itermethods(['keys', 'values', 'items', 'lists', 'listvalues']) class OrderedMultiDict(MultiDict): """Works like a regular :class:`MultiDict` but preserves the order of the fields. To convert the ordered multi dict into a list you can use the :meth:`items` method and pass it ``multi=True``. In general an :class:`OrderedMultiDict` is an order of magnitude slower than a :class:`MultiDict`. .. admonition:: note Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using ``dict(multidict)``. Instead you have to use the :meth:`to_dict` method, otherwise the internal bucket objects are exposed. """ def __init__(self, mapping=None): dict.__init__(self) self._first_bucket = self._last_bucket = None if mapping is not None: OrderedMultiDict.update(self, mapping) def __eq__(self, other): if not isinstance(other, MultiDict): return NotImplemented if isinstance(other, OrderedMultiDict): iter1 = iteritems(self, multi=True) iter2 = iteritems(other, multi=True) try: for k1, v1 in iter1: k2, v2 = next(iter2) if k1 != k2 or v1 != v2: return False except StopIteration: return False try: next(iter2) except StopIteration: return True return False if len(self) != len(other): return False for key, values in iterlists(self): if other.getlist(key) != values: return False return True def __ne__(self, other): return not self.__eq__(other) def __reduce_ex__(self, protocol): return type(self), (list(iteritems(self, multi=True)),) def __getstate__(self): return list(iteritems(self, multi=True)) def __setstate__(self, values): dict.clear(self) for key, value in values: self.add(key, value) def __getitem__(self, key): if key in self: return dict.__getitem__(self, key)[0].value raise exceptions.BadRequestKeyError(key) def __setitem__(self, key, value): self.poplist(key) self.add(key, value) def __delitem__(self, key): self.pop(key) def keys(self): return (key for key, value in iteritems(self)) __iter__ = keys def values(self): return (value for key, value in iteritems(self)) def items(self, multi=False): ptr = self._first_bucket if multi: while ptr is not None: yield ptr.key, ptr.value ptr = ptr.next else: returned_keys = set() while ptr is not None: if ptr.key not in returned_keys: returned_keys.add(ptr.key) yield ptr.key, ptr.value ptr = ptr.next def lists(self): returned_keys = set() ptr = self._first_bucket while ptr is not None: if ptr.key not in returned_keys: yield ptr.key, self.getlist(ptr.key) returned_keys.add(ptr.key) ptr = ptr.next def listvalues(self): for key, values in iterlists(self): yield values def add(self, key, value): dict.setdefault(self, key, []).append(_omd_bucket(self, key, value)) def getlist(self, key, type=None): try: rv = dict.__getitem__(self, key) except KeyError: return [] if type is None: return [x.value for x in rv] result = [] for item in rv: try: result.append(type(item.value)) except ValueError: pass return result def setlist(self, key, new_list): self.poplist(key) for value in new_list: self.add(key, value) def setlistdefault(self, key, default_list=None): raise TypeError('setlistdefault is unsupported for ' 'ordered multi dicts') def update(self, mapping): for key, value in iter_multi_items(mapping): OrderedMultiDict.add(self, key, value) def poplist(self, key): buckets = dict.pop(self, key, ()) for bucket in buckets: bucket.unlink(self) return [x.value for x in buckets] def pop(self, key, default=_missing): try: buckets = dict.pop(self, key) except KeyError as e: if default is not _missing: return default raise exceptions.BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return buckets[0].value def popitem(self): try: key, buckets = dict.popitem(self) except KeyError as e: raise exceptions.BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return key, buckets[0].value def popitemlist(self): try: key, buckets = dict.popitem(self) except KeyError as e: raise exceptions.BadRequestKeyError(str(e)) for bucket in buckets: bucket.unlink(self) return key, [x.value for x in buckets] def _options_header_vkw(value, kw): return dump_options_header(value, dict((k.replace('_', '-'), v) for k, v in kw.items())) def _unicodify_header_value(value): if isinstance(value, bytes): value = value.decode('latin-1') if not isinstance(value, text_type): value = text_type(value) return value @native_itermethods(['keys', 'values', 'items']) class Headers(object): """An object that stores some headers. It has a dict-like interface but is ordered and can store the same keys multiple times. This data structure is useful if you want a nicer way to handle WSGI headers which are stored as tuples in a list. From Werkzeug 0.3 onwards, the :exc:`KeyError` raised by this class is also a subclass of the :class:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. Headers is mostly compatible with the Python :class:`wsgiref.headers.Headers` class, with the exception of `__getitem__`. :mod:`wsgiref` will return `None` for ``headers['missing']``, whereas :class:`Headers` will raise a :class:`KeyError`. To create a new :class:`Headers` object pass it a list or dict of headers which are used as default values. This does not reuse the list passed to the constructor for internal usage. :param defaults: The list of default values for the :class:`Headers`. .. versionchanged:: 0.9 This data structure now stores unicode values similar to how the multi dicts do it. The main difference is that bytes can be set as well which will automatically be latin1 decoded. .. versionchanged:: 0.9 The :meth:`linked` function was removed without replacement as it was an API that does not support the changes to the encoding model. """ def __init__(self, defaults=None): self._list = [] if defaults is not None: if isinstance(defaults, (list, Headers)): self._list.extend(defaults) else: self.extend(defaults) def __getitem__(self, key, _get_mode=False): if not _get_mode: if isinstance(key, integer_types): return self._list[key] elif isinstance(key, slice): return self.__class__(self._list[key]) if not isinstance(key, string_types): raise exceptions.BadRequestKeyError(key) ikey = key.lower() for k, v in self._list: if k.lower() == ikey: return v # micro optimization: if we are in get mode we will catch that # exception one stack level down so we can raise a standard # key error instead of our special one. if _get_mode: raise KeyError() raise exceptions.BadRequestKeyError(key) def __eq__(self, other): return other.__class__ is self.__class__ and \ set(other._list) == set(self._list) def __ne__(self, other): return not self.__eq__(other) def get(self, key, default=None, type=None, as_bytes=False): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>> d = Headers([('Content-Length', '42')]) >>> d.get('Content-Length', type=int) 42 If a headers object is bound you must not add unicode strings because no encoding takes place. .. versionadded:: 0.9 Added support for `as_bytes`. :param key: The key to be looked up. :param default: The default value to be returned if the key can't be looked up. If not further specified `None` is returned. :param type: A callable that is used to cast the value in the :class:`Headers`. If a :exc:`ValueError` is raised by this callable the default value is returned. :param as_bytes: return bytes instead of unicode strings. """ try: rv = self.__getitem__(key, _get_mode=True) except KeyError: return default if as_bytes: rv = rv.encode('latin1') if type is None: return rv try: return type(rv) except ValueError: return default def getlist(self, key, type=None, as_bytes=False): """Return the list of items for a given key. If that key is not in the :class:`Headers`, the return value will be an empty list. Just as :meth:`get` :meth:`getlist` accepts a `type` parameter. All items will be converted with the callable defined there. .. versionadded:: 0.9 Added support for `as_bytes`. :param key: The key to be looked up. :param type: A callable that is used to cast the value in the :class:`Headers`. If a :exc:`ValueError` is raised by this callable the value will be removed from the list. :return: a :class:`list` of all the values for the key. :param as_bytes: return bytes instead of unicode strings. """ ikey = key.lower() result = [] for k, v in self: if k.lower() == ikey: if as_bytes: v = v.encode('latin1') if type is not None: try: v = type(v) except ValueError: continue result.append(v) return result def get_all(self, name): """Return a list of all the values for the named field. This method is compatible with the :mod:`wsgiref` :meth:`~wsgiref.headers.Headers.get_all` method. """ return self.getlist(name) def items(self, lower=False): for key, value in self: if lower: key = key.lower() yield key, value def keys(self, lower=False): for key, _ in iteritems(self, lower): yield key def values(self): for _, value in iteritems(self): yield value def extend(self, iterable): """Extend the headers with a dict or an iterable yielding keys and values. """ if isinstance(iterable, dict): for key, value in iteritems(iterable): if isinstance(value, (tuple, list)): for v in value: self.add(key, v) else: self.add(key, value) else: for key, value in iterable: self.add(key, value) def __delitem__(self, key, _index_operation=True): if _index_operation and isinstance(key, (integer_types, slice)): del self._list[key] return key = key.lower() new = [] for k, v in self._list: if k.lower() != key: new.append((k, v)) self._list[:] = new def remove(self, key): """Remove a key. :param key: The key to be removed. """ return self.__delitem__(key, _index_operation=False) def pop(self, key=None, default=_missing): """Removes and returns a key or index. :param key: The key to be popped. If this is an integer the item at that position is removed, if it's a string the value for that key is. If the key is omitted or `None` the last item is removed. :return: an item. """ if key is None: return self._list.pop() if isinstance(key, integer_types): return self._list.pop(key) try: rv = self[key] self.remove(key) except KeyError: if default is not _missing: return default raise return rv def popitem(self): """Removes a key or index and returns a (key, value) item.""" return self.pop() def __contains__(self, key): """Check if a key is present.""" try: self.__getitem__(key, _get_mode=True) except KeyError: return False return True has_key = __contains__ def __iter__(self): """Yield ``(key, value)`` tuples.""" return iter(self._list) def __len__(self): return len(self._list) def add(self, _key, _value, **kw): """Add a new header tuple to the list. Keyword arguments can specify additional parameters for the header value, with underscores converted to dashes:: >>> d = Headers() >>> d.add('Content-Type', 'text/plain') >>> d.add('Content-Disposition', 'attachment', filename='foo.png') The keyword argument dumping uses :func:`dump_options_header` behind the scenes. .. versionadded:: 0.4.1 keyword arguments were added for :mod:`wsgiref` compatibility. """ if kw: _value = _options_header_vkw(_value, kw) _value = _unicodify_header_value(_value) self._validate_value(_value) self._list.append((_key, _value)) def _validate_value(self, value): if not isinstance(value, text_type): raise TypeError('Value should be unicode.') if u'\n' in value or u'\r' in value: raise ValueError('Detected newline in header value. This is ' 'a potential security problem') def add_header(self, _key, _value, **_kw): """Add a new header tuple to the list. An alias for :meth:`add` for compatibility with the :mod:`wsgiref` :meth:`~wsgiref.headers.Headers.add_header` method. """ self.add(_key, _value, **_kw) def clear(self): """Clears all headers.""" del self._list[:] def set(self, _key, _value, **kw): """Remove all header tuples for `key` and add a new one. The newly added key either appears at the end of the list if there was no entry or replaces the first one. Keyword arguments can specify additional parameters for the header value, with underscores converted to dashes. See :meth:`add` for more information. .. versionchanged:: 0.6.1 :meth:`set` now accepts the same arguments as :meth:`add`. :param key: The key to be inserted. :param value: The value to be inserted. """ if kw: _value = _options_header_vkw(_value, kw) _value = _unicodify_header_value(_value) self._validate_value(_value) if not self._list: self._list.append((_key, _value)) return listiter = iter(self._list) ikey = _key.lower() for idx, (old_key, old_value) in enumerate(listiter): if old_key.lower() == ikey: # replace first ocurrence self._list[idx] = (_key, _value) break else: self._list.append((_key, _value)) return self._list[idx + 1:] = [t for t in listiter if t[0].lower() != ikey] def setdefault(self, key, value): """Returns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`. :param key: The key to be looked up. :param default: The default value to be returned if the key is not in the dict. If not further specified it's `None`. """ if key in self: return self[key] self.set(key, value) return value def __setitem__(self, key, value): """Like :meth:`set` but also supports index/slice based setting.""" if isinstance(key, (slice, integer_types)): if isinstance(key, integer_types): value = [value] value = [(k, _unicodify_header_value(v)) for (k, v) in value] [self._validate_value(v) for (k, v) in value] if isinstance(key, integer_types): self._list[key] = value[0] else: self._list[key] = value else: self.set(key, value) def to_list(self, charset='iso-8859-1'): """Convert the headers into a list suitable for WSGI.""" from warnings import warn warn(DeprecationWarning('Method removed, use to_wsgi_list instead'), stacklevel=2) return self.to_wsgi_list() def to_wsgi_list(self): """Convert the headers into a list suitable for WSGI. The values are byte strings in Python 2 converted to latin1 and unicode strings in Python 3 for the WSGI server to encode. :return: list """ if PY2: return [(to_native(k), v.encode('latin1')) for k, v in self] return list(self) def copy(self): return self.__class__(self._list) def __copy__(self): return self.copy() def __str__(self): """Returns formatted headers suitable for HTTP transmission.""" strs = [] for key, value in self.to_wsgi_list(): strs.append('%s: %s' % (key, value)) strs.append('\r\n') return '\r\n'.join(strs) def __repr__(self): return '%s(%r)' % ( self.__class__.__name__, list(self) ) class ImmutableHeadersMixin(object): """Makes a :class:`Headers` immutable. We do not mark them as hashable though since the only usecase for this datastructure in Werkzeug is a view on a mutable structure. .. versionadded:: 0.5 :private: """ def __delitem__(self, key): is_immutable(self) def __setitem__(self, key, value): is_immutable(self) set = __setitem__ def add(self, item): is_immutable(self) remove = add_header = add def extend(self, iterable): is_immutable(self) def insert(self, pos, value): is_immutable(self) def pop(self, index=-1): is_immutable(self) def popitem(self): is_immutable(self) def setdefault(self, key, default): is_immutable(self) class EnvironHeaders(ImmutableHeadersMixin, Headers): """Read only version of the headers from a WSGI environment. This provides the same interface as `Headers` and is constructed from a WSGI environment. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. """ def __init__(self, environ): self.environ = environ def __eq__(self, other): return self.environ is other.environ def __getitem__(self, key, _get_mode=False): # _get_mode is a no-op for this class as there is no index but # used because get() calls it. key = key.upper().replace('-', '_') if key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): return _unicodify_header_value(self.environ[key]) return _unicodify_header_value(self.environ['HTTP_' + key]) def __len__(self): # the iter is necessary because otherwise list calls our # len which would call list again and so forth. return len(list(iter(self))) def __iter__(self): for key, value in iteritems(self.environ): if key.startswith('HTTP_') and key not in \ ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'): yield (key[5:].replace('_', '-').title(), _unicodify_header_value(value)) elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): yield (key.replace('_', '-').title(), _unicodify_header_value(value)) def copy(self): raise TypeError('cannot create %r copies' % self.__class__.__name__) @native_itermethods(['keys', 'values', 'items', 'lists', 'listvalues']) class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict): """A read only :class:`MultiDict` that you can pass multiple :class:`MultiDict` instances as sequence and it will combine the return values of all wrapped dicts: >>> from werkzeug.datastructures import CombinedMultiDict, MultiDict >>> post = MultiDict([('foo', 'bar')]) >>> get = MultiDict([('blub', 'blah')]) >>> combined = CombinedMultiDict([get, post]) >>> combined['foo'] 'bar' >>> combined['blub'] 'blah' This works for all read operations and will raise a `TypeError` for methods that usually change data which isn't possible. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. """ def __reduce_ex__(self, protocol): return type(self), (self.dicts,) def __init__(self, dicts=None): self.dicts = dicts or [] @classmethod def fromkeys(cls): raise TypeError('cannot create %r instances by fromkeys' % cls.__name__) def __getitem__(self, key): for d in self.dicts: if key in d: return d[key] raise exceptions.BadRequestKeyError(key) def get(self, key, default=None, type=None): for d in self.dicts: if key in d: if type is not None: try: return type(d[key]) except ValueError: continue return d[key] return default def getlist(self, key, type=None): rv = [] for d in self.dicts: rv.extend(d.getlist(key, type)) return rv def _keys_impl(self): """This function exists so __len__ can be implemented more efficiently, saving one list creation from an iterator. Using this for Python 2's ``dict.keys`` behavior would be useless since `dict.keys` in Python 2 returns a list, while we have a set here. """ rv = set() for d in self.dicts: rv.update(iterkeys(d)) return rv def keys(self): return iter(self._keys_impl()) __iter__ = keys def items(self, multi=False): found = set() for d in self.dicts: for key, value in iteritems(d, multi): if multi: yield key, value elif key not in found: found.add(key) yield key, value def values(self): for key, value in iteritems(self): yield value def lists(self): rv = {} for d in self.dicts: for key, values in iterlists(d): rv.setdefault(key, []).extend(values) return iteritems(rv) def listvalues(self): return (x[1] for x in self.lists()) def copy(self): """Return a shallow copy of this object.""" return self.__class__(self.dicts[:]) def to_dict(self, flat=True): """Return the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists. :param flat: If set to `False` the dict returned will have lists with all the values in it. Otherwise it will only contain the first item for each key. :return: a :class:`dict` """ rv = {} for d in reversed(self.dicts): rv.update(d.to_dict(flat)) return rv def __len__(self): return len(self._keys_impl()) def __contains__(self, key): for d in self.dicts: if key in d: return True return False has_key = __contains__ def __repr__(self): return '%s(%r)' % (self.__class__.__name__, self.dicts) class FileMultiDict(MultiDict): """A special :class:`MultiDict` that has convenience methods to add files to it. This is used for :class:`EnvironBuilder` and generally useful for unittesting. .. versionadded:: 0.5 """ def add_file(self, name, file, filename=None, content_type=None): """Adds a new file to the dict. `file` can be a file name or a :class:`file`-like or a :class:`FileStorage` object. :param name: the name of the field. :param file: a filename or :class:`file`-like object :param filename: an optional filename :param content_type: an optional content type """ if isinstance(file, FileStorage): value = file else: if isinstance(file, string_types): if filename is None: filename = file file = open(file, 'rb') if filename and content_type is None: content_type = mimetypes.guess_type(filename)[0] or \ 'application/octet-stream' value = FileStorage(file, filename, name, content_type) self.add(name, value) class ImmutableDict(ImmutableDictMixin, dict): """An immutable :class:`dict`. .. versionadded:: 0.5 """ def __repr__(self): return '%s(%s)' % ( self.__class__.__name__, dict.__repr__(self), ) def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return dict(self) def __copy__(self): return self class ImmutableMultiDict(ImmutableMultiDictMixin, MultiDict): """An immutable :class:`MultiDict`. .. versionadded:: 0.5 """ def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return MultiDict(self) def __copy__(self): return self class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict): """An immutable :class:`OrderedMultiDict`. .. versionadded:: 0.6 """ def _iter_hashitems(self): return enumerate(iteritems(self, multi=True)) def copy(self): """Return a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). """ return OrderedMultiDict(self) def __copy__(self): return self @native_itermethods(['values']) class Accept(ImmutableList): """An :class:`Accept` object is just a list subclass for lists of ``(value, quality)`` tuples. It is automatically sorted by quality. All :class:`Accept` objects work similar to a list but provide extra functionality for working with the data. Containment checks are normalized to the rules of that header: >>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)]) >>> a.best 'ISO-8859-1' >>> 'iso-8859-1' in a True >>> 'UTF8' in a True >>> 'utf7' in a False To get the quality for an item you can use normal item lookup: >>> print a['utf-8'] 0.7 >>> a['utf7'] 0 .. versionchanged:: 0.5 :class:`Accept` objects are forced immutable now. """ def __init__(self, values=()): if values is None: list.__init__(self) self.provided = False elif isinstance(values, Accept): self.provided = values.provided list.__init__(self, values) else: self.provided = True values = [(a, b) for b, a in values] values.sort() values.reverse() list.__init__(self, [(a, b) for b, a in values]) def _value_matches(self, value, item): """Check if a value matches a given accept item.""" return item == '*' or item.lower() == value.lower() def __getitem__(self, key): """Besides index lookup (getting item n) you can also pass it a string to get the quality for the item. If the item is not in the list, the returned quality is ``0``. """ if isinstance(key, string_types): return self.quality(key) return list.__getitem__(self, key) def quality(self, key): """Returns the quality of the key. .. versionadded:: 0.6 In previous versions you had to use the item-lookup syntax (eg: ``obj[key]`` instead of ``obj.quality(key)``) """ for item, quality in self: if self._value_matches(key, item): return quality return 0 def __contains__(self, value): for item, quality in self: if self._value_matches(value, item): return True return False def __repr__(self): return '%s([%s])' % ( self.__class__.__name__, ', '.join('(%r, %s)' % (x, y) for x, y in self) ) def index(self, key): """Get the position of an entry or raise :exc:`ValueError`. :param key: The key to be looked up. .. versionchanged:: 0.5 This used to raise :exc:`IndexError`, which was inconsistent with the list API. """ if isinstance(key, string_types): for idx, (item, quality) in enumerate(self): if self._value_matches(key, item): return idx raise ValueError(key) return list.index(self, key) def find(self, key): """Get the position of an entry or return -1. :param key: The key to be looked up. """ try: return self.index(key) except ValueError: return -1 def values(self): """Iterate over all values.""" for item in self: yield item[0] def to_header(self): """Convert the header set into an HTTP header string.""" result = [] for value, quality in self: if quality != 1: value = '%s;q=%s' % (value, quality) result.append(value) return ','.join(result) def __str__(self): return self.to_header() def best_match(self, matches, default=None): """Returns the best match from a list of possible matches based on the quality of the client. If two items have the same quality, the one is returned that comes first. :param matches: a list of matches to check for :param default: the value that is returned if none match """ best_quality = -1 result = default for server_item in matches: for client_item, quality in self: if quality <= best_quality: break if self._value_matches(server_item, client_item) \ and quality > 0: best_quality = quality result = server_item return result @property def best(self): """The best match as value.""" if self: return self[0][0] class MIMEAccept(Accept): """Like :class:`Accept` but with special methods and behavior for mimetypes. """ def _value_matches(self, value, item): def _normalize(x): x = x.lower() return x == '*' and ('*', '*') or x.split('/', 1) # this is from the application which is trusted. to avoid developer # frustration we actually check these for valid values if '/' not in value: raise ValueError('invalid mimetype %r' % value) value_type, value_subtype = _normalize(value) if value_type == '*' and value_subtype != '*': raise ValueError('invalid mimetype %r' % value) if '/' not in item: return False item_type, item_subtype = _normalize(item) if item_type == '*' and item_subtype != '*': return False return ( (item_type == item_subtype == '*' or value_type == value_subtype == '*') or (item_type == value_type and (item_subtype == '*' or value_subtype == '*' or item_subtype == value_subtype)) ) @property def accept_html(self): """True if this object accepts HTML.""" return ( 'text/html' in self or 'application/xhtml+xml' in self or self.accept_xhtml ) @property def accept_xhtml(self): """True if this object accepts XHTML.""" return ( 'application/xhtml+xml' in self or 'application/xml' in self ) @property def accept_json(self): """True if this object accepts JSON.""" return 'application/json' in self class LanguageAccept(Accept): """Like :class:`Accept` but with normalization for languages.""" def _value_matches(self, value, item): def _normalize(language): return _locale_delim_re.split(language.lower()) return item == '*' or _normalize(value) == _normalize(item) class CharsetAccept(Accept): """Like :class:`Accept` but with normalization for charsets.""" def _value_matches(self, value, item): def _normalize(name): try: return codecs.lookup(name).name except LookupError: return name.lower() return item == '*' or _normalize(value) == _normalize(item) def cache_property(key, empty, type): """Return a new property object for a cache header. Useful if you want to add support for a cache extension in a subclass.""" return property(lambda x: x._get_cache_value(key, empty, type), lambda x, v: x._set_cache_value(key, v, type), lambda x: x._del_cache_value(key), 'accessor for %r' % key) class _CacheControl(UpdateDictMixin, dict): """Subclass of a dict that stores values for a Cache-Control header. It has accessors for all the cache-control directives specified in RFC 2616. The class does not differentiate between request and response directives. Because the cache-control directives in the HTTP header use dashes the python descriptors use underscores for that. To get a header of the :class:`CacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionchanged:: 0.4 Setting `no_cache` or `private` to boolean `True` will set the implicit none-value which is ``*``: >>> cc = ResponseCacheControl() >>> cc.no_cache = True >>> cc <ResponseCacheControl 'no-cache'> >>> cc.no_cache '*' >>> cc.no_cache = None >>> cc <ResponseCacheControl ''> In versions before 0.5 the behavior documented here affected the now no longer existing `CacheControl` class. """ no_cache = cache_property('no-cache', '*', None) no_store = cache_property('no-store', None, bool) max_age = cache_property('max-age', -1, int) no_transform = cache_property('no-transform', None, None) def __init__(self, values=(), on_update=None): dict.__init__(self, values or ()) self.on_update = on_update self.provided = values is not None def _get_cache_value(self, key, empty, type): """Used internally by the accessor properties.""" if type is bool: return key in self if key in self: value = self[key] if value is None: return empty elif type is not None: try: value = type(value) except ValueError: pass return value def _set_cache_value(self, key, value, type): """Used internally by the accessor properties.""" if type is bool: if value: self[key] = None else: self.pop(key, None) else: if value is None: self.pop(key) elif value is True: self[key] = None else: self[key] = value def _del_cache_value(self, key): """Used internally by the accessor properties.""" if key in self: del self[key] def to_header(self): """Convert the stored values into a cache control header.""" return dump_header(self) def __str__(self): return self.to_header() def __repr__(self): return '<%s %s>' % ( self.__class__.__name__, " ".join( "%s=%r" % (k, v) for k, v in sorted(self.items()) ), ) class RequestCacheControl(ImmutableDictMixin, _CacheControl): """A cache control for requests. This is immutable and gives access to all the request-relevant cache control headers. To get a header of the :class:`RequestCacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionadded:: 0.5 In previous versions a `CacheControl` class existed that was used both for request and response. """ max_stale = cache_property('max-stale', '*', int) min_fresh = cache_property('min-fresh', '*', int) no_transform = cache_property('no-transform', None, None) only_if_cached = cache_property('only-if-cached', None, bool) class ResponseCacheControl(_CacheControl): """A cache control for responses. Unlike :class:`RequestCacheControl` this is mutable and gives access to response-relevant cache control headers. To get a header of the :class:`ResponseCacheControl` object again you can convert the object into a string or call the :meth:`to_header` method. If you plan to subclass it and add your own items have a look at the sourcecode for that class. .. versionadded:: 0.5 In previous versions a `CacheControl` class existed that was used both for request and response. """ public = cache_property('public', None, bool) private = cache_property('private', '*', None) must_revalidate = cache_property('must-revalidate', None, bool) proxy_revalidate = cache_property('proxy-revalidate', None, bool) s_maxage = cache_property('s-maxage', None, None) # attach cache_property to the _CacheControl as staticmethod # so that others can reuse it. _CacheControl.cache_property = staticmethod(cache_property) class CallbackDict(UpdateDictMixin, dict): """A dict that calls a function passed every time something is changed. The function is passed the dict instance. """ def __init__(self, initial=None, on_update=None): dict.__init__(self, initial or ()) self.on_update = on_update def __repr__(self): return '<%s %s>' % ( self.__class__.__name__, dict.__repr__(self) ) class HeaderSet(object): """Similar to the :class:`ETags` class this implements a set-like structure. Unlike :class:`ETags` this is case insensitive and used for vary, allow, and content-language headers. If not constructed using the :func:`parse_set_header` function the instantiation works like this: >>> hs = HeaderSet(['foo', 'bar', 'baz']) >>> hs HeaderSet(['foo', 'bar', 'baz']) """ def __init__(self, headers=None, on_update=None): self._headers = list(headers or ()) self._set = set([x.lower() for x in self._headers]) self.on_update = on_update def add(self, header): """Add a new header to the set.""" self.update((header,)) def remove(self, header): """Remove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param header: the header to be removed. """ key = header.lower() if key not in self._set: raise KeyError(header) self._set.remove(key) for idx, key in enumerate(self._headers): if key.lower() == header: del self._headers[idx] break if self.on_update is not None: self.on_update(self) def update(self, iterable): """Add all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable. """ inserted_any = False for header in iterable: key = header.lower() if key not in self._set: self._headers.append(header) self._set.add(key) inserted_any = True if inserted_any and self.on_update is not None: self.on_update(self) def discard(self, header): """Like :meth:`remove` but ignores errors. :param header: the header to be discarded. """ try: return self.remove(header) except KeyError: pass def find(self, header): """Return the index of the header in the set or return -1 if not found. :param header: the header to be looked up. """ header = header.lower() for idx, item in enumerate(self._headers): if item.lower() == header: return idx return -1 def index(self, header): """Return the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up. """ rv = self.find(header) if rv < 0: raise IndexError(header) return rv def clear(self): """Clear the set.""" self._set.clear() del self._headers[:] if self.on_update is not None: self.on_update(self) def as_set(self, preserve_casing=False): """Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the original case like in the :class:`HeaderSet`, otherwise they will be lowercase. """ if preserve_casing: return set(self._headers) return set(self._set) def to_header(self): """Convert the header set into an HTTP header string.""" return ', '.join(map(quote_header_value, self._headers)) def __getitem__(self, idx): return self._headers[idx] def __delitem__(self, idx): rv = self._headers.pop(idx) self._set.remove(rv.lower()) if self.on_update is not None: self.on_update(self) def __setitem__(self, idx, value): old = self._headers[idx] self._set.remove(old.lower()) self._headers[idx] = value self._set.add(value.lower()) if self.on_update is not None: self.on_update(self) def __contains__(self, header): return header.lower() in self._set def __len__(self): return len(self._set) def __iter__(self): return iter(self._headers) def __nonzero__(self): return bool(self._set) def __str__(self): return self.to_header() def __repr__(self): return '%s(%r)' % ( self.__class__.__name__, self._headers ) class ETags(object): """A set that can be used to check if one etag is present in a collection of etags. """ def __init__(self, strong_etags=None, weak_etags=None, star_tag=False): self._strong = frozenset(not star_tag and strong_etags or ()) self._weak = frozenset(weak_etags or ()) self.star_tag = star_tag def as_set(self, include_weak=False): """Convert the `ETags` object into a python set. Per default all the weak etags are not part of this set.""" rv = set(self._strong) if include_weak: rv.update(self._weak) return rv def is_weak(self, etag): """Check if an etag is weak.""" return etag in self._weak def contains_weak(self, etag): """Check if an etag is part of the set including weak and strong tags.""" return self.is_weak(etag) or self.contains(etag) def contains(self, etag): """Check if an etag is part of the set ignoring weak tags. It is also possible to use the ``in`` operator. """ if self.star_tag: return True return etag in self._strong def contains_raw(self, etag): """When passed a quoted tag it will check if this tag is part of the set. If the tag is weak it is checked against weak and strong tags, otherwise strong only.""" etag, weak = unquote_etag(etag) if weak: return self.contains_weak(etag) return self.contains(etag) def to_header(self): """Convert the etags set into a HTTP header string.""" if self.star_tag: return '*' return ', '.join( ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak] ) def __call__(self, etag=None, data=None, include_weak=False): if [etag, data].count(None) != 1: raise TypeError('either tag or data required, but at least one') if etag is None: etag = generate_etag(data) if include_weak: if etag in self._weak: return True return etag in self._strong def __bool__(self): return bool(self.star_tag or self._strong or self._weak) __nonzero__ = __bool__ def __str__(self): return self.to_header() def __iter__(self): return iter(self._strong) def __contains__(self, etag): return self.contains(etag) def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class IfRange(object): """Very simple object that represents the `If-Range` header in parsed form. It will either have neither a etag or date or one of either but never both. .. versionadded:: 0.7 """ def __init__(self, etag=None, date=None): #: The etag parsed and unquoted. Ranges always operate on strong #: etags so the weakness information is not necessary. self.etag = etag #: The date in parsed format or `None`. self.date = date def to_header(self): """Converts the object back into an HTTP header.""" if self.date is not None: return http_date(self.date) if self.etag is not None: return quote_etag(self.etag) return '' def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class Range(object): """Represents a range header. All the methods are only supporting bytes as unit. It does store multiple ranges but :meth:`range_for_length` will only work if only one range is provided. .. versionadded:: 0.7 """ def __init__(self, units, ranges): #: The units of this range. Usually "bytes". self.units = units #: A list of ``(begin, end)`` tuples for the range header provided. #: The ranges are non-inclusive. self.ranges = ranges def range_for_length(self, length): """If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a ``(start, stop)`` tuple, otherwise `None`. """ if self.units != 'bytes' or length is None or len(self.ranges) != 1: return None start, end = self.ranges[0] if end is None: end = length if start < 0: start += length if is_byte_range_valid(start, end, length): return start, min(end, length) def make_content_range(self, length): """Creates a :class:`~werkzeug.datastructures.ContentRange` object from the current range and given content length. """ rng = self.range_for_length(length) if rng is not None: return ContentRange(self.units, rng[0], rng[1], length) def to_header(self): """Converts the object back into an HTTP header.""" ranges = [] for begin, end in self.ranges: if end is None: ranges.append(begin >= 0 and '%s-' % begin or str(begin)) else: ranges.append('%s-%s' % (begin, end - 1)) return '%s=%s' % (self.units, ','.join(ranges)) def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class ContentRange(object): """Represents the content range header. .. versionadded:: 0.7 """ def __init__(self, units, start, stop, length=None, on_update=None): assert is_byte_range_valid(start, stop, length), \ 'Bad range provided' self.on_update = on_update self.set(start, stop, length, units) def _callback_property(name): def fget(self): return getattr(self, name) def fset(self, value): setattr(self, name, value) if self.on_update is not None: self.on_update(self) return property(fget, fset) #: The units to use, usually "bytes" units = _callback_property('_units') #: The start point of the range or `None`. start = _callback_property('_start') #: The stop point of the range (non-inclusive) or `None`. Can only be #: `None` if also start is `None`. stop = _callback_property('_stop') #: The length of the range or `None`. length = _callback_property('_length') def set(self, start, stop, length=None, units='bytes'): """Simple method to update the ranges.""" assert is_byte_range_valid(start, stop, length), \ 'Bad range provided' self._units = units self._start = start self._stop = stop self._length = length if self.on_update is not None: self.on_update(self) def unset(self): """Sets the units to `None` which indicates that the header should no longer be used. """ self.set(None, None, units=None) def to_header(self): if self.units is None: return '' if self.length is None: length = '*' else: length = self.length if self.start is None: return '%s */%s' % (self.units, length) return '%s %s-%s/%s' % ( self.units, self.start, self.stop - 1, length ) def __nonzero__(self): return self.units is not None __bool__ = __nonzero__ def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % (self.__class__.__name__, str(self)) class Authorization(ImmutableDictMixin, dict): """Represents an `Authorization` header sent by the client. You should not create this kind of object yourself but use it when it's returned by the `parse_authorization_header` function. This object is a dict subclass and can be altered by setting dict items but it should be considered immutable as it's returned by the client and not meant for modifications. .. versionchanged:: 0.5 This object became immutable. """ def __init__(self, auth_type, data=None): dict.__init__(self, data or {}) self.type = auth_type username = property(lambda x: x.get('username'), doc=''' The username transmitted. This is set for both basic and digest auth all the time.''') password = property(lambda x: x.get('password'), doc=''' When the authentication type is basic this is the password transmitted by the client, else `None`.''') realm = property(lambda x: x.get('realm'), doc=''' This is the server realm sent back for HTTP digest auth.''') nonce = property(lambda x: x.get('nonce'), doc=''' The nonce the server sent for digest auth, sent back by the client. A nonce should be unique for every 401 response for HTTP digest auth.''') uri = property(lambda x: x.get('uri'), doc=''' The URI from Request-URI of the Request-Line; duplicated because proxies are allowed to change the Request-Line in transit. HTTP digest auth only.''') nc = property(lambda x: x.get('nc'), doc=''' The nonce count value transmitted by clients if a qop-header is also transmitted. HTTP digest auth only.''') cnonce = property(lambda x: x.get('cnonce'), doc=''' If the server sent a qop-header in the ``WWW-Authenticate`` header, the client has to provide this value for HTTP digest auth. See the RFC for more details.''') response = property(lambda x: x.get('response'), doc=''' A string of 32 hex digits computed as defined in RFC 2617, which proves that the user knows a password. Digest auth only.''') opaque = property(lambda x: x.get('opaque'), doc=''' The opaque header from the server returned unchanged by the client. It is recommended that this string be base64 or hexadecimal data. Digest auth only.''') @property def qop(self): """Indicates what "quality of protection" the client has applied to the message for HTTP digest auth.""" def on_update(header_set): if not header_set and 'qop' in self: del self['qop'] elif header_set: self['qop'] = header_set.to_header() return parse_set_header(self.get('qop'), on_update) class WWWAuthenticate(UpdateDictMixin, dict): """Provides simple access to `WWW-Authenticate` headers.""" #: list of keys that require quoting in the generated header _require_quoting = frozenset(['domain', 'nonce', 'opaque', 'realm', 'qop']) def __init__(self, auth_type=None, values=None, on_update=None): dict.__init__(self, values or ()) if auth_type: self['__auth_type__'] = auth_type self.on_update = on_update def set_basic(self, realm='authentication required'): """Clear the auth info and enable basic auth.""" dict.clear(self) dict.update(self, {'__auth_type__': 'basic', 'realm': realm}) if self.on_update: self.on_update(self) def set_digest(self, realm, nonce, qop=('auth',), opaque=None, algorithm=None, stale=False): """Clear the auth info and enable digest auth.""" d = { '__auth_type__': 'digest', 'realm': realm, 'nonce': nonce, 'qop': dump_header(qop) } if stale: d['stale'] = 'TRUE' if opaque is not None: d['opaque'] = opaque if algorithm is not None: d['algorithm'] = algorithm dict.clear(self) dict.update(self, d) if self.on_update: self.on_update(self) def to_header(self): """Convert the stored values into a WWW-Authenticate header.""" d = dict(self) auth_type = d.pop('__auth_type__', None) or 'basic' return '%s %s' % (auth_type.title(), ', '.join([ '%s=%s' % (key, quote_header_value(value, allow_token=key not in self._require_quoting)) for key, value in iteritems(d) ])) def __str__(self): return self.to_header() def __repr__(self): return '<%s %r>' % ( self.__class__.__name__, self.to_header() ) def auth_property(name, doc=None): """A static helper function for subclasses to add extra authentication system properties onto a class:: class FooAuthenticate(WWWAuthenticate): special_realm = auth_property('special_realm') For more information have a look at the sourcecode to see how the regular properties (:attr:`realm` etc.) are implemented. """ def _set_value(self, value): if value is None: self.pop(name, None) else: self[name] = str(value) return property(lambda x: x.get(name), _set_value, doc=doc) def _set_property(name, doc=None): def fget(self): def on_update(header_set): if not header_set and name in self: del self[name] elif header_set: self[name] = header_set.to_header() return parse_set_header(self.get(name), on_update) return property(fget, doc=doc) type = auth_property('__auth_type__', doc=''' The type of the auth mechanism. HTTP currently specifies `Basic` and `Digest`.''') realm = auth_property('realm', doc=''' A string to be displayed to users so they know which username and password to use. This string should contain at least the name of the host performing the authentication and might additionally indicate the collection of users who might have access.''') domain = _set_property('domain', doc=''' A list of URIs that define the protection space. If a URI is an absolute path, it is relative to the canonical root URL of the server being accessed.''') nonce = auth_property('nonce', doc=''' A server-specified data string which should be uniquely generated each time a 401 response is made. It is recommended that this string be base64 or hexadecimal data.''') opaque = auth_property('opaque', doc=''' A string of data, specified by the server, which should be returned by the client unchanged in the Authorization header of subsequent requests with URIs in the same protection space. It is recommended that this string be base64 or hexadecimal data.''') algorithm = auth_property('algorithm', doc=''' A string indicating a pair of algorithms used to produce the digest and a checksum. If this is not present it is assumed to be "MD5". If the algorithm is not understood, the challenge should be ignored (and a different one used, if there is more than one).''') qop = _set_property('qop', doc=''' A set of quality-of-privacy directives such as auth and auth-int.''') def _get_stale(self): val = self.get('stale') if val is not None: return val.lower() == 'true' def _set_stale(self, value): if value is None: self.pop('stale', None) else: self['stale'] = value and 'TRUE' or 'FALSE' stale = property(_get_stale, _set_stale, doc=''' A flag, indicating that the previous request from the client was rejected because the nonce value was stale.''') del _get_stale, _set_stale # make auth_property a staticmethod so that subclasses of # `WWWAuthenticate` can use it for new properties. auth_property = staticmethod(auth_property) del _set_property class FileStorage(object): """The :class:`FileStorage` class is a thin wrapper over incoming files. It is used by the request object to represent uploaded files. All the attributes of the wrapper stream are proxied by the file storage so it's possible to do ``storage.read()`` instead of the long form ``storage.stream.read()``. """ def __init__(self, stream=None, filename=None, name=None, content_type=None, content_length=None, headers=None): self.name = name self.stream = stream or _empty_stream # if no filename is provided we can attempt to get the filename # from the stream object passed. There we have to be careful to # skip things like <fdopen>, <stderr> etc. Python marks these # special filenames with angular brackets. if filename is None: filename = getattr(stream, 'name', None) s = make_literal_wrapper(filename) if filename and filename[0] == s('<') and filename[-1] == s('>'): filename = None # On Python 3 we want to make sure the filename is always unicode. # This might not be if the name attribute is bytes due to the # file being opened from the bytes API. if not PY2 and isinstance(filename, bytes): filename = filename.decode(get_filesystem_encoding(), 'replace') self.filename = filename if headers is None: headers = Headers() self.headers = headers if content_type is not None: headers['Content-Type'] = content_type if content_length is not None: headers['Content-Length'] = str(content_length) def _parse_content_type(self): if not hasattr(self, '_parsed_content_type'): self._parsed_content_type = \ parse_options_header(self.content_type) @property def content_type(self): """The content-type sent in the header. Usually not available""" return self.headers.get('content-type') @property def content_length(self): """The content-length sent in the header. Usually not available""" return int(self.headers.get('content-length') or 0) @property def mimetype(self): """Like :attr:`content_type`, but without parameters (eg, without charset, type etc.) and always lowercase. For example if the content type is ``text/HTML; charset=utf-8`` the mimetype would be ``'text/html'``. .. versionadded:: 0.7 """ self._parse_content_type() return self._parsed_content_type[0].lower() @property def mimetype_params(self): """The mimetype parameters as dict. For example if the content type is ``text/html; charset=utf-8`` the params would be ``{'charset': 'utf-8'}``. .. versionadded:: 0.7 """ self._parse_content_type() return self._parsed_content_type[1] def save(self, dst, buffer_size=16384): """Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB. For secure file saving also have a look at :func:`secure_filename`. :param dst: a filename or open file object the uploaded file is saved to. :param buffer_size: the size of the buffer. This works the same as the `length` parameter of :func:`shutil.copyfileobj`. """ from shutil import copyfileobj close_dst = False if isinstance(dst, string_types): dst = open(dst, 'wb') close_dst = True try: copyfileobj(self.stream, dst, buffer_size) finally: if close_dst: dst.close() def close(self): """Close the underlying file if possible.""" try: self.stream.close() except Exception: pass def __nonzero__(self): return bool(self.filename) __bool__ = __nonzero__ def __getattr__(self, name): return getattr(self.stream, name) def __iter__(self): return iter(self.readline, '') def __repr__(self): return '<%s: %r (%r)>' % ( self.__class__.__name__, self.filename, self.content_type ) # circular dependencies from werkzeug.http import dump_options_header, dump_header, generate_etag, \ quote_header_value, parse_set_header, unquote_etag, quote_etag, \ parse_options_header, http_date, is_byte_range_valid from werkzeug import exceptions
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 23004, 272, 18294, 2878, 23597, 339, 961, 859, 6571, 13667, 3617, 436, 3992, 543, 376, 17092, 3217, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 646, 6010, 199, 646, 13290, 199, 504, 1331, 492, 14800, 199, 504, 7975, 492, 11982, 199, 199, 504, 10380, 423, 4672, 492, 485, 4752, 12, 485, 1667, 63, 1745, 199, 504, 10380, 423, 5819, 492, 25706, 12, 24451, 12, 10849, 12, 2740, 6717, 12, 971, 272, 7843, 18, 12, 1318, 63, 466, 12, 3000, 63, 1313, 12, 1059, 63, 1313, 12, 1852, 63, 8939, 63, 5029, 12, 971, 272, 370, 63, 6106, 199, 504, 10380, 14, 11381, 492, 664, 63, 11381, 63, 2991, 421, 199, 63, 5508, 63, 15966, 63, 264, 275, 295, 14, 2014, 8, 82, 3894, 32069, 10374, 421, 199, 318, 365, 63, 17836, 8, 277, 304, 272, 746, 3146, 3508, 82, 2251, 787, 17092, 7, 450, 291, 855, 533, 4914, 354, 3368, 421, 199, 318, 2740, 63, 3029, 63, 1744, 8, 4745, 304, 272, 408, 3315, 2335, 1806, 314, 2974, 402, 282, 4412, 32035, 2883, 436, 1338, 272, 1928, 366, 20148, 1263, 687, 1655, 6114, 13955, 14, 272, 408, 272, 340, 1228, 8, 4745, 12, 29393, 304, 267, 367, 1242, 315, 10849, 8, 4745, 12, 3510, 29, 549, 304, 288, 1995, 1242, 272, 916, 1228, 8, 4745, 12, 1211, 304, 267, 367, 790, 12, 574, 315, 10849, 8, 4745, 304, 288, 340, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 367, 574, 315, 574, 26, 490, 1995, 790, 12, 574, 288, 587, 26, 355, 1995, 790, 12, 574, 272, 587, 26, 267, 367, 1242, 315, 4412, 26, 288, 1995, 1242, 421, 199, 318, 5438, 63, 1661, 2474, 8, 1247, 304, 272, 340, 440, 7843, 18, 26, 267, 372, 2400, 671, 26, 671, 339, 347, 663, 765, 8, 1886, 12, 536, 304, 267, 2740, 765, 275, 2519, 8, 1886, 12, 536, 9, 267, 5371, 8, 1886, 12, 283, 1661, 5, 83, 7, 450, 536, 12, 2740, 765, 9, 267, 769, 765, 275, 2400, 291, 12, 627, 65, 12, 1011, 829, 26, 769, 8, 1661, 765, 8, 277, 12, 627, 65, 12, 1011, 829, 430, 267, 769, 765, 855, 1301, 363, 275, 971, 288, 283, 12545, 520, 647, 26, 5247, 1705, 1661, 5, 83, 3559, 1325, 2529, 282, 769, 3530, 450, 536, 267, 5371, 8, 1886, 12, 536, 12, 769, 765, 9, 339, 347, 4816, 8, 1886, 304, 267, 367, 536, 315, 1561, 26, 288, 663, 765, 8, 1886, 12, 536, 9, 267, 372, 843, 272, 372, 4816, 421, 199, 533, 25609, 1296, 4256, 8, 785, 304, 339, 408, 27142, 282, 520, 533, 1705, 513, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 485, 2227, 63, 1637, 275, 488, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 2960, 8, 277, 430, 267, 372, 4336, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 513, 8, 277, 16945, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 271, 478, 3037, 721, 277, 12, 284, 12, 1335, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 636, 1017, 348, 363, 275, 636, 28788, 363, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 2193, 3037, 721, 277, 12, 284, 12, 1335, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5666, 8, 277, 12, 1242, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 2813, 275, 5666, 339, 347, 12247, 8, 277, 12, 6076, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5518, 8, 277, 12, 2086, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 1478, 4022, 17, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 3837, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4069, 8, 277, 12, 10467, 29, 403, 12, 790, 29, 403, 12, 3837, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 1296, 8, 29174, 1296, 4256, 12, 769, 304, 339, 408, 2493, 17092, 520, 533, 1705, 513, 2313, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 769, 855, 2722, 721, 277, 395, 267, 776, 421, 199, 533, 25609, 2141, 4256, 8, 785, 304, 339, 408, 27142, 282, 520, 533, 1705, 807, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 272, 485, 2227, 63, 1637, 275, 488, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 2883, 12, 574, 29, 403, 304, 267, 1256, 275, 1613, 8, 1886, 12, 843, 2843, 1222, 721, 1886, 9, 267, 1256, 855, 826, 721, 3065, 8, 1612, 12, 11982, 8, 585, 1724, 267, 372, 1256, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 807, 8, 277, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 10849, 8, 277, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 21362, 8, 277, 423, 1661, 63, 2227, 1744, 4059, 267, 372, 4336, 339, 347, 29408, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 365, 63, 17836, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 23004, 272, 18294, 2878, 23597, 339, 961, 859, 6571, 13667, 3617, 436, 3992, 543, 376, 17092, 3217, 14, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 646, 6010, 199, 646, 13290, 199, 504, 1331, 492, 14800, 199, 504, 7975, 492, 11982, 199, 199, 504, 10380, 423, 4672, 492, 485, 4752, 12, 485, 1667, 63, 1745, 199, 504, 10380, 423, 5819, 492, 25706, 12, 24451, 12, 10849, 12, 2740, 6717, 12, 971, 272, 7843, 18, 12, 1318, 63, 466, 12, 3000, 63, 1313, 12, 1059, 63, 1313, 12, 1852, 63, 8939, 63, 5029, 12, 971, 272, 370, 63, 6106, 199, 504, 10380, 14, 11381, 492, 664, 63, 11381, 63, 2991, 421, 199, 63, 5508, 63, 15966, 63, 264, 275, 295, 14, 2014, 8, 82, 3894, 32069, 10374, 421, 199, 318, 365, 63, 17836, 8, 277, 304, 272, 746, 3146, 3508, 82, 2251, 787, 17092, 7, 450, 291, 855, 533, 4914, 354, 3368, 421, 199, 318, 2740, 63, 3029, 63, 1744, 8, 4745, 304, 272, 408, 3315, 2335, 1806, 314, 2974, 402, 282, 4412, 32035, 2883, 436, 1338, 272, 1928, 366, 20148, 1263, 687, 1655, 6114, 13955, 14, 272, 408, 272, 340, 1228, 8, 4745, 12, 29393, 304, 267, 367, 1242, 315, 10849, 8, 4745, 12, 3510, 29, 549, 304, 288, 1995, 1242, 272, 916, 1228, 8, 4745, 12, 1211, 304, 267, 367, 790, 12, 574, 315, 10849, 8, 4745, 304, 288, 340, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 367, 574, 315, 574, 26, 490, 1995, 790, 12, 574, 288, 587, 26, 355, 1995, 790, 12, 574, 272, 587, 26, 267, 367, 1242, 315, 4412, 26, 288, 1995, 1242, 421, 199, 318, 5438, 63, 1661, 2474, 8, 1247, 304, 272, 340, 440, 7843, 18, 26, 267, 372, 2400, 671, 26, 671, 339, 347, 663, 765, 8, 1886, 12, 536, 304, 267, 2740, 765, 275, 2519, 8, 1886, 12, 536, 9, 267, 5371, 8, 1886, 12, 283, 1661, 5, 83, 7, 450, 536, 12, 2740, 765, 9, 267, 769, 765, 275, 2400, 291, 12, 627, 65, 12, 1011, 829, 26, 769, 8, 1661, 765, 8, 277, 12, 627, 65, 12, 1011, 829, 430, 267, 769, 765, 855, 1301, 363, 275, 971, 288, 283, 12545, 520, 647, 26, 5247, 1705, 1661, 5, 83, 3559, 1325, 2529, 282, 769, 3530, 450, 536, 267, 5371, 8, 1886, 12, 536, 12, 769, 765, 9, 339, 347, 4816, 8, 1886, 304, 267, 367, 536, 315, 1561, 26, 288, 663, 765, 8, 1886, 12, 536, 9, 267, 372, 843, 272, 372, 4816, 421, 199, 533, 25609, 1296, 4256, 8, 785, 304, 339, 408, 27142, 282, 520, 533, 1705, 513, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 485, 2227, 63, 1637, 275, 488, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 440, 488, 26, 288, 372, 291, 423, 2227, 63, 1637, 267, 4336, 275, 291, 423, 2227, 63, 1637, 275, 2631, 8, 2960, 8, 277, 430, 267, 372, 4336, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 513, 8, 277, 16945, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 271, 478, 3037, 721, 277, 12, 284, 12, 1335, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 28788, 721, 277, 12, 1163, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 636, 1017, 348, 363, 275, 636, 28788, 363, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 636, 2193, 3037, 721, 277, 12, 284, 12, 1335, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5666, 8, 277, 12, 1242, 304, 267, 365, 63, 17836, 8, 277, 9, 272, 2813, 275, 5666, 339, 347, 12247, 8, 277, 12, 6076, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 5518, 8, 277, 12, 2086, 12, 574, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4560, 8, 277, 12, 1478, 4022, 17, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 3837, 8, 277, 304, 267, 365, 63, 17836, 8, 277, 9, 339, 347, 4069, 8, 277, 12, 10467, 29, 403, 12, 790, 29, 403, 12, 3837, 29, 403, 304, 267, 365, 63, 17836, 8, 277, 9, 421, 199, 533, 25609, 1296, 8, 29174, 1296, 4256, 12, 769, 304, 339, 408, 2493, 17092, 520, 533, 1705, 513, 2313, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 1543, 83, 4042, 83, 3171, 450, 334, 288, 291, 855, 533, 4914, 354, 3108, 288, 769, 855, 2722, 721, 277, 395, 267, 776, 421, 199, 533, 25609, 2141, 4256, 8, 785, 304, 339, 408, 27142, 282, 520, 533, 1705, 807, 64, 17092, 14, 339, 2508, 7445, 447, 378, 14, 21, 339, 520, 4239, 26, 272, 408, 272, 485, 2227, 63, 1637, 275, 488, 339, 768, 3744, 272, 347, 687, 1612, 8, 1886, 12, 2883, 12, 574, 29, 403, 304, 267, 1256, 275, 1613, 8, 1886, 12, 843, 2843, 1222, 721, 1886, 9, 267, 1256, 855, 826, 721, 3065, 8, 1612, 12, 11982, 8, 585, 1724, 267, 372, 1256, 339, 347, 636, 5270, 63, 476, 721, 277, 12, 4113, 304, 267, 372, 730, 8, 277, 395, 334, 807, 8, 277, 16945, 339, 347, 485, 1661, 63, 2227, 1744, 8, 277, 304, 267, 372, 10849, 8, 277, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 340, 291, 423, 2227, 63, 1637, 365, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
andriibekker/biddingsbase
django/db/backends/mysql/base.py
101
13899
""" MySQL database backend for Django. Requires MySQLdb: http://sourceforge.net/projects/mysql-python """ import re import sys try: import MySQLdb as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) # We want version (1, 2, 1, 'final', 2) or later. We can't just use # lexicographic ordering in this check because then (1, 2, 1, 'gamma') # inadvertently passes the version test. version = Database.version_info if (version < (1,2,1) or (version[:3] == (1, 2, 1) and (len(version) < 5 or version[3] != 'final' or version[4] < 2))): from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__) from MySQLdb.converters import conversions from MySQLdb.constants import FIELD_TYPE, FLAG, CLIENT from django.db import utils from django.db.backends import * from django.db.backends.signals import connection_created from django.db.backends.mysql.client import DatabaseClient from django.db.backends.mysql.creation import DatabaseCreation from django.db.backends.mysql.introspection import DatabaseIntrospection from django.db.backends.mysql.validation import DatabaseValidation from django.utils.safestring import SafeString, SafeUnicode # Raise exceptions for database warnings if DEBUG is on from django.conf import settings if settings.DEBUG: from warnings import filterwarnings filterwarnings("error", category=Database.Warning) DatabaseError = Database.DatabaseError IntegrityError = Database.IntegrityError # MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like # timedelta in terms of actual behavior as they are signed and include days -- # and Django expects time, so we still need to override that. We also need to # add special handling for SafeUnicode and SafeString as MySQLdb's type # checking is too tight to catch those (see Django ticket #6052). django_conversions = conversions.copy() django_conversions.update({ FIELD_TYPE.TIME: util.typecast_time, FIELD_TYPE.DECIMAL: util.typecast_decimal, FIELD_TYPE.NEWDECIMAL: util.typecast_decimal, }) # This should match the numerical portion of the version numbers (we can treat # versions like 5.0.24 and 5.0.24a as the same). Based on the list of version # at http://dev.mysql.com/doc/refman/4.1/en/news.html and # http://dev.mysql.com/doc/refman/5.0/en/news.html . server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})') # MySQLdb-1.2.1 and newer automatically makes use of SHOW WARNINGS on # MySQL-4.1 and newer, so the MysqlDebugWrapper is unnecessary. Since the # point is to raise Warnings as exceptions, this can be done with the Python # warning module, and this is setup when the connection is created, and the # standard util.CursorDebugWrapper can be used. Also, using sql_mode # TRADITIONAL will automatically cause most warnings to be treated as errors. class CursorWrapper(object): """ A thin wrapper around MySQLdb's normal cursor class so that we can catch particular exception instances and reraise them with the right types. Implemented as a wrapper, rather than a subclass, so that we aren't stuck to the particular underlying representation returned by Connection.cursor(). """ codes_for_integrityerror = (1048,) def __init__(self, cursor): self.cursor = cursor def execute(self, query, args=None): try: return self.cursor.execute(query, args) except Database.IntegrityError, e: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] except Database.OperationalError, e: # Map some error codes to IntegrityError, since they seem to be # misclassified and Django would prefer the more logical place. if e[0] in self.codes_for_integrityerror: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] raise except Database.DatabaseError, e: raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2] def executemany(self, query, args): try: return self.cursor.executemany(query, args) except Database.IntegrityError, e: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] except Database.OperationalError, e: # Map some error codes to IntegrityError, since they seem to be # misclassified and Django would prefer the more logical place. if e[0] in self.codes_for_integrityerror: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] raise except Database.DatabaseError, e: raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2] def __getattr__(self, attr): if attr in self.__dict__: return self.__dict__[attr] else: return getattr(self.cursor, attr) def __iter__(self): return iter(self.cursor) class DatabaseFeatures(BaseDatabaseFeatures): empty_fetchmany_value = () update_can_self_select = False allows_group_by_pk = True related_fields_match_type = True allow_sliced_subqueries = False supports_forward_references = False supports_long_model_names = False supports_microsecond_precision = False supports_regex_backreferencing = False supports_date_lookup_using_string = False supports_timezones = False requires_explicit_null_ordering_when_grouping = True allows_primary_key_0 = False def _can_introspect_foreign_keys(self): "Confirm support for introspected foreign keys" cursor = self.connection.cursor() cursor.execute('CREATE TABLE INTROSPECT_TEST (X INT)') # This command is MySQL specific; the second column # will tell you the default table type of the created # table. Since all Django's test tables will have the same # table type, that's enough to evaluate the feature. cursor.execute('SHOW TABLE STATUS WHERE Name="INTROSPECT_TEST"') result = cursor.fetchone() cursor.execute('DROP TABLE INTROSPECT_TEST') return result[1] != 'MyISAM' class DatabaseOperations(BaseDatabaseOperations): compiler_module = "django.db.backends.mysql.compiler" def date_extract_sql(self, lookup_type, field_name): # http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html if lookup_type == 'week_day': # DAYOFWEEK() returns an integer, 1-7, Sunday=1. # Note: WEEKDAY() returns 0-6, Monday=0. return "DAYOFWEEK(%s)" % field_name else: return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), field_name) def date_trunc_sql(self, lookup_type, field_name): fields = ['year', 'month', 'day', 'hour', 'minute', 'second'] format = ('%%Y-', '%%m', '-%%d', ' %%H:', '%%i', ':%%s') # Use double percents to escape. format_def = ('0000-', '01', '-01', ' 00:', '00', ':00') try: i = fields.index(lookup_type) + 1 except ValueError: sql = field_name else: format_str = ''.join([f for f in format[:i]] + [f for f in format_def[i:]]) sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str) return sql def date_interval_sql(self, sql, connector, timedelta): return "(%s %s INTERVAL '%d 0:0:%d:%d' DAY_MICROSECOND)" % (sql, connector, timedelta.days, timedelta.seconds, timedelta.microseconds) def drop_foreignkey_sql(self): return "DROP FOREIGN KEY" def force_no_ordering(self): """ "ORDER BY NULL" prevents MySQL from implicitly ordering by grouped columns. If no ordering would otherwise be applied, we don't want any implicit sorting going on. """ return ["NULL"] def fulltext_search_sql(self, field_name): return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name def no_limit_value(self): # 2**64 - 1, as recommended by the MySQL documentation return 18446744073709551615L def quote_name(self, name): if name.startswith("`") and name.endswith("`"): return name # Quoting once is enough. return "`%s`" % name def random_function_sql(self): return 'RAND()' def sql_flush(self, style, tables, sequences): # NB: The generated SQL below is specific to MySQL # 'TRUNCATE x;', 'TRUNCATE y;', 'TRUNCATE z;'... style SQL statements # to clear all tables of all data if tables: sql = ['SET FOREIGN_KEY_CHECKS = 0;'] for table in tables: sql.append('%s %s;' % (style.SQL_KEYWORD('TRUNCATE'), style.SQL_FIELD(self.quote_name(table)))) sql.append('SET FOREIGN_KEY_CHECKS = 1;') # 'ALTER TABLE table AUTO_INCREMENT = 1;'... style SQL statements # to reset sequence indices sql.extend(["%s %s %s %s %s;" % \ (style.SQL_KEYWORD('ALTER'), style.SQL_KEYWORD('TABLE'), style.SQL_TABLE(self.quote_name(sequence['table'])), style.SQL_KEYWORD('AUTO_INCREMENT'), style.SQL_FIELD('= 1'), ) for sequence in sequences]) return sql else: return [] def value_to_db_datetime(self, value): if value is None: return None # MySQL doesn't support tz-aware datetimes if value.tzinfo is not None: raise ValueError("MySQL backend does not support timezone-aware datetimes.") # MySQL doesn't support microseconds return unicode(value.replace(microsecond=0)) def value_to_db_time(self, value): if value is None: return None # MySQL doesn't support tz-aware datetimes if value.tzinfo is not None: raise ValueError("MySQL backend does not support timezone-aware datetimes.") # MySQL doesn't support microseconds return unicode(value.replace(microsecond=0)) def year_lookup_bounds(self, value): # Again, no microseconds first = '%s-01-01 00:00:00' second = '%s-12-31 23:59:59.99' return [first % value, second % value] def max_name_length(self): return 64 class DatabaseWrapper(BaseDatabaseWrapper): vendor = 'mysql' operators = { 'exact': '= %s', 'iexact': 'LIKE %s', 'contains': 'LIKE BINARY %s', 'icontains': 'LIKE %s', 'regex': 'REGEXP BINARY %s', 'iregex': 'REGEXP %s', 'gt': '> %s', 'gte': '>= %s', 'lt': '< %s', 'lte': '<= %s', 'startswith': 'LIKE BINARY %s', 'endswith': 'LIKE BINARY %s', 'istartswith': 'LIKE %s', 'iendswith': 'LIKE %s', } def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.server_version = None self.features = DatabaseFeatures(self) self.ops = DatabaseOperations() self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = DatabaseValidation(self) def _valid_connection(self): if self.connection is not None: try: self.connection.ping() return True except DatabaseError: self.connection.close() self.connection = None return False def _cursor(self): if not self._valid_connection(): kwargs = { 'conv': django_conversions, 'charset': 'utf8', 'use_unicode': True, } settings_dict = self.settings_dict if settings_dict['USER']: kwargs['user'] = settings_dict['USER'] if settings_dict['NAME']: kwargs['db'] = settings_dict['NAME'] if settings_dict['PASSWORD']: kwargs['passwd'] = settings_dict['PASSWORD'] if settings_dict['HOST'].startswith('/'): kwargs['unix_socket'] = settings_dict['HOST'] elif settings_dict['HOST']: kwargs['host'] = settings_dict['HOST'] if settings_dict['PORT']: kwargs['port'] = int(settings_dict['PORT']) # We need the number of potentially affected rows after an # "UPDATE", not the number of changed rows. kwargs['client_flag'] = CLIENT.FOUND_ROWS kwargs.update(settings_dict['OPTIONS']) self.connection = Database.connect(**kwargs) self.connection.encoders[SafeUnicode] = self.connection.encoders[unicode] self.connection.encoders[SafeString] = self.connection.encoders[str] connection_created.send(sender=self.__class__, connection=self) cursor = CursorWrapper(self.connection.cursor()) return cursor def _rollback(self): try: super(DatabaseWrapper, self)._rollback() except Database.NotSupportedError: pass def get_server_version(self): if not self.server_version: if not self._valid_connection(): self.cursor() m = server_version_re.match(self.connection.get_server_info()) if not m: raise Exception('Unable to determine MySQL version from version string %r' % self.connection.get_server_info()) self.server_version = tuple([int(x) for x in m.groups()]) return self.server_version
bsd-3-clause
[ 624, 199, 20784, 3050, 4865, 367, 5634, 14, 199, 199, 18153, 25709, 26, 1455, 921, 22943, 14, 846, 15, 6776, 15, 8644, 13, 1548, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 199, 893, 26, 272, 492, 25709, 465, 8692, 199, 2590, 3545, 12, 325, 26, 272, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 272, 746, 11897, 480, 547, 8697, 25709, 859, 26, 450, 83, 2, 450, 325, 9, 199, 199, 3, 2136, 2934, 1015, 334, 17, 12, 499, 12, 413, 12, 283, 5094, 297, 499, 9, 503, 2945, 14, 2136, 883, 1133, 2951, 675, 199, 3, 1026, 30077, 9770, 7794, 315, 642, 1104, 2952, 2066, 334, 17, 12, 499, 12, 413, 12, 283, 7325, 358, 199, 3, 315, 350, 422, 767, 590, 14933, 314, 1015, 511, 14, 199, 1023, 275, 8692, 14, 1023, 63, 815, 199, 692, 334, 1023, 665, 334, 17, 12, 18, 12, 17, 9, 503, 334, 1023, 1491, 19, 61, 508, 334, 17, 12, 499, 12, 413, 9, 436, 267, 334, 552, 8, 1023, 9, 665, 959, 503, 1015, 59, 19, 61, 1137, 283, 5094, 7, 503, 1015, 59, 20, 61, 665, 499, 15206, 272, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 272, 746, 11897, 480, 20784, 697, 13, 17, 14, 18, 14, 17, 80, 18, 503, 15666, 365, 1415, 27, 1265, 1172, 450, 83, 2, 450, 8692, 855, 1023, 3368, 199, 199, 504, 25709, 14, 17911, 492, 24796, 199, 504, 25709, 14, 5559, 492, 26130, 63, 2711, 12, 11031, 12, 14214, 1309, 199, 199, 504, 1639, 14, 697, 492, 3778, 199, 504, 1639, 14, 697, 14, 7765, 492, 627, 199, 504, 1639, 14, 697, 14, 7765, 14, 10458, 492, 1950, 63, 3966, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 1258, 492, 8692, 3041, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 8782, 492, 8692, 13921, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 21627, 492, 8692, 30516, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 6136, 492, 8692, 13816, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1558, 12, 14969, 7087, 199, 199, 3, 14771, 4967, 367, 3050, 3598, 340, 10990, 365, 641, 199, 504, 1639, 14, 2190, 492, 2202, 199, 692, 2202, 14, 5287, 26, 272, 687, 3598, 492, 2457, 5451, 272, 2457, 5451, 480, 705, 401, 4637, 29, 7243, 14, 3849, 9, 199, 199, 25198, 275, 8692, 14, 25198, 199, 24823, 275, 8692, 14, 24823, 199, 199, 3, 25709, 13, 17, 14, 18, 14, 17, 2529, 17032, 4362, 465, 6871, 1553, 2985, 787, 1655, 2839, 199, 3, 6871, 315, 2895, 402, 3503, 5953, 465, 2985, 787, 10514, 436, 2387, 7609, 1553, 199, 3, 436, 5634, 14292, 900, 12, 880, 781, 5139, 1929, 370, 4278, 626, 14, 2136, 2597, 1929, 370, 199, 3, 1050, 4539, 7252, 367, 14969, 7087, 436, 14969, 1558, 465, 25709, 1159, 730, 199, 3, 7907, 365, 4634, 3367, 913, 370, 8579, 5204, 334, 3239, 5634, 12052, 327, 22, 19730, 680, 199, 1176, 63, 388, 6234, 275, 24796, 14, 1574, 342, 199, 1176, 63, 388, 6234, 14, 873, 2561, 272, 26130, 63, 2711, 14, 4961, 26, 4884, 14, 466, 2931, 63, 521, 12, 272, 26130, 63, 2711, 14, 23925, 26, 4884, 14, 466, 2931, 63, 6355, 12, 272, 26130, 63, 2711, 14, 11365, 23925, 26, 4884, 14, 466, 2931, 63, 6355, 12, 199, 1552, 199, 199, 3, 961, 1077, 1336, 314, 15470, 18046, 402, 314, 1015, 5579, 334, 1129, 883, 14312, 199, 3, 5459, 2839, 959, 14, 16, 14, 1194, 436, 959, 14, 16, 14, 1194, 65, 465, 314, 2011, 680, 21311, 641, 314, 769, 402, 1015, 199, 3, 737, 1455, 921, 2374, 14, 8644, 14, 957, 15, 1301, 15, 1121, 1237, 15, 20, 14, 17, 15, 287, 15, 13224, 14, 1360, 436, 199, 3, 1455, 921, 2374, 14, 8644, 14, 957, 15, 1301, 15, 1121, 1237, 15, 21, 14, 16, 15, 287, 15, 13224, 14, 1360, 1275, 199, 1000, 63, 1023, 63, 264, 275, 295, 14, 2014, 8, 82, 13445, 68, 91, 17, 12, 18, 1552, 4537, 2961, 68, 91, 17, 12, 18, 1552, 4537, 2961, 68, 91, 17, 12, 18, 1552, 358, 199, 199, 3, 25709, 13, 17, 14, 18, 14, 17, 436, 15666, 5847, 7704, 675, 402, 428, 16210, 13253, 46, 3881, 641, 199, 3, 11200, 13, 20, 14, 17, 436, 15666, 12, 880, 314, 603, 6398, 7084, 4590, 365, 23361, 14, 9336, 314, 199, 3, 2376, 365, 370, 746, 644, 2627, 465, 4967, 12, 642, 883, 506, 4224, 543, 314, 2018, 199, 3, 5721, 859, 12, 436, 642, 365, 3272, 1380, 314, 1950, 365, 2737, 12, 436, 314, 199, 3, 4465, 4884, 14, 8993, 7084, 4590, 883, 506, 1202, 14, 6121, 12, 1808, 3875, 63, 632, 199, 3, 9074, 1554, 12039, 748, 911, 5847, 7675, 4750, 3598, 370, 506, 10184, 465, 2552, 14, 199, 199, 533, 20385, 4590, 8, 785, 304, 272, 408, 272, 437, 30758, 4975, 6818, 25709, 1159, 3293, 3920, 1021, 880, 626, 781, 883, 8579, 272, 6770, 1919, 4454, 436, 24139, 3062, 543, 314, 2451, 2943, 14, 339, 11794, 2509, 465, 282, 4975, 12, 7830, 2419, 282, 5516, 12, 880, 626, 781, 10621, 1133, 410, 10112, 272, 370, 314, 6770, 8793, 6025, 2138, 701, 8113, 14, 3937, 1252, 272, 408, 272, 9479, 63, 509, 63, 5707, 12997, 705, 275, 334, 709, 2006, 4258, 339, 347, 636, 826, 721, 277, 12, 3920, 304, 267, 291, 14, 3937, 275, 3920, 339, 347, 5341, 8, 277, 12, 1827, 12, 1249, 29, 403, 304, 267, 862, 26, 288, 372, 291, 14, 3937, 14, 2526, 8, 1131, 12, 1249, 9, 267, 871, 8692, 14, 24823, 12, 325, 26, 288, 746, 3778, 14, 24823, 12, 3778, 14, 24823, 2031, 2960, 8, 69, 1826, 984, 14, 2804, 63, 815, 3430, 18, 61, 267, 871, 8692, 14, 31998, 547, 12, 325, 26, 288, 327, 9672, 2005, 1125, 9479, 370, 26864, 12, 3967, 2985, 17021, 370, 506, 288, 327, 3201, 12334, 1290, 436, 5634, 3955, 16602, 314, 1655, 11461, 4192, 14, 288, 340, 325, 59, 16, 61, 315, 291, 14, 6021, 63, 509, 63, 5707, 12997, 705, 26, 355, 746, 3778, 14, 24823, 12, 3778, 14, 24823, 2031, 2960, 8, 69, 1826, 984 ]
[ 199, 20784, 3050, 4865, 367, 5634, 14, 199, 199, 18153, 25709, 26, 1455, 921, 22943, 14, 846, 15, 6776, 15, 8644, 13, 1548, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 199, 893, 26, 272, 492, 25709, 465, 8692, 199, 2590, 3545, 12, 325, 26, 272, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 272, 746, 11897, 480, 547, 8697, 25709, 859, 26, 450, 83, 2, 450, 325, 9, 199, 199, 3, 2136, 2934, 1015, 334, 17, 12, 499, 12, 413, 12, 283, 5094, 297, 499, 9, 503, 2945, 14, 2136, 883, 1133, 2951, 675, 199, 3, 1026, 30077, 9770, 7794, 315, 642, 1104, 2952, 2066, 334, 17, 12, 499, 12, 413, 12, 283, 7325, 358, 199, 3, 315, 350, 422, 767, 590, 14933, 314, 1015, 511, 14, 199, 1023, 275, 8692, 14, 1023, 63, 815, 199, 692, 334, 1023, 665, 334, 17, 12, 18, 12, 17, 9, 503, 334, 1023, 1491, 19, 61, 508, 334, 17, 12, 499, 12, 413, 9, 436, 267, 334, 552, 8, 1023, 9, 665, 959, 503, 1015, 59, 19, 61, 1137, 283, 5094, 7, 503, 1015, 59, 20, 61, 665, 499, 15206, 272, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 272, 746, 11897, 480, 20784, 697, 13, 17, 14, 18, 14, 17, 80, 18, 503, 15666, 365, 1415, 27, 1265, 1172, 450, 83, 2, 450, 8692, 855, 1023, 3368, 199, 199, 504, 25709, 14, 17911, 492, 24796, 199, 504, 25709, 14, 5559, 492, 26130, 63, 2711, 12, 11031, 12, 14214, 1309, 199, 199, 504, 1639, 14, 697, 492, 3778, 199, 504, 1639, 14, 697, 14, 7765, 492, 627, 199, 504, 1639, 14, 697, 14, 7765, 14, 10458, 492, 1950, 63, 3966, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 1258, 492, 8692, 3041, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 8782, 492, 8692, 13921, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 21627, 492, 8692, 30516, 199, 504, 1639, 14, 697, 14, 7765, 14, 8644, 14, 6136, 492, 8692, 13816, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1558, 12, 14969, 7087, 199, 199, 3, 14771, 4967, 367, 3050, 3598, 340, 10990, 365, 641, 199, 504, 1639, 14, 2190, 492, 2202, 199, 692, 2202, 14, 5287, 26, 272, 687, 3598, 492, 2457, 5451, 272, 2457, 5451, 480, 705, 401, 4637, 29, 7243, 14, 3849, 9, 199, 199, 25198, 275, 8692, 14, 25198, 199, 24823, 275, 8692, 14, 24823, 199, 199, 3, 25709, 13, 17, 14, 18, 14, 17, 2529, 17032, 4362, 465, 6871, 1553, 2985, 787, 1655, 2839, 199, 3, 6871, 315, 2895, 402, 3503, 5953, 465, 2985, 787, 10514, 436, 2387, 7609, 1553, 199, 3, 436, 5634, 14292, 900, 12, 880, 781, 5139, 1929, 370, 4278, 626, 14, 2136, 2597, 1929, 370, 199, 3, 1050, 4539, 7252, 367, 14969, 7087, 436, 14969, 1558, 465, 25709, 1159, 730, 199, 3, 7907, 365, 4634, 3367, 913, 370, 8579, 5204, 334, 3239, 5634, 12052, 327, 22, 19730, 680, 199, 1176, 63, 388, 6234, 275, 24796, 14, 1574, 342, 199, 1176, 63, 388, 6234, 14, 873, 2561, 272, 26130, 63, 2711, 14, 4961, 26, 4884, 14, 466, 2931, 63, 521, 12, 272, 26130, 63, 2711, 14, 23925, 26, 4884, 14, 466, 2931, 63, 6355, 12, 272, 26130, 63, 2711, 14, 11365, 23925, 26, 4884, 14, 466, 2931, 63, 6355, 12, 199, 1552, 199, 199, 3, 961, 1077, 1336, 314, 15470, 18046, 402, 314, 1015, 5579, 334, 1129, 883, 14312, 199, 3, 5459, 2839, 959, 14, 16, 14, 1194, 436, 959, 14, 16, 14, 1194, 65, 465, 314, 2011, 680, 21311, 641, 314, 769, 402, 1015, 199, 3, 737, 1455, 921, 2374, 14, 8644, 14, 957, 15, 1301, 15, 1121, 1237, 15, 20, 14, 17, 15, 287, 15, 13224, 14, 1360, 436, 199, 3, 1455, 921, 2374, 14, 8644, 14, 957, 15, 1301, 15, 1121, 1237, 15, 21, 14, 16, 15, 287, 15, 13224, 14, 1360, 1275, 199, 1000, 63, 1023, 63, 264, 275, 295, 14, 2014, 8, 82, 13445, 68, 91, 17, 12, 18, 1552, 4537, 2961, 68, 91, 17, 12, 18, 1552, 4537, 2961, 68, 91, 17, 12, 18, 1552, 358, 199, 199, 3, 25709, 13, 17, 14, 18, 14, 17, 436, 15666, 5847, 7704, 675, 402, 428, 16210, 13253, 46, 3881, 641, 199, 3, 11200, 13, 20, 14, 17, 436, 15666, 12, 880, 314, 603, 6398, 7084, 4590, 365, 23361, 14, 9336, 314, 199, 3, 2376, 365, 370, 746, 644, 2627, 465, 4967, 12, 642, 883, 506, 4224, 543, 314, 2018, 199, 3, 5721, 859, 12, 436, 642, 365, 3272, 1380, 314, 1950, 365, 2737, 12, 436, 314, 199, 3, 4465, 4884, 14, 8993, 7084, 4590, 883, 506, 1202, 14, 6121, 12, 1808, 3875, 63, 632, 199, 3, 9074, 1554, 12039, 748, 911, 5847, 7675, 4750, 3598, 370, 506, 10184, 465, 2552, 14, 199, 199, 533, 20385, 4590, 8, 785, 304, 272, 408, 272, 437, 30758, 4975, 6818, 25709, 1159, 3293, 3920, 1021, 880, 626, 781, 883, 8579, 272, 6770, 1919, 4454, 436, 24139, 3062, 543, 314, 2451, 2943, 14, 339, 11794, 2509, 465, 282, 4975, 12, 7830, 2419, 282, 5516, 12, 880, 626, 781, 10621, 1133, 410, 10112, 272, 370, 314, 6770, 8793, 6025, 2138, 701, 8113, 14, 3937, 1252, 272, 408, 272, 9479, 63, 509, 63, 5707, 12997, 705, 275, 334, 709, 2006, 4258, 339, 347, 636, 826, 721, 277, 12, 3920, 304, 267, 291, 14, 3937, 275, 3920, 339, 347, 5341, 8, 277, 12, 1827, 12, 1249, 29, 403, 304, 267, 862, 26, 288, 372, 291, 14, 3937, 14, 2526, 8, 1131, 12, 1249, 9, 267, 871, 8692, 14, 24823, 12, 325, 26, 288, 746, 3778, 14, 24823, 12, 3778, 14, 24823, 2031, 2960, 8, 69, 1826, 984, 14, 2804, 63, 815, 3430, 18, 61, 267, 871, 8692, 14, 31998, 547, 12, 325, 26, 288, 327, 9672, 2005, 1125, 9479, 370, 26864, 12, 3967, 2985, 17021, 370, 506, 288, 327, 3201, 12334, 1290, 436, 5634, 3955, 16602, 314, 1655, 11461, 4192, 14, 288, 340, 325, 59, 16, 61, 315, 291, 14, 6021, 63, 509, 63, 5707, 12997, 705, 26, 355, 746, 3778, 14, 24823, 12, 3778, 14, 24823, 2031, 2960, 8, 69, 1826, 984, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
GhostThrone/django
tests/get_or_create/tests.py
282
15058
from __future__ import unicode_literals import traceback from datetime import date from django.db import DatabaseError, IntegrityError from django.test import TestCase, TransactionTestCase, ignore_warnings from django.utils.encoding import DjangoUnicodeDecodeError from .models import ( Author, Book, DefaultPerson, ManualPrimaryKeyTest, Person, Profile, Publisher, Tag, Thing, ) class GetOrCreateTests(TestCase): def setUp(self): self.lennon = Person.objects.create( first_name='John', last_name='Lennon', birthday=date(1940, 10, 9) ) def test_get_or_create_method_with_get(self): created = Person.objects.get_or_create( first_name="John", last_name="Lennon", defaults={ "birthday": date(1940, 10, 9) } )[1] self.assertFalse(created) self.assertEqual(Person.objects.count(), 1) def test_get_or_create_method_with_create(self): created = Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults={ 'birthday': date(1943, 2, 25) } )[1] self.assertTrue(created) self.assertEqual(Person.objects.count(), 2) def test_get_or_create_redundant_instance(self): """ If we execute the exact same statement twice, the second time, it won't create a Person. """ Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults={ 'birthday': date(1943, 2, 25) } ) created = Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults={ 'birthday': date(1943, 2, 25) } )[1] self.assertFalse(created) self.assertEqual(Person.objects.count(), 2) def test_get_or_create_invalid_params(self): """ If you don't specify a value or default value for all required fields, you will get an error. """ self.assertRaises( IntegrityError, Person.objects.get_or_create, first_name="Tom", last_name="Smith" ) def test_get_or_create_on_related_manager(self): p = Publisher.objects.create(name="Acme Publishing") # Create a book through the publisher. book, created = p.books.get_or_create(name="The Book of Ed & Fred") self.assertTrue(created) # The publisher should have one book. self.assertEqual(p.books.count(), 1) # Try get_or_create again, this time nothing should be created. book, created = p.books.get_or_create(name="The Book of Ed & Fred") self.assertFalse(created) # And the publisher should still have one book. self.assertEqual(p.books.count(), 1) # Add an author to the book. ed, created = book.authors.get_or_create(name="Ed") self.assertTrue(created) # The book should have one author. self.assertEqual(book.authors.count(), 1) # Try get_or_create again, this time nothing should be created. ed, created = book.authors.get_or_create(name="Ed") self.assertFalse(created) # And the book should still have one author. self.assertEqual(book.authors.count(), 1) # Add a second author to the book. fred, created = book.authors.get_or_create(name="Fred") self.assertTrue(created) # The book should have two authors now. self.assertEqual(book.authors.count(), 2) # Create an Author not tied to any books. Author.objects.create(name="Ted") # There should be three Authors in total. The book object should have two. self.assertEqual(Author.objects.count(), 3) self.assertEqual(book.authors.count(), 2) # Try creating a book through an author. _, created = ed.books.get_or_create(name="Ed's Recipes", publisher=p) self.assertTrue(created) # Now Ed has two Books, Fred just one. self.assertEqual(ed.books.count(), 2) self.assertEqual(fred.books.count(), 1) # Use the publisher's primary key value instead of a model instance. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertTrue(created) # Try get_or_create again, this time nothing should be created. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertFalse(created) # The publisher should have three books. self.assertEqual(p.books.count(), 3) def test_defaults_exact(self): """ If you have a field named defaults and want to use it as an exact lookup, you need to use 'defaults__exact'. """ obj, created = Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults__exact='testing', defaults={ 'birthday': date(1943, 2, 25), 'defaults': 'testing', } ) self.assertTrue(created) self.assertEqual(obj.defaults, 'testing') obj2, created = Person.objects.get_or_create( first_name='George', last_name='Harrison', defaults__exact='testing', defaults={ 'birthday': date(1943, 2, 25), 'defaults': 'testing', } ) self.assertFalse(created) self.assertEqual(obj, obj2) class GetOrCreateTestsWithManualPKs(TestCase): def setUp(self): self.first_pk = ManualPrimaryKeyTest.objects.create(id=1, data="Original") def test_create_with_duplicate_primary_key(self): """ If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated. """ self.assertRaises( IntegrityError, ManualPrimaryKeyTest.objects.get_or_create, id=1, data="Different" ) self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original") def test_get_or_create_raises_IntegrityError_plus_traceback(self): """ get_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises here because we need to inspect the actual traceback. Refs #16340. """ try: ManualPrimaryKeyTest.objects.get_or_create(id=1, data="Different") except IntegrityError: formatted_traceback = traceback.format_exc() self.assertIn(str('obj.save'), formatted_traceback) # MySQL emits a warning when broken data is saved @ignore_warnings(module='django.db.backends.mysql.base') def test_savepoint_rollback(self): """ Regression test for #20463: the database connection should still be usable after a DataError or ProgrammingError in .get_or_create(). """ try: Person.objects.get_or_create( birthday=date(1970, 1, 1), defaults={'first_name': b"\xff", 'last_name': b"\xff"}) except (DatabaseError, DjangoUnicodeDecodeError): Person.objects.create( first_name="Bob", last_name="Ross", birthday=date(1950, 1, 1)) else: self.skipTest("This backend accepts broken utf-8.") def test_get_or_create_empty(self): """ Regression test for #16137: get_or_create does not require kwargs. """ try: DefaultPerson.objects.get_or_create() except AssertionError: self.fail("If all the attributes on a model have defaults, we " "shouldn't need to pass any arguments.") class GetOrCreateTransactionTests(TransactionTestCase): available_apps = ['get_or_create'] def test_get_or_create_integrityerror(self): """ Regression test for #15117. Requires a TransactionTestCase on databases that delay integrity checks until the end of transactions, otherwise the exception is never raised. """ try: Profile.objects.get_or_create(person=Person(id=1)) except IntegrityError: pass else: self.skipTest("This backend does not support integrity checks.") class GetOrCreateThroughManyToMany(TestCase): def test_get_get_or_create(self): tag = Tag.objects.create(text='foo') a_thing = Thing.objects.create(name='a') a_thing.tags.add(tag) obj, created = a_thing.tags.get_or_create(text='foo') self.assertFalse(created) self.assertEqual(obj.pk, tag.pk) def test_create_get_or_create(self): a_thing = Thing.objects.create(name='a') obj, created = a_thing.tags.get_or_create(text='foo') self.assertTrue(created) self.assertEqual(obj.text, 'foo') self.assertIn(obj, a_thing.tags.all()) def test_something(self): Tag.objects.create(text='foo') a_thing = Thing.objects.create(name='a') self.assertRaises(IntegrityError, a_thing.tags.get_or_create, text='foo') class UpdateOrCreateTests(TestCase): def test_update(self): Person.objects.create( first_name='John', last_name='Lennon', birthday=date(1940, 10, 9) ) p, created = Person.objects.update_or_create( first_name='John', last_name='Lennon', defaults={ 'birthday': date(1940, 10, 10) } ) self.assertFalse(created) self.assertEqual(p.first_name, 'John') self.assertEqual(p.last_name, 'Lennon') self.assertEqual(p.birthday, date(1940, 10, 10)) def test_create(self): p, created = Person.objects.update_or_create( first_name='John', last_name='Lennon', defaults={ 'birthday': date(1940, 10, 10) } ) self.assertTrue(created) self.assertEqual(p.first_name, 'John') self.assertEqual(p.last_name, 'Lennon') self.assertEqual(p.birthday, date(1940, 10, 10)) def test_create_twice(self): params = { 'first_name': 'John', 'last_name': 'Lennon', 'birthday': date(1940, 10, 10), } Person.objects.update_or_create(**params) # If we execute the exact same statement, it won't create a Person. p, created = Person.objects.update_or_create(**params) self.assertFalse(created) def test_integrity(self): """ If you don't specify a value or default value for all required fields, you will get an error. """ self.assertRaises(IntegrityError, Person.objects.update_or_create, first_name="Tom", last_name="Smith") def test_manual_primary_key_test(self): """ If you specify an existing primary key, but different other fields, then you will get an error and data will not be updated. """ ManualPrimaryKeyTest.objects.create(id=1, data="Original") self.assertRaises( IntegrityError, ManualPrimaryKeyTest.objects.update_or_create, id=1, data="Different" ) self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original") def test_error_contains_full_traceback(self): """ update_or_create should raise IntegrityErrors with the full traceback. This is tested by checking that a known method call is in the traceback. We cannot use assertRaises/assertRaises here because we need to inspect the actual traceback. Refs #16340. """ try: ManualPrimaryKeyTest.objects.update_or_create(id=1, data="Different") except IntegrityError: formatted_traceback = traceback.format_exc() self.assertIn('obj.save', formatted_traceback) def test_create_with_related_manager(self): """ Should be able to use update_or_create from the related manager to create a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") book, created = p.books.update_or_create(name="The Book of Ed & Fred") self.assertTrue(created) self.assertEqual(p.books.count(), 1) def test_update_with_related_manager(self): """ Should be able to use update_or_create from the related manager to update a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") book = Book.objects.create(name="The Book of Ed & Fred", publisher=p) self.assertEqual(p.books.count(), 1) name = "The Book of Django" book, created = p.books.update_or_create(defaults={'name': name}, id=book.id) self.assertFalse(created) self.assertEqual(book.name, name) self.assertEqual(p.books.count(), 1) def test_create_with_many(self): """ Should be able to use update_or_create from the m2m related manager to create a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") author = Author.objects.create(name="Ted") book, created = author.books.update_or_create(name="The Book of Ed & Fred", publisher=p) self.assertTrue(created) self.assertEqual(author.books.count(), 1) def test_update_with_many(self): """ Should be able to use update_or_create from the m2m related manager to update a book. Refs #23611. """ p = Publisher.objects.create(name="Acme Publishing") author = Author.objects.create(name="Ted") book = Book.objects.create(name="The Book of Ed & Fred", publisher=p) book.authors.add(author) self.assertEqual(author.books.count(), 1) name = "The Book of Django" book, created = author.books.update_or_create(defaults={'name': name}, id=book.id) self.assertFalse(created) self.assertEqual(book.name, name) self.assertEqual(author.books.count(), 1) def test_defaults_exact(self): """ If you have a field named defaults and want to use it as an exact lookup, you need to use 'defaults__exact'. """ obj, created = Person.objects.update_or_create( first_name='George', last_name='Harrison', defaults__exact='testing', defaults={ 'birthday': date(1943, 2, 25), 'defaults': 'testing', } ) self.assertTrue(created) self.assertEqual(obj.defaults, 'testing') obj, created = Person.objects.update_or_create( first_name='George', last_name='Harrison', defaults__exact='testing', defaults={ 'birthday': date(1943, 2, 25), 'defaults': 'another testing', } ) self.assertFalse(created) self.assertEqual(obj.defaults, 'another testing')
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5190, 199, 504, 2197, 492, 1434, 199, 199, 504, 1639, 14, 697, 492, 27728, 12, 26864, 199, 504, 1639, 14, 396, 492, 7640, 12, 18244, 1746, 12, 3686, 63, 5451, 199, 504, 1639, 14, 1208, 14, 2991, 492, 5634, 7087, 12620, 199, 199, 504, 1275, 992, 492, 334, 272, 6529, 12, 8944, 12, 3758, 7344, 12, 30247, 29457, 774, 12, 8028, 12, 14386, 12, 272, 19952, 281, 12, 8053, 12, 3868, 316, 12, 199, 9, 421, 199, 533, 2372, 2844, 2499, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 552, 2865, 275, 8028, 14, 1462, 14, 981, 8, 288, 1642, 63, 354, 534, 12923, 297, 2061, 63, 354, 534, 3166, 2865, 297, 21036, 2977, 29, 602, 8, 30614, 12, 1616, 12, 1749, 9, 267, 776, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 765, 63, 1045, 63, 362, 8, 277, 304, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 3166, 2865, 401, 4243, 3126, 355, 298, 15881, 582, 1434, 8, 30614, 12, 1616, 12, 1749, 9, 288, 789, 267, 29688, 17, 61, 267, 291, 14, 3334, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 413, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 765, 63, 1045, 63, 981, 8, 277, 304, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 29688, 17, 61, 267, 291, 14, 1815, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 581, 17013, 63, 842, 8, 277, 304, 267, 408, 267, 982, 781, 5341, 314, 5835, 2011, 5164, 13373, 12, 314, 3499, 900, 12, 267, 652, 7859, 1133, 1218, 282, 8028, 14, 267, 408, 267, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 776, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 29688, 17, 61, 398, 291, 14, 3334, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 3197, 63, 1162, 8, 277, 304, 267, 408, 267, 982, 1265, 2793, 1133, 4165, 282, 574, 503, 849, 574, 367, 1006, 1415, 267, 1504, 12, 1265, 911, 664, 376, 1125, 14, 267, 408, 267, 291, 14, 1855, 8, 288, 26864, 12, 288, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 12, 1642, 63, 354, 628, 52, 676, 401, 2061, 63, 354, 628, 16782, 448, 2, 267, 776, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 265, 63, 2407, 63, 2609, 8, 277, 304, 267, 299, 275, 19952, 281, 14, 1462, 14, 981, 8, 354, 628, 1945, 278, 19952, 316, 531, 267, 327, 2790, 282, 6719, 4012, 314, 19704, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 19704, 1077, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 19704, 1077, 5139, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 2654, 376, 4132, 370, 314, 6719, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 6719, 1077, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 6719, 1077, 5139, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 2654, 282, 3499, 4132, 370, 314, 6719, 14, 267, 289, 581, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 38, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 710, 6719, 1077, 1172, 2877, 11462, 3063, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 2790, 376, 6529, 440, 29142, 370, 1263, 19040, 14, 267, 6529, 14, 1462, 14, 981, 8, 354, 628, 52, 379, 531, 398, 327, 6006, 1077, 506, 7795, 6642, 315, 3141, 14, 710, 6719, 909, 1077, 1172, 2877, 14, 267, 291, 14, 629, 8, 5949, 14, 1462, 14, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 7649, 6425, 282, 6719, 4012, 376, 4132, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 1159, 799, 8233, 83, 401, 19704, 29, 80, 9, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 7356, 17379, 965, 2877, 8944, 83 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5190, 199, 504, 2197, 492, 1434, 199, 199, 504, 1639, 14, 697, 492, 27728, 12, 26864, 199, 504, 1639, 14, 396, 492, 7640, 12, 18244, 1746, 12, 3686, 63, 5451, 199, 504, 1639, 14, 1208, 14, 2991, 492, 5634, 7087, 12620, 199, 199, 504, 1275, 992, 492, 334, 272, 6529, 12, 8944, 12, 3758, 7344, 12, 30247, 29457, 774, 12, 8028, 12, 14386, 12, 272, 19952, 281, 12, 8053, 12, 3868, 316, 12, 199, 9, 421, 199, 533, 2372, 2844, 2499, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 552, 2865, 275, 8028, 14, 1462, 14, 981, 8, 288, 1642, 63, 354, 534, 12923, 297, 2061, 63, 354, 534, 3166, 2865, 297, 21036, 2977, 29, 602, 8, 30614, 12, 1616, 12, 1749, 9, 267, 776, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 765, 63, 1045, 63, 362, 8, 277, 304, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 628, 12923, 401, 2061, 63, 354, 628, 3166, 2865, 401, 4243, 3126, 355, 298, 15881, 582, 1434, 8, 30614, 12, 1616, 12, 1749, 9, 288, 789, 267, 29688, 17, 61, 267, 291, 14, 3334, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 413, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 765, 63, 1045, 63, 981, 8, 277, 304, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 29688, 17, 61, 267, 291, 14, 1815, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 581, 17013, 63, 842, 8, 277, 304, 267, 408, 267, 982, 781, 5341, 314, 5835, 2011, 5164, 13373, 12, 314, 3499, 900, 12, 267, 652, 7859, 1133, 1218, 282, 8028, 14, 267, 408, 267, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 776, 267, 2737, 275, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 288, 1642, 63, 354, 534, 4240, 24591, 297, 2061, 63, 354, 534, 18248, 322, 834, 297, 4243, 3126, 355, 283, 15881, 356, 1434, 8, 1167, 2824, 12, 499, 12, 5661, 9, 288, 789, 267, 29688, 17, 61, 398, 291, 14, 3334, 8, 3966, 9, 267, 291, 14, 629, 8, 7344, 14, 1462, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 3197, 63, 1162, 8, 277, 304, 267, 408, 267, 982, 1265, 2793, 1133, 4165, 282, 574, 503, 849, 574, 367, 1006, 1415, 267, 1504, 12, 1265, 911, 664, 376, 1125, 14, 267, 408, 267, 291, 14, 1855, 8, 288, 26864, 12, 288, 8028, 14, 1462, 14, 362, 63, 269, 63, 981, 12, 1642, 63, 354, 628, 52, 676, 401, 2061, 63, 354, 628, 16782, 448, 2, 267, 776, 339, 347, 511, 63, 362, 63, 269, 63, 981, 63, 265, 63, 2407, 63, 2609, 8, 277, 304, 267, 299, 275, 19952, 281, 14, 1462, 14, 981, 8, 354, 628, 1945, 278, 19952, 316, 531, 267, 327, 2790, 282, 6719, 4012, 314, 19704, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 19704, 1077, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 19704, 1077, 5139, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 2654, 376, 4132, 370, 314, 6719, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 6719, 1077, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 6719, 1077, 5139, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 2654, 282, 3499, 4132, 370, 314, 6719, 14, 267, 289, 581, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 38, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 710, 6719, 1077, 1172, 2877, 11462, 3063, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 2790, 376, 6529, 440, 29142, 370, 1263, 19040, 14, 267, 6529, 14, 1462, 14, 981, 8, 354, 628, 52, 379, 531, 398, 327, 6006, 1077, 506, 7795, 6642, 315, 3141, 14, 710, 6719, 909, 1077, 1172, 2877, 14, 267, 291, 14, 629, 8, 5949, 14, 1462, 14, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 7649, 6425, 282, 6719, 4012, 376, 4132, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dennybaa/st2
st2common/st2common/models/base.py
11
1579
# Licensed to the StackStorm, Inc ('StackStorm') 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. """ Common model related classes. """ __all__ = [ 'DictSerializableClassMixin' ] class DictSerializableClassMixin(object): """ Mixin class which is to be used with classes which can be serialized as a dictionary, """ def mask_secrets(self, value): """ Process the object and mask secret values. :type value: ``dict`` :param value: Document dictionary. :rtype: ``dict`` """ return value def to_serializable_dict(self, mask_secrets=False): """ Serialize object to a dictionary which can be serialized as JSON. :param mask_secrets: True to mask secrets in the resulting dict. :type mask_secrets: ``boolean`` :rtype: ``dict`` """ raise NotImplementedError()
apache-2.0
[ 3, 3909, 370, 314, 13894, 933, 1025, 12, 3277, 661, 4851, 933, 1025, 358, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 7844, 1402, 4048, 3992, 14, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2141, 3571, 14065, 2543, 4256, 7, 199, 61, 421, 199, 533, 7448, 3571, 14065, 2543, 4256, 8, 785, 304, 272, 408, 272, 28438, 1021, 1314, 365, 370, 506, 1202, 543, 3992, 1314, 883, 506, 6380, 465, 282, 2600, 12, 272, 408, 339, 347, 3656, 63, 16153, 8, 277, 12, 574, 304, 267, 408, 267, 7132, 314, 909, 436, 3656, 7565, 1338, 14, 398, 520, 466, 574, 26, 1124, 807, 1040, 267, 520, 635, 574, 26, 7543, 2600, 14, 398, 520, 4500, 26, 1124, 807, 1040, 267, 408, 267, 372, 574, 339, 347, 370, 63, 2171, 14065, 63, 807, 8, 277, 12, 3656, 63, 16153, 29, 797, 304, 267, 408, 267, 11973, 794, 909, 370, 282, 2600, 1314, 883, 506, 6380, 465, 4840, 14, 398, 520, 635, 3656, 63, 16153, 26, 715, 370, 3656, 25563, 315, 314, 9183, 1211, 14, 267, 520, 466, 3656, 63, 16153, 26, 1124, 4871, 1040, 398, 520, 4500, 26, 1124, 807, 1040, 267, 408, 267, 746, 4279, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 13894, 933, 1025, 12, 3277, 661, 4851, 933, 1025, 358, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 7844, 1402, 4048, 3992, 14, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2141, 3571, 14065, 2543, 4256, 7, 199, 61, 421, 199, 533, 7448, 3571, 14065, 2543, 4256, 8, 785, 304, 272, 408, 272, 28438, 1021, 1314, 365, 370, 506, 1202, 543, 3992, 1314, 883, 506, 6380, 465, 282, 2600, 12, 272, 408, 339, 347, 3656, 63, 16153, 8, 277, 12, 574, 304, 267, 408, 267, 7132, 314, 909, 436, 3656, 7565, 1338, 14, 398, 520, 466, 574, 26, 1124, 807, 1040, 267, 520, 635, 574, 26, 7543, 2600, 14, 398, 520, 4500, 26, 1124, 807, 1040, 267, 408, 267, 372, 574, 339, 347, 370, 63, 2171, 14065, 63, 807, 8, 277, 12, 3656, 63, 16153, 29, 797, 304, 267, 408, 267, 11973, 794, 909, 370, 282, 2600, 1314, 883, 506, 6380, 465, 4840, 14, 398, 520, 635, 3656, 63, 16153, 26, 715, 370, 3656, 25563, 315, 314, 9183, 1211, 14, 267, 520, 466, 3656, 63, 16153, 26, 1124, 4871, 1040, 398, 520, 4500, 26, 1124, 807, 1040, 267, 408, 267, 746, 4279, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
weblabdeusto/weblabdeusto
server/src/test/unit/voodoo/test_representable.py
3
7531
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2005 onwards University of Deusto # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # # This software consists of contributions made by many individuals, # listed below: # # Author: Pablo Orduña <pablo@ordunya.com> # from __future__ import print_function, unicode_literals import unittest from abc import ABCMeta, abstractmethod from voodoo.representable import Representable, AbstractRepresentable from voodoo.typechecker import typecheck ######################################################### # # Regular scenario: parent class is representable, # the inherited classes are also representable. # class DirectClass(object): __metaclass__ = Representable def __init__(self, a, b): self.a = a self.b = b class ChildClass(DirectClass): def __init__(self, a, b, c): super(ChildClass, self).__init__(a, b) self.c = c class GrandChildClass(ChildClass): pass ######################################################### # # Typed Regular scenario: parent class is representable, # the inherited classes are also representable. # class TypedDirectClass(object): __metaclass__ = Representable @typecheck(int, int) def __init__(self, a, b): self.a = a self.b = b class TypedChildClass(TypedDirectClass): @typecheck(int, int, int) def __init__(self, a, b, c): super(TypedChildClass, self).__init__(a, b) self.c = c class TypedGrandChildClass(TypedChildClass): pass ############################################################# # # Don't cause problems when using _field or __field, neither # with properties # class ClassWithProtectedData(object): __metaclass__ = Representable def __init__(self, x, y): self._x = x self._y = y class ClassWithPrivateData(object): __metaclass__ = Representable def __init__(self, x, y): self.__x = x self.__y = y class ClassWithProperties(object): __metaclass__ = Representable def __init__(self, x): self._x = x @property def x(self): return self._x @x.setter def x(self, value): self._x = value ########################################################### # # Wrong case: the constructor does not set a field that # appears in the constructor of the class. This should # fail when creating the object. # class WrongClass(object): __metaclass__ = Representable def __init__(self, a, b, missing_field): self.a = a self.b = b # No field called "missing_field" ############################################################# # # Abstract class: enable classes to be abstract and # representables at the very same time. # class AbstractClass(object): __metaclass__ = AbstractRepresentable def __init__(self, a, b): self.a = a self.b = b @abstractmethod def method(self): pass class ConcreteClass(AbstractClass): def __init__(self, a, b, c): super(ConcreteClass, self).__init__(a,b) self.c = c def method(self): pass class ClassWithVariables(object): __metaclass__ = Representable def __init__(self, a): self.a = a something = 5 something += 1 ############################################################## # # Abstract class: enable a class to be abstract, and then # a derived class to be representable # class PureAbstractClass(object): __metaclass__ = ABCMeta def __init__(self, a, b): self.a = a self.b = b @abstractmethod def method(self): pass class ConcreteRepresentableClass(PureAbstractClass): __metaclass__ = AbstractRepresentable def __init__(self, a, b, c): super(ConcreteRepresentableClass, self).__init__(a, b) self.c = c def method(self): pass class RepresentableTestCase(unittest.TestCase): def test_equality(self): self.assertEquals(DirectClass(5,6), DirectClass(5,6)) self.assertNotEquals(DirectClass(5,6), DirectClass(6,5)) def test_repr(self): self.assertEquals(DirectClass(5,6), eval(repr(DirectClass(5,6)))) self.assertNotEquals(DirectClass(6,5), eval(repr(DirectClass(5,6)))) def test_typed_repr(self): self.assertEquals(TypedDirectClass(5,6), eval(repr(TypedDirectClass(5,6)))) self.assertNotEquals(TypedDirectClass(6,5), eval(repr(TypedDirectClass(5,6)))) def test_class_with_private(self): self.assertEquals(ClassWithPrivateData(5,6), eval(repr(ClassWithPrivateData(5,6)))) self.assertNotEquals(ClassWithPrivateData(6,5), eval(repr(ClassWithPrivateData(5,6)))) def test_class_with_protected(self): self.assertEquals(ClassWithProtectedData(5,6), eval(repr(ClassWithProtectedData(5,6)))) self.assertNotEquals(ClassWithProtectedData(6,5), eval(repr(ClassWithProtectedData(5,6)))) def test_class_with_properties(self): self.assertEquals(ClassWithProperties(5), eval(repr(ClassWithProperties(5)))) self.assertNotEquals(ClassWithProperties(6), eval(repr(ClassWithProperties(5)))) def test_repr_with_vars_in_ctor(self): self.assertEquals(ClassWithVariables(5), eval(repr(ClassWithVariables(5)))) def test_child_equality(self): self.assertEquals(ChildClass(5,6,7), ChildClass(5,6,7)) self.assertNotEquals(ChildClass(5,6,7), ChildClass(5,6,8)) self.assertNotEquals(ChildClass(5,6,7), ChildClass(6,5,7)) def test_child_repr(self): self.assertEquals(ChildClass(5,6,7), eval(repr(ChildClass(5,6,7)))) self.assertNotEquals(ChildClass(6,5,7), eval(repr(ChildClass(5,6,7)))) def test_typed_child_repr(self): self.assertEquals(TypedChildClass(5,6,7), eval(repr(TypedChildClass(5,6,7)))) self.assertNotEquals(TypedChildClass(6,5,7), eval(repr(TypedChildClass(5,6,7)))) def test_grand_child_equality(self): self.assertEquals(GrandChildClass(5,6,7), GrandChildClass(5,6,7)) self.assertNotEquals(GrandChildClass(5,6,7), GrandChildClass(5,6,8)) self.assertNotEquals(GrandChildClass(5,6,7), GrandChildClass(6,5,7)) self.assertNotEquals(GrandChildClass(5,6,7), ChildClass(5,6,7)) def test_grand_child_repr(self): self.assertEquals(GrandChildClass(5,6,7), eval(repr(GrandChildClass(5,6,7)))) self.assertNotEquals(GrandChildClass(6,5,7), eval(repr(GrandChildClass(5,6,7)))) def test_field_requirement(self): try: WrongClass('a', 'b', 'c') self.fail("TypeError expected") except TypeError as te: self.assertTrue('missing_field' in str(te)) def test_child_abstract_repr(self): # It's still abstract self.assertRaises(TypeError, AbstractClass, 5, 6) # But the concrete class is representable self.assertEquals(ConcreteClass(5,6,7), eval(repr(ConcreteClass(5,6,7)))) self.assertNotEquals(ConcreteClass(6,5,7), eval(repr(ConcreteClass(5,6,7)))) def test_child_pure_abstract_repr(self): self.assertEquals(ConcreteRepresentableClass(5,6,7), eval(repr(ConcreteRepresentableClass(5,6,7)))) self.assertNotEquals(ConcreteRepresentableClass(6,5,7), eval(repr(ConcreteRepresentableClass(5,6,7)))) def suite(): return unittest.makeSuite(RepresentableTestCase) if __name__ == '__main__': unittest.main()
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 11811, 641, 4751, 15904, 402, 1487, 833, 79, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 199, 3, 199, 3, 961, 2032, 18581, 402, 406, 26675, 6326, 701, 5002, 8212, 83, 12, 199, 3, 10532, 5084, 26, 199, 3, 199, 3, 6529, 26, 510, 371, 320, 4236, 2033, 22692, 65, 665, 80, 371, 320, 32, 2181, 324, 11552, 14, 957, 30, 199, 3, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 2882, 199, 199, 504, 13022, 492, 29565, 12, 9006, 765, 199, 504, 14164, 22058, 14, 13063, 461, 492, 17634, 461, 12, 11836, 10755, 461, 199, 504, 14164, 22058, 14, 466, 6743, 492, 730, 1074, 199, 199, 1371, 19054, 199, 3, 199, 3, 18528, 15728, 26, 1676, 1021, 365, 2954, 461, 12, 199, 3, 314, 12623, 3992, 787, 2597, 2954, 461, 14, 199, 3, 199, 199, 533, 21128, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 199, 199, 533, 12988, 2543, 8, 16281, 2543, 304, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 3493, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 199, 199, 533, 598, 3759, 3493, 2543, 8, 3493, 2543, 304, 272, 986, 199, 199, 1371, 19054, 199, 3, 199, 3, 31906, 18528, 15728, 26, 1676, 1021, 365, 2954, 461, 12, 199, 3, 314, 12623, 3992, 787, 2597, 2954, 461, 14, 199, 3, 199, 199, 533, 31906, 16281, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 768, 466, 1074, 8, 442, 12, 1109, 9, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 199, 199, 533, 31906, 3493, 2543, 8, 22193, 16281, 2543, 304, 339, 768, 466, 1074, 8, 442, 12, 1109, 12, 1109, 9, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 22193, 3493, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 199, 199, 533, 2434, 28929, 3759, 3493, 2543, 8, 22193, 3493, 2543, 304, 272, 986, 199, 199, 26207, 8776, 199, 3, 199, 3, 7529, 1133, 7675, 8826, 1380, 1808, 485, 698, 503, 636, 698, 12, 15564, 199, 3, 543, 4382, 199, 3, 199, 199, 533, 8089, 3007, 919, 4530, 1451, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 423, 88, 275, 671, 267, 291, 423, 89, 275, 612, 199, 199, 533, 8089, 3007, 12185, 1451, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 855, 88, 275, 671, 267, 291, 855, 89, 275, 612, 199, 199, 533, 8089, 3007, 8516, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 304, 267, 291, 423, 88, 275, 671, 339, 768, 1829, 272, 347, 671, 8, 277, 304, 267, 372, 291, 423, 88, 339, 768, 88, 14, 8345, 272, 347, 671, 8, 277, 12, 574, 304, 267, 291, 423, 88, 275, 574, 199, 199, 26207, 5680, 199, 3, 199, 3, 30801, 1930, 26, 314, 3787, 1630, 440, 663, 282, 901, 626, 199, 3, 11337, 315, 314, 3787, 402, 314, 1021, 14, 961, 1077, 199, 3, 2449, 1380, 6425, 314, 909, 14, 199, 3, 199, 199, 533, 30801, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 4124, 63, 698, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 267, 327, 3091, 901, 2797, 298, 4752, 63, 698, 2, 199, 199, 26207, 8776, 199, 3, 199, 3, 11836, 1021, 26, 4756, 3992, 370, 506, 9006, 436, 199, 3, 2954, 5921, 737, 314, 7437, 2011, 900, 14, 199, 3, 199, 199, 533, 11836, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 11836, 10755, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 339, 768, 10315, 272, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 1448, 7564, 2543, 8, 8458, 2543, 304, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 714, 7564, 2543, 12, 291, 2843, 826, 721, 65, 12, 66, 9, 267, 291, 14, 67, 275, 286, 339, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 8089, 3007, 11458, 8, 785, 304, 272, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 304, 267, 291, 14, 65, 275, 282, 267, 6020, 275, 959, 267, 6020, 847, 413, 199, 199, 26207, 3726, 199, 3, 199, 3, 11836, 1021, 26, 4756, 282, 1021, 370, 506, 9006, 12, 436, 2066, 199, 3, 282, 7131, 1021, 370, 506, 2954, 461, 199, 3, 199, 199, 533, 510, 608, 8458, 2543, 8, 785, 304, 272, 636, 6577, 363, 275, 29565, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 339, 768, 10315, 272, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 1448, 7564, 10755, 461, 2543, 8, 28928, 8458, 2543, 304, 272, 636, 6577, 363, 275, 11836, 10755, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 714, 7564, 10755, 461, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 339, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 17634, 461, 1746, 8, 2796, 14, 1746 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 11811, 641, 4751, 15904, 402, 1487, 833, 79, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 199, 3, 199, 3, 961, 2032, 18581, 402, 406, 26675, 6326, 701, 5002, 8212, 83, 12, 199, 3, 10532, 5084, 26, 199, 3, 199, 3, 6529, 26, 510, 371, 320, 4236, 2033, 22692, 65, 665, 80, 371, 320, 32, 2181, 324, 11552, 14, 957, 30, 199, 3, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 2882, 199, 199, 504, 13022, 492, 29565, 12, 9006, 765, 199, 504, 14164, 22058, 14, 13063, 461, 492, 17634, 461, 12, 11836, 10755, 461, 199, 504, 14164, 22058, 14, 466, 6743, 492, 730, 1074, 199, 199, 1371, 19054, 199, 3, 199, 3, 18528, 15728, 26, 1676, 1021, 365, 2954, 461, 12, 199, 3, 314, 12623, 3992, 787, 2597, 2954, 461, 14, 199, 3, 199, 199, 533, 21128, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 199, 199, 533, 12988, 2543, 8, 16281, 2543, 304, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 3493, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 199, 199, 533, 598, 3759, 3493, 2543, 8, 3493, 2543, 304, 272, 986, 199, 199, 1371, 19054, 199, 3, 199, 3, 31906, 18528, 15728, 26, 1676, 1021, 365, 2954, 461, 12, 199, 3, 314, 12623, 3992, 787, 2597, 2954, 461, 14, 199, 3, 199, 199, 533, 31906, 16281, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 768, 466, 1074, 8, 442, 12, 1109, 9, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 199, 199, 533, 31906, 3493, 2543, 8, 22193, 16281, 2543, 304, 339, 768, 466, 1074, 8, 442, 12, 1109, 12, 1109, 9, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 22193, 3493, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 199, 199, 533, 2434, 28929, 3759, 3493, 2543, 8, 22193, 3493, 2543, 304, 272, 986, 199, 199, 26207, 8776, 199, 3, 199, 3, 7529, 1133, 7675, 8826, 1380, 1808, 485, 698, 503, 636, 698, 12, 15564, 199, 3, 543, 4382, 199, 3, 199, 199, 533, 8089, 3007, 919, 4530, 1451, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 423, 88, 275, 671, 267, 291, 423, 89, 275, 612, 199, 199, 533, 8089, 3007, 12185, 1451, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 267, 291, 855, 88, 275, 671, 267, 291, 855, 89, 275, 612, 199, 199, 533, 8089, 3007, 8516, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 671, 304, 267, 291, 423, 88, 275, 671, 339, 768, 1829, 272, 347, 671, 8, 277, 304, 267, 372, 291, 423, 88, 339, 768, 88, 14, 8345, 272, 347, 671, 8, 277, 12, 574, 304, 267, 291, 423, 88, 275, 574, 199, 199, 26207, 5680, 199, 3, 199, 3, 30801, 1930, 26, 314, 3787, 1630, 440, 663, 282, 901, 626, 199, 3, 11337, 315, 314, 3787, 402, 314, 1021, 14, 961, 1077, 199, 3, 2449, 1380, 6425, 314, 909, 14, 199, 3, 199, 199, 533, 30801, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 4124, 63, 698, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 267, 327, 3091, 901, 2797, 298, 4752, 63, 698, 2, 199, 199, 26207, 8776, 199, 3, 199, 3, 11836, 1021, 26, 4756, 3992, 370, 506, 9006, 436, 199, 3, 2954, 5921, 737, 314, 7437, 2011, 900, 14, 199, 3, 199, 199, 533, 11836, 2543, 8, 785, 304, 339, 636, 6577, 363, 275, 11836, 10755, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 339, 768, 10315, 272, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 1448, 7564, 2543, 8, 8458, 2543, 304, 272, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 714, 7564, 2543, 12, 291, 2843, 826, 721, 65, 12, 66, 9, 267, 291, 14, 67, 275, 286, 339, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 8089, 3007, 11458, 8, 785, 304, 272, 636, 6577, 363, 275, 17634, 461, 339, 347, 636, 826, 721, 277, 12, 282, 304, 267, 291, 14, 65, 275, 282, 267, 6020, 275, 959, 267, 6020, 847, 413, 199, 199, 26207, 3726, 199, 3, 199, 3, 11836, 1021, 26, 4756, 282, 1021, 370, 506, 9006, 12, 436, 2066, 199, 3, 282, 7131, 1021, 370, 506, 2954, 461, 199, 3, 199, 199, 533, 510, 608, 8458, 2543, 8, 785, 304, 272, 636, 6577, 363, 275, 29565, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 304, 267, 291, 14, 65, 275, 282, 267, 291, 14, 66, 275, 330, 339, 768, 10315, 272, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 1448, 7564, 10755, 461, 2543, 8, 28928, 8458, 2543, 304, 272, 636, 6577, 363, 275, 11836, 10755, 461, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 304, 267, 1613, 8, 714, 7564, 10755, 461, 2543, 12, 291, 2843, 826, 721, 65, 12, 330, 9, 267, 291, 14, 67, 275, 286, 339, 347, 1083, 8, 277, 304, 267, 986, 199, 199, 533, 17634, 461, 1746, 8, 2796, 14, 1746, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kailIII/geraldo
site/newsite/site-geraldo/django/contrib/localflavor/pe/forms.py
26
2238
# -*- coding: utf-8 -*- """ PE-specific Form helpers. """ from django.forms import ValidationError from django.forms.fields import RegexField, CharField, Select, EMPTY_VALUES from django.utils.translation import ugettext_lazy as _ class PERegionSelect(Select): """ A Select widget that uses a list of Peruvian Regions as its choices. """ def __init__(self, attrs=None): from pe_region import REGION_CHOICES super(PERegionSelect, self).__init__(attrs, choices=REGION_CHOICES) class PEDNIField(CharField): """ A field that validates `Documento Nacional de IdentidadŽ (DNI) numbers. """ default_error_messages = { 'invalid': _("This field requires only numbers."), 'max_digits': _("This field requires 8 digits."), } def __init__(self, *args, **kwargs): super(PEDNIField, self).__init__(max_length=8, min_length=8, *args, **kwargs) def clean(self, value): """ Value must be a string in the XXXXXXXX formats. """ value = super(PEDNIField, self).clean(value) if value in EMPTY_VALUES: return u'' if not value.isdigit(): raise ValidationError(self.error_messages['invalid']) if len(value) != 8: raise ValidationError(self.error_messages['max_digits']) return value class PERUCField(RegexField): """ This field validates a RUC (Registro Unico de Contribuyentes). A RUC is of the form XXXXXXXXXXX. """ default_error_messages = { 'invalid': _("This field requires only numbers."), 'max_digits': _("This field requires 11 digits."), } def __init__(self, *args, **kwargs): super(PERUCField, self).__init__(max_length=11, min_length=11, *args, **kwargs) def clean(self, value): """ Value must be an 11-digit number. """ value = super(PERUCField, self).clean(value) if value in EMPTY_VALUES: return u'' if not value.isdigit(): raise ValidationError(self.error_messages['invalid']) if len(value) != 11: raise ValidationError(self.error_messages['max_digits']) return value
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 1510, 13, 6100, 8204, 10897, 14, 199, 624, 199, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 12939, 792, 12, 12064, 12, 9496, 12, 16589, 63, 15514, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 533, 19599, 10708, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 3492, 85, 433, 290, 5044, 15293, 465, 2399, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 4837, 63, 4551, 492, 14142, 1075, 63, 16236, 267, 1613, 8, 1510, 10708, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 23030, 63, 16236, 9, 199, 199, 533, 510, 1149, 16730, 792, 8, 2183, 304, 272, 408, 272, 437, 901, 626, 29280, 658, 5564, 79, 11290, 559, 8125, 477, 473, 848, 5700, 350, 130, 122, 334, 10872, 41, 9, 5579, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 3824, 2765, 901, 5074, 1454, 5579, 7651, 267, 283, 988, 63, 7022, 356, 3824, 2765, 901, 5074, 1695, 7576, 7651, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 19359, 16730, 792, 12, 291, 2843, 826, 721, 988, 63, 1267, 29, 24, 12, 1748, 63, 1267, 29, 24, 12, 627, 589, 12, 355, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 1594, 1471, 506, 282, 1059, 315, 314, 5787, 6873, 56, 6752, 14, 267, 408, 267, 574, 275, 1613, 8, 19359, 16730, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 574, 14, 13896, 837, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 267, 340, 822, 8, 585, 9, 1137, 1695, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 988, 63, 7022, 1105, 398, 372, 574, 199, 199, 533, 13873, 13371, 792, 8, 5103, 792, 304, 272, 408, 272, 961, 901, 29280, 282, 820, 13371, 334, 2872, 631, 293, 1910, 12802, 477, 1448, 786, 28695, 744, 680, 437, 820, 13371, 365, 402, 272, 314, 1824, 5787, 13312, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 3824, 2765, 901, 5074, 1454, 5579, 7651, 267, 283, 988, 63, 7022, 356, 3824, 2765, 901, 5074, 4119, 7576, 7651, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4227, 13371, 792, 12, 291, 2843, 826, 721, 988, 63, 1267, 29, 845, 12, 1748, 63, 1267, 29, 845, 12, 627, 589, 12, 288, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 1594, 1471, 506, 376, 4119, 13, 8573, 1329, 14, 267, 408, 267, 574, 275, 1613, 8, 4227, 13371, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 574, 14, 13896, 837, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 267, 340, 822, 8, 585, 9, 1137, 4119, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 988, 63, 7022, 1105, 267, 372, 574, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 1510, 13, 6100, 8204, 10897, 14, 199, 624, 199, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 12939, 792, 12, 12064, 12, 9496, 12, 16589, 63, 15514, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 533, 19599, 10708, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 3492, 85, 433, 290, 5044, 15293, 465, 2399, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 4837, 63, 4551, 492, 14142, 1075, 63, 16236, 267, 1613, 8, 1510, 10708, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 23030, 63, 16236, 9, 199, 199, 533, 510, 1149, 16730, 792, 8, 2183, 304, 272, 408, 272, 437, 901, 626, 29280, 658, 5564, 79, 11290, 559, 8125, 477, 473, 848, 5700, 350, 130, 122, 334, 10872, 41, 9, 5579, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 3824, 2765, 901, 5074, 1454, 5579, 7651, 267, 283, 988, 63, 7022, 356, 3824, 2765, 901, 5074, 1695, 7576, 7651, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 19359, 16730, 792, 12, 291, 2843, 826, 721, 988, 63, 1267, 29, 24, 12, 1748, 63, 1267, 29, 24, 12, 627, 589, 12, 355, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 1594, 1471, 506, 282, 1059, 315, 314, 5787, 6873, 56, 6752, 14, 267, 408, 267, 574, 275, 1613, 8, 19359, 16730, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 574, 14, 13896, 837, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 267, 340, 822, 8, 585, 9, 1137, 1695, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 988, 63, 7022, 1105, 398, 372, 574, 199, 199, 533, 13873, 13371, 792, 8, 5103, 792, 304, 272, 408, 272, 961, 901, 29280, 282, 820, 13371, 334, 2872, 631, 293, 1910, 12802, 477, 1448, 786, 28695, 744, 680, 437, 820, 13371, 365, 402, 272, 314, 1824, 5787, 13312, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 3824, 2765, 901, 5074, 1454, 5579, 7651, 267, 283, 988, 63, 7022, 356, 3824, 2765, 901, 5074, 4119, 7576, 7651, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4227, 13371, 792, 12, 291, 2843, 826, 721, 988, 63, 1267, 29, 845, 12, 1748, 63, 1267, 29, 845, 12, 627, 589, 12, 288, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 408, 267, 1594, 1471, 506, 376, 4119, 13, 8573, 1329, 14, 267, 408, 267, 574, 275, 1613, 8, 4227, 13371, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 574, 14, 13896, 837, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 267, 340, 822, 8, 585, 9, 1137, 4119, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 988, 63, 7022, 1105, 267, 372, 574, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
22rostislav/xhtml2pdf
xhtml2pdf/paragraph2.py
1
26923
#!/bin/env/python # -*- coding: utf-8 -*- # Copyright 2010 Dirk Holtwick, holtwick.it # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ A paragraph class to be used with ReportLab Platypus. TODO ==== - Bullets - Weblinks and internal links - Borders and margins (Box) - Underline, Background, Strike - Images - Hyphenation + Alignment + Breakline, empty lines + TextIndent - Sub and super """ from __future__ import print_function from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY, TA_LEFT, TA_RIGHT from reportlab.pdfbase.pdfmetrics import stringWidth from reportlab.platypus.flowables import Flowable from reportlab.lib.colors import Color from six import binary_type WORD = 1 SPACE = 2 BR = 3 BEGIN = 4 END = 5 IMAGE = 6 class Style(dict): """ Style. Single place for style definitions: Paragraphs and Fragments. The naming follows the convention of CSS written in camelCase letters. """ DEFAULT = { "textAlign": TA_LEFT, "textIndent": 0.0, "width": None, "height": None, "fontName": "Times-Roman", "fontSize": 10.0, "color": Color(0, 0, 0), "lineHeight": 1.5, "lineHeightAbsolute": None, "pdfLineSpacing": 0, "link": None, } def __init__(self, **kw): self.update(self.DEFAULT) self.update(kw) self.spaceBefore = 0 self.spaceAfter = 0 self.keepWithNext = False class Box(dict): """ Box. Handles the following styles: # underline, underLineColor (?) # strike, strikeColor (?) backgroundColor, backgroundImage paddingLeft, paddingRight, paddingTop, paddingBottom marginLeft, marginRight, marginTop, marginBottom borderLeftColor, borderLeftWidth, borderLeftStyle borderRightColor, borderRightWidth, borderRightStyle borderTopColor, borderTopWidth, borderTopStyle borderBottomColor, borderBottomWidth, borderBottomStyle Not used in inline Elements: paddingTop, paddingBottom marginTop, marginBottom Needs also: fontName, fontSize, color """ name = "box" def _drawBefore(self, canvas, x, y, w, h): canvas.saveState() textColor = self.get("color", Color(0, 0, 0)) # Background bg = self.get("backgroundColor", None) if bg is not None: # draw a filled rectangle (with no stroke) using bg color canvas.setFillColor(bg) canvas.rect(x, y, w, h, fill=1, stroke=0) # Borders def _drawBorderLine(bstyle, width, color, x1, y1, x2, y2): # We need width and border style to be able to draw a border if width and bstyle: # If no color for border is given, the text color is used (like defined by W3C) if color is None: color = textColor if color is not None: canvas.setStrokeColor(color) canvas.setLineWidth(width) canvas.line(x1, y1, x2, y2) _drawBorderLine(self.get("borderLeftStyle", None), self.get("borderLeftWidth", None), self.get("borderLeftColor", None), x, y, x, y + h) _drawBorderLine(self.get("borderRightStyle", None), self.get("borderRightWidth", None), self.get("borderRightColor", None), x + w, y, x + w, y + h) _drawBorderLine(self.get("borderTopStyle", None), self.get("borderTopWidth", None), self.get("borderTopColor", None), x, y + h, x + w, y + h) _drawBorderLine(self.get("borderBottomStyle", None), self.get("borderBottomWidth", None), self.get("borderBottomColor", None), x, y, x + w, y) # Underline if self.get("underline", None): ff = 0.125 * self["fontSize"] yUnderline = y - 1.0 * ff canvas.setLineWidth(ff * 0.75) canvas.setStrokeColor(textColor) canvas.line(x, yUnderline, x + w, yUnderline) canvas.restoreState() def _drawAfter(self, canvas, x, y, w, h): # Strike if self.get("strike", None): ff = 0.125 * self["fontSize"] yStrike = y + 2.0 * ff textColor = self.get("color", Color(0, 0, 0)) canvas.saveState() canvas.setLineWidth(ff * 0.75) canvas.setStrokeColor(textColor) canvas.line(x, yStrike, x + w, yStrike) canvas.restoreState() class Fragment(Box): """ Fragment. text: String containing text fontName: fontSize: width: Width of string height: Height of string """ name = "fragment" type = None isSoft = False isText = False isLF = False def calc(self): self["width"] = 0 def __str__(self): if self.isText: return "'%s'" % self["text"] return "<%s>" % self.name.upper() class BoxBegin(Fragment): name = "begin" type = BEGIN def calc(self): self["width"] = self.get("marginLeft", 0) + self.get("paddingLeft", 0) # + border if border def drawBefore(self, canvas, y): # print(repr(self)) x = self.get("marginLeft", 0) + self["x"] w = self["length"] + self.get("paddingRight", 0) h = self["fontSize"] self["box"] = (x, w, h) self._drawBefore(canvas, x, y, w, h) def drawAfter(self, canvas, y): x, w, h = self["box"] self._drawAfter(canvas, x, y, w, h) class BoxEnd(Fragment): name = "end" type = END def calc(self): self["width"] = self.get("marginRight", 0) + self.get("paddingRight", 0) # + border class Word(Fragment): """ A single word. """ name = "word" type = WORD isText = True def calc(self): """ XXX Cache stringWith if not accelerated?! """ self["width"] = stringWidth(self["text"], self["fontName"], self["fontSize"]) class Space(Fragment): """ A space between fragments that is the usual place for line breaking. """ name = "space" type = SPACE isSoft = True def calc(self): self["width"] = stringWidth(" ", self["fontName"], self["fontSize"]) class LineBreak(Fragment): " Line break. " name = "br" type = BR isSoft = True isLF = True pass class Image(Fragment): name = "image" type = IMAGE isText = True pass class Line(list): """ Container for line fragments. """ LINEHEIGHT = 1.0 def __init__(self, style): self.width = 0 self.height = 0 self.isLast = False self.br = False self.style = style self.boxStack = [] list.__init__(self) def doAlignment(self, width, alignment): # Apply alignment if alignment != TA_LEFT: lineWidth = self[- 1]["x"] + self[- 1]["width"] emptySpace = width - lineWidth if alignment == TA_RIGHT: for frag in self: frag["x"] += emptySpace elif alignment == TA_CENTER: for frag in self: frag["x"] += emptySpace / 2.0 elif alignment == TA_JUSTIFY and not self.br: # XXX Just spaces! Currently divides also sticky fragments delta = emptySpace / (len(self) - 1) for i, frag in enumerate(self): frag["x"] += i * delta # Boxes for frag in self: x = frag["x"] + frag["width"] if isinstance(frag, BoxBegin): self.boxStack.append(frag) elif isinstance(frag, BoxEnd): if self.boxStack: frag = self.boxStack.pop() frag["length"] = x - frag["x"] # Handle the rest for frag in self.boxStack: frag["length"] = x - frag["x"] def doLayout(self, width): "Align words in previous line." # Calculate dimensions self.width = width self.height = self.lineHeight = max(frag.get("fontSize", 0) * self.LINEHEIGHT for frag in self) # Apply line height self.fontSize = max(frag.get("fontSize", 0) for frag in self) y = (self.lineHeight - self.fontSize) # / 2 for frag in self: frag["y"] = y return self.height def dumpFragments(self): print("Line", 40 * "-") for frag in self: print("%s" % frag.get("text", frag.name.upper()), end=' ') print() class Group(list): pass class Text(list): """ Container for text fragments. Helper functions for splitting text into lines and calculating sizes and positions. """ def __init__(self, data=None, style=None): if data is None: data = [] self.lines = [] self.width = 0 self.height = 0 self.maxWidth = 0 self.maxHeight = 0 self.pos = 0 self.oldSpace = None self.newSpace = None self.style = style list.__init__(self, data) def calc(self): """ Calculate sizes of fragments. """ for word in self: word.calc() def getGroup(self): self.oldSpace = self.newSpace # For Space recycing group = [] width = 0 br = False length = len(self) while self.pos < length: frag = self[self.pos] type_ = frag.type self.pos += 1 if type_ == SPACE: self.newSpace = frag # For Space recycing if group: break continue group.append(frag) width += frag.get("width", 0) if type_ == BR: br = True break return width, br, group def splitIntoLines(self, maxWidth, maxHeight, splitted=False): """ Split text into lines and calculate X positions. If we need more space in height than available we return the rest of the text """ self.lines = [] self.pos = 0 self.height = 0 self.maxWidth = self.width = maxWidth self.maxHeight = maxHeight boxStack = [] style = self.style x = 0 # Start with indent in first line of text if not splitted: x = style["textIndent"] # Loop for each line while True: # Reset values for new line posBegin = self.pos line = Line(style) # Update boxes for next line for box in copy.deepcopy(boxStack): box["x"] = 0 line.append(BoxBegin(box)) # Loop for collecting line elements while True: # Get next group of unbreakable elements self.groupPos = self.pos groupWidth, br, group = self.getGroup() # No more groups? Leave line if not group: break # To we fit the line? Reset cursor and finish line if groupWidth + x > maxWidth: self.pos = self.groupPos break # Space recycling if self.oldSpace: group.insert(0, self.oldSpace) # Add fragments to line and update x for frag in group: # Add fragment to line and update x frag["x"] = x x += frag["width"] line.append(frag) # Keep in mind boxes for next lines if isinstance(frag, BoxBegin): boxStack.append(frag) elif isinstance(frag, BoxEnd): boxStack.pop() # We got a new line forced if br: line.br = True break self.newSpace = None # Add line to list line.dumpFragments() if line: self.height += line.doLayout(self.width) self.lines.append(line) # If not enough space for current line force to split if self.height > maxHeight: return posBegin # Reached the end if not group: break # Reset variables x = 0 # Apply alignment self.lines[- 1].br = True for line in self.lines: line.doAlignment(maxWidth, style["textAlign"]) return None def dumpLines(self): """ For debugging dump all line and their content """ for i, line in enumerate(self.lines): print("Line %d:" % i, end=' ') line.dumpFragments() class Paragraph(Flowable): """A simple Paragraph class respecting alignment. Does text without tags. Respects only the following global style attributes: fontName, fontSize, leading, firstLineIndent, leftIndent, rightIndent, textColor, alignment. (spaceBefore, spaceAfter are handled by the Platypus framework.) """ def __init__(self, text, style, debug=False, splitted=False, **kwDict): Flowable.__init__(self) # self._showBoundary = True self.text = text self.text.calc() self.style = style self.text.style = style self.debug = debug self.splitted = splitted # More attributes for k, v in kwDict.items(): setattr(self, k, v) # set later... self.splitIndex = None # overwritten methods from Flowable class def wrap(self, availWidth, availHeight): """ Determine the rectangle this paragraph really needs. """ # memorize available space self.avWidth = availWidth self.avHeight = availHeight if self.debug: print("*** wrap (%f, %f)" % (availWidth, availHeight)) if not self.text: if self.debug: print("*** wrap (%f, %f) needed" % (0, 0)) return 0, 0 # Split lines width = availWidth self.splitIndex = self.text.splitIntoLines(width, availHeight) self.width, self.height = availWidth, self.text.height if self.debug: print("*** wrap (%f, %f) needed, splitIndex %r" % (self.width, self.height, self.splitIndex)) return self.width, self.height def split(self, availWidth, availHeight): """ Split ourself in two paragraphs. """ if self.debug: print("*** split (%f, %f)" % (availWidth, availHeight)) splitted = [] if self.splitIndex: text1 = self.text[:self.splitIndex] text2 = self.text[self.splitIndex:] p1 = Paragraph(Text(text1), self.style, debug=self.debug) p2 = Paragraph(Text(text2), self.style, debug=self.debug, splitted=True) splitted = [p1, p2] if self.debug: print("*** text1 %s / text %s" % (len(text1), len(text2))) if self.debug: print('*** return %s' % self.splitted) return splitted def draw(self): """ Render the content of the paragraph. """ if self.debug: print("*** draw") if not self.text: return canvas = self.canv style = self.style canvas.saveState() # Draw box arround paragraph for debugging if self.debug: bw = 0.5 bc = Color(1, 1, 0) bg = Color(0.9, 0.9, 0.9) canvas.setStrokeColor(bc) canvas.setLineWidth(bw) canvas.setFillColor(bg) canvas.rect( style.leftIndent, 0, self.width, self.height, fill=1, stroke=1) y = 0 dy = self.height for line in self.text.lines: y += line.height for frag in line: type_ = frag.type # Box if type_ == BEGIN: frag.drawBefore(canvas, dy - y) # Text if type_ == WORD: canvas.setFont(frag["fontName"], frag["fontSize"]) canvas.setFillColor(frag.get("color", style["color"])) canvas.drawString(frag["x"], dy - y + frag["y"], frag["text"]) # Box if type_ == BEGIN: frag.drawAfter(canvas, dy - y) # XXX LINK link = frag.get("link", None) if link: _scheme_re = re.compile('^[a-zA-Z][-+a-zA-Z0-9]+$') x, y, w, h = frag["x"], dy - y, frag["width"], frag["fontSize"] rect = (x, y, w, h) if not isinstance(link, binary_type): link = link.encode('utf8') parts = link.split(':', 1) scheme = len(parts) == 2 and parts[0].lower() or '' if _scheme_re.match(scheme) and scheme != 'document': kind = scheme.lower() == 'pdf' and 'GoToR' or 'URI' if kind == 'GoToR': link = parts[1] tx._canvas.linkURL(link, rect, relative=1, kind=kind) else: if link[0] == '#': link = link[1:] scheme = '' canvas.linkRect("", scheme != 'document' and link or parts[1], rect, relative=1) canvas.restoreState() if __name__ == "__main__": from reportlab.platypus import SimpleDocTemplate from reportlab.lib.styles import * from reportlab.rl_config import * from reportlab.lib.units import * import os import copy import re styles = getSampleStyleSheet() ALIGNMENTS = (TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY) TEXT = """ Lörem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. """.strip() def textGenerator(data, fn, fs): i = 1 for word in re.split('\s+', data): if word: yield Word( text="[%d|%s]" % (i, word), fontName=fn, fontSize=fs ) yield Space( fontName=fn, fontSize=fs ) i += 1 def createText(data, fn, fs): text = Text(list(textGenerator(data, fn, fs))) return text def makeBorder(width, style="solid", color=Color(1, 0, 0)): return dict( borderLeftColor=color, borderLeftWidth=width, borderLeftStyle=style, borderRightColor=color, borderRightWidth=width, borderRightStyle=style, borderTopColor=color, borderTopWidth=width, borderTopStyle=style, borderBottomColor=color, borderBottomWidth=width, borderBottomStyle=style ) def makeSpecial(fn="Times-Roman", fs=10): return [ Space( fontName=fn, fontSize=fs), Word( text="TrennbarTrennbar", pairs=[("Trenn-", "barTrennbar")], fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Normal", color=Color(1, 0, 0), fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxBegin( fontName=fn, fontSize=fs, underline=True, strike=True), Word( text="gGrößer", fontName=fn, fontSize=fs * 1.5), Space( fontName=fn, fontSize=fs), Word( text="Bold", fontName="Times-Bold", fontSize=fs), BoxEnd(), Space( fontName=fn, fontSize=fs), Word( text="jItalic", fontName="Times-Italic", fontSize=fs), Space( fontName=fn, fontSize=fs), # <span style="border: 1px solid red;">ipsum <span style="border: 1px solid green; padding: 4px; padding-left: 20px; background: yellow; margin-bottom: 8px; margin-left: 10px;"> # Lo<font size="12pt">re</font>m</span> <span style="background:blue; height: 30px;">ipsum</span> Lorem</span> BoxBegin( fontName=fn, fontSize=fs, **makeBorder(0.5, "solid", Color(0, 1, 0))), Word( text="Lorem", fontName="Times-Bold", fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName="Times-Bold", fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxBegin( fontName=fn, fontSize=fs, backgroundColor=Color(1, 1, 0), **makeBorder(1, "solid", Color(1, 0, 0))), Word( text="Lorem", fontName=fn, fontSize=fs), BoxEnd(), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxEnd(), LineBreak( fontName=fn, fontSize=fs), LineBreak( fontName=fn, fontSize=fs), ] def test(): doc = SimpleDocTemplate("test.pdf") story = [] style = Style(fontName="Helvetica", textIndent=24.0) fn = style["fontName"] fs = style["fontSize"] sampleText1 = createText(TEXT[:100], fn, fs) sampleText2 = createText(TEXT[100:], fn, fs) text = Text(sampleText1 + makeSpecial(fn, fs) + sampleText2) story.append(Paragraph( copy.copy(text), style, debug=0)) if 0: # FIXME: Why is this here? for i in range(10): style = copy.deepcopy(style) style["textAlign"] = ALIGNMENTS[i % 4] text = createText(("(%d) " % i) + TEXT, fn, fs) story.append(Paragraph( copy.copy(text), style, debug=0)) doc.build(story) def test2(): # text = Text(list(textGenerator(TEXT, "Times-Roman", 10))) text = Text(makeSpecial()) text.calc() print(text[1].type) while 1: width, br, group = text.getGroup() if not group: print("ENDE", repr(group)) break print(width, br, " ".join([str(x) for x in group])) # test2() if 1: # FIXME: Again, why this? And the commented lines around here. test() os.system("start test.pdf") # createText(TEXT, styles["Normal"].fontName, styles["Normal"].fontSize)
apache-2.0
[ 3381, 1393, 15, 1813, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7129, 25866, 75, 869, 393, 8122, 2000, 12, 394, 393, 8122, 2000, 14, 390, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 33, 13168, 1021, 370, 506, 1202, 543, 11774, 22511, 510, 4452, 2279, 527, 14, 199, 199, 11768, 199, 532, 199, 199, 13, 699, 348, 16537, 199, 13, 6001, 4614, 436, 5007, 6220, 199, 13, 699, 14387, 436, 11042, 83, 334, 3532, 9, 199, 13, 25010, 604, 12, 10257, 3928, 12, 31309, 415, 199, 13, 32658, 199, 13, 29591, 17579, 425, 199, 11, 15170, 784, 434, 199, 11, 22535, 604, 12, 2701, 2385, 199, 11, 4516, 7583, 199, 13, 4804, 436, 1613, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 21773, 14, 773, 14, 19921, 492, 377, 33, 63, 17611, 12, 377, 33, 63, 42, 7698, 13367, 12, 377, 33, 63, 9894, 12, 377, 33, 63, 12811, 199, 504, 21773, 14, 5607, 1095, 14, 5607, 6759, 492, 1059, 6216, 199, 504, 21773, 14, 14156, 2279, 527, 14, 1659, 5921, 492, 20823, 461, 199, 504, 21773, 14, 773, 14, 7120, 492, 11581, 199, 199, 504, 3816, 492, 3366, 63, 466, 421, 199, 5172, 275, 413, 199, 11658, 275, 499, 199, 7184, 275, 650, 199, 15947, 275, 841, 199, 3902, 275, 959, 199, 9438, 275, 1227, 421, 199, 533, 19442, 8, 807, 304, 272, 408, 272, 19442, 14, 339, 13050, 4192, 367, 3449, 10269, 26, 2235, 7109, 83, 436, 481, 2527, 1470, 14, 710, 272, 19720, 11924, 314, 16129, 402, 15750, 5313, 315, 31129, 1538, 14435, 14, 272, 408, 339, 6186, 275, 469, 267, 298, 505, 9497, 582, 377, 33, 63, 9894, 12, 267, 298, 505, 7583, 582, 378, 14, 16, 12, 267, 298, 2063, 582, 488, 12, 267, 298, 3333, 582, 488, 12, 267, 298, 4246, 985, 582, 298, 17687, 13, 50, 21604, 401, 267, 298, 31995, 582, 1616, 14, 16, 12, 267, 298, 2326, 582, 11581, 8, 16, 12, 378, 12, 378, 395, 267, 298, 604, 8436, 582, 413, 14, 21, 12, 267, 298, 604, 8436, 24677, 582, 488, 12, 267, 298, 5607, 3049, 24052, 582, 378, 12, 267, 298, 1073, 582, 488, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 873, 8, 277, 14, 3472, 9, 267, 291, 14, 873, 8, 829, 9, 267, 291, 14, 2638, 13569, 275, 378, 267, 291, 14, 2638, 10881, 275, 378, 267, 291, 14, 3250, 3007, 5765, 275, 756, 421, 199, 533, 20783, 8, 807, 304, 272, 408, 272, 20783, 14, 339, 23873, 314, 2569, 15725, 26, 398, 327, 25735, 12, 1334, 3049, 4117, 7558, 9, 267, 327, 4024, 415, 12, 4024, 415, 4117, 7558, 9, 398, 8020, 4117, 12, 8020, 3491, 267, 6273, 8185, 12, 6273, 9121, 12, 6273, 6105, 12, 6273, 22886, 267, 11042, 8185, 12, 11042, 9121, 12, 11042, 6105, 12, 11042, 22886, 267, 9162, 8185, 4117, 12, 9162, 8185, 6216, 12, 9162, 8185, 6609, 267, 9162, 9121, 4117, 12, 9162, 9121, 6216, 12, 9162, 9121, 6609, 267, 9162, 6105, 4117, 12, 9162, 6105, 6216, 12, 9162, 6105, 6609, 267, 9162, 22886, 4117, 12, 9162, 22886, 6216, 12, 9162, 22886, 6609, 339, 2832, 1202, 315, 8308, 6566, 83, 26, 398, 6273, 6105, 12, 6273, 22886, 267, 11042, 6105, 12, 11042, 22886, 339, 29613, 2597, 26, 398, 5023, 985, 12, 5023, 2320, 12, 3164, 339, 408, 339, 536, 275, 298, 1977, 2, 339, 347, 485, 5485, 13569, 8, 277, 12, 10218, 12, 671, 12, 612, 12, 336, 12, 394, 304, 267, 10218, 14, 2117, 2223, 342, 398, 1318, 4117, 275, 291, 14, 362, 480, 2326, 401, 11581, 8, 16, 12, 378, 12, 378, 430, 398, 327, 10257, 3928, 267, 12994, 275, 291, 14, 362, 480, 7451, 4117, 401, 488, 9, 267, 340, 12994, 365, 440, 488, 26, 288, 327, 5954, 282, 13457, 20412, 334, 1045, 949, 22824, 9, 1808, 12994, 3164, 288, 10218, 14, 409, 12914, 4117, 8, 6856, 9, 288, 10218, 14, 1201, 8, 88, 12, 612, 12, 336, 12, 394, 12, 5554, 29, 17, 12, 22824, 29, 16, 9, 398, 327, 699, 14387, 267, 347, 485, 5485, 22590, 3049, 8, 66, 2487, 12, 3462, 12, 3164, 12, 671, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 304, 288, 327, 2136, 1929, 3462, 436, 9162, 3449, 370, 506, 7688, 370, 5954, 282, 9162, 288, 340, 3462, 436, 330, 2487, 26, 355, 327, 982, 949, 3164, 367, 9162, 365, 1627, 12, 314, 1318, 3164, 365, 1202, 334, 2930, 3247, 701, 644, 19, 35, 9, 355, 340, 3164, 365, 488, 26, 490, 3164, 275, 1318, 4117, 355, 340, 3164, 365, 440, 488, 26, 490, 10218, 14, 409, 32492, 4117, 8, 2326, 9, 490, 10218, 14, 409, 3049, 6216, 8, 2063, 9, 490, 10218, 14, 604, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 9, 398, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 8185, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 4117, 401, 488, 395, 717, 671, 12, 612, 12, 671, 12, 612, 435, 394, 9, 267, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 9121, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 4117 ]
[ 1393, 15, 1813, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7129, 25866, 75, 869, 393, 8122, 2000, 12, 394, 393, 8122, 2000, 14, 390, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 33, 13168, 1021, 370, 506, 1202, 543, 11774, 22511, 510, 4452, 2279, 527, 14, 199, 199, 11768, 199, 532, 199, 199, 13, 699, 348, 16537, 199, 13, 6001, 4614, 436, 5007, 6220, 199, 13, 699, 14387, 436, 11042, 83, 334, 3532, 9, 199, 13, 25010, 604, 12, 10257, 3928, 12, 31309, 415, 199, 13, 32658, 199, 13, 29591, 17579, 425, 199, 11, 15170, 784, 434, 199, 11, 22535, 604, 12, 2701, 2385, 199, 11, 4516, 7583, 199, 13, 4804, 436, 1613, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 21773, 14, 773, 14, 19921, 492, 377, 33, 63, 17611, 12, 377, 33, 63, 42, 7698, 13367, 12, 377, 33, 63, 9894, 12, 377, 33, 63, 12811, 199, 504, 21773, 14, 5607, 1095, 14, 5607, 6759, 492, 1059, 6216, 199, 504, 21773, 14, 14156, 2279, 527, 14, 1659, 5921, 492, 20823, 461, 199, 504, 21773, 14, 773, 14, 7120, 492, 11581, 199, 199, 504, 3816, 492, 3366, 63, 466, 421, 199, 5172, 275, 413, 199, 11658, 275, 499, 199, 7184, 275, 650, 199, 15947, 275, 841, 199, 3902, 275, 959, 199, 9438, 275, 1227, 421, 199, 533, 19442, 8, 807, 304, 272, 408, 272, 19442, 14, 339, 13050, 4192, 367, 3449, 10269, 26, 2235, 7109, 83, 436, 481, 2527, 1470, 14, 710, 272, 19720, 11924, 314, 16129, 402, 15750, 5313, 315, 31129, 1538, 14435, 14, 272, 408, 339, 6186, 275, 469, 267, 298, 505, 9497, 582, 377, 33, 63, 9894, 12, 267, 298, 505, 7583, 582, 378, 14, 16, 12, 267, 298, 2063, 582, 488, 12, 267, 298, 3333, 582, 488, 12, 267, 298, 4246, 985, 582, 298, 17687, 13, 50, 21604, 401, 267, 298, 31995, 582, 1616, 14, 16, 12, 267, 298, 2326, 582, 11581, 8, 16, 12, 378, 12, 378, 395, 267, 298, 604, 8436, 582, 413, 14, 21, 12, 267, 298, 604, 8436, 24677, 582, 488, 12, 267, 298, 5607, 3049, 24052, 582, 378, 12, 267, 298, 1073, 582, 488, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 873, 8, 277, 14, 3472, 9, 267, 291, 14, 873, 8, 829, 9, 267, 291, 14, 2638, 13569, 275, 378, 267, 291, 14, 2638, 10881, 275, 378, 267, 291, 14, 3250, 3007, 5765, 275, 756, 421, 199, 533, 20783, 8, 807, 304, 272, 408, 272, 20783, 14, 339, 23873, 314, 2569, 15725, 26, 398, 327, 25735, 12, 1334, 3049, 4117, 7558, 9, 267, 327, 4024, 415, 12, 4024, 415, 4117, 7558, 9, 398, 8020, 4117, 12, 8020, 3491, 267, 6273, 8185, 12, 6273, 9121, 12, 6273, 6105, 12, 6273, 22886, 267, 11042, 8185, 12, 11042, 9121, 12, 11042, 6105, 12, 11042, 22886, 267, 9162, 8185, 4117, 12, 9162, 8185, 6216, 12, 9162, 8185, 6609, 267, 9162, 9121, 4117, 12, 9162, 9121, 6216, 12, 9162, 9121, 6609, 267, 9162, 6105, 4117, 12, 9162, 6105, 6216, 12, 9162, 6105, 6609, 267, 9162, 22886, 4117, 12, 9162, 22886, 6216, 12, 9162, 22886, 6609, 339, 2832, 1202, 315, 8308, 6566, 83, 26, 398, 6273, 6105, 12, 6273, 22886, 267, 11042, 6105, 12, 11042, 22886, 339, 29613, 2597, 26, 398, 5023, 985, 12, 5023, 2320, 12, 3164, 339, 408, 339, 536, 275, 298, 1977, 2, 339, 347, 485, 5485, 13569, 8, 277, 12, 10218, 12, 671, 12, 612, 12, 336, 12, 394, 304, 267, 10218, 14, 2117, 2223, 342, 398, 1318, 4117, 275, 291, 14, 362, 480, 2326, 401, 11581, 8, 16, 12, 378, 12, 378, 430, 398, 327, 10257, 3928, 267, 12994, 275, 291, 14, 362, 480, 7451, 4117, 401, 488, 9, 267, 340, 12994, 365, 440, 488, 26, 288, 327, 5954, 282, 13457, 20412, 334, 1045, 949, 22824, 9, 1808, 12994, 3164, 288, 10218, 14, 409, 12914, 4117, 8, 6856, 9, 288, 10218, 14, 1201, 8, 88, 12, 612, 12, 336, 12, 394, 12, 5554, 29, 17, 12, 22824, 29, 16, 9, 398, 327, 699, 14387, 267, 347, 485, 5485, 22590, 3049, 8, 66, 2487, 12, 3462, 12, 3164, 12, 671, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 304, 288, 327, 2136, 1929, 3462, 436, 9162, 3449, 370, 506, 7688, 370, 5954, 282, 9162, 288, 340, 3462, 436, 330, 2487, 26, 355, 327, 982, 949, 3164, 367, 9162, 365, 1627, 12, 314, 1318, 3164, 365, 1202, 334, 2930, 3247, 701, 644, 19, 35, 9, 355, 340, 3164, 365, 488, 26, 490, 3164, 275, 1318, 4117, 355, 340, 3164, 365, 440, 488, 26, 490, 10218, 14, 409, 32492, 4117, 8, 2326, 9, 490, 10218, 14, 409, 3049, 6216, 8, 2063, 9, 490, 10218, 14, 604, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 9, 398, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 8185, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 4117, 401, 488, 395, 717, 671, 12, 612, 12, 671, 12, 612, 435, 394, 9, 267, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 9121, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 4117, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chshu/openthread
tests/toranj/test-018-child-supervision.py
7
7002
#!/usr/bin/env python3 # # Copyright (c) 2018, The OpenThread Authors. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder 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 HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import time import wpan from wpan import verify # ----------------------------------------------------------------------------------------------------------------------- # Test description: Child Supervision feature # # This test covers the behavior of Child Supervision feature. # # This test uses MAC allowlisting to emulate the situation where a child is # removed from parent's child table while the child continues to stay attached # to the parent (since data polls from child are acked at radio platform layer). # Specifically the test verifies that once supervision check is enabled on the # child, the child detects that it is no longer present in the parent's table # and tries to re-attach. # The test verifies the behavior of both parent and child, when supervision is # enabled. It verifies that parent is periodically sending supervision messages # to the child and that the child is monitoring the messages. # # This test also indirectly verifies the child timeout on parent. # test_name = __file__[:-3] if __file__.endswith('.py') else __file__ print('-' * 120) print('Starting \'{}\''.format(test_name)) # ----------------------------------------------------------------------------------------------------------------------- # Creating `wpan.Nodes` instances speedup = 2 wpan.Node.set_time_speedup_factor(speedup) parent = wpan.Node() child = wpan.Node() # ----------------------------------------------------------------------------------------------------------------------- # Init all nodes wpan.Node.init_all_nodes() # ----------------------------------------------------------------------------------------------------------------------- # Build network topology CHILD_TIMEOUT = 6 CHILD_SUPERVISION_CHECK_TIMEOUT = 2 PARENT_SUPERVISION_INTERVAL = 1 child.set(wpan.WPAN_POLL_INTERVAL, '500') child.set(wpan.WPAN_THREAD_CHILD_TIMEOUT, str(CHILD_TIMEOUT)) parent.form("child-sup") child.join_node(parent, wpan.JOIN_TYPE_SLEEPY_END_DEVICE) # ----------------------------------------------------------------------------------------------------------------------- # Test implementation # Disable child supervision on child and parent parent.set(wpan.WPAN_CHILD_SUPERVISION_INTERVAL, '0') child.set(wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT, '0') verify(int(parent.get(wpan.WPAN_CHILD_SUPERVISION_INTERVAL), 0) == 0) verify(int(child.get(wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT), 0) == 0) # Check that the child is associated and has correct timeout verify(child.is_associated()) verify(int(child.get(wpan.WPAN_THREAD_CHILD_TIMEOUT), 0) == CHILD_TIMEOUT) # Verify the child table on parent contains the child with correct timeout child_table = wpan.parse_child_table_result(parent.get(wpan.WPAN_THREAD_CHILD_TABLE)) verify(len(child_table) == 1) verify(int(child_table[0].timeout, 0) == CHILD_TIMEOUT) # Enabling allowlisting on parent # # Since child is not in parent's allowlist, the data polls from child # should be rejected and the child should be removed from parent's # child table after timeout. The child however should continue to # stay attached (since data polls are acked by radio driver) and # supervision check is disabled on the child. parent.set(wpan.WPAN_MAC_ALLOWLIST_ENABLED, '1') def check_child_is_removed_from_parent_child_table(): child_table = wpan.parse_child_table_result(parent.get(wpan.WPAN_THREAD_CHILD_TABLE)) verify(len(child_table) == 0) # wait till child is removed from parent's child table # after this child should still be associated wpan.verify_within(check_child_is_removed_from_parent_child_table, CHILD_TIMEOUT / speedup + 2) verify(child.is_associated()) # Enable supervision check on child and expect the child to # become detached after the check timeout child.set( wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT, str(CHILD_SUPERVISION_CHECK_TIMEOUT), ) def check_child_is_detached(): verify(not child.is_associated()) wpan.verify_within(check_child_is_detached, CHILD_SUPERVISION_CHECK_TIMEOUT / speedup + 8) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Enable child supervision on parent and disable allowlisting parent.set(wpan.WPAN_CHILD_SUPERVISION_INTERVAL, str(PARENT_SUPERVISION_INTERVAL)) parent.set(wpan.WPAN_MAC_ALLOWLIST_ENABLED, '0') # Wait for the child to attach back def check_child_is_attached(): verify(child.is_associated()) wpan.verify_within(check_child_is_attached, 5) # MAC counters are used to verify the child supervision behavior. parent_unicast_tx_count = int(parent.get("NCP:Counter:TX_PKT_UNICAST"), 0) time.sleep(PARENT_SUPERVISION_INTERVAL * 1.2 / speedup) # To verify that the parent is indeed sending empty "supervision" # messages to its child, MAC counter for number of unicast tx is # used. Note that supervision interval on parent is set to 1 sec. verify(int(parent.get("NCP:Counter:TX_PKT_UNICAST"), 0) >= parent_unicast_tx_count + 1) verify(child.is_associated()) # Disable child supervision on parent parent.set(wpan.WPAN_CHILD_SUPERVISION_INTERVAL, '0') time.sleep(CHILD_SUPERVISION_CHECK_TIMEOUT * 3 / speedup) verify(child.is_associated()) # ----------------------------------------------------------------------------------------------------------------------- # Test finished wpan.Node.finalize_all_nodes() print('\'{}\' passed.'.format(test_name))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 14894, 12, 710, 3232, 4436, 6642, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 221, 650, 14, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 199, 3, 258, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 221, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 221, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 199, 3, 221, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 199, 3, 221, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 199, 3, 221, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 221, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 199, 3, 221, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 221, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 221, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 900, 199, 646, 336, 10384, 199, 504, 336, 10384, 492, 4911, 199, 199, 3, 5620, 6489, 12797, 199, 3, 1379, 1369, 26, 12988, 17897, 2317, 3878, 199, 3, 199, 3, 961, 511, 25858, 314, 5953, 402, 12988, 17897, 2317, 3878, 14, 199, 3, 199, 3, 961, 511, 4440, 13347, 2040, 16115, 370, 31102, 314, 25781, 2382, 282, 1982, 365, 199, 3, 4829, 687, 1676, 1159, 1982, 1817, 1830, 314, 1982, 32438, 370, 25578, 10102, 199, 3, 370, 314, 1676, 334, 8585, 666, 3708, 478, 687, 1982, 787, 19807, 379, 737, 22008, 4298, 4045, 680, 199, 3, 30836, 314, 511, 22694, 626, 5403, 1613, 2317, 1104, 365, 5223, 641, 314, 199, 3, 1982, 12, 314, 1982, 477, 28853, 626, 652, 365, 949, 8088, 3451, 315, 314, 1676, 1159, 1817, 199, 3, 436, 11275, 370, 295, 13, 5040, 14, 199, 199, 3, 710, 511, 22694, 314, 5953, 402, 3865, 1676, 436, 1982, 12, 1380, 1613, 2317, 365, 199, 3, 5223, 14, 2779, 22694, 626, 1676, 365, 18745, 1183, 10209, 1613, 2317, 3788, 199, 3, 370, 314, 1982, 436, 626, 314, 1982, 365, 20391, 314, 3788, 14, 199, 3, 199, 3, 961, 511, 2597, 19458, 590, 22694, 314, 1982, 2653, 641, 1676, 14, 199, 3, 199, 199, 396, 63, 354, 275, 636, 493, 363, 4439, 19, 61, 340, 636, 493, 4343, 4130, 5175, 647, 358, 587, 636, 493, 363, 199, 1361, 3654, 7, 627, 13960, 9, 199, 1361, 360, 14139, 8891, 24423, 17067, 908, 8, 396, 63, 354, 430, 199, 199, 3, 5620, 6489, 12797, 199, 3, 20507, 658, 87, 10384, 14, 6300, 64, 4454, 199, 199, 7625, 384, 275, 499, 199, 87, 10384, 14, 1716, 14, 409, 63, 521, 63, 7625, 384, 63, 4778, 8, 7625, 384, 9, 199, 199, 1708, 275, 336, 10384, 14, 1716, 342, 199, 1739, 275, 336, 10384, 14, 1716, 342, 199, 199, 3, 5620, 6489, 12797, 199, 3, 21026, 1006, 3380, 199, 199, 87, 10384, 14, 1716, 14, 826, 63, 452, 63, 2415, 342, 199, 199, 3, 5620, 6489, 12797, 199, 3, 6516, 2784, 14611, 199, 199, 30460, 63, 8899, 275, 1227, 199, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 275, 499, 199, 20562, 63, 7380, 540, 18775, 63, 17359, 275, 413, 199, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 16428, 63, 17359, 12, 283, 5783, 358, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 16103, 63, 30460, 63, 8899, 12, 620, 8, 30460, 63, 8899, 430, 199, 199, 1708, 14, 964, 480, 1739, 13, 1961, 531, 199, 1739, 14, 904, 63, 932, 8, 1708, 12, 336, 10384, 14, 23321, 63, 2711, 63, 51, 906, 37, 4521, 63, 3902, 63, 10555, 9, 199, 199, 3, 5620, 6489, 12797, 199, 3, 1379, 4514, 199, 199, 3, 17534, 1982, 1613, 2317, 641, 1982, 436, 1676, 199, 1708, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 17359, 12, 283, 16, 358, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 12, 283, 16, 358, 199, 4712, 8, 442, 8, 1708, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 17359, 395, 378, 9, 508, 378, 9, 199, 4712, 8, 442, 8, 1739, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 395, 378, 9, 508, 378, 9, 199, 199, 3, 2670, 626, 314, 1982, 365, 4568, 436, 965, 3211, 2653, 199, 4712, 8, 1739, 14, 374, 63, 22288, 1012, 199, 4712, 8, 442, 8, 1739, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 16103, 63, 30460, 63, 8899, 395, 378, 9, 508, 6624, 6853, 63, 8899, 9, 199, 199, 3, 7635, 314, 1982, 1817, 641, 1676, 3509, 314, 1982, 543, 3211, 2653, 199, 1739, 63, 1224, 275, 336, 10384, 14, 1122, 63, 1739, 63, 1224, 63, 1099, 8, 1708, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 16103, 63, 30460, 63, 8723, 430, 199 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 14894, 12, 710, 3232, 4436, 6642, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 221, 650, 14, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 199, 3, 258, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 221, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 221, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 199, 3, 221, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 199, 3, 221, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 199, 3, 221, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 221, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 199, 3, 221, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 199, 3, 221, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 221, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 900, 199, 646, 336, 10384, 199, 504, 336, 10384, 492, 4911, 199, 199, 3, 5620, 6489, 12797, 199, 3, 1379, 1369, 26, 12988, 17897, 2317, 3878, 199, 3, 199, 3, 961, 511, 25858, 314, 5953, 402, 12988, 17897, 2317, 3878, 14, 199, 3, 199, 3, 961, 511, 4440, 13347, 2040, 16115, 370, 31102, 314, 25781, 2382, 282, 1982, 365, 199, 3, 4829, 687, 1676, 1159, 1982, 1817, 1830, 314, 1982, 32438, 370, 25578, 10102, 199, 3, 370, 314, 1676, 334, 8585, 666, 3708, 478, 687, 1982, 787, 19807, 379, 737, 22008, 4298, 4045, 680, 199, 3, 30836, 314, 511, 22694, 626, 5403, 1613, 2317, 1104, 365, 5223, 641, 314, 199, 3, 1982, 12, 314, 1982, 477, 28853, 626, 652, 365, 949, 8088, 3451, 315, 314, 1676, 1159, 1817, 199, 3, 436, 11275, 370, 295, 13, 5040, 14, 199, 199, 3, 710, 511, 22694, 314, 5953, 402, 3865, 1676, 436, 1982, 12, 1380, 1613, 2317, 365, 199, 3, 5223, 14, 2779, 22694, 626, 1676, 365, 18745, 1183, 10209, 1613, 2317, 3788, 199, 3, 370, 314, 1982, 436, 626, 314, 1982, 365, 20391, 314, 3788, 14, 199, 3, 199, 3, 961, 511, 2597, 19458, 590, 22694, 314, 1982, 2653, 641, 1676, 14, 199, 3, 199, 199, 396, 63, 354, 275, 636, 493, 363, 4439, 19, 61, 340, 636, 493, 4343, 4130, 5175, 647, 358, 587, 636, 493, 363, 199, 1361, 3654, 7, 627, 13960, 9, 199, 1361, 360, 14139, 8891, 24423, 17067, 908, 8, 396, 63, 354, 430, 199, 199, 3, 5620, 6489, 12797, 199, 3, 20507, 658, 87, 10384, 14, 6300, 64, 4454, 199, 199, 7625, 384, 275, 499, 199, 87, 10384, 14, 1716, 14, 409, 63, 521, 63, 7625, 384, 63, 4778, 8, 7625, 384, 9, 199, 199, 1708, 275, 336, 10384, 14, 1716, 342, 199, 1739, 275, 336, 10384, 14, 1716, 342, 199, 199, 3, 5620, 6489, 12797, 199, 3, 21026, 1006, 3380, 199, 199, 87, 10384, 14, 1716, 14, 826, 63, 452, 63, 2415, 342, 199, 199, 3, 5620, 6489, 12797, 199, 3, 6516, 2784, 14611, 199, 199, 30460, 63, 8899, 275, 1227, 199, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 275, 499, 199, 20562, 63, 7380, 540, 18775, 63, 17359, 275, 413, 199, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 16428, 63, 17359, 12, 283, 5783, 358, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 16103, 63, 30460, 63, 8899, 12, 620, 8, 30460, 63, 8899, 430, 199, 199, 1708, 14, 964, 480, 1739, 13, 1961, 531, 199, 1739, 14, 904, 63, 932, 8, 1708, 12, 336, 10384, 14, 23321, 63, 2711, 63, 51, 906, 37, 4521, 63, 3902, 63, 10555, 9, 199, 199, 3, 5620, 6489, 12797, 199, 3, 1379, 4514, 199, 199, 3, 17534, 1982, 1613, 2317, 641, 1982, 436, 1676, 199, 1708, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 17359, 12, 283, 16, 358, 199, 1739, 14, 409, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 12, 283, 16, 358, 199, 4712, 8, 442, 8, 1708, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 17359, 395, 378, 9, 508, 378, 9, 199, 4712, 8, 442, 8, 1739, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 30460, 63, 7380, 540, 18775, 63, 8936, 63, 8899, 395, 378, 9, 508, 378, 9, 199, 199, 3, 2670, 626, 314, 1982, 365, 4568, 436, 965, 3211, 2653, 199, 4712, 8, 1739, 14, 374, 63, 22288, 1012, 199, 4712, 8, 442, 8, 1739, 14, 362, 8, 87, 10384, 14, 22512, 879, 63, 16103, 63, 30460, 63, 8899, 395, 378, 9, 508, 6624, 6853, 63, 8899, 9, 199, 199, 3, 7635, 314, 1982, 1817, 641, 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 ]
elmerdpadilla/iv
addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py
374
2830
#-*- coding:utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 OpenERP SA (<http://openerp.com>). All Rights Reserved # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from openerp.osv import fields, osv class hr_salary_employee_bymonth(osv.osv_memory): _name = 'hr.salary.employee.month' _description = 'Hr Salary Employee By Month Report' _columns = { 'start_date': fields.date('Start Date', required=True), 'end_date': fields.date('End Date', required=True), 'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'employee_id', 'Employees', required=True), 'category_id': fields.many2one('hr.salary.rule.category', 'Category', required=True), } def _get_default_category(self, cr, uid, context=None): category_ids = self.pool.get('hr.salary.rule.category').search(cr, uid, [('code', '=', 'NET')], context=context) return category_ids and category_ids[0] or False _defaults = { 'start_date': lambda *a: time.strftime('%Y-01-01'), 'end_date': lambda *a: time.strftime('%Y-%m-%d'), 'category_id': _get_default_category } def print_report(self, cr, uid, ids, context=None): """ To get the date and print the report @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return: return report """ if context is None: context = {} datas = {'ids': context.get('active_ids', [])} res = self.read(cr, uid, ids, context=context) res = res and res[0] or {} datas.update({'form': res}) return self.pool['report'].get_action(cr, uid, ids, 'l10n_in_hr_payroll.report_hrsalarybymonth', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 16140, 63, 22025, 63, 10103, 63, 991, 4482, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 283, 6271, 14, 22025, 14, 10103, 14, 4482, 7, 272, 485, 1802, 275, 283, 40, 82, 428, 279, 695, 24089, 4885, 28835, 11774, 7, 272, 485, 3406, 275, 469, 267, 283, 928, 63, 602, 356, 1504, 14, 602, 360, 3162, 6148, 297, 1415, 29, 549, 395, 267, 283, 500, 63, 602, 356, 1504, 14, 602, 360, 3005, 6148, 297, 1415, 29, 549, 395, 267, 283, 10103, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 6271, 14, 10103, 297, 283, 5989, 2827, 63, 3403, 63, 3369, 297, 283, 5989, 2827, 63, 3403, 63, 344, 297, 283, 10103, 63, 344, 297, 283, 37, 311, 18149, 297, 1415, 29, 549, 395, 267, 283, 3710, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 6271, 14, 22025, 14, 2200, 14, 3710, 297, 283, 7841, 297, 1415, 29, 549, 395, 272, 789, 339, 347, 485, 362, 63, 885, 63, 3710, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 4637, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 6271, 14, 22025, 14, 2200, 14, 3710, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 600, 297, 6291, 283, 7278, 2665, 1067, 29, 1100, 9, 267, 372, 4637, 63, 1580, 436, 4637, 63, 1580, 59, 16, 61, 503, 756, 339, 485, 4322, 275, 469, 268, 283, 928, 63, 602, 356, 2400, 627, 65, 26, 900, 14, 6205, 3508, 57, 13, 614, 13, 614, 659, 268, 283, 500, 63, 602, 356, 2400, 627, 65, 26, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 659, 268, 283, 3710, 63, 344, 356, 485, 362, 63, 885, 63, 3710, 272, 789, 339, 347, 870, 63, 3070, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 268, 4005, 664, 314, 1434, 436, 870, 314, 3622, 268, 768, 635, 291, 26, 710, 909, 7849, 14, 268, 768, 635, 2467, 26, 437, 3050, 3920, 268, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 268, 768, 635, 1067, 26, 437, 4465, 2600, 268, 768, 1107, 26, 372, 3622, 267, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 15012, 275, 791, 1580, 356, 1067, 14, 362, 360, 2682, 63, 1580, 297, 3073, 93, 398, 522, 275, 291, 14, 739, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 267, 522, 275, 522, 436, 522, 59, 16, 61, 503, 1052, 267, 15012, 14, 873, 3252, 964, 356, 522, 1552, 267, 372, 291, 14, 2293, 459, 3070, 2278, 362, 63, 1287, 8, 1556, 12, 1747, 12, 2762, 12, 12723, 283, 76, 709, 78, 63, 262, 63, 6271, 63, 5989, 2827, 14, 3070, 63, 72, 2393, 279, 695, 991, 4482, 297, 12723, 666, 29, 11563, 12, 1067, 29, 1100, 9, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 16140, 63, 22025, 63, 10103, 63, 991, 4482, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 283, 6271, 14, 22025, 14, 10103, 14, 4482, 7, 272, 485, 1802, 275, 283, 40, 82, 428, 279, 695, 24089, 4885, 28835, 11774, 7, 272, 485, 3406, 275, 469, 267, 283, 928, 63, 602, 356, 1504, 14, 602, 360, 3162, 6148, 297, 1415, 29, 549, 395, 267, 283, 500, 63, 602, 356, 1504, 14, 602, 360, 3005, 6148, 297, 1415, 29, 549, 395, 267, 283, 10103, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 6271, 14, 10103, 297, 283, 5989, 2827, 63, 3403, 63, 3369, 297, 283, 5989, 2827, 63, 3403, 63, 344, 297, 283, 10103, 63, 344, 297, 283, 37, 311, 18149, 297, 1415, 29, 549, 395, 267, 283, 3710, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 6271, 14, 22025, 14, 2200, 14, 3710, 297, 283, 7841, 297, 1415, 29, 549, 395, 272, 789, 339, 347, 485, 362, 63, 885, 63, 3710, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 4637, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 6271, 14, 22025, 14, 2200, 14, 3710, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 600, 297, 6291, 283, 7278, 2665, 1067, 29, 1100, 9, 267, 372, 4637, 63, 1580, 436, 4637, 63, 1580, 59, 16, 61, 503, 756, 339, 485, 4322, 275, 469, 268, 283, 928, 63, 602, 356, 2400, 627, 65, 26, 900, 14, 6205, 3508, 57, 13, 614, 13, 614, 659, 268, 283, 500, 63, 602, 356, 2400, 627, 65, 26, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 659, 268, 283, 3710, 63, 344, 356, 485, 362, 63, 885, 63, 3710, 272, 789, 339, 347, 870, 63, 3070, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 268, 4005, 664, 314, 1434, 436, 870, 314, 3622, 268, 768, 635, 291, 26, 710, 909, 7849, 14, 268, 768, 635, 2467, 26, 437, 3050, 3920, 268, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 268, 768, 635, 1067, 26, 437, 4465, 2600, 268, 768, 1107, 26, 372, 3622, 267, 408, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 15012, 275, 791, 1580, 356, 1067, 14, 362, 360, 2682, 63, 1580, 297, 3073, 93, 398, 522, 275, 291, 14, 739, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 267, 522, 275, 522, 436, 522, 59, 16, 61, 503, 1052, 267, 15012, 14, 873, 3252, 964, 356, 522, 1552, 267, 372, 291, 14, 2293, 459, 3070, 2278, 362, 63, 1287, 8, 1556, 12, 1747, 12, 2762, 12, 12723, 283, 76, 709, 78, 63, 262, 63, 6271, 63, 5989, 2827, 14, 3070, 63, 72, 2393, 279, 695, 991, 4482, 297, 12723, 666, 29, 11563, 12, 1067, 29, 1100, 9, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
anish/buildbot
master/buildbot/process/workerforbuilder.py
1
8107
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright Buildbot Team Members from twisted.internet import defer from twisted.python import log from twisted.python.constants import NamedConstant from twisted.python.constants import Names class States(Names): # The worker isn't attached, or is in the process of attaching. DETACHED = NamedConstant() # The worker is available to build: either attached, or a latent worker. AVAILABLE = NamedConstant() # The worker is building. BUILDING = NamedConstant() class AbstractWorkerForBuilder: def __init__(self): self.ping_watchers = [] self.state = None # set in subclass self.worker = None self.builder_name = None self.locks = None def __repr__(self): r = ["<", self.__class__.__name__] if self.builder_name: r.extend([" builder=", repr(self.builder_name)]) if self.worker: r.extend([" worker=", repr(self.worker.workername)]) r.extend([" state=", self.state.name, ">"]) return ''.join(r) def setBuilder(self, b): self.builder = b self.builder_name = b.name def getWorkerCommandVersion(self, command, oldversion=None): if self.remoteCommands is None: # the worker is 0.5.0 or earlier return oldversion return self.remoteCommands.get(command) def isAvailable(self): # if this WorkerForBuilder is busy, then it's definitely not available if self.isBusy(): return False # otherwise, check in with the Worker if self.worker: return self.worker.canStartBuild() # no worker? not very available. return False def isBusy(self): return self.state != States.AVAILABLE def buildStarted(self): self.state = States.BUILDING # AbstractWorker doesn't always have a buildStarted method # so only call it if it is available. try: worker_buildStarted = self.worker.buildStarted except AttributeError: pass else: worker_buildStarted(self) def buildFinished(self): self.state = States.AVAILABLE if self.worker: self.worker.buildFinished(self) @defer.inlineCallbacks def attached(self, worker, commands): """ @type worker: L{buildbot.worker.Worker} @param worker: the Worker that represents the worker as a whole @type commands: dict: string -> string, or None @param commands: provides the worker's version of each RemoteCommand """ self.remoteCommands = commands # maps command name to version if self.worker is None: self.worker = worker self.worker.addWorkerForBuilder(self) else: assert self.worker == worker log.msg("Worker %s attached to %s" % (worker.workername, self.builder_name)) yield self.worker.conn.remotePrint(message="attached") return self def prepare(self, build): if not self.worker or not self.worker.acquireLocks(): return defer.succeed(False) return defer.succeed(True) def ping(self, status=None): """Ping the worker to make sure it is still there. Returns a Deferred that fires with True if it is. @param status: if you point this at a BuilderStatus, a 'pinging' event will be pushed. """ newping = not self.ping_watchers d = defer.Deferred() self.ping_watchers.append(d) if newping: Ping().ping(self.worker.conn).addBoth(self._pong) return d def abortPingIfAny(self): watchers, self.ping_watchers = self.ping_watchers, [] for d in watchers: d.errback(PingException('aborted ping')) def _pong(self, res): watchers, self.ping_watchers = self.ping_watchers, [] for d in watchers: d.callback(res) def detached(self): log.msg("Worker %s detached from %s" % (self.worker.workername, self.builder_name)) if self.worker: self.worker.removeWorkerForBuilder(self) self.worker = None self.remoteCommands = None class PingException(Exception): pass class Ping: running = False def ping(self, conn): assert not self.running if not conn: # clearly the ping must fail return defer.fail(PingException("Worker not connected?")) self.running = True log.msg("sending ping") self.d = defer.Deferred() # TODO: add a distinct 'ping' command on the worker.. using 'print' # for this purpose is kind of silly. conn.remotePrint(message="ping").addCallbacks(self._pong, self._ping_failed, errbackArgs=(conn,)) return self.d def _pong(self, res): log.msg("ping finished: success") self.d.callback(True) def _ping_failed(self, res, conn): log.msg("ping finished: failure") # the worker has some sort of internal error, disconnect them. If we # don't, we'll requeue a build and ping them again right away, # creating a nasty loop. conn.loseConnection() self.d.errback(res) class WorkerForBuilder(AbstractWorkerForBuilder): def __init__(self): super().__init__() self.state = States.DETACHED @defer.inlineCallbacks def attached(self, worker, commands): wfb = yield super().attached(worker, commands) # Only set available on non-latent workers, since latent workers # only attach while a build is in progress. self.state = States.AVAILABLE return wfb def detached(self): super().detached() if self.worker: self.worker.removeWorkerForBuilder(self) self.worker = None self.state = States.DETACHED class LatentWorkerForBuilder(AbstractWorkerForBuilder): def __init__(self, worker, builder): super().__init__() self.worker = worker self.state = States.AVAILABLE self.setBuilder(builder) self.worker.addWorkerForBuilder(self) log.msg("Latent worker %s attached to %s" % (worker.workername, self.builder_name)) def prepare(self, build): # If we can't lock, then don't bother trying to substantiate if not self.worker or not self.worker.acquireLocks(): return defer.succeed(False) self.state = States.DETACHED d = self.substantiate(build) return d def attached(self, worker, commands): # When a latent worker is attached, it is actually because it prepared for a build # thus building and not available like for normal worker if self.state == States.DETACHED: self.state = States.BUILDING return super().attached(worker, commands) def substantiate(self, build): return self.worker.substantiate(self, build) def ping(self, status=None): if not self.worker.substantiated: return defer.fail(PingException("worker is not substantiated")) return super().ping(status)
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 421, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 1548, 14, 5559, 492, 16198, 9737, 199, 504, 7390, 14, 1548, 14, 5559, 492, 23923, 421, 199, 533, 24230, 8, 5866, 304, 272, 327, 710, 7239, 5712, 1133, 10102, 12, 503, 365, 315, 314, 2112, 402, 6554, 316, 14, 272, 577, 15808, 22492, 275, 16198, 9737, 342, 272, 327, 710, 7239, 365, 2808, 370, 1900, 26, 1902, 10102, 12, 503, 282, 2465, 343, 7239, 14, 272, 437, 54, 6593, 2617, 275, 16198, 9737, 342, 272, 327, 710, 7239, 365, 10015, 14, 272, 22974, 1206, 275, 16198, 9737, 342, 421, 199, 533, 11836, 12678, 1858, 6437, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 4073, 63, 6821, 1192, 275, 942, 267, 291, 14, 929, 275, 488, 221, 327, 663, 315, 5516, 267, 291, 14, 6599, 275, 488, 267, 291, 14, 5649, 63, 354, 275, 488, 267, 291, 14, 20218, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 519, 275, 24652, 401, 291, 855, 533, 4914, 354, 22705, 267, 340, 291, 14, 5649, 63, 354, 26, 288, 519, 14, 2880, 5234, 6545, 11107, 4700, 8, 277, 14, 5649, 63, 354, 3948, 267, 340, 291, 14, 6599, 26, 288, 519, 14, 2880, 5234, 7239, 11107, 4700, 8, 277, 14, 6599, 14, 6599, 354, 3948, 267, 519, 14, 2880, 5234, 1174, 11107, 291, 14, 929, 14, 354, 12, 15281, 3135, 267, 372, 6522, 904, 8, 82, 9, 339, 347, 663, 6437, 8, 277, 12, 330, 304, 267, 291, 14, 5649, 275, 330, 267, 291, 14, 5649, 63, 354, 275, 330, 14, 354, 339, 347, 664, 12678, 3110, 3353, 8, 277, 12, 1414, 12, 2269, 1023, 29, 403, 304, 267, 340, 291, 14, 3846, 14680, 365, 488, 26, 288, 327, 314, 7239, 365, 378, 14, 21, 14, 16, 503, 14119, 288, 372, 2269, 1023, 267, 372, 291, 14, 3846, 14680, 14, 362, 8, 1531, 9, 339, 347, 365, 11464, 8, 277, 304, 267, 327, 340, 642, 23886, 1858, 6437, 365, 10414, 89, 12, 2066, 652, 1159, 28088, 590, 440, 2808, 267, 340, 291, 14, 374, 28759, 837, 288, 372, 756, 398, 327, 4257, 12, 1104, 315, 543, 314, 23886, 267, 340, 291, 14, 6599, 26, 288, 372, 291, 14, 6599, 14, 2425, 3162, 3425, 342, 398, 327, 949, 7239, 31, 440, 7437, 2808, 14, 267, 372, 756, 339, 347, 365, 28759, 8, 277, 304, 267, 372, 291, 14, 929, 1137, 24230, 14, 17377, 339, 347, 1900, 21031, 8, 277, 304, 267, 291, 14, 929, 275, 24230, 14, 8248, 1206, 267, 327, 11836, 12678, 3181, 1133, 3544, 1172, 282, 1900, 21031, 1083, 267, 327, 880, 1454, 1240, 652, 340, 652, 365, 2808, 14, 267, 862, 26, 288, 7239, 63, 1506, 21031, 275, 291, 14, 6599, 14, 1506, 21031, 267, 871, 4281, 26, 288, 986, 267, 587, 26, 288, 7239, 63, 1506, 21031, 8, 277, 9, 339, 347, 1900, 13430, 8, 277, 304, 267, 291, 14, 929, 275, 24230, 14, 17377, 267, 340, 291, 14, 6599, 26, 288, 291, 14, 6599, 14, 1506, 13430, 8, 277, 9, 339, 768, 11610, 14, 24813, 272, 347, 10102, 8, 277, 12, 7239, 12, 3718, 304, 267, 408, 267, 768, 466, 221, 7239, 26, 491, 91, 25497, 14, 6599, 14, 12678, 93, 267, 768, 635, 7239, 26, 314, 23886, 626, 8469, 314, 7239, 465, 282, 8852, 267, 768, 466, 221, 3718, 26, 1211, 26, 1059, 1035, 1059, 12, 503, 488, 267, 768, 635, 3718, 26, 6571, 314, 7239, 1159, 1015, 402, 1924, 17283, 3110, 267, 408, 267, 291, 14, 3846, 14680, 275, 3718, 221, 327, 9033, 1414, 536, 370, 1015, 267, 340, 291, 14, 6599, 365, 488, 26, 288, 291, 14, 6599, 275, 7239, 288, 291, 14, 6599, 14, 525, 12678, 1858, 6437, 8, 277, 9, 267, 587, 26, 288, 702, 291, 14, 6599, 508, 7239, 267, 943, 14, 1328, 480, 12678, 450, 83, 10102, 370, 450, 83, 2, 450, 334, 6599, 14, 6599, 354, 12, 6343, 291, 14, 5649, 63, 354, 430, 398, 1995, 291, 14, 6599, 14, 1631, 14, 3846, 5375, 8, 1188, 628, 17099, 531, 267, 372, 291, 339, 347, 9275, 8, 277, 12, 1900, 304, 267, 340, 440, 291, 14, 6599, 503, 440, 291, 14, 6599, 14, 8174, 6432, 83, 837, 288, 372, 10133, 14, 26622, 8, 797, 9, 267, 372, 10133, 14, 26622, 8, 549, 9, 339, 347, 18249, 8, 277, 12, 2004, 29, 403, 304, 267, 408, 22638, 314, 7239, 370, 1852, 3238, 652, 365, 5139, 2337, 14, 1803, 282, 17448, 267, 626, 28887, 543, 715, 340, 652, 365, 14, 398, 768, 635, 2004, 26, 340, 1265, 2376, 642, 737, 282, 19286, 3694, 12, 282, 283, 4073, 316, 7, 2432, 1566, 911, 506, 22319, 14, 267, 408, 267, 892, 4073, 275, 440, 291, 14, 4073, 63, 6821, 1192, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 4073, 63, 6821, 1192, 14, 740, 8, 68, 9, 267, 340, 892, 4073, 26, 288, 510, 316, 1252, 4073, 8, 277, 14, 6599, 14, 1631, 680, 525, 18088, 8, 277, 423, 26992, 9, 398, 372, 366, 339, 347, 12004, 22638, 3917, 9874, 8, 277, 304, 267, 9626, 1192, 12, 291, 14, 4073, 63 ]
[ 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 421, 199, 504, 7390, 14, 4901, 492, 10133, 199, 504, 7390, 14, 1548, 492, 943, 199, 504, 7390, 14, 1548, 14, 5559, 492, 16198, 9737, 199, 504, 7390, 14, 1548, 14, 5559, 492, 23923, 421, 199, 533, 24230, 8, 5866, 304, 272, 327, 710, 7239, 5712, 1133, 10102, 12, 503, 365, 315, 314, 2112, 402, 6554, 316, 14, 272, 577, 15808, 22492, 275, 16198, 9737, 342, 272, 327, 710, 7239, 365, 2808, 370, 1900, 26, 1902, 10102, 12, 503, 282, 2465, 343, 7239, 14, 272, 437, 54, 6593, 2617, 275, 16198, 9737, 342, 272, 327, 710, 7239, 365, 10015, 14, 272, 22974, 1206, 275, 16198, 9737, 342, 421, 199, 533, 11836, 12678, 1858, 6437, 26, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 4073, 63, 6821, 1192, 275, 942, 267, 291, 14, 929, 275, 488, 221, 327, 663, 315, 5516, 267, 291, 14, 6599, 275, 488, 267, 291, 14, 5649, 63, 354, 275, 488, 267, 291, 14, 20218, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 519, 275, 24652, 401, 291, 855, 533, 4914, 354, 22705, 267, 340, 291, 14, 5649, 63, 354, 26, 288, 519, 14, 2880, 5234, 6545, 11107, 4700, 8, 277, 14, 5649, 63, 354, 3948, 267, 340, 291, 14, 6599, 26, 288, 519, 14, 2880, 5234, 7239, 11107, 4700, 8, 277, 14, 6599, 14, 6599, 354, 3948, 267, 519, 14, 2880, 5234, 1174, 11107, 291, 14, 929, 14, 354, 12, 15281, 3135, 267, 372, 6522, 904, 8, 82, 9, 339, 347, 663, 6437, 8, 277, 12, 330, 304, 267, 291, 14, 5649, 275, 330, 267, 291, 14, 5649, 63, 354, 275, 330, 14, 354, 339, 347, 664, 12678, 3110, 3353, 8, 277, 12, 1414, 12, 2269, 1023, 29, 403, 304, 267, 340, 291, 14, 3846, 14680, 365, 488, 26, 288, 327, 314, 7239, 365, 378, 14, 21, 14, 16, 503, 14119, 288, 372, 2269, 1023, 267, 372, 291, 14, 3846, 14680, 14, 362, 8, 1531, 9, 339, 347, 365, 11464, 8, 277, 304, 267, 327, 340, 642, 23886, 1858, 6437, 365, 10414, 89, 12, 2066, 652, 1159, 28088, 590, 440, 2808, 267, 340, 291, 14, 374, 28759, 837, 288, 372, 756, 398, 327, 4257, 12, 1104, 315, 543, 314, 23886, 267, 340, 291, 14, 6599, 26, 288, 372, 291, 14, 6599, 14, 2425, 3162, 3425, 342, 398, 327, 949, 7239, 31, 440, 7437, 2808, 14, 267, 372, 756, 339, 347, 365, 28759, 8, 277, 304, 267, 372, 291, 14, 929, 1137, 24230, 14, 17377, 339, 347, 1900, 21031, 8, 277, 304, 267, 291, 14, 929, 275, 24230, 14, 8248, 1206, 267, 327, 11836, 12678, 3181, 1133, 3544, 1172, 282, 1900, 21031, 1083, 267, 327, 880, 1454, 1240, 652, 340, 652, 365, 2808, 14, 267, 862, 26, 288, 7239, 63, 1506, 21031, 275, 291, 14, 6599, 14, 1506, 21031, 267, 871, 4281, 26, 288, 986, 267, 587, 26, 288, 7239, 63, 1506, 21031, 8, 277, 9, 339, 347, 1900, 13430, 8, 277, 304, 267, 291, 14, 929, 275, 24230, 14, 17377, 267, 340, 291, 14, 6599, 26, 288, 291, 14, 6599, 14, 1506, 13430, 8, 277, 9, 339, 768, 11610, 14, 24813, 272, 347, 10102, 8, 277, 12, 7239, 12, 3718, 304, 267, 408, 267, 768, 466, 221, 7239, 26, 491, 91, 25497, 14, 6599, 14, 12678, 93, 267, 768, 635, 7239, 26, 314, 23886, 626, 8469, 314, 7239, 465, 282, 8852, 267, 768, 466, 221, 3718, 26, 1211, 26, 1059, 1035, 1059, 12, 503, 488, 267, 768, 635, 3718, 26, 6571, 314, 7239, 1159, 1015, 402, 1924, 17283, 3110, 267, 408, 267, 291, 14, 3846, 14680, 275, 3718, 221, 327, 9033, 1414, 536, 370, 1015, 267, 340, 291, 14, 6599, 365, 488, 26, 288, 291, 14, 6599, 275, 7239, 288, 291, 14, 6599, 14, 525, 12678, 1858, 6437, 8, 277, 9, 267, 587, 26, 288, 702, 291, 14, 6599, 508, 7239, 267, 943, 14, 1328, 480, 12678, 450, 83, 10102, 370, 450, 83, 2, 450, 334, 6599, 14, 6599, 354, 12, 6343, 291, 14, 5649, 63, 354, 430, 398, 1995, 291, 14, 6599, 14, 1631, 14, 3846, 5375, 8, 1188, 628, 17099, 531, 267, 372, 291, 339, 347, 9275, 8, 277, 12, 1900, 304, 267, 340, 440, 291, 14, 6599, 503, 440, 291, 14, 6599, 14, 8174, 6432, 83, 837, 288, 372, 10133, 14, 26622, 8, 797, 9, 267, 372, 10133, 14, 26622, 8, 549, 9, 339, 347, 18249, 8, 277, 12, 2004, 29, 403, 304, 267, 408, 22638, 314, 7239, 370, 1852, 3238, 652, 365, 5139, 2337, 14, 1803, 282, 17448, 267, 626, 28887, 543, 715, 340, 652, 365, 14, 398, 768, 635, 2004, 26, 340, 1265, 2376, 642, 737, 282, 19286, 3694, 12, 282, 283, 4073, 316, 7, 2432, 1566, 911, 506, 22319, 14, 267, 408, 267, 892, 4073, 275, 440, 291, 14, 4073, 63, 6821, 1192, 267, 366, 275, 10133, 14, 9937, 342, 267, 291, 14, 4073, 63, 6821, 1192, 14, 740, 8, 68, 9, 267, 340, 892, 4073, 26, 288, 510, 316, 1252, 4073, 8, 277, 14, 6599, 14, 1631, 680, 525, 18088, 8, 277, 423, 26992, 9, 398, 372, 366, 339, 347, 12004, 22638, 3917, 9874, 8, 277, 304, 267, 9626, 1192, 12, 291, 14, 4073, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
openstack/congress
congress/tests/test_data_types.py
1
4900
# Copyright (c) 2018 VMware # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function from __future__ import division from __future__ import absolute_import import testtools from congress import data_types class TestDataTypes(testtools.TestCase): def test_nullable(self): for type_class in data_types.TYPES: self.assertIsNone(type_class.marshal(None)) def test_Scalar(self): valid_values = [1, 1.0, 'str', u'str', True] invalid_values = [{}, []] for val in valid_values: self.assertEqual(val, data_types.Scalar.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.Scalar.marshal, val) def test_Str(self): valid_values = ['str', u'str', '1'] invalid_values = [{}, [], True, 1] for val in valid_values: self.assertEqual(val, data_types.Str.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.Str.marshal, val) def test_Bool(self): valid_values = [True, False] invalid_values = [{}, [], 'True', 0, 1] for val in valid_values: self.assertEqual(val, data_types.Bool.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.Bool.marshal, val) def test_Int(self): valid_values = [1, 1.0, -1, True, False] invalid_values = [{}, [], 1.1, '1'] for val in valid_values: self.assertEqual(val, data_types.Int.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.Int.marshal, val) def test_Float(self): valid_values = [1, 1.0, -1, True, False] invalid_values = [{}, [], '1'] for val in valid_values: self.assertEqual(val, data_types.Int.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.Int.marshal, val) def test_UUID(self): valid_values = ['026f66d3-d6f1-44d1-8451-0a95ee984ffa', '026f66d3d6f144d184510a95ee984ffa', '-0-2-6f66d3d6f144d184510a95ee984ffa'] invalid_values = [{}, [], '1', True, 1, 'z26f66d3d6f144d184510a95ee984ffa'] for val in valid_values: self.assertEqual(val, data_types.UUID.marshal(val)) for val in invalid_values: self.assertRaises(ValueError, data_types.UUID.marshal, val) def test_IPAddress(self): valid_values = [('10.0.0.1', '10.0.0.1'), ('::ffff:0a00:0001', '10.0.0.1'), ('0000:0000:0000:0000:0000:ffff:0a00:0001', '10.0.0.1'), ('2001:db8::ff00:42:8329', '2001:db8::ff00:42:8329'), ('2001:0db8:0000:0000:0000:ff00:0042:8329', '2001:db8::ff00:42:8329')] invalid_values = [{}, [], '1', True, 1, '256.0.0.1'] for val in valid_values: self.assertEqual(val[1], data_types.IPAddress.marshal(val[0])) for val in invalid_values: self.assertRaises(ValueError, data_types.IPAddress.marshal, val) def test_IPNetwork(self): valid_values = [('10.0.0.0/16', '10.0.0.0/16'), ('2001:db00::0/24', '2001:db00::/24'), ('::ffff:0a00:0000/128', '::ffff:a00:0/128')] invalid_values = [{}, [], '1', True, 1, '10.0.0.0/4' '10.0.0.1/16'] for val in valid_values: self.assertEqual(val[1], data_types.IPNetwork.marshal(val[0])) for val in invalid_values: self.assertRaises(ValueError, data_types.IPNetwork.marshal, val) def test_enum_types(self): Test1 = data_types.create_congress_enum_type( 'Test', [1, 2], data_types.Int) self.assertEqual(1, Test1.marshal(1)) self.assertIsNone(Test1.marshal(None)) self.assertRaises(ValueError, Test1.marshal, 0) Test2 = data_types.create_congress_enum_type( 'Test', [1, 2], data_types.Int, catch_all_default_value=0) self.assertEqual(1, Test2.marshal(1)) self.assertEqual(0, Test2.marshal(-1)) self.assertEqual(0, Test2.marshal('blah'))
apache-2.0
[ 3, 1898, 334, 67, 9, 14894, 27391, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 30741, 199, 199, 504, 406, 3313, 492, 666, 63, 1313, 421, 199, 533, 1379, 1451, 4100, 8, 396, 2537, 14, 1746, 304, 339, 347, 511, 63, 16375, 8, 277, 304, 267, 367, 730, 63, 533, 315, 666, 63, 1313, 14, 7893, 26, 288, 291, 14, 7702, 8, 466, 63, 533, 14, 18376, 8, 403, 430, 339, 347, 511, 63, 13090, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 283, 495, 297, 399, 1159, 454, 297, 715, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 942, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 13090, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 13090, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 2848, 8, 277, 304, 267, 1686, 63, 1459, 275, 788, 495, 297, 399, 1159, 454, 297, 283, 17, 418, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 715, 12, 413, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 2848, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 2848, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 10349, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 549, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 549, 297, 378, 12, 413, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 10349, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 10349, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 3241, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 446, 17, 12, 715, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 413, 14, 17, 12, 283, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 3241, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 3241, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 5136, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 446, 17, 12, 715, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 3241, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 3241, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 8757, 8, 277, 304, 267, 1686, 63, 1459, 275, 788, 14842, 70, 1272, 68, 19, 13, 68, 22, 70, 17, 13, 1602, 68, 17, 13, 1349, 2869, 13, 16, 65, 2720, 1024, 29703, 556, 65, 297, 717, 283, 14842, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 297, 717, 2475, 16, 13, 18, 13, 22, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 418, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 297, 715, 12, 413, 12, 2079, 283, 90, 1479, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 8757, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 8757, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 14955, 8, 277, 304, 267, 1686, 63, 1459, 275, 4274, 709, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 334, 356, 26, 4717, 26, 16, 65, 383, 26, 4183, 297, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 661, 993, 26, 993, 26, 993, 26, 993, 26, 993, 26, 4717, 26, 16, 65, 383, 26, 4183, 297, 586, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 661, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 297, 283, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 659, 717, 661, 8339, 26, 16, 697, 24, 26, 993, 26, 993, 26, 993, 26, 556, 383, 26, 32728, 26, 24, 11685, 297, 586, 283, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 5440, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 297, 715, 12, 413, 12, 2079, 283, 3912, 14, 16, 14, 16, 14, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 59 ]
[ 1898, 334, 67, 9, 14894, 27391, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 30741, 199, 199, 504, 406, 3313, 492, 666, 63, 1313, 421, 199, 533, 1379, 1451, 4100, 8, 396, 2537, 14, 1746, 304, 339, 347, 511, 63, 16375, 8, 277, 304, 267, 367, 730, 63, 533, 315, 666, 63, 1313, 14, 7893, 26, 288, 291, 14, 7702, 8, 466, 63, 533, 14, 18376, 8, 403, 430, 339, 347, 511, 63, 13090, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 283, 495, 297, 399, 1159, 454, 297, 715, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 942, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 13090, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 13090, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 2848, 8, 277, 304, 267, 1686, 63, 1459, 275, 788, 495, 297, 399, 1159, 454, 297, 283, 17, 418, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 715, 12, 413, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 2848, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 2848, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 10349, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 549, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 549, 297, 378, 12, 413, 61, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 10349, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 10349, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 3241, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 446, 17, 12, 715, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 413, 14, 17, 12, 283, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 3241, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 3241, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 5136, 8, 277, 304, 267, 1686, 63, 1459, 275, 359, 17, 12, 413, 14, 16, 12, 446, 17, 12, 715, 12, 756, 61, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 3241, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 3241, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 8757, 8, 277, 304, 267, 1686, 63, 1459, 275, 788, 14842, 70, 1272, 68, 19, 13, 68, 22, 70, 17, 13, 1602, 68, 17, 13, 1349, 2869, 13, 16, 65, 2720, 1024, 29703, 556, 65, 297, 717, 283, 14842, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 297, 717, 2475, 16, 13, 18, 13, 22, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 418, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 297, 715, 12, 413, 12, 2079, 283, 90, 1479, 70, 1272, 68, 19, 68, 22, 70, 9862, 68, 1085, 2322, 709, 65, 2720, 1024, 29703, 556, 65, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 12, 666, 63, 1313, 14, 8757, 14, 18376, 8, 637, 430, 398, 367, 1139, 315, 3866, 63, 1459, 26, 288, 291, 14, 1855, 8, 3393, 12, 666, 63, 1313, 14, 8757, 14, 18376, 12, 1139, 9, 339, 347, 511, 63, 14955, 8, 277, 304, 267, 1686, 63, 1459, 275, 4274, 709, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 334, 356, 26, 4717, 26, 16, 65, 383, 26, 4183, 297, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 661, 993, 26, 993, 26, 993, 26, 993, 26, 993, 26, 4717, 26, 16, 65, 383, 26, 4183, 297, 586, 283, 709, 14, 16, 14, 16, 14, 17, 659, 717, 661, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 297, 283, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 659, 717, 661, 8339, 26, 16, 697, 24, 26, 993, 26, 993, 26, 993, 26, 556, 383, 26, 32728, 26, 24, 11685, 297, 586, 283, 8339, 26, 697, 24, 447, 556, 383, 26, 2260, 26, 24, 11685, 5440, 267, 3866, 63, 1459, 275, 8910, 1386, 990, 283, 17, 297, 715, 12, 413, 12, 2079, 283, 3912, 14, 16, 14, 16, 14, 17, 418, 267, 367, 1139, 315, 1686, 63, 1459, 26, 288, 291, 14, 629, 8, 637, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bikashgupta11/javarobot
src/main/resources/jython/Lib/lib2to3/fixes/fix_imports.py
326
5693
"""Fix incompatible imports and module references.""" # Authors: Collin Winter, Nick Edds # Local imports from .. import fixer_base from ..fixer_util import Name, attr_chain MAPPING = {'StringIO': 'io', 'cStringIO': 'io', 'cPickle': 'pickle', '__builtin__' : 'builtins', 'copy_reg': 'copyreg', 'Queue': 'queue', 'SocketServer': 'socketserver', 'ConfigParser': 'configparser', 'repr': 'reprlib', 'FileDialog': 'tkinter.filedialog', 'tkFileDialog': 'tkinter.filedialog', 'SimpleDialog': 'tkinter.simpledialog', 'tkSimpleDialog': 'tkinter.simpledialog', 'tkColorChooser': 'tkinter.colorchooser', 'tkCommonDialog': 'tkinter.commondialog', 'Dialog': 'tkinter.dialog', 'Tkdnd': 'tkinter.dnd', 'tkFont': 'tkinter.font', 'tkMessageBox': 'tkinter.messagebox', 'ScrolledText': 'tkinter.scrolledtext', 'Tkconstants': 'tkinter.constants', 'Tix': 'tkinter.tix', 'ttk': 'tkinter.ttk', 'Tkinter': 'tkinter', 'markupbase': '_markupbase', '_winreg': 'winreg', 'thread': '_thread', 'dummy_thread': '_dummy_thread', # anydbm and whichdb are handled by fix_imports2 'dbhash': 'dbm.bsd', 'dumbdbm': 'dbm.dumb', 'dbm': 'dbm.ndbm', 'gdbm': 'dbm.gnu', 'xmlrpclib': 'xmlrpc.client', 'DocXMLRPCServer': 'xmlrpc.server', 'SimpleXMLRPCServer': 'xmlrpc.server', 'httplib': 'http.client', 'htmlentitydefs' : 'html.entities', 'HTMLParser' : 'html.parser', 'Cookie': 'http.cookies', 'cookielib': 'http.cookiejar', 'BaseHTTPServer': 'http.server', 'SimpleHTTPServer': 'http.server', 'CGIHTTPServer': 'http.server', #'test.test_support': 'test.support', 'commands': 'subprocess', 'UserString' : 'collections', 'UserList' : 'collections', 'urlparse' : 'urllib.parse', 'robotparser' : 'urllib.robotparser', } def alternates(members): return "(" + "|".join(map(repr, members)) + ")" def build_pattern(mapping=MAPPING): mod_list = ' | '.join(["module_name='%s'" % key for key in mapping]) bare_names = alternates(mapping.keys()) yield """name_import=import_name< 'import' ((%s) | multiple_imports=dotted_as_names< any* (%s) any* >) > """ % (mod_list, mod_list) yield """import_from< 'from' (%s) 'import' ['('] ( any | import_as_name< any 'as' any > | import_as_names< any* >) [')'] > """ % mod_list yield """import_name< 'import' (dotted_as_name< (%s) 'as' any > | multiple_imports=dotted_as_names< any* dotted_as_name< (%s) 'as' any > any* >) > """ % (mod_list, mod_list) # Find usages of module members in code e.g. thread.foo(bar) yield "power< bare_with_attr=(%s) trailer<'.' any > any* >" % bare_names class FixImports(fixer_base.BaseFix): BM_compatible = True keep_line_order = True # This is overridden in fix_imports2. mapping = MAPPING # We want to run this fixer late, so fix_import doesn't try to make stdlib # renames into relative imports. run_order = 6 def build_pattern(self): return "|".join(build_pattern(self.mapping)) def compile_pattern(self): # We override this, so MAPPING can be pragmatically altered and the # changes will be reflected in PATTERN. self.PATTERN = self.build_pattern() super(FixImports, self).compile_pattern() # Don't match the node if it's within another match. def match(self, node): match = super(FixImports, self).match results = match(node) if results: # Module usage could be in the trailer of an attribute lookup, so we # might have nested matches when "bare_with_attr" is present. if "bare_with_attr" not in results and \ any(match(obj) for obj in attr_chain(node, "parent")): return False return results return False def start_tree(self, tree, filename): super(FixImports, self).start_tree(tree, filename) self.replace = {} def transform(self, node, results): import_mod = results.get("module_name") if import_mod: mod_name = import_mod.value new_name = unicode(self.mapping[mod_name]) import_mod.replace(Name(new_name, prefix=import_mod.prefix)) if "name_import" in results: # If it's not a "from x import x, y" or "import x as y" import, # marked its usage to be replaced. self.replace[mod_name] = new_name if "multiple_imports" in results: # This is a nasty hack to fix multiple imports on a line (e.g., # "import StringIO, urlparse"). The problem is that I can't # figure out an easy way to make a pattern recognize the keys of # MAPPING randomly sprinkled in an import statement. results = self.match(node) if results: self.transform(node, results) else: # Replace usage of the module. bare_name = results["bare_with_attr"][0] new_name = self.replace.get(bare_name.value) if new_name: bare_name.replace(Name(new_name, prefix=bare_name.prefix))
gpl-3.0
[ 624, 11985, 18457, 8925, 436, 859, 6941, 1041, 199, 3, 6642, 26, 3626, 472, 644, 1058, 12, 653, 2000, 662, 617, 83, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 2812, 12, 1921, 63, 4429, 199, 199, 20351, 275, 791, 6424, 356, 221, 283, 2308, 297, 1779, 283, 67, 6424, 356, 283, 2308, 297, 1779, 283, 67, 12755, 356, 283, 8092, 297, 1779, 2560, 5351, 12217, 520, 283, 10372, 297, 1779, 283, 1574, 63, 1135, 356, 283, 1574, 1135, 297, 1779, 283, 3737, 356, 283, 1825, 297, 1779, 283, 3869, 3120, 356, 283, 3450, 1000, 297, 1779, 283, 15218, 356, 283, 888, 2087, 297, 1779, 283, 2722, 356, 283, 2722, 773, 297, 1779, 283, 25213, 356, 283, 12223, 14, 493, 7196, 297, 1779, 283, 2663, 25213, 356, 283, 12223, 14, 493, 7196, 297, 1779, 283, 3184, 5619, 356, 283, 12223, 14, 4129, 7196, 297, 1779, 283, 2663, 3184, 5619, 356, 283, 12223, 14, 4129, 7196, 297, 1779, 283, 2663, 4117, 17693, 356, 283, 12223, 14, 2326, 31123, 297, 1779, 283, 2663, 7844, 5619, 356, 283, 12223, 14, 2330, 7196, 297, 1779, 283, 5619, 356, 283, 12223, 14, 7196, 297, 1779, 283, 15189, 68, 977, 356, 283, 12223, 14, 68, 977, 297, 1779, 283, 2663, 6986, 356, 283, 12223, 14, 4246, 297, 1779, 283, 2663, 13695, 356, 283, 12223, 14, 1188, 1977, 297, 1779, 283, 29145, 1872, 356, 283, 12223, 14, 551, 10504, 505, 297, 1779, 283, 15189, 5559, 356, 283, 12223, 14, 5559, 297, 1779, 283, 30167, 356, 283, 12223, 14, 31625, 297, 1779, 283, 24865, 356, 283, 12223, 14, 24865, 297, 1779, 283, 15189, 1058, 356, 283, 12223, 297, 1779, 283, 10131, 1095, 356, 2513, 10131, 1095, 297, 1779, 2513, 15658, 356, 283, 15658, 297, 1779, 283, 2671, 356, 2513, 2671, 297, 1779, 283, 5869, 63, 2671, 356, 2513, 5869, 63, 2671, 297, 1779, 327, 1263, 20666, 436, 1314, 697, 787, 8860, 701, 5325, 63, 12775, 18, 1779, 283, 697, 2227, 356, 283, 20666, 14, 15746, 297, 1779, 283, 29271, 20666, 356, 283, 20666, 14, 29271, 297, 1779, 283, 20666, 356, 283, 20666, 14, 78, 20666, 297, 1779, 283, 17119, 77, 356, 283, 20666, 14, 3689, 297, 1779, 283, 17596, 773, 356, 283, 17596, 14, 1258, 297, 1779, 283, 3768, 27026, 3120, 356, 283, 17596, 14, 1000, 297, 1779, 283, 3184, 27026, 3120, 356, 283, 17596, 14, 1000, 297, 1779, 283, 12942, 356, 283, 1014, 14, 1258, 297, 1779, 283, 15575, 552, 1701, 8710, 7, 520, 283, 1360, 14, 8327, 297, 1779, 283, 27375, 7, 520, 283, 1360, 14, 2087, 297, 1779, 283, 7810, 356, 283, 1014, 14, 7792, 297, 1779, 283, 5306, 773, 356, 283, 1014, 14, 30552, 297, 1779, 283, 1563, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 283, 3184, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 283, 21337, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 17384, 396, 14, 396, 63, 4058, 356, 283, 396, 14, 4058, 297, 1779, 283, 4405, 356, 283, 5781, 297, 1779, 283, 1899, 1558, 7, 520, 283, 7882, 297, 1779, 283, 1899, 1296, 7, 520, 283, 7882, 297, 1779, 283, 10290, 7, 520, 283, 4078, 14, 1122, 297, 1779, 283, 20969, 7, 520, 283, 4078, 14, 20969, 297, 199, 93, 421, 199, 318, 8679, 2335, 8, 6334, 304, 272, 372, 26054, 435, 15733, 1674, 904, 8, 1130, 8, 2722, 12, 7556, 430, 435, 19607, 421, 199, 318, 1900, 63, 3401, 8, 4745, 29, 20351, 304, 272, 3413, 63, 513, 275, 283, 1204, 1987, 904, 5234, 578, 63, 354, 9569, 83, 4065, 450, 790, 367, 790, 315, 4412, 566, 272, 18753, 63, 1247, 275, 8679, 2335, 8, 4745, 14, 1612, 1012, 339, 1995, 408, 354, 63, 646, 29, 646, 63, 354, 28, 283, 646, 7, 3666, 5, 83, 9, 1204, 2049, 3663, 63, 12775, 29, 19404, 63, 305, 63, 1247, 28, 1263, 10, 4366, 83, 9, 1263, 10, 690, 9, 690, 881, 408, 450, 334, 1494, 63, 513, 12, 3413, 63, 513, 9, 272, 1995, 408, 646, 63, 504, 28, 283, 504, 7, 4366, 83, 9, 283, 646, 7, 788, 360, 61, 1598, 334, 1263, 1204, 492, 63, 305, 63, 354, 28, 1263, 283, 305, 7, 1263, 690, 1204, 355, 492, 63, 305, 63, 1247, 28, 1263, 10, 690, 9, 221, 359, 358, 418, 690, 881, 408, 450, 3413, 63, 513, 272, 1995, 408, 646, 63, 354, 28, 283, 646, 7, 334, 19404, 63, 305, 63, 354, 28, 4366, 83, 9, 283, 305, 7, 1263, 690, 1204, 2049, 3663, 63, 12775, 29, 19404, 63, 305, 63, 1247, 28, 326, 1263, 10, 18947, 63, 305, 63, 354, 28, 4366, 83, 9, 283, 305, 7, 1263, 690, 1263, 10, 690, 9, 690, 881, 408, 450, 334, 1494, 63, 513, 12, 3413, 63, 513, 9, 339, 327, 6668, 4503, 83, 402, 859, 7556, 315, 1233, 325, 14, 71, 14, 2462, 14, 1421, 8, 1700, 9, 272, 1995, 298, 5652, 28, 18753, 63, 1045, 63, 962, 2687, 5, 83, 9, 17357, 28, 30484, 1263, 690, 1263, 10, 690, 2, 450, 18753, 63, 1247, 421, 199, 533, 14811, 32447, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 4215, 63, 604, 63, 1648, 275, 715, 272, 327, 961, 365, 10087, 315, 5325, 63, 12775, 18, 14, 272, 4412, 275, 603, 7121, 1206, 339, 327, 2136, 2934, 370, 1255, 642, 24739, 2465, 12, 880, 5325, 63, 646, 3181, 1133, 862, 370, 1852, 26678, 272, 327, 295, 1247, 1901, 3847, 8925, 14, 272, 1255, 63, 1648, 275, 1227, 339, 347, 1900, 63, 3401, 8, 277, 304, 267, 372, 15733, 1674, 904, 8, 1506, 63, 3401, 8, 277, 14, 4745, 430, 339, 347, 6555, 63, 3401, 8, 277, 304, 267, 327, 2136, 4278, 642, 12, 880, 603, 7121, 1206, 883, 506, 299, 2527, 17174, 29815, 436, 314, 267, 327, 4493, 911, 506, 31948, 315, 31467, 7689, 14, 267, 291, 14, 10764, 275, 291, 14, 1506, 63, 3401, 342, 267, 1613, 8, 11985, 32447, 12, 291, 680, 2014, 63, 3401, 342, 339, 327, 7529, 1133, 1336, 314, 1031, 340, 652, 1159, 4453, 4573, 1336, 14, 272, 347, 1336, 8, 277, 12, 1031, 304, 267, 1336 ]
[ 11985, 18457, 8925, 436, 859, 6941, 1041, 199, 3, 6642, 26, 3626, 472, 644, 1058, 12, 653, 2000, 662, 617, 83, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 2812, 12, 1921, 63, 4429, 199, 199, 20351, 275, 791, 6424, 356, 221, 283, 2308, 297, 1779, 283, 67, 6424, 356, 283, 2308, 297, 1779, 283, 67, 12755, 356, 283, 8092, 297, 1779, 2560, 5351, 12217, 520, 283, 10372, 297, 1779, 283, 1574, 63, 1135, 356, 283, 1574, 1135, 297, 1779, 283, 3737, 356, 283, 1825, 297, 1779, 283, 3869, 3120, 356, 283, 3450, 1000, 297, 1779, 283, 15218, 356, 283, 888, 2087, 297, 1779, 283, 2722, 356, 283, 2722, 773, 297, 1779, 283, 25213, 356, 283, 12223, 14, 493, 7196, 297, 1779, 283, 2663, 25213, 356, 283, 12223, 14, 493, 7196, 297, 1779, 283, 3184, 5619, 356, 283, 12223, 14, 4129, 7196, 297, 1779, 283, 2663, 3184, 5619, 356, 283, 12223, 14, 4129, 7196, 297, 1779, 283, 2663, 4117, 17693, 356, 283, 12223, 14, 2326, 31123, 297, 1779, 283, 2663, 7844, 5619, 356, 283, 12223, 14, 2330, 7196, 297, 1779, 283, 5619, 356, 283, 12223, 14, 7196, 297, 1779, 283, 15189, 68, 977, 356, 283, 12223, 14, 68, 977, 297, 1779, 283, 2663, 6986, 356, 283, 12223, 14, 4246, 297, 1779, 283, 2663, 13695, 356, 283, 12223, 14, 1188, 1977, 297, 1779, 283, 29145, 1872, 356, 283, 12223, 14, 551, 10504, 505, 297, 1779, 283, 15189, 5559, 356, 283, 12223, 14, 5559, 297, 1779, 283, 30167, 356, 283, 12223, 14, 31625, 297, 1779, 283, 24865, 356, 283, 12223, 14, 24865, 297, 1779, 283, 15189, 1058, 356, 283, 12223, 297, 1779, 283, 10131, 1095, 356, 2513, 10131, 1095, 297, 1779, 2513, 15658, 356, 283, 15658, 297, 1779, 283, 2671, 356, 2513, 2671, 297, 1779, 283, 5869, 63, 2671, 356, 2513, 5869, 63, 2671, 297, 1779, 327, 1263, 20666, 436, 1314, 697, 787, 8860, 701, 5325, 63, 12775, 18, 1779, 283, 697, 2227, 356, 283, 20666, 14, 15746, 297, 1779, 283, 29271, 20666, 356, 283, 20666, 14, 29271, 297, 1779, 283, 20666, 356, 283, 20666, 14, 78, 20666, 297, 1779, 283, 17119, 77, 356, 283, 20666, 14, 3689, 297, 1779, 283, 17596, 773, 356, 283, 17596, 14, 1258, 297, 1779, 283, 3768, 27026, 3120, 356, 283, 17596, 14, 1000, 297, 1779, 283, 3184, 27026, 3120, 356, 283, 17596, 14, 1000, 297, 1779, 283, 12942, 356, 283, 1014, 14, 1258, 297, 1779, 283, 15575, 552, 1701, 8710, 7, 520, 283, 1360, 14, 8327, 297, 1779, 283, 27375, 7, 520, 283, 1360, 14, 2087, 297, 1779, 283, 7810, 356, 283, 1014, 14, 7792, 297, 1779, 283, 5306, 773, 356, 283, 1014, 14, 30552, 297, 1779, 283, 1563, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 283, 3184, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 283, 21337, 14938, 356, 283, 1014, 14, 1000, 297, 1779, 17384, 396, 14, 396, 63, 4058, 356, 283, 396, 14, 4058, 297, 1779, 283, 4405, 356, 283, 5781, 297, 1779, 283, 1899, 1558, 7, 520, 283, 7882, 297, 1779, 283, 1899, 1296, 7, 520, 283, 7882, 297, 1779, 283, 10290, 7, 520, 283, 4078, 14, 1122, 297, 1779, 283, 20969, 7, 520, 283, 4078, 14, 20969, 297, 199, 93, 421, 199, 318, 8679, 2335, 8, 6334, 304, 272, 372, 26054, 435, 15733, 1674, 904, 8, 1130, 8, 2722, 12, 7556, 430, 435, 19607, 421, 199, 318, 1900, 63, 3401, 8, 4745, 29, 20351, 304, 272, 3413, 63, 513, 275, 283, 1204, 1987, 904, 5234, 578, 63, 354, 9569, 83, 4065, 450, 790, 367, 790, 315, 4412, 566, 272, 18753, 63, 1247, 275, 8679, 2335, 8, 4745, 14, 1612, 1012, 339, 1995, 408, 354, 63, 646, 29, 646, 63, 354, 28, 283, 646, 7, 3666, 5, 83, 9, 1204, 2049, 3663, 63, 12775, 29, 19404, 63, 305, 63, 1247, 28, 1263, 10, 4366, 83, 9, 1263, 10, 690, 9, 690, 881, 408, 450, 334, 1494, 63, 513, 12, 3413, 63, 513, 9, 272, 1995, 408, 646, 63, 504, 28, 283, 504, 7, 4366, 83, 9, 283, 646, 7, 788, 360, 61, 1598, 334, 1263, 1204, 492, 63, 305, 63, 354, 28, 1263, 283, 305, 7, 1263, 690, 1204, 355, 492, 63, 305, 63, 1247, 28, 1263, 10, 690, 9, 221, 359, 358, 418, 690, 881, 408, 450, 3413, 63, 513, 272, 1995, 408, 646, 63, 354, 28, 283, 646, 7, 334, 19404, 63, 305, 63, 354, 28, 4366, 83, 9, 283, 305, 7, 1263, 690, 1204, 2049, 3663, 63, 12775, 29, 19404, 63, 305, 63, 1247, 28, 326, 1263, 10, 18947, 63, 305, 63, 354, 28, 4366, 83, 9, 283, 305, 7, 1263, 690, 1263, 10, 690, 9, 690, 881, 408, 450, 334, 1494, 63, 513, 12, 3413, 63, 513, 9, 339, 327, 6668, 4503, 83, 402, 859, 7556, 315, 1233, 325, 14, 71, 14, 2462, 14, 1421, 8, 1700, 9, 272, 1995, 298, 5652, 28, 18753, 63, 1045, 63, 962, 2687, 5, 83, 9, 17357, 28, 30484, 1263, 690, 1263, 10, 690, 2, 450, 18753, 63, 1247, 421, 199, 533, 14811, 32447, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 4215, 63, 604, 63, 1648, 275, 715, 272, 327, 961, 365, 10087, 315, 5325, 63, 12775, 18, 14, 272, 4412, 275, 603, 7121, 1206, 339, 327, 2136, 2934, 370, 1255, 642, 24739, 2465, 12, 880, 5325, 63, 646, 3181, 1133, 862, 370, 1852, 26678, 272, 327, 295, 1247, 1901, 3847, 8925, 14, 272, 1255, 63, 1648, 275, 1227, 339, 347, 1900, 63, 3401, 8, 277, 304, 267, 372, 15733, 1674, 904, 8, 1506, 63, 3401, 8, 277, 14, 4745, 430, 339, 347, 6555, 63, 3401, 8, 277, 304, 267, 327, 2136, 4278, 642, 12, 880, 603, 7121, 1206, 883, 506, 299, 2527, 17174, 29815, 436, 314, 267, 327, 4493, 911, 506, 31948, 315, 31467, 7689, 14, 267, 291, 14, 10764, 275, 291, 14, 1506, 63, 3401, 342, 267, 1613, 8, 11985, 32447, 12, 291, 680, 2014, 63, 3401, 342, 339, 327, 7529, 1133, 1336, 314, 1031, 340, 652, 1159, 4453, 4573, 1336, 14, 272, 347, 1336, 8, 277, 12, 1031, 304, 267, 1336, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ganeshrn/ansible
test/support/integration/plugins/module_utils/rabbitmq.py
57
9054
# -*- coding: utf-8 -*- # # Copyright: (c) 2016, Jorge Rodriguez <jorge.rodriguez@tiriel.eu> # Copyright: (c) 2018, John Imison <john+github@imison.net> # # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils._text import to_native from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.six.moves.urllib import parse as urllib_parse from mimetypes import MimeTypes import os import json import traceback PIKA_IMP_ERR = None try: import pika import pika.exceptions from pika import spec HAS_PIKA = True except ImportError: PIKA_IMP_ERR = traceback.format_exc() HAS_PIKA = False def rabbitmq_argument_spec(): return dict( login_user=dict(type='str', default='guest'), login_password=dict(type='str', default='guest', no_log=True), login_host=dict(type='str', default='localhost'), login_port=dict(type='str', default='15672'), login_protocol=dict(type='str', default='http', choices=['http', 'https']), ca_cert=dict(type='path', aliases=['cacert']), client_cert=dict(type='path', aliases=['cert']), client_key=dict(type='path', aliases=['key']), vhost=dict(type='str', default='/'), ) # notification/rabbitmq_basic_publish.py class RabbitClient(): def __init__(self, module): self.module = module self.params = module.params self.check_required_library() self.check_host_params() self.url = self.params['url'] self.proto = self.params['proto'] self.username = self.params['username'] self.password = self.params['password'] self.host = self.params['host'] self.port = self.params['port'] self.vhost = self.params['vhost'] self.queue = self.params['queue'] self.headers = self.params['headers'] self.cafile = self.params['cafile'] self.certfile = self.params['certfile'] self.keyfile = self.params['keyfile'] if self.host is not None: self.build_url() if self.cafile is not None: self.append_ssl_certs() self.connect_to_rabbitmq() def check_required_library(self): if not HAS_PIKA: self.module.fail_json(msg=missing_required_lib("pika"), exception=PIKA_IMP_ERR) def check_host_params(self): # Fail if url is specified and other conflicting parameters have been specified if self.params['url'] is not None and any(self.params[k] is not None for k in ['proto', 'host', 'port', 'password', 'username', 'vhost']): self.module.fail_json(msg="url and proto, host, port, vhost, username or password cannot be specified at the same time.") # Fail if url not specified and there is a missing parameter to build the url if self.params['url'] is None and any(self.params[k] is None for k in ['proto', 'host', 'port', 'password', 'username', 'vhost']): self.module.fail_json(msg="Connection parameters must be passed via url, or, proto, host, port, vhost, username or password.") def append_ssl_certs(self): ssl_options = {} if self.cafile: ssl_options['cafile'] = self.cafile if self.certfile: ssl_options['certfile'] = self.certfile if self.keyfile: ssl_options['keyfile'] = self.keyfile self.url = self.url + '?ssl_options=' + urllib_parse.quote(json.dumps(ssl_options)) @staticmethod def rabbitmq_argument_spec(): return dict( url=dict(type='str'), proto=dict(type='str', choices=['amqp', 'amqps']), host=dict(type='str'), port=dict(type='int'), username=dict(type='str'), password=dict(type='str', no_log=True), vhost=dict(type='str'), queue=dict(type='str') ) ''' Consider some file size limits here ''' def _read_file(self, path): try: with open(path, "rb") as file_handle: return file_handle.read() except IOError as e: self.module.fail_json(msg="Unable to open file %s: %s" % (path, to_native(e))) @staticmethod def _check_file_mime_type(path): mime = MimeTypes() return mime.guess_type(path) def build_url(self): self.url = '{0}://{1}:{2}@{3}:{4}/{5}'.format(self.proto, self.username, self.password, self.host, self.port, self.vhost) def connect_to_rabbitmq(self): """ Function to connect to rabbitmq using username and password """ try: parameters = pika.URLParameters(self.url) except Exception as e: self.module.fail_json(msg="URL malformed: %s" % to_native(e)) try: self.connection = pika.BlockingConnection(parameters) except Exception as e: self.module.fail_json(msg="Connection issue: %s" % to_native(e)) try: self.conn_channel = self.connection.channel() except pika.exceptions.AMQPChannelError as e: self.close_connection() self.module.fail_json(msg="Channel issue: %s" % to_native(e)) def close_connection(self): try: self.connection.close() except pika.exceptions.AMQPConnectionError: pass def basic_publish(self): self.content_type = self.params.get("content_type") if self.params.get("body") is not None: args = dict( body=self.params.get("body"), exchange=self.params.get("exchange"), routing_key=self.params.get("routing_key"), properties=pika.BasicProperties(content_type=self.content_type, delivery_mode=1, headers=self.headers)) # If src (file) is defined and content_type is left as default, do a mime lookup on the file if self.params.get("src") is not None and self.content_type == 'text/plain': self.content_type = RabbitClient._check_file_mime_type(self.params.get("src"))[0] self.headers.update( filename=os.path.basename(self.params.get("src")) ) args = dict( body=self._read_file(self.params.get("src")), exchange=self.params.get("exchange"), routing_key=self.params.get("routing_key"), properties=pika.BasicProperties(content_type=self.content_type, delivery_mode=1, headers=self.headers )) elif self.params.get("src") is not None: args = dict( body=self._read_file(self.params.get("src")), exchange=self.params.get("exchange"), routing_key=self.params.get("routing_key"), properties=pika.BasicProperties(content_type=self.content_type, delivery_mode=1, headers=self.headers )) try: # If queue is not defined, RabbitMQ will return the queue name of the automatically generated queue. if self.queue is None: result = self.conn_channel.queue_declare(durable=self.params.get("durable"), exclusive=self.params.get("exclusive"), auto_delete=self.params.get("auto_delete")) self.conn_channel.confirm_delivery() self.queue = result.method.queue else: self.conn_channel.queue_declare(queue=self.queue, durable=self.params.get("durable"), exclusive=self.params.get("exclusive"), auto_delete=self.params.get("auto_delete")) self.conn_channel.confirm_delivery() except Exception as e: self.module.fail_json(msg="Queue declare issue: %s" % to_native(e)) # https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/cloudstack.py#L150 if args['routing_key'] is None: args['routing_key'] = self.queue if args['exchange'] is None: args['exchange'] = '' try: self.conn_channel.basic_publish(**args) return True except pika.exceptions.UnroutableError: return False
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 1603, 24591, 820, 364, 322, 71, 310, 90, 665, 5857, 303, 14, 293, 17824, 71, 310, 90, 32, 280, 322, 352, 14, 16913, 30, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 17815, 473, 1292, 265, 665, 20216, 11, 5031, 32, 1017, 28287, 14, 846, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 4124, 63, 2427, 63, 773, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 14, 4078, 492, 2198, 465, 4011, 63, 1122, 199, 504, 13290, 492, 603, 1036, 4100, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 5190, 199, 199, 2252, 19606, 63, 8947, 63, 2666, 275, 488, 199, 893, 26, 272, 492, 299, 26966, 272, 492, 299, 26966, 14, 3924, 272, 687, 299, 26966, 492, 3158, 272, 7509, 63, 2252, 19606, 275, 715, 199, 2590, 3545, 26, 272, 16678, 19606, 63, 8947, 63, 2666, 275, 5190, 14, 908, 63, 2804, 342, 272, 7509, 63, 2252, 19606, 275, 756, 421, 199, 318, 29773, 29490, 63, 2094, 63, 1650, 837, 272, 372, 1211, 8, 267, 4676, 63, 751, 29, 807, 8, 466, 534, 495, 297, 849, 534, 10409, 659, 267, 4676, 63, 2060, 29, 807, 8, 466, 534, 495, 297, 849, 534, 10409, 297, 949, 63, 793, 29, 549, 395, 267, 4676, 63, 1102, 29, 807, 8, 466, 534, 495, 297, 849, 534, 5967, 659, 267, 4676, 63, 719, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1046, 20298, 659, 267, 4676, 63, 3922, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1014, 297, 3415, 2968, 1014, 297, 283, 2859, 3815, 267, 1704, 63, 4736, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 11055, 15299, 3815, 267, 1890, 63, 4736, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 4736, 3815, 267, 1890, 63, 498, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 498, 3815, 267, 373, 1102, 29, 807, 8, 466, 534, 495, 297, 849, 8805, 659, 272, 776, 421, 199, 3, 6955, 15, 14411, 29490, 63, 4316, 63, 4763, 14, 647, 199, 533, 820, 371, 2075, 3041, 837, 272, 347, 636, 826, 721, 277, 12, 859, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 1162, 275, 859, 14, 1162, 267, 291, 14, 1074, 63, 2427, 63, 4342, 342, 267, 291, 14, 1074, 63, 1102, 63, 1162, 342, 267, 291, 14, 633, 275, 291, 14, 1162, 459, 633, 418, 267, 291, 14, 2625, 275, 291, 14, 1162, 459, 2625, 418, 267, 291, 14, 2473, 275, 291, 14, 1162, 459, 2473, 418, 267, 291, 14, 2060, 275, 291, 14, 1162, 459, 2060, 418, 267, 291, 14, 1102, 275, 291, 14, 1162, 459, 1102, 418, 267, 291, 14, 719, 275, 291, 14, 1162, 459, 719, 418, 267, 291, 14, 32071, 275, 291, 14, 1162, 459, 32071, 418, 267, 291, 14, 1825, 275, 291, 14, 1162, 459, 1825, 418, 267, 291, 14, 2139, 275, 291, 14, 1162, 459, 2139, 418, 267, 291, 14, 696, 493, 275, 291, 14, 1162, 459, 696, 493, 418, 267, 291, 14, 28340, 275, 291, 14, 1162, 459, 28340, 418, 267, 291, 14, 21856, 275, 291, 14, 1162, 459, 21856, 418, 398, 340, 291, 14, 1102, 365, 440, 488, 26, 288, 291, 14, 1506, 63, 633, 342, 398, 340, 291, 14, 696, 493, 365, 440, 488, 26, 288, 291, 14, 740, 63, 4266, 63, 8356, 342, 398, 291, 14, 2242, 63, 475, 63, 14411, 29490, 342, 339, 347, 1104, 63, 2427, 63, 4342, 8, 277, 304, 267, 340, 440, 7509, 63, 2252, 19606, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 29, 4752, 63, 2427, 63, 773, 480, 1038, 7351, 1288, 1919, 29, 2252, 19606, 63, 8947, 63, 2666, 9, 339, 347, 1104, 63, 1102, 63, 1162, 8, 277, 304, 267, 327, 12176, 340, 1166, 365, 2013, 436, 1163, 28204, 2633, 1172, 2757, 2013, 267, 340, 291, 14, 1162, 459, 633, 418, 365, 440, 488, 436, 1263, 8, 277, 14, 1162, 59, 75, 61, 365, 440, 488, 367, 1022, 315, 788, 2625, 297, 283, 1102, 297, 283, 719, 297, 283, 2060, 297, 283, 2473, 297, 283, 32071, 9090, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 633, 436, 4104, 12, 1591, 12, 1844, 12, 373, 1102, 12, 3434, 503, 2505, 3913, 506, 2013, 737, 314, 2011, 900, 2685, 398, 327, 12176, 340, 1166, 440, 2013, 436, 2337, 365, 282, 4124, 2725, 370, 1900, 314, 1166, 267, 340, 291, 14, 1162, 459, 633, 418, 365, 488, 436, 1263, 8, 277, 14, 1162, 59, 75, 61, 365, 488, 367, 1022, 315, 788, 2625, 297, 283, 1102, 297, 283, 719, 297, 283, 2060, 297, 283, 2473, 297, 283, 32071, 9090, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 3225, 2633, 1471, 506, 3032, 4799, 1166, 12, 503, 12, 221, 4104, 12, 1591, 12, 1844, 12, 373, 1102, 12, 3434, 503, 2505, 2685, 339, 347, 5666, 63, 4266, 63, 8356, 8, 277, 304, 267, 6149, 63, 1419, 275, 1052, 267, 340, 291, 14, 696, 493, 26, 288, 6149, 63, 1419, 459, 696, 493, 418, 275, 291, 14, 696, 493, 267, 340, 291, 14, 28340, 26, 288, 6149, 63, 1419, 459, 28340, 418, 275, 291, 14, 28340, 267, 340, 291, 14, 21856, 26, 288, 6149, 63, 1419, 459, 21856, 418, 275, 291, 14, 21856, 398, 291, 14, 633, 275, 291, 14, 633, 435, 8720, 4266, 63, 1419, 534, 435, 4011, 63, 1122, 14, 3513, 8, 1001, 14, 4180, 8, 4266, 63, 1419, 430, 339, 768, 4639, 272, 347, 29773, 29490, 63, 2094, 63, 1650, 837, 267, 372, 1211, 8, 288, 1166, 29, 807, 8, 466, 534, 495, 659, 288, 4104, 29, 807, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 1603, 24591, 820, 364, 322, 71, 310, 90, 665, 5857, 303, 14, 293, 17824, 71, 310, 90, 32, 280, 322, 352, 14, 16913, 30, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 17815, 473, 1292, 265, 665, 20216, 11, 5031, 32, 1017, 28287, 14, 846, 30, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 4124, 63, 2427, 63, 773, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 14, 4078, 492, 2198, 465, 4011, 63, 1122, 199, 504, 13290, 492, 603, 1036, 4100, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 5190, 199, 199, 2252, 19606, 63, 8947, 63, 2666, 275, 488, 199, 893, 26, 272, 492, 299, 26966, 272, 492, 299, 26966, 14, 3924, 272, 687, 299, 26966, 492, 3158, 272, 7509, 63, 2252, 19606, 275, 715, 199, 2590, 3545, 26, 272, 16678, 19606, 63, 8947, 63, 2666, 275, 5190, 14, 908, 63, 2804, 342, 272, 7509, 63, 2252, 19606, 275, 756, 421, 199, 318, 29773, 29490, 63, 2094, 63, 1650, 837, 272, 372, 1211, 8, 267, 4676, 63, 751, 29, 807, 8, 466, 534, 495, 297, 849, 534, 10409, 659, 267, 4676, 63, 2060, 29, 807, 8, 466, 534, 495, 297, 849, 534, 10409, 297, 949, 63, 793, 29, 549, 395, 267, 4676, 63, 1102, 29, 807, 8, 466, 534, 495, 297, 849, 534, 5967, 659, 267, 4676, 63, 719, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1046, 20298, 659, 267, 4676, 63, 3922, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1014, 297, 3415, 2968, 1014, 297, 283, 2859, 3815, 267, 1704, 63, 4736, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 11055, 15299, 3815, 267, 1890, 63, 4736, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 4736, 3815, 267, 1890, 63, 498, 29, 807, 8, 466, 534, 515, 297, 5481, 2968, 498, 3815, 267, 373, 1102, 29, 807, 8, 466, 534, 495, 297, 849, 8805, 659, 272, 776, 421, 199, 3, 6955, 15, 14411, 29490, 63, 4316, 63, 4763, 14, 647, 199, 533, 820, 371, 2075, 3041, 837, 272, 347, 636, 826, 721, 277, 12, 859, 304, 267, 291, 14, 578, 275, 859, 267, 291, 14, 1162, 275, 859, 14, 1162, 267, 291, 14, 1074, 63, 2427, 63, 4342, 342, 267, 291, 14, 1074, 63, 1102, 63, 1162, 342, 267, 291, 14, 633, 275, 291, 14, 1162, 459, 633, 418, 267, 291, 14, 2625, 275, 291, 14, 1162, 459, 2625, 418, 267, 291, 14, 2473, 275, 291, 14, 1162, 459, 2473, 418, 267, 291, 14, 2060, 275, 291, 14, 1162, 459, 2060, 418, 267, 291, 14, 1102, 275, 291, 14, 1162, 459, 1102, 418, 267, 291, 14, 719, 275, 291, 14, 1162, 459, 719, 418, 267, 291, 14, 32071, 275, 291, 14, 1162, 459, 32071, 418, 267, 291, 14, 1825, 275, 291, 14, 1162, 459, 1825, 418, 267, 291, 14, 2139, 275, 291, 14, 1162, 459, 2139, 418, 267, 291, 14, 696, 493, 275, 291, 14, 1162, 459, 696, 493, 418, 267, 291, 14, 28340, 275, 291, 14, 1162, 459, 28340, 418, 267, 291, 14, 21856, 275, 291, 14, 1162, 459, 21856, 418, 398, 340, 291, 14, 1102, 365, 440, 488, 26, 288, 291, 14, 1506, 63, 633, 342, 398, 340, 291, 14, 696, 493, 365, 440, 488, 26, 288, 291, 14, 740, 63, 4266, 63, 8356, 342, 398, 291, 14, 2242, 63, 475, 63, 14411, 29490, 342, 339, 347, 1104, 63, 2427, 63, 4342, 8, 277, 304, 267, 340, 440, 7509, 63, 2252, 19606, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 29, 4752, 63, 2427, 63, 773, 480, 1038, 7351, 1288, 1919, 29, 2252, 19606, 63, 8947, 63, 2666, 9, 339, 347, 1104, 63, 1102, 63, 1162, 8, 277, 304, 267, 327, 12176, 340, 1166, 365, 2013, 436, 1163, 28204, 2633, 1172, 2757, 2013, 267, 340, 291, 14, 1162, 459, 633, 418, 365, 440, 488, 436, 1263, 8, 277, 14, 1162, 59, 75, 61, 365, 440, 488, 367, 1022, 315, 788, 2625, 297, 283, 1102, 297, 283, 719, 297, 283, 2060, 297, 283, 2473, 297, 283, 32071, 9090, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 633, 436, 4104, 12, 1591, 12, 1844, 12, 373, 1102, 12, 3434, 503, 2505, 3913, 506, 2013, 737, 314, 2011, 900, 2685, 398, 327, 12176, 340, 1166, 440, 2013, 436, 2337, 365, 282, 4124, 2725, 370, 1900, 314, 1166, 267, 340, 291, 14, 1162, 459, 633, 418, 365, 488, 436, 1263, 8, 277, 14, 1162, 59, 75, 61, 365, 488, 367, 1022, 315, 788, 2625, 297, 283, 1102, 297, 283, 719, 297, 283, 2060, 297, 283, 2473, 297, 283, 32071, 9090, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 3225, 2633, 1471, 506, 3032, 4799, 1166, 12, 503, 12, 221, 4104, 12, 1591, 12, 1844, 12, 373, 1102, 12, 3434, 503, 2505, 2685, 339, 347, 5666, 63, 4266, 63, 8356, 8, 277, 304, 267, 6149, 63, 1419, 275, 1052, 267, 340, 291, 14, 696, 493, 26, 288, 6149, 63, 1419, 459, 696, 493, 418, 275, 291, 14, 696, 493, 267, 340, 291, 14, 28340, 26, 288, 6149, 63, 1419, 459, 28340, 418, 275, 291, 14, 28340, 267, 340, 291, 14, 21856, 26, 288, 6149, 63, 1419, 459, 21856, 418, 275, 291, 14, 21856, 398, 291, 14, 633, 275, 291, 14, 633, 435, 8720, 4266, 63, 1419, 534, 435, 4011, 63, 1122, 14, 3513, 8, 1001, 14, 4180, 8, 4266, 63, 1419, 430, 339, 768, 4639, 272, 347, 29773, 29490, 63, 2094, 63, 1650, 837, 267, 372, 1211, 8, 288, 1166, 29, 807, 8, 466, 534, 495, 659, 288, 4104, 29, 807, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SylvainCorlay/PyDev.Debugger
pydev_runfiles.py
52
30194
from __future__ import nested_scopes import fnmatch import os.path from pydev_runfiles_coverage import StartCoverageSupport from pydevd_constants import * #@UnusedWildImport import re import time #======================================================================================================================= # Configuration #======================================================================================================================= class Configuration: def __init__( self, files_or_dirs='', verbosity=2, include_tests=None, tests=None, port=None, files_to_tests=None, jobs=1, split_jobs='tests', coverage_output_dir=None, coverage_include=None, coverage_output_file=None, exclude_files=None, exclude_tests=None, include_files=None, django=False, ): self.files_or_dirs = files_or_dirs self.verbosity = verbosity self.include_tests = include_tests self.tests = tests self.port = port self.files_to_tests = files_to_tests self.jobs = jobs self.split_jobs = split_jobs self.django = django if include_tests: assert isinstance(include_tests, (list, tuple)) if exclude_files: assert isinstance(exclude_files, (list, tuple)) if exclude_tests: assert isinstance(exclude_tests, (list, tuple)) self.exclude_files = exclude_files self.include_files = include_files self.exclude_tests = exclude_tests self.coverage_output_dir = coverage_output_dir self.coverage_include = coverage_include self.coverage_output_file = coverage_output_file def __str__(self): return '''Configuration - files_or_dirs: %s - verbosity: %s - tests: %s - port: %s - files_to_tests: %s - jobs: %s - split_jobs: %s - include_files: %s - include_tests: %s - exclude_files: %s - exclude_tests: %s - coverage_output_dir: %s - coverage_include_dir: %s - coverage_output_file: %s - django: %s ''' % ( self.files_or_dirs, self.verbosity, self.tests, self.port, self.files_to_tests, self.jobs, self.split_jobs, self.include_files, self.include_tests, self.exclude_files, self.exclude_tests, self.coverage_output_dir, self.coverage_include, self.coverage_output_file, self.django, ) #======================================================================================================================= # parse_cmdline #======================================================================================================================= def parse_cmdline(argv=None): """ Parses command line and returns test directories, verbosity, test filter and test suites usage: runfiles.py -v|--verbosity <level> -t|--tests <Test.test1,Test2> dirs|files Multiprocessing options: jobs=number (with the number of jobs to be used to run the tests) split_jobs='module'|'tests' if == module, a given job will always receive all the tests from a module if == tests, the tests will be split independently of their originating module (default) --exclude_files = comma-separated list of patterns with files to exclude (fnmatch style) --include_files = comma-separated list of patterns with files to include (fnmatch style) --exclude_tests = comma-separated list of patterns with test names to exclude (fnmatch style) Note: if --tests is given, --exclude_files, --include_files and --exclude_tests are ignored! """ if argv is None: argv = sys.argv verbosity = 2 include_tests = None tests = None port = None jobs = 1 split_jobs = 'tests' files_to_tests = {} coverage_output_dir = None coverage_include = None exclude_files = None exclude_tests = None include_files = None django = False from _pydev_getopt import gnu_getopt optlist, dirs = gnu_getopt( argv[1:], "", [ "verbosity=", "tests=", "port=", "config_file=", "jobs=", "split_jobs=", "include_tests=", "include_files=", "exclude_files=", "exclude_tests=", "coverage_output_dir=", "coverage_include=", "django=" ] ) for opt, value in optlist: if opt in ("-v", "--verbosity"): verbosity = value elif opt in ("-p", "--port"): port = int(value) elif opt in ("-j", "--jobs"): jobs = int(value) elif opt in ("-s", "--split_jobs"): split_jobs = value if split_jobs not in ('module', 'tests'): raise AssertionError('Expected split to be either "module" or "tests". Was :%s' % (split_jobs,)) elif opt in ("-d", "--coverage_output_dir",): coverage_output_dir = value.strip() elif opt in ("-i", "--coverage_include",): coverage_include = value.strip() elif opt in ("-I", "--include_tests"): include_tests = value.split(',') elif opt in ("-E", "--exclude_files"): exclude_files = value.split(',') elif opt in ("-F", "--include_files"): include_files = value.split(',') elif opt in ("-e", "--exclude_tests"): exclude_tests = value.split(',') elif opt in ("-t", "--tests"): tests = value.split(',') elif opt in ("--django",): django = value.strip() in ['true', 'True', '1'] elif opt in ("-c", "--config_file"): config_file = value.strip() if os.path.exists(config_file): f = open(config_file, 'rU') try: config_file_contents = f.read() finally: f.close() if config_file_contents: config_file_contents = config_file_contents.strip() if config_file_contents: for line in config_file_contents.splitlines(): file_and_test = line.split('|') if len(file_and_test) == 2: file, test = file_and_test if DictContains(files_to_tests, file): files_to_tests[file].append(test) else: files_to_tests[file] = [test] else: sys.stderr.write('Could not find config file: %s\n' % (config_file,)) if type([]) != type(dirs): dirs = [dirs] ret_dirs = [] for d in dirs: if '|' in d: #paths may come from the ide separated by | ret_dirs.extend(d.split('|')) else: ret_dirs.append(d) verbosity = int(verbosity) if tests: if verbosity > 4: sys.stdout.write('--tests provided. Ignoring --exclude_files, --exclude_tests and --include_files\n') exclude_files = exclude_tests = include_files = None config = Configuration( ret_dirs, verbosity, include_tests, tests, port, files_to_tests, jobs, split_jobs, coverage_output_dir, coverage_include, exclude_files=exclude_files, exclude_tests=exclude_tests, include_files=include_files, django=django, ) if verbosity > 5: sys.stdout.write(str(config) + '\n') return config #======================================================================================================================= # PydevTestRunner #======================================================================================================================= class PydevTestRunner(object): """ finds and runs a file or directory of files as a unit test """ __py_extensions = ["*.py", "*.pyw"] __exclude_files = ["__init__.*"] #Just to check that only this attributes will be written to this file __slots__ = [ 'verbosity', #Always used 'files_to_tests', #If this one is given, the ones below are not used 'files_or_dirs', #Files or directories received in the command line 'include_tests', #The filter used to collect the tests 'tests', #Strings with the tests to be run 'jobs', #Integer with the number of jobs that should be used to run the test cases 'split_jobs', #String with 'tests' or 'module' (how should the jobs be split) 'configuration', 'coverage', ] def __init__(self, configuration): self.verbosity = configuration.verbosity self.jobs = configuration.jobs self.split_jobs = configuration.split_jobs files_to_tests = configuration.files_to_tests if files_to_tests: self.files_to_tests = files_to_tests self.files_or_dirs = list(files_to_tests.keys()) self.tests = None else: self.files_to_tests = {} self.files_or_dirs = configuration.files_or_dirs self.tests = configuration.tests self.configuration = configuration self.__adjust_path() def __adjust_path(self): """ add the current file or directory to the python path """ path_to_append = None for n in xrange(len(self.files_or_dirs)): dir_name = self.__unixify(self.files_or_dirs[n]) if os.path.isdir(dir_name): if not dir_name.endswith("/"): self.files_or_dirs[n] = dir_name + "/" path_to_append = os.path.normpath(dir_name) elif os.path.isfile(dir_name): path_to_append = os.path.dirname(dir_name) else: if not os.path.exists(dir_name): block_line = '*' * 120 sys.stderr.write('\n%s\n* PyDev test runner error: %s does not exist.\n%s\n' % (block_line, dir_name, block_line)) return msg = ("unknown type. \n%s\nshould be file or a directory.\n" % (dir_name)) raise RuntimeError(msg) if path_to_append is not None: #Add it as the last one (so, first things are resolved against the default dirs and #if none resolves, then we try a relative import). sys.path.append(path_to_append) def __is_valid_py_file(self, fname): """ tests that a particular file contains the proper file extension and is not in the list of files to exclude """ is_valid_fname = 0 for invalid_fname in self.__class__.__exclude_files: is_valid_fname += int(not fnmatch.fnmatch(fname, invalid_fname)) if_valid_ext = 0 for ext in self.__class__.__py_extensions: if_valid_ext += int(fnmatch.fnmatch(fname, ext)) return is_valid_fname > 0 and if_valid_ext > 0 def __unixify(self, s): """ stupid windows. converts the backslash to forwardslash for consistency """ return os.path.normpath(s).replace(os.sep, "/") def __importify(self, s, dir=False): """ turns directory separators into dots and removes the ".py*" extension so the string can be used as import statement """ if not dir: dirname, fname = os.path.split(s) if fname.count('.') > 1: #if there's a file named xxx.xx.py, it is not a valid module, so, let's not load it... return imp_stmt_pieces = [dirname.replace("\\", "/").replace("/", "."), os.path.splitext(fname)[0]] if len(imp_stmt_pieces[0]) == 0: imp_stmt_pieces = imp_stmt_pieces[1:] return ".".join(imp_stmt_pieces) else: #handle dir return s.replace("\\", "/").replace("/", ".") def __add_files(self, pyfiles, root, files): """ if files match, appends them to pyfiles. used by os.path.walk fcn """ for fname in files: if self.__is_valid_py_file(fname): name_without_base_dir = self.__unixify(os.path.join(root, fname)) pyfiles.append(name_without_base_dir) def find_import_files(self): """ return a list of files to import """ if self.files_to_tests: pyfiles = self.files_to_tests.keys() else: pyfiles = [] for base_dir in self.files_or_dirs: if os.path.isdir(base_dir): if hasattr(os, 'walk'): for root, dirs, files in os.walk(base_dir): #Note: handling directories that should be excluded from the search because #they don't have __init__.py exclude = {} for d in dirs: for init in ['__init__.py', '__init__.pyo', '__init__.pyc', '__init__.pyw']: if os.path.exists(os.path.join(root, d, init).replace('\\', '/')): break else: exclude[d] = 1 if exclude: new = [] for d in dirs: if d not in exclude: new.append(d) dirs[:] = new self.__add_files(pyfiles, root, files) else: # jython2.1 is too old for os.walk! os.path.walk(base_dir, self.__add_files, pyfiles) elif os.path.isfile(base_dir): pyfiles.append(base_dir) if self.configuration.exclude_files or self.configuration.include_files: ret = [] for f in pyfiles: add = True basename = os.path.basename(f) if self.configuration.include_files: add = False for pat in self.configuration.include_files: if fnmatch.fnmatchcase(basename, pat): add = True break if not add: if self.verbosity > 3: sys.stdout.write('Skipped file: %s (did not match any include_files pattern: %s)\n' % (f, self.configuration.include_files)) elif self.configuration.exclude_files: for pat in self.configuration.exclude_files: if fnmatch.fnmatchcase(basename, pat): if self.verbosity > 3: sys.stdout.write('Skipped file: %s (matched exclude_files pattern: %s)\n' % (f, pat)) elif self.verbosity > 2: sys.stdout.write('Skipped file: %s\n' % (f,)) add = False break if add: if self.verbosity > 3: sys.stdout.write('Adding file: %s for test discovery.\n' % (f,)) ret.append(f) pyfiles = ret return pyfiles def __get_module_from_str(self, modname, print_exception, pyfile): """ Import the module in the given import path. * Returns the "final" module, so importing "coilib40.subject.visu" returns the "visu" module, not the "coilib40" as returned by __import__ """ try: mod = __import__(modname) for part in modname.split('.')[1:]: mod = getattr(mod, part) return mod except: if print_exception: import pydev_runfiles_xml_rpc import pydevd_io buf_err = pydevd_io.StartRedirect(keep_original_redirection=True, std='stderr') buf_out = pydevd_io.StartRedirect(keep_original_redirection=True, std='stdout') try: import traceback;traceback.print_exc() sys.stderr.write('ERROR: Module: %s could not be imported (file: %s).\n' % (modname, pyfile)) finally: pydevd_io.EndRedirect('stderr') pydevd_io.EndRedirect('stdout') pydev_runfiles_xml_rpc.notifyTest( 'error', buf_out.getvalue(), buf_err.getvalue(), pyfile, modname, 0) return None def find_modules_from_files(self, pyfiles): """ returns a list of modules given a list of files """ #let's make sure that the paths we want are in the pythonpath... imports = [(s, self.__importify(s)) for s in pyfiles] system_paths = [] for s in sys.path: system_paths.append(self.__importify(s, True)) ret = [] for pyfile, imp in imports: if imp is None: continue #can happen if a file is not a valid module choices = [] for s in system_paths: if imp.startswith(s): add = imp[len(s) + 1:] if add: choices.append(add) #sys.stdout.write(' ' + add + ' ') if not choices: sys.stdout.write('PYTHONPATH not found for file: %s\n' % imp) else: for i, import_str in enumerate(choices): print_exception = i == len(choices) - 1 mod = self.__get_module_from_str(import_str, print_exception, pyfile) if mod is not None: ret.append((pyfile, mod, import_str)) break return ret #=================================================================================================================== # GetTestCaseNames #=================================================================================================================== class GetTestCaseNames: """Yes, we need a class for that (cannot use outer context on jython 2.1)""" def __init__(self, accepted_classes, accepted_methods): self.accepted_classes = accepted_classes self.accepted_methods = accepted_methods def __call__(self, testCaseClass): """Return a sorted sequence of method names found within testCaseClass""" testFnNames = [] className = testCaseClass.__name__ if DictContains(self.accepted_classes, className): for attrname in dir(testCaseClass): #If a class is chosen, we select all the 'test' methods' if attrname.startswith('test') and hasattr(getattr(testCaseClass, attrname), '__call__'): testFnNames.append(attrname) else: for attrname in dir(testCaseClass): #If we have the class+method name, we must do a full check and have an exact match. if DictContains(self.accepted_methods, className + '.' + attrname): if hasattr(getattr(testCaseClass, attrname), '__call__'): testFnNames.append(attrname) #sorted() is not available in jython 2.1 testFnNames.sort() return testFnNames def _decorate_test_suite(self, suite, pyfile, module_name): import unittest if isinstance(suite, unittest.TestSuite): add = False suite.__pydev_pyfile__ = pyfile suite.__pydev_module_name__ = module_name for t in suite._tests: t.__pydev_pyfile__ = pyfile t.__pydev_module_name__ = module_name if self._decorate_test_suite(t, pyfile, module_name): add = True return add elif isinstance(suite, unittest.TestCase): return True else: return False def find_tests_from_modules(self, file_and_modules_and_module_name): """ returns the unittests given a list of modules """ #Use our own suite! import pydev_runfiles_unittest import unittest unittest.TestLoader.suiteClass = pydev_runfiles_unittest.PydevTestSuite loader = unittest.TestLoader() ret = [] if self.files_to_tests: for pyfile, m, module_name in file_and_modules_and_module_name: accepted_classes = {} accepted_methods = {} tests = self.files_to_tests[pyfile] for t in tests: accepted_methods[t] = t loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods) suite = loader.loadTestsFromModule(m) if self._decorate_test_suite(suite, pyfile, module_name): ret.append(suite) return ret if self.tests: accepted_classes = {} accepted_methods = {} for t in self.tests: splitted = t.split('.') if len(splitted) == 1: accepted_classes[t] = t elif len(splitted) == 2: accepted_methods[t] = t loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods) for pyfile, m, module_name in file_and_modules_and_module_name: suite = loader.loadTestsFromModule(m) if self._decorate_test_suite(suite, pyfile, module_name): ret.append(suite) return ret def filter_tests(self, test_objs, internal_call=False): """ based on a filter name, only return those tests that have the test case names that match """ import unittest if not internal_call: if not self.configuration.include_tests and not self.tests and not self.configuration.exclude_tests: #No need to filter if we have nothing to filter! return test_objs if self.verbosity > 1: if self.configuration.include_tests: sys.stdout.write('Tests to include: %s\n' % (self.configuration.include_tests,)) if self.tests: sys.stdout.write('Tests to run: %s\n' % (self.tests,)) if self.configuration.exclude_tests: sys.stdout.write('Tests to exclude: %s\n' % (self.configuration.exclude_tests,)) test_suite = [] for test_obj in test_objs: if isinstance(test_obj, unittest.TestSuite): #Note: keep the suites as they are and just 'fix' the tests (so, don't use the iter_tests). if test_obj._tests: test_obj._tests = self.filter_tests(test_obj._tests, True) if test_obj._tests: #Only add the suite if we still have tests there. test_suite.append(test_obj) elif isinstance(test_obj, unittest.TestCase): try: testMethodName = test_obj._TestCase__testMethodName except AttributeError: #changed in python 2.5 testMethodName = test_obj._testMethodName add = True if self.configuration.exclude_tests: for pat in self.configuration.exclude_tests: if fnmatch.fnmatchcase(testMethodName, pat): if self.verbosity > 3: sys.stdout.write('Skipped test: %s (matched exclude_tests pattern: %s)\n' % (testMethodName, pat)) elif self.verbosity > 2: sys.stdout.write('Skipped test: %s\n' % (testMethodName,)) add = False break if add: if self.__match_tests(self.tests, test_obj, testMethodName): include = True if self.configuration.include_tests: include = False for pat in self.configuration.include_tests: if fnmatch.fnmatchcase(testMethodName, pat): include = True break if include: test_suite.append(test_obj) else: if self.verbosity > 3: sys.stdout.write('Skipped test: %s (did not match any include_tests pattern %s)\n' % (self.configuration.include_tests,)) return test_suite def iter_tests(self, test_objs): #Note: not using yield because of Jython 2.1. import unittest tests = [] for test_obj in test_objs: if isinstance(test_obj, unittest.TestSuite): tests.extend(self.iter_tests(test_obj._tests)) elif isinstance(test_obj, unittest.TestCase): tests.append(test_obj) return tests def list_test_names(self, test_objs): names = [] for tc in self.iter_tests(test_objs): try: testMethodName = tc._TestCase__testMethodName except AttributeError: #changed in python 2.5 testMethodName = tc._testMethodName names.append(testMethodName) return names def __match_tests(self, tests, test_case, test_method_name): if not tests: return 1 for t in tests: class_and_method = t.split('.') if len(class_and_method) == 1: #only class name if class_and_method[0] == test_case.__class__.__name__: return 1 elif len(class_and_method) == 2: if class_and_method[0] == test_case.__class__.__name__ and class_and_method[1] == test_method_name: return 1 return 0 def __match(self, filter_list, name): """ returns whether a test name matches the test filter """ if filter_list is None: return 1 for f in filter_list: if re.match(f, name): return 1 return 0 def run_tests(self, handle_coverage=True): """ runs all tests """ sys.stdout.write("Finding files... ") files = self.find_import_files() if self.verbosity > 3: sys.stdout.write('%s ... done.\n' % (self.files_or_dirs)) else: sys.stdout.write('done.\n') sys.stdout.write("Importing test modules ... ") if handle_coverage: coverage_files, coverage = StartCoverageSupport(self.configuration) file_and_modules_and_module_name = self.find_modules_from_files(files) sys.stdout.write("done.\n") all_tests = self.find_tests_from_modules(file_and_modules_and_module_name) all_tests = self.filter_tests(all_tests) import pydev_runfiles_unittest test_suite = pydev_runfiles_unittest.PydevTestSuite(all_tests) import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.notifyTestsCollected(test_suite.countTestCases()) start_time = time.time() def run_tests(): executed_in_parallel = False if self.jobs > 1: import pydev_runfiles_parallel #What may happen is that the number of jobs needed is lower than the number of jobs requested #(e.g.: 2 jobs were requested for running 1 test) -- in which case ExecuteTestsInParallel will #return False and won't run any tests. executed_in_parallel = pydev_runfiles_parallel.ExecuteTestsInParallel( all_tests, self.jobs, self.split_jobs, self.verbosity, coverage_files, self.configuration.coverage_include) if not executed_in_parallel: #If in coverage, we don't need to pass anything here (coverage is already enabled for this execution). runner = pydev_runfiles_unittest.PydevTextTestRunner(stream=sys.stdout, descriptions=1, verbosity=self.verbosity) sys.stdout.write('\n') runner.run(test_suite) if self.configuration.django: MyDjangoTestSuiteRunner(run_tests).run_tests([]) else: run_tests() if handle_coverage: coverage.stop() coverage.save() total_time = 'Finished in: %.2f secs.' % (time.time() - start_time,) pydev_runfiles_xml_rpc.notifyTestRunFinished(total_time) try: from django.test.simple import DjangoTestSuiteRunner except: class DjangoTestSuiteRunner: def __init__(self): pass def run_tests(self, *args, **kwargs): raise AssertionError("Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.") class MyDjangoTestSuiteRunner(DjangoTestSuiteRunner): def __init__(self, on_run_suite): DjangoTestSuiteRunner.__init__(self) self.on_run_suite = on_run_suite def build_suite(self, *args, **kwargs): pass def suite_result(self, *args, **kwargs): pass def run_suite(self, *args, **kwargs): self.on_run_suite() #======================================================================================================================= # main #======================================================================================================================= def main(configuration): PydevTestRunner(configuration).run_tests()
epl-1.0
[ 504, 636, 2443, 363, 492, 6032, 63, 14129, 199, 199, 646, 15951, 199, 646, 747, 14, 515, 199, 504, 29240, 63, 1065, 1725, 63, 10828, 492, 7707, 27444, 11532, 199, 504, 29240, 68, 63, 5559, 492, 627, 9213, 20782, 55, 668, 6295, 199, 646, 295, 199, 646, 900, 421, 199, 14813, 12813, 18673, 199, 3, 11595, 199, 14813, 12813, 18673, 199, 533, 11595, 26, 339, 347, 636, 826, 721, 267, 291, 12, 267, 1584, 63, 269, 63, 3220, 4581, 267, 8661, 29, 18, 12, 267, 2387, 63, 2219, 29, 403, 12, 267, 2295, 29, 403, 12, 267, 1844, 29, 403, 12, 267, 1584, 63, 475, 63, 2219, 29, 403, 12, 267, 9643, 29, 17, 12, 267, 3715, 63, 6920, 534, 2219, 297, 267, 11745, 63, 1199, 63, 694, 29, 403, 12, 267, 11745, 63, 2613, 29, 403, 12, 267, 11745, 63, 1199, 63, 493, 29, 403, 12, 267, 5760, 63, 1725, 29, 403, 12, 267, 5760, 63, 2219, 29, 403, 12, 267, 2387, 63, 1725, 29, 403, 12, 267, 1639, 29, 797, 12, 267, 3461, 267, 291, 14, 1725, 63, 269, 63, 3220, 275, 1584, 63, 269, 63, 3220, 267, 291, 14, 9833, 275, 8661, 267, 291, 14, 2613, 63, 2219, 275, 2387, 63, 2219, 267, 291, 14, 2219, 275, 2295, 267, 291, 14, 719, 275, 1844, 267, 291, 14, 1725, 63, 475, 63, 2219, 275, 1584, 63, 475, 63, 2219, 267, 291, 14, 6920, 275, 9643, 267, 291, 14, 1294, 63, 6920, 275, 3715, 63, 6920, 267, 291, 14, 1176, 275, 1639, 398, 340, 2387, 63, 2219, 26, 288, 702, 1228, 8, 2613, 63, 2219, 12, 334, 513, 12, 2008, 430, 398, 340, 5760, 63, 1725, 26, 288, 702, 1228, 8, 5473, 63, 1725, 12, 334, 513, 12, 2008, 430, 398, 340, 5760, 63, 2219, 26, 288, 702, 1228, 8, 5473, 63, 2219, 12, 334, 513, 12, 2008, 430, 398, 291, 14, 5473, 63, 1725, 275, 5760, 63, 1725, 267, 291, 14, 2613, 63, 1725, 275, 2387, 63, 1725, 267, 291, 14, 5473, 63, 2219, 275, 5760, 63, 2219, 398, 291, 14, 10828, 63, 1199, 63, 694, 275, 11745, 63, 1199, 63, 694, 267, 291, 14, 10828, 63, 2613, 275, 11745, 63, 2613, 267, 291, 14, 10828, 63, 1199, 63, 493, 275, 11745, 63, 1199, 63, 493, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1449, 5688, 199, 446, 1584, 63, 269, 63, 3220, 26, 450, 83, 199, 446, 8661, 26, 450, 83, 199, 446, 2295, 26, 450, 83, 199, 446, 1844, 26, 450, 83, 199, 446, 1584, 63, 475, 63, 2219, 26, 450, 83, 199, 446, 9643, 26, 450, 83, 199, 446, 3715, 63, 6920, 26, 450, 83, 421, 446, 2387, 63, 1725, 26, 450, 83, 199, 446, 2387, 63, 2219, 26, 450, 83, 421, 446, 5760, 63, 1725, 26, 450, 83, 199, 446, 5760, 63, 2219, 26, 450, 83, 421, 446, 11745, 63, 1199, 63, 694, 26, 450, 83, 199, 446, 11745, 63, 2613, 63, 694, 26, 450, 83, 199, 446, 11745, 63, 1199, 63, 493, 26, 450, 83, 421, 446, 1639, 26, 450, 83, 199, 2344, 450, 334, 267, 291, 14, 1725, 63, 269, 63, 3220, 12, 267, 291, 14, 9833, 12, 267, 291, 14, 2219, 12, 267, 291, 14, 719, 12, 267, 291, 14, 1725, 63, 475, 63, 2219, 12, 267, 291, 14, 6920, 12, 267, 291, 14, 1294, 63, 6920, 12, 398, 291, 14, 2613, 63, 1725, 12, 267, 291, 14, 2613, 63, 2219, 12, 398, 291, 14, 5473, 63, 1725, 12, 267, 291, 14, 5473, 63, 2219, 12, 398, 291, 14, 10828, 63, 1199, 63, 694, 12, 267, 291, 14, 10828, 63, 2613, 12, 267, 291, 14, 10828, 63, 1199, 63, 493, 12, 398, 291, 14, 1176, 12, 272, 776, 421, 199, 14813, 12813, 18673, 199, 3, 2198, 63, 15612, 199, 14813, 12813, 18673, 199, 318, 2198, 63, 15612, 8, 3020, 29, 403, 304, 272, 408, 272, 29968, 1414, 1004, 436, 2529, 511, 6602, 12, 8661, 12, 511, 2457, 436, 511, 24203, 339, 4503, 26, 267, 1255, 1725, 14, 647, 221, 446, 86, 92, 306, 9833, 665, 1896, 30, 221, 446, 84, 92, 306, 2219, 665, 774, 14, 396, 17, 12, 774, 18, 30, 221, 7606, 92, 1725, 339, 6879, 6338, 1511, 26, 272, 9643, 29, 1955, 334, 1045, 314, 1329, 402, 9643, 370, 506, 1202, 370, 1255, 314, 2295, 9, 272, 3715, 63, 6920, 534, 578, 26972, 2219, 7, 267, 340, 508, 859, 12, 282, 1627, 3906, 911, 3544, 9128, 1006, 314, 2295, 687, 282, 859, 267, 340, 508, 2295, 12, 314, 2295, 911, 506, 3715, 30426, 402, 3932, 6330, 1958, 859, 334, 885, 9, 339, 1553, 5473, 63, 1725, 221, 275, 10029, 13, 12794, 769, 402, 7970, 543, 1584, 370, 5760, 334, 15359, 3449, 9, 272, 1553, 2613, 63, 1725, 275, 10029, 13, 12794, 769, 402, 7970, 543, 1584, 370, 2387, 334, 15359, 3449, 9, 272, 1553, 5473, 63, 2219, 275, 10029, 13, 12794, 769, 402, 7970, 543, 511, 1561, 370, 5760, 334, 15359, 3449, 9, 339, 3390, 26, 340, 1553, 2219, 365, 1627, 12, 1553, 5473, 63, 1725, 12, 1553, 2613, 63, 1725, 436, 1553, 5473, 63, 2219, 787, 5525, 1, 272, 408, 272, 340, 9238, 365, 488, 26, 267, 9238, 275, 984, 14, 3020, 339, 8661, 275, 499, 272, 2387, 63, 2219, 275, 488, 272, 2295, 275, 488, 272, 1844, 275, 488, 272, 9643, 275, 413, 272, 3715, 63, 6920, 275, 283, 2219, 7, 272, 1584, 63, 475, 63, 2219, 275, 1052, 272, 11745, 63, 1199, 63, 694, 275, 488, 272, 11745, 63, 2613, 275, 488, 272, 5760, 63, 1725, 275, 488, 272, 5760, 63, 2219, 275, 488, 272, 2387, 63, 1725, 275, 488, 272, 1639, 275, 756, 339, 687, 485, 23996, 63, 18907, 492, 486, 4850, 63, 18907, 272, 2450, 513, 12, 7606, 275, 486, 4850, 63, 18907, 8, 267, 9238, 59, 17, 8429, 4873, 267, 359, 288, 298, 9833, 11107, 288, 298, 2219, 11107, 953, 298, 719, 11107, 288, 298, 888, 63, 493, 11107, 953, 298, 6920, 11107, 288, 298, 1294, 63, 6920, 11107, 953, 298, 2613, 63, 2219, 11107, 288, 298, 2613, 63, 1725, 11107, 953, 298, 5473, 63, 1725, 11107, 288, 298, 5473, 63, 2219, 11107, 953, 298 ]
[ 636, 2443, 363, 492, 6032, 63, 14129, 199, 199, 646, 15951, 199, 646, 747, 14, 515, 199, 504, 29240, 63, 1065, 1725, 63, 10828, 492, 7707, 27444, 11532, 199, 504, 29240, 68, 63, 5559, 492, 627, 9213, 20782, 55, 668, 6295, 199, 646, 295, 199, 646, 900, 421, 199, 14813, 12813, 18673, 199, 3, 11595, 199, 14813, 12813, 18673, 199, 533, 11595, 26, 339, 347, 636, 826, 721, 267, 291, 12, 267, 1584, 63, 269, 63, 3220, 4581, 267, 8661, 29, 18, 12, 267, 2387, 63, 2219, 29, 403, 12, 267, 2295, 29, 403, 12, 267, 1844, 29, 403, 12, 267, 1584, 63, 475, 63, 2219, 29, 403, 12, 267, 9643, 29, 17, 12, 267, 3715, 63, 6920, 534, 2219, 297, 267, 11745, 63, 1199, 63, 694, 29, 403, 12, 267, 11745, 63, 2613, 29, 403, 12, 267, 11745, 63, 1199, 63, 493, 29, 403, 12, 267, 5760, 63, 1725, 29, 403, 12, 267, 5760, 63, 2219, 29, 403, 12, 267, 2387, 63, 1725, 29, 403, 12, 267, 1639, 29, 797, 12, 267, 3461, 267, 291, 14, 1725, 63, 269, 63, 3220, 275, 1584, 63, 269, 63, 3220, 267, 291, 14, 9833, 275, 8661, 267, 291, 14, 2613, 63, 2219, 275, 2387, 63, 2219, 267, 291, 14, 2219, 275, 2295, 267, 291, 14, 719, 275, 1844, 267, 291, 14, 1725, 63, 475, 63, 2219, 275, 1584, 63, 475, 63, 2219, 267, 291, 14, 6920, 275, 9643, 267, 291, 14, 1294, 63, 6920, 275, 3715, 63, 6920, 267, 291, 14, 1176, 275, 1639, 398, 340, 2387, 63, 2219, 26, 288, 702, 1228, 8, 2613, 63, 2219, 12, 334, 513, 12, 2008, 430, 398, 340, 5760, 63, 1725, 26, 288, 702, 1228, 8, 5473, 63, 1725, 12, 334, 513, 12, 2008, 430, 398, 340, 5760, 63, 2219, 26, 288, 702, 1228, 8, 5473, 63, 2219, 12, 334, 513, 12, 2008, 430, 398, 291, 14, 5473, 63, 1725, 275, 5760, 63, 1725, 267, 291, 14, 2613, 63, 1725, 275, 2387, 63, 1725, 267, 291, 14, 5473, 63, 2219, 275, 5760, 63, 2219, 398, 291, 14, 10828, 63, 1199, 63, 694, 275, 11745, 63, 1199, 63, 694, 267, 291, 14, 10828, 63, 2613, 275, 11745, 63, 2613, 267, 291, 14, 10828, 63, 1199, 63, 493, 275, 11745, 63, 1199, 63, 493, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1449, 5688, 199, 446, 1584, 63, 269, 63, 3220, 26, 450, 83, 199, 446, 8661, 26, 450, 83, 199, 446, 2295, 26, 450, 83, 199, 446, 1844, 26, 450, 83, 199, 446, 1584, 63, 475, 63, 2219, 26, 450, 83, 199, 446, 9643, 26, 450, 83, 199, 446, 3715, 63, 6920, 26, 450, 83, 421, 446, 2387, 63, 1725, 26, 450, 83, 199, 446, 2387, 63, 2219, 26, 450, 83, 421, 446, 5760, 63, 1725, 26, 450, 83, 199, 446, 5760, 63, 2219, 26, 450, 83, 421, 446, 11745, 63, 1199, 63, 694, 26, 450, 83, 199, 446, 11745, 63, 2613, 63, 694, 26, 450, 83, 199, 446, 11745, 63, 1199, 63, 493, 26, 450, 83, 421, 446, 1639, 26, 450, 83, 199, 2344, 450, 334, 267, 291, 14, 1725, 63, 269, 63, 3220, 12, 267, 291, 14, 9833, 12, 267, 291, 14, 2219, 12, 267, 291, 14, 719, 12, 267, 291, 14, 1725, 63, 475, 63, 2219, 12, 267, 291, 14, 6920, 12, 267, 291, 14, 1294, 63, 6920, 12, 398, 291, 14, 2613, 63, 1725, 12, 267, 291, 14, 2613, 63, 2219, 12, 398, 291, 14, 5473, 63, 1725, 12, 267, 291, 14, 5473, 63, 2219, 12, 398, 291, 14, 10828, 63, 1199, 63, 694, 12, 267, 291, 14, 10828, 63, 2613, 12, 267, 291, 14, 10828, 63, 1199, 63, 493, 12, 398, 291, 14, 1176, 12, 272, 776, 421, 199, 14813, 12813, 18673, 199, 3, 2198, 63, 15612, 199, 14813, 12813, 18673, 199, 318, 2198, 63, 15612, 8, 3020, 29, 403, 304, 272, 408, 272, 29968, 1414, 1004, 436, 2529, 511, 6602, 12, 8661, 12, 511, 2457, 436, 511, 24203, 339, 4503, 26, 267, 1255, 1725, 14, 647, 221, 446, 86, 92, 306, 9833, 665, 1896, 30, 221, 446, 84, 92, 306, 2219, 665, 774, 14, 396, 17, 12, 774, 18, 30, 221, 7606, 92, 1725, 339, 6879, 6338, 1511, 26, 272, 9643, 29, 1955, 334, 1045, 314, 1329, 402, 9643, 370, 506, 1202, 370, 1255, 314, 2295, 9, 272, 3715, 63, 6920, 534, 578, 26972, 2219, 7, 267, 340, 508, 859, 12, 282, 1627, 3906, 911, 3544, 9128, 1006, 314, 2295, 687, 282, 859, 267, 340, 508, 2295, 12, 314, 2295, 911, 506, 3715, 30426, 402, 3932, 6330, 1958, 859, 334, 885, 9, 339, 1553, 5473, 63, 1725, 221, 275, 10029, 13, 12794, 769, 402, 7970, 543, 1584, 370, 5760, 334, 15359, 3449, 9, 272, 1553, 2613, 63, 1725, 275, 10029, 13, 12794, 769, 402, 7970, 543, 1584, 370, 2387, 334, 15359, 3449, 9, 272, 1553, 5473, 63, 2219, 275, 10029, 13, 12794, 769, 402, 7970, 543, 511, 1561, 370, 5760, 334, 15359, 3449, 9, 339, 3390, 26, 340, 1553, 2219, 365, 1627, 12, 1553, 5473, 63, 1725, 12, 1553, 2613, 63, 1725, 436, 1553, 5473, 63, 2219, 787, 5525, 1, 272, 408, 272, 340, 9238, 365, 488, 26, 267, 9238, 275, 984, 14, 3020, 339, 8661, 275, 499, 272, 2387, 63, 2219, 275, 488, 272, 2295, 275, 488, 272, 1844, 275, 488, 272, 9643, 275, 413, 272, 3715, 63, 6920, 275, 283, 2219, 7, 272, 1584, 63, 475, 63, 2219, 275, 1052, 272, 11745, 63, 1199, 63, 694, 275, 488, 272, 11745, 63, 2613, 275, 488, 272, 5760, 63, 1725, 275, 488, 272, 5760, 63, 2219, 275, 488, 272, 2387, 63, 1725, 275, 488, 272, 1639, 275, 756, 339, 687, 485, 23996, 63, 18907, 492, 486, 4850, 63, 18907, 272, 2450, 513, 12, 7606, 275, 486, 4850, 63, 18907, 8, 267, 9238, 59, 17, 8429, 4873, 267, 359, 288, 298, 9833, 11107, 288, 298, 2219, 11107, 953, 298, 719, 11107, 288, 298, 888, 63, 493, 11107, 953, 298, 6920, 11107, 288, 298, 1294, 63, 6920, 11107, 953, 298, 2613, 63, 2219, 11107, 288, 298, 2613, 63, 1725, 11107, 953, 298, 5473, 63, 1725, 11107, 288, 298, 5473, 63, 2219, 11107, 953, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
martinrajdl/faunafilm
node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/ordered_dict.py
2354
10366
# Unmodified from http://code.activestate.com/recipes/576693/ # other than to add MIT license header (as specified on page, but not in code). # Linked from Python documentation here: # http://docs.python.org/2/library/collections.html#collections.OrderedDict # # This should be deleted once Py2.7 is available on all bots, see # http://crbug.com/241769. # # Copyright (c) 2009 Raymond Hettinger. # # 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. # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. # Passes Python2.7's test suite and incorporates all the latest updates. try: from thread import get_ident as _get_ident except ImportError: from dummy_thread import get_ident as _get_ident try: from _abcoll import KeysView, ValuesView, ItemsView except ImportError: pass class OrderedDict(dict): 'Dictionary that remembers insertion order' # An inherited dict maps keys to values. # The inherited dict provides __getitem__, __len__, __contains__, and get. # The remaining methods are order-aware. # Big-O running times for all methods are the same as for regular dictionaries. # The internal self.__map dictionary maps keys to links in a doubly linked list. # The circular doubly linked list starts and ends with a sentinel element. # The sentinel element never gets deleted (this simplifies the algorithm). # Each link is stored as a list of length three: [PREV, NEXT, KEY]. def __init__(self, *args, **kwds): '''Initialize an ordered dictionary. Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. ''' if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__root except AttributeError: self.__root = root = [] # sentinel node root[:] = [root, root, None] self.__map = {} self.__update(*args, **kwds) def __setitem__(self, key, value, dict_setitem=dict.__setitem__): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link which goes at the end of the linked # list, and the inherited dictionary is updated with the new key/value pair. if key not in self: root = self.__root last = root[0] last[1] = root[0] = self.__map[key] = [last, root, key] dict_setitem(self, key, value) def __delitem__(self, key, dict_delitem=dict.__delitem__): 'od.__delitem__(y) <==> del od[y]' # Deleting an existing item uses self.__map to find the link which is # then removed by updating the links in the predecessor and successor nodes. dict_delitem(self, key) link_prev, link_next, key = self.__map.pop(key) link_prev[1] = link_next link_next[0] = link_prev def __iter__(self): 'od.__iter__() <==> iter(od)' root = self.__root curr = root[1] while curr is not root: yield curr[2] curr = curr[1] def __reversed__(self): 'od.__reversed__() <==> reversed(od)' root = self.__root curr = root[0] while curr is not root: yield curr[2] curr = curr[0] def clear(self): 'od.clear() -> None. Remove all items from od.' try: for node in self.__map.itervalues(): del node[:] root = self.__root root[:] = [root, root, None] self.__map.clear() except AttributeError: pass dict.clear(self) def popitem(self, last=True): '''od.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false. ''' if not self: raise KeyError('dictionary is empty') root = self.__root if last: link = root[0] link_prev = link[0] link_prev[1] = root root[0] = link_prev else: link = root[1] link_next = link[1] root[1] = link_next link_next[0] = root key = link[2] del self.__map[key] value = dict.pop(self, key) return key, value # -- the following methods do not depend on the internal structure -- def keys(self): 'od.keys() -> list of keys in od' return list(self) def values(self): 'od.values() -> list of values in od' return [self[key] for key in self] def items(self): 'od.items() -> list of (key, value) pairs in od' return [(key, self[key]) for key in self] def iterkeys(self): 'od.iterkeys() -> an iterator over the keys in od' return iter(self) def itervalues(self): 'od.itervalues -> an iterator over the values in od' for k in self: yield self[k] def iteritems(self): 'od.iteritems -> an iterator over the (key, value) items in od' for k in self: yield (k, self[k]) # Suppress 'OrderedDict.update: Method has no argument': # pylint: disable=E0211 def update(*args, **kwds): '''od.update(E, **F) -> None. Update od from dict/iterable E and F. If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v ''' if len(args) > 2: raise TypeError('update() takes at most 2 positional ' 'arguments (%d given)' % (len(args),)) elif not args: raise TypeError('update() takes at least 1 argument (0 given)') self = args[0] # Make progressively weaker assumptions about "other" other = () if len(args) == 2: other = args[1] if isinstance(other, dict): for key in other: self[key] = other[key] elif hasattr(other, 'keys'): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value __update = update # let subclasses override update without breaking __init__ __marker = object() def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' if key in self: result = self[key] del self[key] return result if default is self.__marker: raise KeyError(key) return default def setdefault(self, key, default=None): 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' if key in self: return self[key] self[key] = default return default def __repr__(self, _repr_running={}): 'od.__repr__() <==> repr(od)' call_key = id(self), _get_ident() if call_key in _repr_running: return '...' _repr_running[call_key] = 1 try: if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) finally: del _repr_running[call_key] def __reduce__(self): 'Return state information for pickling' items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S and values equal to v (which defaults to None). ''' d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ''' if isinstance(other, OrderedDict): return len(self)==len(other) and self.items() == other.items() return dict.__eq__(self, other) def __ne__(self, other): return not self == other # -- the following methods are only used in Python 2.7 -- def viewkeys(self): "od.viewkeys() -> a set-like object providing a view on od's keys" return KeysView(self) def viewvalues(self): "od.viewvalues() -> an object providing a view on od's values" return ValuesView(self) def viewitems(self): "od.viewitems() -> a set-like object providing a view on od's items" return ItemsView(self)
mit
[ 3, 1910, 5540, 687, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 3, 1163, 2419, 370, 1050, 10697, 4190, 1406, 334, 305, 2013, 641, 2034, 12, 1325, 440, 315, 1233, 680, 199, 3, 10967, 379, 687, 2018, 3794, 2348, 26, 199, 3, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 7882, 14, 1360, 3, 7882, 14, 16882, 199, 3, 199, 3, 961, 1077, 506, 5463, 5403, 1611, 18, 14, 23, 365, 2808, 641, 1006, 31726, 12, 1937, 199, 3, 1455, 921, 1556, 1266, 14, 957, 15, 1194, 1196, 1876, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 8937, 30703, 2106, 68, 869, 386, 1337, 281, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 199, 3, 10257, 719, 402, 8773, 342, 1021, 626, 7858, 641, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 499, 14, 22, 12, 499, 14, 23, 436, 1134, 647, 14, 199, 3, 510, 1916, 2018, 18, 14, 23, 1159, 511, 5241, 436, 30147, 2335, 1006, 314, 8839, 7029, 14, 199, 199, 893, 26, 272, 687, 2462, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 2590, 3545, 26, 272, 687, 7283, 63, 2671, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 199, 893, 26, 272, 687, 485, 371, 15772, 492, 17276, 2768, 12, 13468, 2768, 12, 20720, 2768, 199, 2590, 3545, 26, 272, 986, 421, 199, 533, 8773, 8, 807, 304, 272, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402, 2582, 7795, 26, 221, 359, 28422, 12, 653, 2472, 12, 9301, 1055, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 18603, 365, 314, 2011, 465, 367, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 267, 2952, 3932, 22470, 1865, 365, 9697, 14, 398, 1449, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 1231, 267, 871, 4281, 26, 288, 291, 855, 1231, 275, 1738, 275, 942, 9326, 327, 13792, 1031, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 275, 1052, 267, 291, 855, 873, 2031, 589, 12, 1011, 10340, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 1211, 63, 8617, 29, 807, 855, 8617, 18580, 267, 283, 364, 855, 8617, 721, 73, 12, 612, 9, 22651, 14467, 59, 73, 10404, 89, 7, 267, 327, 13510, 282, 892, 1242, 8491, 282, 892, 2142, 1314, 13538, 737, 314, 1284, 402, 314, 10632, 267, 327, 769, 12, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 59, 16, 61, 288, 2061, 59, 17, 61, 275, 1738, 59, 16, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 2019, 12, 1738, 12, 790, 61, 267, 1211, 63, 8617, 8, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 12, 1211, 63, 13228, 29, 807, 855, 13228, 18580, 267, 283, 364, 855, 13228, 721, 89, 9, 22651, 2150, 14467, 59, 89, 6616, 267, 327, 15920, 376, 3411, 1242, 4440, 291, 855, 1130, 370, 2342, 314, 2142, 1314, 365, 267, 327, 2066, 4829, 701, 12928, 314, 6220, 315, 314, 876, 27914, 269, 436, 3182, 269, 3380, 14, 267, 1211, 63, 13228, 8, 277, 12, 790, 9, 267, 2142, 63, 5701, 12, 2142, 63, 2184, 12, 790, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 59, 17, 61, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 59, 16, 61, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 17, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 636, 13501, 721 ]
[ 1910, 5540, 687, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 1641, 1272, 3129, 15, 199, 3, 1163, 2419, 370, 1050, 10697, 4190, 1406, 334, 305, 2013, 641, 2034, 12, 1325, 440, 315, 1233, 680, 199, 3, 10967, 379, 687, 2018, 3794, 2348, 26, 199, 3, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 7882, 14, 1360, 3, 7882, 14, 16882, 199, 3, 199, 3, 961, 1077, 506, 5463, 5403, 1611, 18, 14, 23, 365, 2808, 641, 1006, 31726, 12, 1937, 199, 3, 1455, 921, 1556, 1266, 14, 957, 15, 1194, 1196, 1876, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 8937, 30703, 2106, 68, 869, 386, 1337, 281, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 199, 3, 10257, 719, 402, 8773, 342, 1021, 626, 7858, 641, 2018, 499, 14, 20, 12, 499, 14, 21, 12, 499, 14, 22, 12, 499, 14, 23, 436, 1134, 647, 14, 199, 3, 510, 1916, 2018, 18, 14, 23, 1159, 511, 5241, 436, 30147, 2335, 1006, 314, 8839, 7029, 14, 199, 199, 893, 26, 272, 687, 2462, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 2590, 3545, 26, 272, 687, 7283, 63, 2671, 492, 664, 63, 5425, 465, 485, 362, 63, 5425, 199, 199, 893, 26, 272, 687, 485, 371, 15772, 492, 17276, 2768, 12, 13468, 2768, 12, 20720, 2768, 199, 2590, 3545, 26, 272, 986, 421, 199, 533, 8773, 8, 807, 304, 272, 283, 11728, 626, 295, 6334, 22470, 1865, 7, 272, 327, 1626, 12623, 1211, 9033, 2883, 370, 1338, 14, 272, 327, 710, 12623, 1211, 6571, 636, 6095, 3108, 636, 552, 3108, 636, 6134, 3108, 436, 664, 14, 272, 327, 710, 7971, 3102, 787, 1865, 13, 14600, 14, 272, 327, 13123, 13, 47, 3879, 5431, 367, 1006, 3102, 787, 314, 2011, 465, 367, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 2600, 9033, 2883, 370, 6220, 315, 282, 28584, 590, 10632, 769, 14, 272, 327, 710, 15032, 28584, 590, 10632, 769, 9174, 436, 11187, 543, 282, 13792, 1819, 14, 272, 327, 710, 13792, 1819, 7078, 7545, 5463, 334, 3749, 17553, 5604, 314, 5563, 680, 272, 327, 7048, 2142, 365, 5489, 465, 282, 769, 402, 2582, 7795, 26, 221, 359, 28422, 12, 653, 2472, 12, 9301, 1055, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 18603, 365, 314, 2011, 465, 367, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 267, 2952, 3932, 22470, 1865, 365, 9697, 14, 398, 1449, 267, 340, 822, 8, 589, 9, 690, 413, 26, 288, 746, 3146, 360, 2062, 737, 4750, 413, 2368, 12, 4788, 450, 68, 7, 450, 822, 8, 589, 430, 267, 862, 26, 288, 291, 855, 1231, 267, 871, 4281, 26, 288, 291, 855, 1231, 275, 1738, 275, 942, 9326, 327, 13792, 1031, 288, 1738, 5873, 275, 359, 1231, 12, 1738, 12, 488, 61, 288, 291, 855, 1130, 275, 1052, 267, 291, 855, 873, 2031, 589, 12, 1011, 10340, 9, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 1211, 63, 8617, 29, 807, 855, 8617, 18580, 267, 283, 364, 855, 8617, 721, 73, 12, 612, 9, 22651, 14467, 59, 73, 10404, 89, 7, 267, 327, 13510, 282, 892, 1242, 8491, 282, 892, 2142, 1314, 13538, 737, 314, 1284, 402, 314, 10632, 267, 327, 769, 12, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 59, 16, 61, 288, 2061, 59, 17, 61, 275, 1738, 59, 16, 61, 275, 291, 855, 1130, 59, 498, 61, 275, 359, 2019, 12, 1738, 12, 790, 61, 267, 1211, 63, 8617, 8, 277, 12, 790, 12, 574, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 12, 1211, 63, 13228, 29, 807, 855, 13228, 18580, 267, 283, 364, 855, 13228, 721, 89, 9, 22651, 2150, 14467, 59, 89, 6616, 267, 327, 15920, 376, 3411, 1242, 4440, 291, 855, 1130, 370, 2342, 314, 2142, 1314, 365, 267, 327, 2066, 4829, 701, 12928, 314, 6220, 315, 314, 876, 27914, 269, 436, 3182, 269, 3380, 14, 267, 1211, 63, 13228, 8, 277, 12, 790, 9, 267, 2142, 63, 5701, 12, 2142, 63, 2184, 12, 790, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 59, 17, 61, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 59, 16, 61, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 59, 17, 61, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 59, 18, 61, 288, 8230, 275, 8230, 59, 17, 61, 339, 347, 636, 13501, 721, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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#!/usr/bin/env python # -*- coding: utf-8 -*- # This test can be run stand-alone with something like: # > PYTHONPATH=. python2 openerp/tests/test_misc.py ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import unittest2 from openerp.tools import html_sanitize, html_email_clean, append_content_to_html, plaintext2html, email_split import test_mail_examples class TestSanitizer(unittest2.TestCase): """ Test the html sanitizer that filters html to remove unwanted attributes """ def test_basic_sanitizer(self): cases = [ ("yop", "<p>yop</p>"), # simple ("lala<p>yop</p>xxx", "<p>lala</p><p>yop</p>xxx"), # trailing text ("Merci à l'intérêt pour notre produit.nous vous contacterons bientôt. Merci", u"<p>Merci à l'intérêt pour notre produit.nous vous contacterons bientôt. Merci</p>"), # unicode ] for content, expected in cases: html = html_sanitize(content) self.assertEqual(html, expected, 'html_sanitize is broken') def test_mako(self): cases = [ ('''<p>Some text</p> <% set signup_url = object.get_signup_url() %> % if signup_url: <p> You can access this document and pay online via our Customer Portal: </p>''', '''<p>Some text</p> <% set signup_url = object.get_signup_url() %> % if signup_url: <p> You can access this document and pay online via our Customer Portal: </p>''') ] for content, expected in cases: html = html_sanitize(content, silent=False) self.assertEqual(html, expected, 'html_sanitize: broken mako management') def test_evil_malicious_code(self): # taken from https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Tests cases = [ ("<IMG SRC=javascript:alert('XSS')>"), # no quotes and semicolons ("<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>"), # UTF-8 Unicode encoding ("<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>"), # hex encoding ("<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">"), # embedded carriage return ("<IMG SRC=\"jav&#x0A;ascript:alert('XSS');\">"), # embedded newline ("<IMG SRC=\"jav ascript:alert('XSS');\">"), # embedded tab ("<IMG SRC=\"jav&#x09;ascript:alert('XSS');\">"), # embedded encoded tab ("<IMG SRC=\" &#14; javascript:alert('XSS');\">"), # spaces and meta-characters ("<IMG SRC=\"javascript:alert('XSS')\""), # half-open html ("<IMG \"\"\"><SCRIPT>alert(\"XSS\")</SCRIPT>\">"), # malformed tag ("<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>"), # non-alpha-non-digits ("<SCRIPT/SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>"), # non-alpha-non-digits ("<<SCRIPT>alert(\"XSS\");//<</SCRIPT>"), # extraneous open brackets ("<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >"), # non-closing script tags ("<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">"), # input image ("<BODY BACKGROUND=\"javascript:alert('XSS')\">"), # body image ("<IMG DYNSRC=\"javascript:alert('XSS')\">"), # img dynsrc ("<IMG LOWSRC=\"javascript:alert('XSS')\">"), # img lowsrc ("<TABLE BACKGROUND=\"javascript:alert('XSS')\">"), # table ("<TABLE><TD BACKGROUND=\"javascript:alert('XSS')\">"), # td ("<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">"), # div background ("<DIV STYLE=\"background-image:\0075\0072\006C\0028'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029'\0029\">"), # div background with unicoded exploit ("<DIV STYLE=\"background-image: url(&#1;javascript:alert('XSS'))\">"), # div background + extra characters ("<IMG SRC='vbscript:msgbox(\"XSS\")'>"), # VBscrip in an image ("<BODY ONLOAD=alert('XSS')>"), # event handler ("<BR SIZE=\"&{alert('XSS')}\>"), # & javascript includes ("<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">"), # style sheet ("<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">"), # remote style sheet ("<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>"), # remote style sheet 2 ("<META HTTP-EQUIV=\"Link\" Content=\"<http://ha.ckers.org/xss.css>; REL=stylesheet\">"), # remote style sheet 3 ("<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>"), # remote style sheet 4 ("<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">"), # style attribute using a comment to break up expression ] for content in cases: html = html_sanitize(content) self.assertNotIn('javascript', html, 'html_sanitize did not remove a malicious javascript') self.assertTrue('ha.ckers.org' not in html or 'http://ha.ckers.org/xss.css' in html, 'html_sanitize did not remove a malicious code in %s (%s)' % (content, html)) content = "<!--[if gte IE 4]><SCRIPT>alert('XSS');</SCRIPT><![endif]-->" # down-level hidden block self.assertEquals(html_sanitize(content, silent=False), '') def test_html(self): sanitized_html = html_sanitize(test_mail_examples.MISC_HTML_SOURCE) for tag in ['<div', '<b', '<i', '<u', '<strike', '<li', '<blockquote', '<a href']: self.assertIn(tag, sanitized_html, 'html_sanitize stripped too much of original html') for attr in ['javascript']: self.assertNotIn(attr, sanitized_html, 'html_sanitize did not remove enough unwanted attributes') emails = [("Charles <charles.bidule@truc.fr>", "Charles &lt;charles.bidule@truc.fr&gt;"), ("Dupuis <'tr/-: ${dupuis#$'@truc.baz.fr>", "Dupuis &lt;'tr/-: ${dupuis#$'@truc.baz.fr&gt;"), ("Technical <service/technical+2@open.com>", "Technical &lt;service/technical+2@open.com&gt;"), ("Div nico <div-nico@open.com>", "Div nico &lt;div-nico@open.com&gt;")] for email in emails: self.assertIn(email[1], html_sanitize(email[0]), 'html_sanitize stripped emails of original html') def test_edi_source(self): html = html_sanitize(test_mail_examples.EDI_LIKE_HTML_SOURCE) self.assertIn('div style="font-family: \'Lucica Grande\', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF;', html, 'html_sanitize removed valid style attribute') self.assertIn('<span style="color: #222; margin-bottom: 5px; display: block; ">', html, 'html_sanitize removed valid style attribute') self.assertIn('img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"', html, 'html_sanitize removed valid img') self.assertNotIn('</body></html>', html, 'html_sanitize did not remove extra closing tags') class TestCleaner(unittest2.TestCase): """ Test the email cleaner function that filters the content of incoming emails """ def test_00_basic_text(self): """ html_email_clean test for signatures """ test_data = [ ( """This is Sparta!\n--\nAdministrator\n+9988776655""", ['This is Sparta!'], ['Administrator', '9988776655'] ), ( """<p>--\nAdministrator</p>""", [], ['--', 'Administrator'] ), ( """<p>This is Sparta!\n---\nAdministrator</p>""", ['This is Sparta!'], ['---', 'Administrator'] ), ( """<p>--<br>Administrator</p>""", [], [] ), ( """<p>This is Sparta!<br/>--<br>Administrator</p>""", ['This is Sparta!'], [] ), ( """This is Sparta!\n>Ah bon ?\nCertes\n> Chouette !\nClair""", ['This is Sparta!', 'Certes', 'Clair'], ['Ah bon', 'Chouette'] ) ] for test, in_lst, out_lst in test_data: new_html = html_email_clean(test, remove=True) for text in in_lst: self.assertIn(text, new_html, 'html_email_cleaner wrongly removed content') for text in out_lst: self.assertNotIn(text, new_html, 'html_email_cleaner did not remove unwanted content') def test_05_shorten(self): # TEST: shorten length test_str = '''<div> <span> </span> <p>Hello, <span>Raoul</span> <bold>You</bold> are pretty</p> <span>Really</span> </div> ''' # shorten at 'H' of Hello -> should shorten after Hello, html = html_email_clean(test_str, shorten=True, max_length=1, remove=True) self.assertIn('Hello,', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('Raoul', html, 'html_email_cleaner: shorten error or too long') self.assertIn('read more', html, 'html_email_cleaner: shorten error about read more inclusion') # shorten at 'are' -> should shorten after are html = html_email_clean(test_str, shorten=True, max_length=17, remove=True) self.assertIn('Hello,', html, 'html_email_cleaner: shorten error or too short') self.assertIn('Raoul', html, 'html_email_cleaner: shorten error or too short') self.assertIn('are', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('pretty', html, 'html_email_cleaner: shorten error or too long') self.assertNotIn('Really', html, 'html_email_cleaner: shorten error or too long') self.assertIn('read more', html, 'html_email_cleaner: shorten error about read more inclusion') # TEST: shorten in quote test_str = '''<div> Blahble bluih blouh <blockquote>This is a quote <span>And this is quite a long quote, after all.</span> </blockquote> </div>''' # shorten in the quote html = html_email_clean(test_str, shorten=True, max_length=25, remove=True) self.assertIn('Blahble', html, 'html_email_cleaner: shorten error or too short') self.assertIn('bluih', html, 'html_email_cleaner: shorten error or too short') self.assertIn('blouh', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('quote', html, 'html_email_cleaner: shorten error or too long') self.assertIn('read more', html, 'html_email_cleaner: shorten error about read more inclusion') # shorten in second word html = html_email_clean(test_str, shorten=True, max_length=9, remove=True) self.assertIn('Blahble', html, 'html_email_cleaner: shorten error or too short') self.assertIn('bluih', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('blouh', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('quote', html, 'html_email_cleaner: shorten error or too long') self.assertIn('read more', html, 'html_email_cleaner: shorten error about read more inclusion') # shorten waaay too large html = html_email_clean(test_str, shorten=True, max_length=900, remove=True) self.assertIn('Blahble', html, 'html_email_cleaner: shorten error or too short') self.assertIn('bluih', html, 'html_email_cleaner: shorten error or too short') self.assertIn('blouh', html, 'html_email_cleaner: shorten error or too short') self.assertNotIn('quote', html, 'html_email_cleaner: shorten error or too long') def test_10_email_text(self): """ html_email_clean test for text-based emails """ new_html = html_email_clean(test_mail_examples.TEXT_1, remove=True) for ext in test_mail_examples.TEXT_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.TEXT_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') new_html = html_email_clean(test_mail_examples.TEXT_2, remove=True) for ext in test_mail_examples.TEXT_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.TEXT_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_20_email_html(self): new_html = html_email_clean(test_mail_examples.HTML_1, remove=True) for ext in test_mail_examples.HTML_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.HTML_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') new_html = html_email_clean(test_mail_examples.HTML_2, remove=True) for ext in test_mail_examples.HTML_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.HTML_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') # --- MAIL ORIGINAL --- -> can't parse this one currently, too much language-dependent # new_html = html_email_clean(test_mail_examples.HTML_3, remove=False) # for ext in test_mail_examples.HTML_3_IN: # self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') # for ext in test_mail_examples.HTML_3_OUT: # self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_30_email_msoffice(self): new_html = html_email_clean(test_mail_examples.MSOFFICE_1, remove=True) for ext in test_mail_examples.MSOFFICE_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.MSOFFICE_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') new_html = html_email_clean(test_mail_examples.MSOFFICE_2, remove=True) for ext in test_mail_examples.MSOFFICE_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.MSOFFICE_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') new_html = html_email_clean(test_mail_examples.MSOFFICE_3, remove=True) for ext in test_mail_examples.MSOFFICE_3_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.MSOFFICE_3_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_40_email_hotmail(self): new_html = html_email_clean(test_mail_examples.HOTMAIL_1, remove=True) for ext in test_mail_examples.HOTMAIL_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.HOTMAIL_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_50_email_gmail(self): new_html = html_email_clean(test_mail_examples.GMAIL_1, remove=True) for ext in test_mail_examples.GMAIL_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.GMAIL_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_60_email_thunderbird(self): new_html = html_email_clean(test_mail_examples.THUNDERBIRD_1, remove=True) for ext in test_mail_examples.THUNDERBIRD_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.THUNDERBIRD_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase signature / quoted content') def test_70_read_more_and_shorten(self): expand_options = { 'oe_expand_container_class': 'span_class', 'oe_expand_container_content': 'Herbert Einstein', 'oe_expand_separator_node': 'br_lapin', 'oe_expand_a_class': 'a_class', 'oe_expand_a_content': 'read mee', } new_html = html_email_clean(test_mail_examples.OERP_WEBSITE_HTML_1, remove=True, shorten=True, max_length=100, expand_options=expand_options) for ext in test_mail_examples.OERP_WEBSITE_HTML_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.OERP_WEBSITE_HTML_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase overlimit content') for ext in ['<span class="span_class">Herbert Einstein<br_lapin></br_lapin><a href="#" class="a_class">read mee</a></span>']: self.assertIn(ext, new_html, 'html_email_cleaner wrongly take into account specific expand options') new_html = html_email_clean(test_mail_examples.OERP_WEBSITE_HTML_2, remove=True, shorten=True, max_length=200, expand_options=expand_options, protect_sections=False) for ext in test_mail_examples.OERP_WEBSITE_HTML_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.OERP_WEBSITE_HTML_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase overlimit content') for ext in ['<span class="span_class">Herbert Einstein<br_lapin></br_lapin><a href="#" class="a_class">read mee</a></span>']: self.assertIn(ext, new_html, 'html_email_cleaner wrongly take into account specific expand options') new_html = html_email_clean(test_mail_examples.OERP_WEBSITE_HTML_2, remove=True, shorten=True, max_length=200, expand_options=expand_options, protect_sections=True) for ext in test_mail_examples.OERP_WEBSITE_HTML_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed not quoted content') for ext in test_mail_examples.OERP_WEBSITE_HTML_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not erase overlimit content') for ext in [ '<span class="span_class">Herbert Einstein<br_lapin></br_lapin><a href="#" class="a_class">read mee</a></span>', 'tasks using the gantt chart and control deadlines']: self.assertIn(ext, new_html, 'html_email_cleaner wrongly take into account specific expand options') def test_70_read_more(self): new_html = html_email_clean(test_mail_examples.BUG1, remove=True, shorten=True, max_length=100) for ext in test_mail_examples.BUG_1_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') for ext in test_mail_examples.BUG_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') new_html = html_email_clean(test_mail_examples.BUG2, remove=True, shorten=True, max_length=250) for ext in test_mail_examples.BUG_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') for ext in test_mail_examples.BUG_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') new_html = html_email_clean(test_mail_examples.BUG3, remove=True, shorten=True, max_length=250) for ext in test_mail_examples.BUG_3_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') for ext in test_mail_examples.BUG_3_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') def test_90_misc(self): # False boolean for text must return empty string new_html = html_email_clean(False) self.assertEqual(new_html, False, 'html_email_cleaner did change a False in an other value.') # Message with xml and doctype tags don't crash new_html = html_email_clean(u'<?xml version="1.0" encoding="iso-8859-1"?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n <head>\n <title>404 - Not Found</title>\n </head>\n <body>\n <h1>404 - Not Found</h1>\n </body>\n</html>\n') self.assertNotIn('encoding', new_html, 'html_email_cleaner did not remove correctly encoding attributes') class TestHtmlTools(unittest2.TestCase): """ Test some of our generic utility functions about html """ def test_plaintext2html(self): cases = [ ("First \nSecond \nThird\n \nParagraph\n\r--\nSignature paragraph", 'div', "<div><p>First <br/>Second <br/>Third</p><p>Paragraph</p><p>--<br/>Signature paragraph</p></div>"), ("First<p>It should be escaped</p>\nSignature", False, "<p>First&lt;p&gt;It should be escaped&lt;/p&gt;<br/>Signature</p>") ] for content, container_tag, expected in cases: html = plaintext2html(content, container_tag) self.assertEqual(html, expected, 'plaintext2html is broken') def test_append_to_html(self): test_samples = [ ('<!DOCTYPE...><HTML encoding="blah">some <b>content</b></HtMl>', '--\nYours truly', True, True, False, '<!DOCTYPE...><html encoding="blah">some <b>content</b>\n<pre>--\nYours truly</pre>\n</html>'), ('<!DOCTYPE...><HTML encoding="blah">some <b>content</b></HtMl>', '--\nYours truly', True, False, False, '<!DOCTYPE...><html encoding="blah">some <b>content</b>\n<p>--<br/>Yours truly</p>\n</html>'), ('<html><body>some <b>content</b></body></html>', '<!DOCTYPE...>\n<html><body>\n<p>--</p>\n<p>Yours truly</p>\n</body>\n</html>', False, False, False, '<html><body>some <b>content</b>\n\n\n<p>--</p>\n<p>Yours truly</p>\n\n\n</body></html>'), ] for html, content, plaintext_flag, preserve_flag, container_tag, expected in test_samples: self.assertEqual(append_content_to_html(html, content, plaintext_flag, preserve_flag, container_tag), expected, 'append_content_to_html is broken') class TestEmailTools(unittest2.TestCase): """ Test some of our generic utility functions for emails """ def test_email_split(self): cases = [ ("John <12345@gmail.com>", ['12345@gmail.com']), # regular form ("d@x; 1@2", ['d@x', '1@2']), # semi-colon + extra space ("'(ss)' <123@gmail.com>, 'foo' <foo@bar>", ['123@gmail.com', 'foo@bar']), # comma + single-quoting ('"john@gmail.com"<johnny@gmail.com>', ['johnny@gmail.com']), # double-quoting ('"<jg>" <johnny@gmail.com>', ['johnny@gmail.com']), # double-quoting with brackets ] for text, expected in cases: self.assertEqual(email_split(text), expected, 'email_split is broken') if __name__ == '__main__': unittest2.main()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 511, 883, 506, 1255, 10584, 13, 10636, 543, 6020, 2839, 26, 199, 3, 690, 31176, 15856, 2366, 18, 5166, 15, 2219, 15, 396, 63, 9923, 14, 647, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2882, 18, 199, 199, 504, 5166, 14, 2537, 492, 3517, 63, 18177, 12, 3517, 63, 2123, 63, 3118, 12, 5666, 63, 1317, 63, 475, 63, 1360, 12, 18577, 18, 1360, 12, 3031, 63, 1294, 199, 646, 511, 63, 1198, 63, 8589, 421, 199, 533, 1379, 51, 9385, 2282, 8, 2796, 18, 14, 1746, 304, 272, 408, 1379, 314, 3517, 25092, 2282, 626, 4766, 3517, 370, 2813, 625, 19361, 3004, 408, 339, 347, 511, 63, 4316, 63, 83, 9385, 2282, 8, 277, 304, 267, 5560, 275, 359, 288, 1689, 89, 411, 401, 3886, 80, 30, 89, 411, 1108, 80, 30, 1288, 221, 327, 3486, 288, 1689, 76, 14774, 28, 80, 30, 89, 411, 1108, 80, 30, 10013, 401, 3886, 80, 30, 76, 14774, 1108, 80, 2535, 80, 30, 89, 411, 1108, 80, 30, 10013, 1288, 221, 327, 8520, 1318, 288, 1689, 16797, 559, 26031, 634, 7, 442, 5741, 82, 28413, 84, 299, 567, 440, 264, 557, 2033, 390, 14, 889, 527, 373, 1785, 406, 27308, 351, 4654, 330, 6792, 128, 113, 84, 14, 18880, 559, 401, 355, 399, 17030, 80, 30, 16797, 559, 26031, 634, 7, 442, 5741, 82, 28413, 84, 299, 567, 440, 264, 557, 2033, 390, 14, 889, 527, 373, 1785, 406, 27308, 351, 4654, 330, 6792, 128, 113, 84, 14, 18880, 559, 1108, 80, 30, 1288, 221, 327, 2649, 267, 1622, 267, 367, 1564, 12, 1420, 315, 5560, 26, 288, 3517, 275, 3517, 63, 18177, 8, 1317, 9, 288, 291, 14, 629, 8, 1360, 12, 1420, 12, 283, 1360, 63, 18177, 365, 10529, 358, 339, 347, 511, 63, 19491, 8, 277, 304, 267, 5560, 275, 359, 288, 661, 891, 28, 80, 30, 7700, 1318, 1108, 80, 30, 199, 21110, 663, 2070, 384, 63, 633, 275, 909, 14, 362, 63, 19799, 63, 633, 342, 450, 30, 199, 5, 340, 2070, 384, 63, 633, 26, 199, 28, 80, 30, 272, 2047, 883, 2879, 642, 2213, 436, 8633, 18470, 4799, 4154, 22397, 10977, 279, 26, 199, 1108, 80, 30, 18108, 28827, 80, 30, 7700, 1318, 1108, 80, 30, 199, 21110, 663, 2070, 384, 63, 633, 275, 909, 14, 362, 63, 19799, 63, 633, 342, 450, 30, 199, 5, 340, 2070, 384, 63, 633, 26, 199, 28, 80, 30, 272, 2047, 883, 2879, 642, 2213, 436, 8633, 18470, 4799, 4154, 22397, 10977, 279, 26, 199, 1108, 80, 30, 12310, 267, 1622, 267, 367, 1564, 12, 1420, 315, 5560, 26, 288, 3517, 275, 3517, 63, 18177, 8, 1317, 12, 10866, 29, 797, 9, 288, 291, 14, 629, 8, 1360, 12, 1420, 12, 283, 1360, 63, 18177, 26, 10529, 26834, 10041, 358, 339, 347, 511, 63, 6857, 382, 63, 2174, 530, 17326, 63, 600, 8, 277, 304, 267, 327, 9394, 687, 4178, 921, 1544, 14, 583, 20222, 14, 1308, 15, 1080, 14, 8624, 15, 56, 2300, 63, 4131, 63, 37, 4755, 1636, 63, 35, 16614, 63, 16715, 3, 2925, 267, 5560, 275, 359, 288, 1689, 28, 26246, 428, 8205, 29, 9554, 26, 9241, 360, 56, 2300, 358, 30, 1288, 221, 327, 949, 9344, 436, 18734, 761, 4654, 288, 1689, 28, 26246, 428, 8205, 29, 7997, 7357, 14328, 2576, 14328, 7906, 14328, 2576, 14328, 7680, 14328, 1020, 14328, 7636, 14328, 7320, 14328, 6094, 14328, 7524, 14328, 2010, 14328, 2576, 14328, 8079, 14328, 4893, 14328, 7636, 14328, 7524, 14328, 2167, 14328, 1355, 14328, 1299, 14328, 2658, 14328, 2658, 14328, 1355, 14328, 2953, 27, 30, 1288, 221, 327, 9094, 13, 24, 6140, 2644, 288, 1689, 28, 26246, 428, 8205, 29, 7997, 88, 22, 33, 7997, 88, 2976, 7997, 88, 2114, 7997, 88, 2976, 7997, 88, 2898, 7997, 88, 2766, 7997, 88, 2819, 7997, 88, 1876, 7997, 88, 2760, 7997, 88, 1342, 7997, 88, 19, 33, 7997, 88, 2976, 7997, 88, 22, 35, 7997, 88, 2182, 7997, 88, 2819, 7997, 88, 1342, 7997, 88, 1651, 7997, 88, 1465, 7997, 88, 2010, 7997, 88, 2481, 7997, 88, 2481, 7997, 88, 1465, 7997, 88, 1398, 30, 1288, 221, 327, 6318, 2644, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 16, 36, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 9590, 25220, 372, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 16, 33, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 8057, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 257, 465, 1669, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 5174, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 1643, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 5737, 5174, 288, 1689, 28, 26246, 428, 8205, 8178, 1253, 3, 1079, 27, 221, 18910 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 511, 883, 506, 1255, 10584, 13, 10636, 543, 6020, 2839, 26, 199, 3, 690, 31176, 15856, 2366, 18, 5166, 15, 2219, 15, 396, 63, 9923, 14, 647, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2882, 18, 199, 199, 504, 5166, 14, 2537, 492, 3517, 63, 18177, 12, 3517, 63, 2123, 63, 3118, 12, 5666, 63, 1317, 63, 475, 63, 1360, 12, 18577, 18, 1360, 12, 3031, 63, 1294, 199, 646, 511, 63, 1198, 63, 8589, 421, 199, 533, 1379, 51, 9385, 2282, 8, 2796, 18, 14, 1746, 304, 272, 408, 1379, 314, 3517, 25092, 2282, 626, 4766, 3517, 370, 2813, 625, 19361, 3004, 408, 339, 347, 511, 63, 4316, 63, 83, 9385, 2282, 8, 277, 304, 267, 5560, 275, 359, 288, 1689, 89, 411, 401, 3886, 80, 30, 89, 411, 1108, 80, 30, 1288, 221, 327, 3486, 288, 1689, 76, 14774, 28, 80, 30, 89, 411, 1108, 80, 30, 10013, 401, 3886, 80, 30, 76, 14774, 1108, 80, 2535, 80, 30, 89, 411, 1108, 80, 30, 10013, 1288, 221, 327, 8520, 1318, 288, 1689, 16797, 559, 26031, 634, 7, 442, 5741, 82, 28413, 84, 299, 567, 440, 264, 557, 2033, 390, 14, 889, 527, 373, 1785, 406, 27308, 351, 4654, 330, 6792, 128, 113, 84, 14, 18880, 559, 401, 355, 399, 17030, 80, 30, 16797, 559, 26031, 634, 7, 442, 5741, 82, 28413, 84, 299, 567, 440, 264, 557, 2033, 390, 14, 889, 527, 373, 1785, 406, 27308, 351, 4654, 330, 6792, 128, 113, 84, 14, 18880, 559, 1108, 80, 30, 1288, 221, 327, 2649, 267, 1622, 267, 367, 1564, 12, 1420, 315, 5560, 26, 288, 3517, 275, 3517, 63, 18177, 8, 1317, 9, 288, 291, 14, 629, 8, 1360, 12, 1420, 12, 283, 1360, 63, 18177, 365, 10529, 358, 339, 347, 511, 63, 19491, 8, 277, 304, 267, 5560, 275, 359, 288, 661, 891, 28, 80, 30, 7700, 1318, 1108, 80, 30, 199, 21110, 663, 2070, 384, 63, 633, 275, 909, 14, 362, 63, 19799, 63, 633, 342, 450, 30, 199, 5, 340, 2070, 384, 63, 633, 26, 199, 28, 80, 30, 272, 2047, 883, 2879, 642, 2213, 436, 8633, 18470, 4799, 4154, 22397, 10977, 279, 26, 199, 1108, 80, 30, 18108, 28827, 80, 30, 7700, 1318, 1108, 80, 30, 199, 21110, 663, 2070, 384, 63, 633, 275, 909, 14, 362, 63, 19799, 63, 633, 342, 450, 30, 199, 5, 340, 2070, 384, 63, 633, 26, 199, 28, 80, 30, 272, 2047, 883, 2879, 642, 2213, 436, 8633, 18470, 4799, 4154, 22397, 10977, 279, 26, 199, 1108, 80, 30, 12310, 267, 1622, 267, 367, 1564, 12, 1420, 315, 5560, 26, 288, 3517, 275, 3517, 63, 18177, 8, 1317, 12, 10866, 29, 797, 9, 288, 291, 14, 629, 8, 1360, 12, 1420, 12, 283, 1360, 63, 18177, 26, 10529, 26834, 10041, 358, 339, 347, 511, 63, 6857, 382, 63, 2174, 530, 17326, 63, 600, 8, 277, 304, 267, 327, 9394, 687, 4178, 921, 1544, 14, 583, 20222, 14, 1308, 15, 1080, 14, 8624, 15, 56, 2300, 63, 4131, 63, 37, 4755, 1636, 63, 35, 16614, 63, 16715, 3, 2925, 267, 5560, 275, 359, 288, 1689, 28, 26246, 428, 8205, 29, 9554, 26, 9241, 360, 56, 2300, 358, 30, 1288, 221, 327, 949, 9344, 436, 18734, 761, 4654, 288, 1689, 28, 26246, 428, 8205, 29, 7997, 7357, 14328, 2576, 14328, 7906, 14328, 2576, 14328, 7680, 14328, 1020, 14328, 7636, 14328, 7320, 14328, 6094, 14328, 7524, 14328, 2010, 14328, 2576, 14328, 8079, 14328, 4893, 14328, 7636, 14328, 7524, 14328, 2167, 14328, 1355, 14328, 1299, 14328, 2658, 14328, 2658, 14328, 1355, 14328, 2953, 27, 30, 1288, 221, 327, 9094, 13, 24, 6140, 2644, 288, 1689, 28, 26246, 428, 8205, 29, 7997, 88, 22, 33, 7997, 88, 2976, 7997, 88, 2114, 7997, 88, 2976, 7997, 88, 2898, 7997, 88, 2766, 7997, 88, 2819, 7997, 88, 1876, 7997, 88, 2760, 7997, 88, 1342, 7997, 88, 19, 33, 7997, 88, 2976, 7997, 88, 22, 35, 7997, 88, 2182, 7997, 88, 2819, 7997, 88, 1342, 7997, 88, 1651, 7997, 88, 1465, 7997, 88, 2010, 7997, 88, 2481, 7997, 88, 2481, 7997, 88, 1465, 7997, 88, 1398, 30, 1288, 221, 327, 6318, 2644, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 16, 36, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 9590, 25220, 372, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 16, 33, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 8057, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 257, 465, 1669, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 5174, 288, 1689, 28, 26246, 428, 8205, 8178, 30738, 7997, 88, 1643, 27, 7229, 26, 9241, 360, 56, 2300, 358, 3779, 1743, 1288, 221, 327, 12169, 5737, 5174, 288, 1689, 28, 26246, 428, 8205, 8178, 1253, 3, 1079, 27, 221, 18910, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
petecummings/django
django/db/migrations/autodetector.py
140
56583
from __future__ import unicode_literals import datetime import re from itertools import chain from django.conf import settings from django.db import models from django.db.migrations import operations from django.db.migrations.migration import Migration from django.db.migrations.operations.models import AlterModelOptions from django.db.migrations.optimizer import MigrationOptimizer from django.db.migrations.questioner import MigrationQuestioner from django.db.migrations.utils import COMPILED_REGEX_TYPE, RegexObject from django.utils import six from .topological_sort import stable_topological_sort class MigrationAutodetector(object): """ Takes a pair of ProjectStates, and compares them to see what the first would need doing to make it match the second (the second usually being the project's current state). Note that this naturally operates on entire projects at a time, as it's likely that changes interact (for example, you can't add a ForeignKey without having a migration to add the table it depends on first). A user interface may offer single-app usage if it wishes, with the caveat that it may not always be possible. """ def __init__(self, from_state, to_state, questioner=None): self.from_state = from_state self.to_state = to_state self.questioner = questioner or MigrationQuestioner() self.existing_apps = {app for app, model in from_state.models} def changes(self, graph, trim_to_apps=None, convert_apps=None, migration_name=None): """ Main entry point to produce a list of appliable changes. Takes a graph to base names on and an optional set of apps to try and restrict to (restriction is not guaranteed) """ changes = self._detect_changes(convert_apps, graph) changes = self.arrange_for_graph(changes, graph, migration_name) if trim_to_apps: changes = self._trim_to_apps(changes, trim_to_apps) return changes def deep_deconstruct(self, obj): """ Recursive deconstruction for a field and its arguments. Used for full comparison for rename/alter; sometimes a single-level deconstruction will not compare correctly. """ if isinstance(obj, list): return [self.deep_deconstruct(value) for value in obj] elif isinstance(obj, tuple): return tuple(self.deep_deconstruct(value) for value in obj) elif isinstance(obj, dict): return { key: self.deep_deconstruct(value) for key, value in obj.items() } elif isinstance(obj, COMPILED_REGEX_TYPE): return RegexObject(obj) elif isinstance(obj, type): # If this is a type that implements 'deconstruct' as an instance method, # avoid treating this as being deconstructible itself - see #22951 return obj elif hasattr(obj, 'deconstruct'): deconstructed = obj.deconstruct() if isinstance(obj, models.Field): # we have a field which also returns a name deconstructed = deconstructed[1:] path, args, kwargs = deconstructed return ( path, [self.deep_deconstruct(value) for value in args], { key: self.deep_deconstruct(value) for key, value in kwargs.items() }, ) else: return obj def only_relation_agnostic_fields(self, fields): """ Return a definition of the fields that ignores field names and what related fields actually relate to. Used for detecting renames (as, of course, the related fields change during renames) """ fields_def = [] for name, field in sorted(fields): deconstruction = self.deep_deconstruct(field) if field.remote_field and field.remote_field.model: del deconstruction[2]['to'] fields_def.append(deconstruction) return fields_def def _detect_changes(self, convert_apps=None, graph=None): """ Returns a dict of migration plans which will achieve the change from from_state to to_state. The dict has app labels as keys and a list of migrations as values. The resulting migrations aren't specially named, but the names do matter for dependencies inside the set. convert_apps is the list of apps to convert to use migrations (i.e. to make initial migrations for, in the usual case) graph is an optional argument that, if provided, can help improve dependency generation and avoid potential circular dependencies. """ # The first phase is generating all the operations for each app # and gathering them into a big per-app list. # We'll then go through that list later and order it and split # into migrations to resolve dependencies caused by M2Ms and FKs. self.generated_operations = {} # Prepare some old/new state and model lists, separating # proxy models and ignoring unmigrated apps. self.old_apps = self.from_state.concrete_apps self.new_apps = self.to_state.apps self.old_model_keys = [] self.old_proxy_keys = [] self.old_unmanaged_keys = [] self.new_model_keys = [] self.new_proxy_keys = [] self.new_unmanaged_keys = [] for al, mn in sorted(self.from_state.models.keys()): model = self.old_apps.get_model(al, mn) if not model._meta.managed: self.old_unmanaged_keys.append((al, mn)) elif al not in self.from_state.real_apps: if model._meta.proxy: self.old_proxy_keys.append((al, mn)) else: self.old_model_keys.append((al, mn)) for al, mn in sorted(self.to_state.models.keys()): model = self.new_apps.get_model(al, mn) if not model._meta.managed: self.new_unmanaged_keys.append((al, mn)) elif ( al not in self.from_state.real_apps or (convert_apps and al in convert_apps) ): if model._meta.proxy: self.new_proxy_keys.append((al, mn)) else: self.new_model_keys.append((al, mn)) # Renames have to come first self.generate_renamed_models() # Prepare lists of fields and generate through model map self._prepare_field_lists() self._generate_through_model_map() # Generate non-rename model operations self.generate_deleted_models() self.generate_created_models() self.generate_deleted_proxies() self.generate_created_proxies() self.generate_altered_options() self.generate_altered_managers() # Generate field operations self.generate_renamed_fields() self.generate_removed_fields() self.generate_added_fields() self.generate_altered_fields() self.generate_altered_unique_together() self.generate_altered_index_together() self.generate_altered_db_table() self.generate_altered_order_with_respect_to() self._sort_migrations() self._build_migration_list(graph) self._optimize_migrations() return self.migrations def _prepare_field_lists(self): """ Prepare field lists, and prepare a list of the fields that used through models in the old state so we can make dependencies from the through model deletion to the field that uses it. """ self.kept_model_keys = set(self.old_model_keys).intersection(self.new_model_keys) self.kept_proxy_keys = set(self.old_proxy_keys).intersection(self.new_proxy_keys) self.kept_unmanaged_keys = set(self.old_unmanaged_keys).intersection(self.new_unmanaged_keys) self.through_users = {} self.old_field_keys = set() self.new_field_keys = set() for app_label, model_name in sorted(self.kept_model_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] self.old_field_keys.update((app_label, model_name, x) for x, y in old_model_state.fields) self.new_field_keys.update((app_label, model_name, x) for x, y in new_model_state.fields) def _generate_through_model_map(self): """ Through model map generation """ for app_label, model_name in sorted(self.old_model_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] for field_name, field in old_model_state.fields: old_field = self.old_apps.get_model(app_label, old_model_name)._meta.get_field(field_name) if (hasattr(old_field, "remote_field") and getattr(old_field.remote_field, "through", None) and not old_field.remote_field.through._meta.auto_created): through_key = ( old_field.remote_field.through._meta.app_label, old_field.remote_field.through._meta.model_name, ) self.through_users[through_key] = (app_label, old_model_name, field_name) def _build_migration_list(self, graph=None): """ We need to chop the lists of operations up into migrations with dependencies on each other. We do this by stepping up an app's list of operations until we find one that has an outgoing dependency that isn't in another app's migration yet (hasn't been chopped off its list). We then chop off the operations before it into a migration and move onto the next app. If we loop back around without doing anything, there's a circular dependency (which _should_ be impossible as the operations are all split at this point so they can't depend and be depended on). """ self.migrations = {} num_ops = sum(len(x) for x in self.generated_operations.values()) chop_mode = False while num_ops: # On every iteration, we step through all the apps and see if there # is a completed set of operations. # If we find that a subset of the operations are complete we can # try to chop it off from the rest and continue, but we only # do this if we've already been through the list once before # without any chopping and nothing has changed. for app_label in sorted(self.generated_operations.keys()): chopped = [] dependencies = set() for operation in list(self.generated_operations[app_label]): deps_satisfied = True operation_dependencies = set() for dep in operation._auto_deps: is_swappable_dep = False if dep[0] == "__setting__": # We need to temporarily resolve the swappable dependency to prevent # circular references. While keeping the dependency checks on the # resolved model we still add the swappable dependencies. # See #23322 resolved_app_label, resolved_object_name = getattr(settings, dep[1]).split('.') original_dep = dep dep = (resolved_app_label, resolved_object_name.lower(), dep[2], dep[3]) is_swappable_dep = True if dep[0] != app_label and dep[0] != "__setting__": # External app dependency. See if it's not yet # satisfied. for other_operation in self.generated_operations.get(dep[0], []): if self.check_dependency(other_operation, dep): deps_satisfied = False break if not deps_satisfied: break else: if is_swappable_dep: operation_dependencies.add((original_dep[0], original_dep[1])) elif dep[0] in self.migrations: operation_dependencies.add((dep[0], self.migrations[dep[0]][-1].name)) else: # If we can't find the other app, we add a first/last dependency, # but only if we've already been through once and checked everything if chop_mode: # If the app already exists, we add a dependency on the last migration, # as we don't know which migration contains the target field. # If it's not yet migrated or has no migrations, we use __first__ if graph and graph.leaf_nodes(dep[0]): operation_dependencies.add(graph.leaf_nodes(dep[0])[0]) else: operation_dependencies.add((dep[0], "__first__")) else: deps_satisfied = False if deps_satisfied: chopped.append(operation) dependencies.update(operation_dependencies) self.generated_operations[app_label] = self.generated_operations[app_label][1:] else: break # Make a migration! Well, only if there's stuff to put in it if dependencies or chopped: if not self.generated_operations[app_label] or chop_mode: subclass = type(str("Migration"), (Migration,), {"operations": [], "dependencies": []}) instance = subclass("auto_%i" % (len(self.migrations.get(app_label, [])) + 1), app_label) instance.dependencies = list(dependencies) instance.operations = chopped instance.initial = app_label not in self.existing_apps self.migrations.setdefault(app_label, []).append(instance) chop_mode = False else: self.generated_operations[app_label] = chopped + self.generated_operations[app_label] new_num_ops = sum(len(x) for x in self.generated_operations.values()) if new_num_ops == num_ops: if not chop_mode: chop_mode = True else: raise ValueError("Cannot resolve operation dependencies: %r" % self.generated_operations) num_ops = new_num_ops def _sort_migrations(self): """ Reorder to make things possible. The order we have already isn't bad, but we need to pull a few things around so FKs work nicely inside the same app """ for app_label, ops in sorted(self.generated_operations.items()): # construct a dependency graph for intra-app dependencies dependency_graph = {op: set() for op in ops} for op in ops: for dep in op._auto_deps: if dep[0] == app_label: for op2 in ops: if self.check_dependency(op2, dep): dependency_graph[op].add(op2) # we use a stable sort for deterministic tests & general behavior self.generated_operations[app_label] = stable_topological_sort(ops, dependency_graph) def _optimize_migrations(self): # Add in internal dependencies among the migrations for app_label, migrations in self.migrations.items(): for m1, m2 in zip(migrations, migrations[1:]): m2.dependencies.append((app_label, m1.name)) # De-dupe dependencies for app_label, migrations in self.migrations.items(): for migration in migrations: migration.dependencies = list(set(migration.dependencies)) # Optimize migrations for app_label, migrations in self.migrations.items(): for migration in migrations: migration.operations = MigrationOptimizer().optimize(migration.operations, app_label=app_label) def check_dependency(self, operation, dependency): """ Returns ``True`` if the given operation depends on the given dependency, ``False`` otherwise. """ # Created model if dependency[2] is None and dependency[3] is True: return ( isinstance(operation, operations.CreateModel) and operation.name_lower == dependency[1].lower() ) # Created field elif dependency[2] is not None and dependency[3] is True: return ( ( isinstance(operation, operations.CreateModel) and operation.name_lower == dependency[1].lower() and any(dependency[2] == x for x, y in operation.fields) ) or ( isinstance(operation, operations.AddField) and operation.model_name_lower == dependency[1].lower() and operation.name_lower == dependency[2].lower() ) ) # Removed field elif dependency[2] is not None and dependency[3] is False: return ( isinstance(operation, operations.RemoveField) and operation.model_name_lower == dependency[1].lower() and operation.name_lower == dependency[2].lower() ) # Removed model elif dependency[2] is None and dependency[3] is False: return ( isinstance(operation, operations.DeleteModel) and operation.name_lower == dependency[1].lower() ) # Field being altered elif dependency[2] is not None and dependency[3] == "alter": return ( isinstance(operation, operations.AlterField) and operation.model_name_lower == dependency[1].lower() and operation.name_lower == dependency[2].lower() ) # order_with_respect_to being unset for a field elif dependency[2] is not None and dependency[3] == "order_wrt_unset": return ( isinstance(operation, operations.AlterOrderWithRespectTo) and operation.name_lower == dependency[1].lower() and (operation.order_with_respect_to or "").lower() != dependency[2].lower() ) # Field is removed and part of an index/unique_together elif dependency[2] is not None and dependency[3] == "foo_together_change": return ( isinstance(operation, (operations.AlterUniqueTogether, operations.AlterIndexTogether)) and operation.name_lower == dependency[1].lower() ) # Unknown dependency. Raise an error. else: raise ValueError("Can't handle dependency %r" % (dependency, )) def add_operation(self, app_label, operation, dependencies=None, beginning=False): # Dependencies are (app_label, model_name, field_name, create/delete as True/False) operation._auto_deps = dependencies or [] if beginning: self.generated_operations.setdefault(app_label, []).insert(0, operation) else: self.generated_operations.setdefault(app_label, []).append(operation) def swappable_first_key(self, item): """ Sorting key function that places potential swappable models first in lists of created models (only real way to solve #22783) """ try: model = self.new_apps.get_model(item[0], item[1]) base_names = [base.__name__ for base in model.__bases__] string_version = "%s.%s" % (item[0], item[1]) if ( model._meta.swappable or "AbstractUser" in base_names or "AbstractBaseUser" in base_names or settings.AUTH_USER_MODEL.lower() == string_version.lower() ): return ("___" + item[0], "___" + item[1]) except LookupError: pass return item def generate_renamed_models(self): """ Finds any renamed models, and generates the operations for them, and removes the old entry from the model lists. Must be run before other model-level generation. """ self.renamed_models = {} self.renamed_models_rel = {} added_models = set(self.new_model_keys) - set(self.old_model_keys) for app_label, model_name in sorted(added_models): model_state = self.to_state.models[app_label, model_name] model_fields_def = self.only_relation_agnostic_fields(model_state.fields) removed_models = set(self.old_model_keys) - set(self.new_model_keys) for rem_app_label, rem_model_name in removed_models: if rem_app_label == app_label: rem_model_state = self.from_state.models[rem_app_label, rem_model_name] rem_model_fields_def = self.only_relation_agnostic_fields(rem_model_state.fields) if model_fields_def == rem_model_fields_def: if self.questioner.ask_rename_model(rem_model_state, model_state): self.add_operation( app_label, operations.RenameModel( old_name=rem_model_state.name, new_name=model_state.name, ) ) self.renamed_models[app_label, model_name] = rem_model_name renamed_models_rel_key = '%s.%s' % (rem_model_state.app_label, rem_model_state.name) self.renamed_models_rel[renamed_models_rel_key] = '%s.%s' % ( model_state.app_label, model_state.name, ) self.old_model_keys.remove((rem_app_label, rem_model_name)) self.old_model_keys.append((app_label, model_name)) break def generate_created_models(self): """ Find all new models (both managed and unmanaged) and make create operations for them as well as separate operations to create any foreign key or M2M relationships (we'll optimize these back in later if we can). We also defer any model options that refer to collections of fields that might be deferred (e.g. unique_together, index_together). """ old_keys = set(self.old_model_keys).union(self.old_unmanaged_keys) added_models = set(self.new_model_keys) - old_keys added_unmanaged_models = set(self.new_unmanaged_keys) - old_keys all_added_models = chain( sorted(added_models, key=self.swappable_first_key, reverse=True), sorted(added_unmanaged_models, key=self.swappable_first_key, reverse=True) ) for app_label, model_name in all_added_models: model_state = self.to_state.models[app_label, model_name] model_opts = self.new_apps.get_model(app_label, model_name)._meta # Gather related fields related_fields = {} primary_key_rel = None for field in model_opts.local_fields: if field.remote_field: if field.remote_field.model: if field.primary_key: primary_key_rel = field.remote_field.model elif not field.remote_field.parent_link: related_fields[field.name] = field # through will be none on M2Ms on swapped-out models; # we can treat lack of through as auto_created=True, though. if (getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created): related_fields[field.name] = field for field in model_opts.local_many_to_many: if field.remote_field.model: related_fields[field.name] = field if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created: related_fields[field.name] = field # Are there unique/index_together to defer? unique_together = model_state.options.pop('unique_together', None) index_together = model_state.options.pop('index_together', None) order_with_respect_to = model_state.options.pop('order_with_respect_to', None) # Depend on the deletion of any possible proxy version of us dependencies = [ (app_label, model_name, None, False), ] # Depend on all bases for base in model_state.bases: if isinstance(base, six.string_types) and "." in base: base_app_label, base_name = base.split(".", 1) dependencies.append((base_app_label, base_name, None, True)) # Depend on the other end of the primary key if it's a relation if primary_key_rel: dependencies.append(( primary_key_rel._meta.app_label, primary_key_rel._meta.object_name, None, True )) # Generate creation operation self.add_operation( app_label, operations.CreateModel( name=model_state.name, fields=[d for d in model_state.fields if d[0] not in related_fields], options=model_state.options, bases=model_state.bases, managers=model_state.managers, ), dependencies=dependencies, beginning=True, ) # Don't add operations which modify the database for unmanaged models if not model_opts.managed: continue # Generate operations for each related field for name, field in sorted(related_fields.items()): # Account for FKs to swappable models swappable_setting = getattr(field, 'swappable_setting', None) if swappable_setting is not None: dep_app_label = "__setting__" dep_object_name = swappable_setting else: dep_app_label = field.remote_field.model._meta.app_label dep_object_name = field.remote_field.model._meta.object_name dependencies = [(dep_app_label, dep_object_name, None, True)] if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created: dependencies.append(( field.remote_field.through._meta.app_label, field.remote_field.through._meta.object_name, None, True )) # Depend on our own model being created dependencies.append((app_label, model_name, None, True)) # Make operation self.add_operation( app_label, operations.AddField( model_name=model_name, name=name, field=field, ), dependencies=list(set(dependencies)), ) # Generate other opns related_dependencies = [ (app_label, model_name, name, True) for name, field in sorted(related_fields.items()) ] related_dependencies.append((app_label, model_name, None, True)) if unique_together: self.add_operation( app_label, operations.AlterUniqueTogether( name=model_name, unique_together=unique_together, ), dependencies=related_dependencies ) if index_together: self.add_operation( app_label, operations.AlterIndexTogether( name=model_name, index_together=index_together, ), dependencies=related_dependencies ) if order_with_respect_to: self.add_operation( app_label, operations.AlterOrderWithRespectTo( name=model_name, order_with_respect_to=order_with_respect_to, ), dependencies=[ (app_label, model_name, order_with_respect_to, True), (app_label, model_name, None, True), ] ) def generate_created_proxies(self): """ Makes CreateModel statements for proxy models. We use the same statements as that way there's less code duplication, but of course for proxy models we can skip all that pointless field stuff and just chuck out an operation. """ added = set(self.new_proxy_keys) - set(self.old_proxy_keys) for app_label, model_name in sorted(added): model_state = self.to_state.models[app_label, model_name] assert model_state.options.get("proxy") # Depend on the deletion of any possible non-proxy version of us dependencies = [ (app_label, model_name, None, False), ] # Depend on all bases for base in model_state.bases: if isinstance(base, six.string_types) and "." in base: base_app_label, base_name = base.split(".", 1) dependencies.append((base_app_label, base_name, None, True)) # Generate creation operation self.add_operation( app_label, operations.CreateModel( name=model_state.name, fields=[], options=model_state.options, bases=model_state.bases, managers=model_state.managers, ), # Depend on the deletion of any possible non-proxy version of us dependencies=dependencies, ) def generate_deleted_models(self): """ Find all deleted models (managed and unmanaged) and make delete operations for them as well as separate operations to delete any foreign key or M2M relationships (we'll optimize these back in later if we can). We also bring forward removal of any model options that refer to collections of fields - the inverse of generate_created_models(). """ new_keys = set(self.new_model_keys).union(self.new_unmanaged_keys) deleted_models = set(self.old_model_keys) - new_keys deleted_unmanaged_models = set(self.old_unmanaged_keys) - new_keys all_deleted_models = chain(sorted(deleted_models), sorted(deleted_unmanaged_models)) for app_label, model_name in all_deleted_models: model_state = self.from_state.models[app_label, model_name] model = self.old_apps.get_model(app_label, model_name) if not model._meta.managed: # Skip here, no need to handle fields for unmanaged models continue # Gather related fields related_fields = {} for field in model._meta.local_fields: if field.remote_field: if field.remote_field.model: related_fields[field.name] = field # through will be none on M2Ms on swapped-out models; # we can treat lack of through as auto_created=True, though. if (getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created): related_fields[field.name] = field for field in model._meta.local_many_to_many: if field.remote_field.model: related_fields[field.name] = field if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created: related_fields[field.name] = field # Generate option removal first unique_together = model_state.options.pop('unique_together', None) index_together = model_state.options.pop('index_together', None) if unique_together: self.add_operation( app_label, operations.AlterUniqueTogether( name=model_name, unique_together=None, ) ) if index_together: self.add_operation( app_label, operations.AlterIndexTogether( name=model_name, index_together=None, ) ) # Then remove each related field for name, field in sorted(related_fields.items()): self.add_operation( app_label, operations.RemoveField( model_name=model_name, name=name, ) ) # Finally, remove the model. # This depends on both the removal/alteration of all incoming fields # and the removal of all its own related fields, and if it's # a through model the field that references it. dependencies = [] for related_object in model._meta.related_objects: related_object_app_label = related_object.related_model._meta.app_label object_name = related_object.related_model._meta.object_name field_name = related_object.field.name dependencies.append((related_object_app_label, object_name, field_name, False)) if not related_object.many_to_many: dependencies.append((related_object_app_label, object_name, field_name, "alter")) for name, field in sorted(related_fields.items()): dependencies.append((app_label, model_name, name, False)) # We're referenced in another field's through= through_user = self.through_users.get((app_label, model_state.name_lower)) if through_user: dependencies.append((through_user[0], through_user[1], through_user[2], False)) # Finally, make the operation, deduping any dependencies self.add_operation( app_label, operations.DeleteModel( name=model_state.name, ), dependencies=list(set(dependencies)), ) def generate_deleted_proxies(self): """ Makes DeleteModel statements for proxy models. """ deleted = set(self.old_proxy_keys) - set(self.new_proxy_keys) for app_label, model_name in sorted(deleted): model_state = self.from_state.models[app_label, model_name] assert model_state.options.get("proxy") self.add_operation( app_label, operations.DeleteModel( name=model_state.name, ), ) def generate_renamed_fields(self): """ Works out renamed fields """ self.renamed_fields = {} for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] field = self.new_apps.get_model(app_label, model_name)._meta.get_field(field_name) # Scan to see if this is actually a rename! field_dec = self.deep_deconstruct(field) for rem_app_label, rem_model_name, rem_field_name in sorted(self.old_field_keys - self.new_field_keys): if rem_app_label == app_label and rem_model_name == model_name: old_field_dec = self.deep_deconstruct(old_model_state.get_field_by_name(rem_field_name)) if field.remote_field and field.remote_field.model and 'to' in old_field_dec[2]: old_rel_to = old_field_dec[2]['to'] if old_rel_to in self.renamed_models_rel: old_field_dec[2]['to'] = self.renamed_models_rel[old_rel_to] if old_field_dec == field_dec: if self.questioner.ask_rename(model_name, rem_field_name, field_name, field): self.add_operation( app_label, operations.RenameField( model_name=model_name, old_name=rem_field_name, new_name=field_name, ) ) self.old_field_keys.remove((rem_app_label, rem_model_name, rem_field_name)) self.old_field_keys.add((app_label, model_name, field_name)) self.renamed_fields[app_label, model_name, field_name] = rem_field_name break def generate_added_fields(self): """ Fields that have been added """ for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys): self._generate_added_field(app_label, model_name, field_name) def _generate_added_field(self, app_label, model_name, field_name): field = self.new_apps.get_model(app_label, model_name)._meta.get_field(field_name) # Fields that are foreignkeys/m2ms depend on stuff dependencies = [] if field.remote_field and field.remote_field.model: # Account for FKs to swappable models swappable_setting = getattr(field, 'swappable_setting', None) if swappable_setting is not None: dep_app_label = "__setting__" dep_object_name = swappable_setting else: dep_app_label = field.remote_field.model._meta.app_label dep_object_name = field.remote_field.model._meta.object_name dependencies = [(dep_app_label, dep_object_name, None, True)] if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created: dependencies.append(( field.remote_field.through._meta.app_label, field.remote_field.through._meta.object_name, None, True, )) # You can't just add NOT NULL fields with no default or fields # which don't allow empty strings as default. preserve_default = True if (not field.null and not field.has_default() and not isinstance(field, models.ManyToManyField) and not (field.blank and field.empty_strings_allowed)): field = field.clone() field.default = self.questioner.ask_not_null_addition(field_name, model_name) preserve_default = False self.add_operation( app_label, operations.AddField( model_name=model_name, name=field_name, field=field, preserve_default=preserve_default, ), dependencies=dependencies, ) def generate_removed_fields(self): """ Fields that have been removed. """ for app_label, model_name, field_name in sorted(self.old_field_keys - self.new_field_keys): self._generate_removed_field(app_label, model_name, field_name) def _generate_removed_field(self, app_label, model_name, field_name): self.add_operation( app_label, operations.RemoveField( model_name=model_name, name=field_name, ), # We might need to depend on the removal of an # order_with_respect_to or index/unique_together operation; # this is safely ignored if there isn't one dependencies=[ (app_label, model_name, field_name, "order_wrt_unset"), (app_label, model_name, field_name, "foo_together_change"), ], ) def generate_altered_fields(self): """ Fields that have been altered. """ for app_label, model_name, field_name in sorted(self.old_field_keys.intersection(self.new_field_keys)): # Did the field change? old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_field_name = self.renamed_fields.get((app_label, model_name, field_name), field_name) old_field = self.old_apps.get_model(app_label, old_model_name)._meta.get_field(old_field_name) new_field = self.new_apps.get_model(app_label, model_name)._meta.get_field(field_name) # Implement any model renames on relations; these are handled by RenameModel # so we need to exclude them from the comparison if hasattr(new_field, "remote_field") and getattr(new_field.remote_field, "model", None): rename_key = ( new_field.remote_field.model._meta.app_label, new_field.remote_field.model._meta.model_name, ) if rename_key in self.renamed_models: new_field.remote_field.model = old_field.remote_field.model old_field_dec = self.deep_deconstruct(old_field) new_field_dec = self.deep_deconstruct(new_field) if old_field_dec != new_field_dec: both_m2m = ( isinstance(old_field, models.ManyToManyField) and isinstance(new_field, models.ManyToManyField) ) neither_m2m = ( not isinstance(old_field, models.ManyToManyField) and not isinstance(new_field, models.ManyToManyField) ) if both_m2m or neither_m2m: # Either both fields are m2m or neither is preserve_default = True if (old_field.null and not new_field.null and not new_field.has_default() and not isinstance(new_field, models.ManyToManyField)): field = new_field.clone() new_default = self.questioner.ask_not_null_alteration(field_name, model_name) if new_default is not models.NOT_PROVIDED: field.default = new_default preserve_default = False else: field = new_field self.add_operation( app_label, operations.AlterField( model_name=model_name, name=field_name, field=field, preserve_default=preserve_default, ) ) else: # We cannot alter between m2m and concrete fields self._generate_removed_field(app_label, model_name, field_name) self._generate_added_field(app_label, model_name, field_name) def _generate_altered_foo_together(self, operation): option_name = operation.option_name for app_label, model_name in sorted(self.kept_model_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] # We run the old version through the field renames to account for those old_value = old_model_state.options.get(option_name) or set() if old_value: old_value = { tuple( self.renamed_fields.get((app_label, model_name, n), n) for n in unique ) for unique in old_value } new_value = new_model_state.options.get(option_name) or set() if new_value: new_value = set(new_value) if old_value != new_value: self.add_operation( app_label, operation( name=model_name, **{option_name: new_value} ) ) def generate_altered_unique_together(self): self._generate_altered_foo_together(operations.AlterUniqueTogether) def generate_altered_index_together(self): self._generate_altered_foo_together(operations.AlterIndexTogether) def generate_altered_db_table(self): models_to_check = self.kept_model_keys.union(self.kept_proxy_keys).union(self.kept_unmanaged_keys) for app_label, model_name in sorted(models_to_check): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] old_db_table_name = old_model_state.options.get('db_table') new_db_table_name = new_model_state.options.get('db_table') if old_db_table_name != new_db_table_name: self.add_operation( app_label, operations.AlterModelTable( name=model_name, table=new_db_table_name, ) ) def generate_altered_options(self): """ Works out if any non-schema-affecting options have changed and makes an operation to represent them in state changes (in case Python code in migrations needs them) """ models_to_check = self.kept_model_keys.union( self.kept_proxy_keys ).union( self.kept_unmanaged_keys ).union( # unmanaged converted to managed set(self.old_unmanaged_keys).intersection(self.new_model_keys) ).union( # managed converted to unmanaged set(self.old_model_keys).intersection(self.new_unmanaged_keys) ) for app_label, model_name in sorted(models_to_check): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] old_options = dict( option for option in old_model_state.options.items() if option[0] in AlterModelOptions.ALTER_OPTION_KEYS ) new_options = dict( option for option in new_model_state.options.items() if option[0] in AlterModelOptions.ALTER_OPTION_KEYS ) if old_options != new_options: self.add_operation( app_label, operations.AlterModelOptions( name=model_name, options=new_options, ) ) def generate_altered_order_with_respect_to(self): for app_label, model_name in sorted(self.kept_model_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] if (old_model_state.options.get("order_with_respect_to") != new_model_state.options.get("order_with_respect_to")): # Make sure it comes second if we're adding # (removal dependency is part of RemoveField) dependencies = [] if new_model_state.options.get("order_with_respect_to"): dependencies.append(( app_label, model_name, new_model_state.options["order_with_respect_to"], True, )) # Actually generate the operation self.add_operation( app_label, operations.AlterOrderWithRespectTo( name=model_name, order_with_respect_to=new_model_state.options.get('order_with_respect_to'), ), dependencies=dependencies, ) def generate_altered_managers(self): for app_label, model_name in sorted(self.kept_model_keys): old_model_name = self.renamed_models.get((app_label, model_name), model_name) old_model_state = self.from_state.models[app_label, old_model_name] new_model_state = self.to_state.models[app_label, model_name] if old_model_state.managers != new_model_state.managers: self.add_operation( app_label, operations.AlterModelManagers( name=model_name, managers=new_model_state.managers, ) ) def arrange_for_graph(self, changes, graph, migration_name=None): """ Takes in a result from changes() and a MigrationGraph, and fixes the names and dependencies of the changes so they extend the graph from the leaf nodes for each app. """ leaves = graph.leaf_nodes() name_map = {} for app_label, migrations in list(changes.items()): if not migrations: continue # Find the app label's current leaf node app_leaf = None for leaf in leaves: if leaf[0] == app_label: app_leaf = leaf break # Do they want an initial migration for this app? if app_leaf is None and not self.questioner.ask_initial(app_label): # They don't. for migration in migrations: name_map[(app_label, migration.name)] = (app_label, "__first__") del changes[app_label] continue # Work out the next number in the sequence if app_leaf is None: next_number = 1 else: next_number = (self.parse_number(app_leaf[1]) or 0) + 1 # Name each migration for i, migration in enumerate(migrations): if i == 0 and app_leaf: migration.dependencies.append(app_leaf) if i == 0 and not app_leaf: new_name = "0001_%s" % migration_name if migration_name else "0001_initial" else: new_name = "%04i_%s" % ( next_number, migration_name or self.suggest_name(migration.operations)[:100], ) name_map[(app_label, migration.name)] = (app_label, new_name) next_number += 1 migration.name = new_name # Now fix dependencies for app_label, migrations in changes.items(): for migration in migrations: migration.dependencies = [name_map.get(d, d) for d in migration.dependencies] return changes def _trim_to_apps(self, changes, app_labels): """ Takes changes from arrange_for_graph and set of app labels and returns a modified set of changes which trims out as many migrations that are not in app_labels as possible. Note that some other migrations may still be present, as they may be required dependencies. """ # Gather other app dependencies in a first pass app_dependencies = {} for app_label, migrations in changes.items(): for migration in migrations: for dep_app_label, name in migration.dependencies: app_dependencies.setdefault(app_label, set()).add(dep_app_label) required_apps = set(app_labels) # Keep resolving till there's no change old_required_apps = None while old_required_apps != required_apps: old_required_apps = set(required_apps) for app_label in list(required_apps): required_apps.update(app_dependencies.get(app_label, set())) # Remove all migrations that aren't needed for app_label in list(changes.keys()): if app_label not in required_apps: del changes[app_label] return changes @classmethod def suggest_name(cls, ops): """ Given a set of operations, suggests a name for the migration they might represent. Names are not guaranteed to be unique, but we put some effort in to the fallback name to avoid VCS conflicts if we can. """ if len(ops) == 1: if isinstance(ops[0], operations.CreateModel): return ops[0].name_lower elif isinstance(ops[0], operations.DeleteModel): return "delete_%s" % ops[0].name_lower elif isinstance(ops[0], operations.AddField): return "%s_%s" % (ops[0].model_name_lower, ops[0].name_lower) elif isinstance(ops[0], operations.RemoveField): return "remove_%s_%s" % (ops[0].model_name_lower, ops[0].name_lower) elif len(ops) > 1: if all(isinstance(o, operations.CreateModel) for o in ops): return "_".join(sorted(o.name_lower for o in ops)) return "auto_%s" % datetime.datetime.now().strftime("%Y%m%d_%H%M") @classmethod def parse_number(cls, name): """ Given a migration name, tries to extract a number from the beginning of it. If no number found, returns None. """ match = re.match(r'^\d+', name) if match: return int(match.group()) return None
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 295, 199, 504, 7975, 492, 6036, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 7685, 492, 5331, 199, 504, 1639, 14, 697, 14, 7685, 14, 8998, 492, 12090, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 992, 492, 4580, 351, 1685, 4558, 199, 504, 1639, 14, 697, 14, 7685, 14, 12290, 492, 12090, 13946, 199, 504, 1639, 14, 697, 14, 7685, 14, 4790, 281, 492, 12090, 16778, 281, 199, 504, 1639, 14, 697, 14, 7685, 14, 1208, 492, 16503, 11540, 63, 10710, 63, 2711, 12, 12939, 1692, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 16851, 7954, 63, 3191, 492, 17830, 63, 16851, 7954, 63, 3191, 421, 199, 533, 12090, 23570, 380, 9119, 8, 785, 304, 272, 408, 272, 17415, 282, 4092, 402, 7290, 18010, 12, 436, 30827, 3062, 370, 1937, 4052, 314, 272, 1642, 3955, 1929, 9689, 370, 1852, 652, 1336, 314, 3499, 334, 1589, 3499, 272, 9987, 3769, 314, 2199, 1159, 1453, 1174, 680, 339, 3390, 626, 642, 13872, 300, 1183, 1758, 2335, 641, 8039, 11336, 737, 282, 900, 12, 272, 465, 652, 1159, 12060, 626, 4493, 17232, 334, 509, 2893, 12, 1265, 883, 1133, 272, 1050, 282, 12718, 1928, 9445, 282, 8367, 370, 1050, 314, 1817, 652, 272, 8350, 641, 1642, 680, 437, 922, 3217, 1443, 19793, 2849, 13, 571, 4503, 272, 340, 652, 13809, 397, 12, 543, 314, 286, 811, 292, 626, 652, 1443, 440, 3544, 506, 3962, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 687, 63, 929, 12, 370, 63, 929, 12, 7894, 281, 29, 403, 304, 267, 291, 14, 504, 63, 929, 275, 687, 63, 929, 267, 291, 14, 475, 63, 929, 275, 370, 63, 929, 267, 291, 14, 4790, 281, 275, 7894, 281, 503, 12090, 16778, 281, 342, 267, 291, 14, 5952, 63, 5181, 275, 469, 571, 367, 1145, 12, 1402, 315, 687, 63, 929, 14, 992, 93, 339, 347, 4493, 8, 277, 12, 3343, 12, 11639, 63, 475, 63, 5181, 29, 403, 12, 3957, 63, 5181, 29, 403, 12, 8367, 63, 354, 29, 403, 304, 267, 408, 267, 11298, 2397, 2376, 370, 7389, 282, 769, 402, 1145, 317, 461, 4493, 14, 267, 17415, 282, 3343, 370, 1300, 1561, 641, 436, 376, 2716, 663, 402, 8686, 267, 370, 862, 436, 18152, 370, 334, 23423, 365, 440, 17334, 9, 267, 408, 267, 4493, 275, 291, 423, 13552, 63, 6627, 8, 3916, 63, 5181, 12, 3343, 9, 267, 4493, 275, 291, 14, 285, 1842, 63, 509, 63, 2180, 8, 6627, 12, 3343, 12, 8367, 63, 354, 9, 267, 340, 11639, 63, 475, 63, 5181, 26, 288, 4493, 275, 291, 423, 12263, 63, 475, 63, 5181, 8, 6627, 12, 11639, 63, 475, 63, 5181, 9, 267, 372, 4493, 339, 347, 13217, 63, 23693, 8, 277, 12, 1559, 304, 267, 408, 267, 18306, 3398, 477, 12708, 367, 282, 901, 436, 2399, 2368, 14, 267, 8051, 367, 2615, 9132, 367, 11441, 15, 11858, 27, 15026, 282, 2849, 13, 1896, 267, 477, 12708, 911, 440, 6540, 6657, 14, 267, 408, 267, 340, 1228, 8, 1113, 12, 769, 304, 288, 372, 359, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1559, 61, 267, 916, 1228, 8, 1113, 12, 2008, 304, 288, 372, 2008, 8, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1559, 9, 267, 916, 1228, 8, 1113, 12, 1211, 304, 288, 372, 469, 355, 790, 26, 291, 14, 16131, 63, 23693, 8, 585, 9, 355, 367, 790, 12, 574, 315, 1559, 14, 1744, 342, 288, 789, 267, 916, 1228, 8, 1113, 12, 16503, 11540, 63, 10710, 63, 2711, 304, 288, 372, 12939, 1692, 8, 1113, 9, 267, 916, 1228, 8, 1113, 12, 730, 304, 288, 327, 982, 642, 365, 282, 730, 626, 9031, 283, 23693, 7, 465, 376, 1256, 1083, 12, 288, 327, 5126, 20991, 1958, 642, 465, 3769, 477, 388, 9853, 21602, 6337, 446, 1937, 327, 1081, 26525, 288, 372, 1559, 267, 916, 2688, 8, 1113, 12, 283, 23693, 735, 288, 477, 388, 11614, 275, 1559, 14, 23693, 342, 288, 340, 1228, 8, 1113, 12, 1709, 14, 792, 304, 355, 327, 781, 1172, 282, 901, 1314, 2597, 2529, 282, 536, 355, 477, 388, 11614, 275, 477, 388, 11614, 59, 17, 2938, 288, 931, 12, 1249, 12, 2074, 275, 477, 388, 11614, 288, 372, 334, 355, 931, 12, 355, 359, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1249, 467, 355, 469, 490, 790, 26, 291, 14, 16131, 63, 23693, 8, 585, 9, 490, 367, 790, 12, 574, 315, 2074, 14, 1744, 342, 355, 1660, 288, 776, 267, 587, 26, 288, 372, 1559, 339, 347, 1454, 63, 5690, 63, 643, 19075, 63, 955, 8, 277, 12, 1504, 304, 267, 408, 267, 1432, 282, 5492, 402, 314, 1504, 626, 24010, 901, 1561, 436, 267, 4052, 4048, 1504, 5965, 295, 750, 370, 14, 267, 8051, 367, 9696, 316, 295, 1247, 334, 305, 12, 402, 2518, 12, 314, 4048, 1504, 267, 1570, 5309, 295, 1247, 9, 267, 408, 267, 1504, 63, 318, 275, 942, 267, 367, 536, 12, 901, 315, 3355, 8, 955, 304, 288, 477, 12708, 275, 291, 14, 16131, 63, 23693, 8, 698, 9, 288, 340, 901, 14, 3846, 63, 698, 436, 901, 14, 3846, 63, 698, 14, 1238, 26, 355, 2150, 477, 12708, 59, 18, 2733, 475, 418, 288, 1504, 63, 318, 14, 740, 8, 271, 12708, 9, 267, 372, 1504, 63, 318, 339, 347, 485, 13552, 63, 6627, 8, 277, 12, 3957, 63, 5181, 29, 403, 12, 3343, 29, 403, 304, 267, 408, 267, 1803, 282, 1211, 402, 8367, 1620, 796, 1314, 911, 32194, 314, 267, 1570, 687, 687, 63, 929, 370, 370, 63, 929, 14, 710, 1211, 965, 1145, 3628, 267, 465, 2883, 436, 282, 769, 402, 6180, 465, 1338, 14, 398, 710, 9183, 6180, 10621, 1133, 1106, 1183, 4310, 12, 1325, 314, 1561, 267, 886, 17247, 367, 5124, 6272, 314, 663, 14, 398, 3957, 63, 5181, 365, 314, 769, 402, 8686, 370, 3957, 370, 675, 6180, 267, 334, 73, 14, 69, 14, 370, 1852, 2536 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 295, 199, 504, 7975, 492, 6036, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 7685, 492, 5331, 199, 504, 1639, 14, 697, 14, 7685, 14, 8998, 492, 12090, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 992, 492, 4580, 351, 1685, 4558, 199, 504, 1639, 14, 697, 14, 7685, 14, 12290, 492, 12090, 13946, 199, 504, 1639, 14, 697, 14, 7685, 14, 4790, 281, 492, 12090, 16778, 281, 199, 504, 1639, 14, 697, 14, 7685, 14, 1208, 492, 16503, 11540, 63, 10710, 63, 2711, 12, 12939, 1692, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 16851, 7954, 63, 3191, 492, 17830, 63, 16851, 7954, 63, 3191, 421, 199, 533, 12090, 23570, 380, 9119, 8, 785, 304, 272, 408, 272, 17415, 282, 4092, 402, 7290, 18010, 12, 436, 30827, 3062, 370, 1937, 4052, 314, 272, 1642, 3955, 1929, 9689, 370, 1852, 652, 1336, 314, 3499, 334, 1589, 3499, 272, 9987, 3769, 314, 2199, 1159, 1453, 1174, 680, 339, 3390, 626, 642, 13872, 300, 1183, 1758, 2335, 641, 8039, 11336, 737, 282, 900, 12, 272, 465, 652, 1159, 12060, 626, 4493, 17232, 334, 509, 2893, 12, 1265, 883, 1133, 272, 1050, 282, 12718, 1928, 9445, 282, 8367, 370, 1050, 314, 1817, 652, 272, 8350, 641, 1642, 680, 437, 922, 3217, 1443, 19793, 2849, 13, 571, 4503, 272, 340, 652, 13809, 397, 12, 543, 314, 286, 811, 292, 626, 652, 1443, 440, 3544, 506, 3962, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 687, 63, 929, 12, 370, 63, 929, 12, 7894, 281, 29, 403, 304, 267, 291, 14, 504, 63, 929, 275, 687, 63, 929, 267, 291, 14, 475, 63, 929, 275, 370, 63, 929, 267, 291, 14, 4790, 281, 275, 7894, 281, 503, 12090, 16778, 281, 342, 267, 291, 14, 5952, 63, 5181, 275, 469, 571, 367, 1145, 12, 1402, 315, 687, 63, 929, 14, 992, 93, 339, 347, 4493, 8, 277, 12, 3343, 12, 11639, 63, 475, 63, 5181, 29, 403, 12, 3957, 63, 5181, 29, 403, 12, 8367, 63, 354, 29, 403, 304, 267, 408, 267, 11298, 2397, 2376, 370, 7389, 282, 769, 402, 1145, 317, 461, 4493, 14, 267, 17415, 282, 3343, 370, 1300, 1561, 641, 436, 376, 2716, 663, 402, 8686, 267, 370, 862, 436, 18152, 370, 334, 23423, 365, 440, 17334, 9, 267, 408, 267, 4493, 275, 291, 423, 13552, 63, 6627, 8, 3916, 63, 5181, 12, 3343, 9, 267, 4493, 275, 291, 14, 285, 1842, 63, 509, 63, 2180, 8, 6627, 12, 3343, 12, 8367, 63, 354, 9, 267, 340, 11639, 63, 475, 63, 5181, 26, 288, 4493, 275, 291, 423, 12263, 63, 475, 63, 5181, 8, 6627, 12, 11639, 63, 475, 63, 5181, 9, 267, 372, 4493, 339, 347, 13217, 63, 23693, 8, 277, 12, 1559, 304, 267, 408, 267, 18306, 3398, 477, 12708, 367, 282, 901, 436, 2399, 2368, 14, 267, 8051, 367, 2615, 9132, 367, 11441, 15, 11858, 27, 15026, 282, 2849, 13, 1896, 267, 477, 12708, 911, 440, 6540, 6657, 14, 267, 408, 267, 340, 1228, 8, 1113, 12, 769, 304, 288, 372, 359, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1559, 61, 267, 916, 1228, 8, 1113, 12, 2008, 304, 288, 372, 2008, 8, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1559, 9, 267, 916, 1228, 8, 1113, 12, 1211, 304, 288, 372, 469, 355, 790, 26, 291, 14, 16131, 63, 23693, 8, 585, 9, 355, 367, 790, 12, 574, 315, 1559, 14, 1744, 342, 288, 789, 267, 916, 1228, 8, 1113, 12, 16503, 11540, 63, 10710, 63, 2711, 304, 288, 372, 12939, 1692, 8, 1113, 9, 267, 916, 1228, 8, 1113, 12, 730, 304, 288, 327, 982, 642, 365, 282, 730, 626, 9031, 283, 23693, 7, 465, 376, 1256, 1083, 12, 288, 327, 5126, 20991, 1958, 642, 465, 3769, 477, 388, 9853, 21602, 6337, 446, 1937, 327, 1081, 26525, 288, 372, 1559, 267, 916, 2688, 8, 1113, 12, 283, 23693, 735, 288, 477, 388, 11614, 275, 1559, 14, 23693, 342, 288, 340, 1228, 8, 1113, 12, 1709, 14, 792, 304, 355, 327, 781, 1172, 282, 901, 1314, 2597, 2529, 282, 536, 355, 477, 388, 11614, 275, 477, 388, 11614, 59, 17, 2938, 288, 931, 12, 1249, 12, 2074, 275, 477, 388, 11614, 288, 372, 334, 355, 931, 12, 355, 359, 277, 14, 16131, 63, 23693, 8, 585, 9, 367, 574, 315, 1249, 467, 355, 469, 490, 790, 26, 291, 14, 16131, 63, 23693, 8, 585, 9, 490, 367, 790, 12, 574, 315, 2074, 14, 1744, 342, 355, 1660, 288, 776, 267, 587, 26, 288, 372, 1559, 339, 347, 1454, 63, 5690, 63, 643, 19075, 63, 955, 8, 277, 12, 1504, 304, 267, 408, 267, 1432, 282, 5492, 402, 314, 1504, 626, 24010, 901, 1561, 436, 267, 4052, 4048, 1504, 5965, 295, 750, 370, 14, 267, 8051, 367, 9696, 316, 295, 1247, 334, 305, 12, 402, 2518, 12, 314, 4048, 1504, 267, 1570, 5309, 295, 1247, 9, 267, 408, 267, 1504, 63, 318, 275, 942, 267, 367, 536, 12, 901, 315, 3355, 8, 955, 304, 288, 477, 12708, 275, 291, 14, 16131, 63, 23693, 8, 698, 9, 288, 340, 901, 14, 3846, 63, 698, 436, 901, 14, 3846, 63, 698, 14, 1238, 26, 355, 2150, 477, 12708, 59, 18, 2733, 475, 418, 288, 1504, 63, 318, 14, 740, 8, 271, 12708, 9, 267, 372, 1504, 63, 318, 339, 347, 485, 13552, 63, 6627, 8, 277, 12, 3957, 63, 5181, 29, 403, 12, 3343, 29, 403, 304, 267, 408, 267, 1803, 282, 1211, 402, 8367, 1620, 796, 1314, 911, 32194, 314, 267, 1570, 687, 687, 63, 929, 370, 370, 63, 929, 14, 710, 1211, 965, 1145, 3628, 267, 465, 2883, 436, 282, 769, 402, 6180, 465, 1338, 14, 398, 710, 9183, 6180, 10621, 1133, 1106, 1183, 4310, 12, 1325, 314, 1561, 267, 886, 17247, 367, 5124, 6272, 314, 663, 14, 398, 3957, 63, 5181, 365, 314, 769, 402, 8686, 370, 3957, 370, 675, 6180, 267, 334, 73, 14, 69, 14, 370, 1852, 2536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mykytamorachov/outpost
flask/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/vendor/html5lib/tokenizer.py
1710
76929
from __future__ import absolute_import, division, unicode_literals try: chr = unichr # flake8: noqa except NameError: pass from collections import deque from .constants import spaceCharacters from .constants import entities from .constants import asciiLetters, asciiUpper2Lower from .constants import digits, hexDigits, EOF from .constants import tokenTypes, tagTokenTypes from .constants import replacementCharacters from .inputstream import HTMLInputStream from .trie import Trie entitiesTrie = Trie(entities) class HTMLTokenizer(object): """ This class takes care of tokenizing HTML. * self.currentToken Holds the token that is currently being processed. * self.state Holds a reference to the method to be invoked... XXX * self.stream Points to HTMLInputStream object. """ def __init__(self, stream, encoding=None, parseMeta=True, useChardet=True, lowercaseElementName=True, lowercaseAttrName=True, parser=None): self.stream = HTMLInputStream(stream, encoding, parseMeta, useChardet) self.parser = parser # Perform case conversions? self.lowercaseElementName = lowercaseElementName self.lowercaseAttrName = lowercaseAttrName # Setup the initial tokenizer state self.escapeFlag = False self.lastFourChars = [] self.state = self.dataState self.escape = False # The current token being created self.currentToken = None super(HTMLTokenizer, self).__init__() def __iter__(self): """ This is where the magic happens. We do our usually processing through the states and when we have a token to return we yield the token which pauses processing until the next token is requested. """ self.tokenQueue = deque([]) # Start processing. When EOF is reached self.state will return False # instead of True and the loop will terminate. while self.state(): while self.stream.errors: yield {"type": tokenTypes["ParseError"], "data": self.stream.errors.pop(0)} while self.tokenQueue: yield self.tokenQueue.popleft() def consumeNumberEntity(self, isHex): """This function returns either U+FFFD or the character based on the decimal or hexadecimal representation. It also discards ";" if present. If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked. """ allowed = digits radix = 10 if isHex: allowed = hexDigits radix = 16 charStack = [] # Consume all the characters that are in range while making sure we # don't hit an EOF. c = self.stream.char() while c in allowed and c is not EOF: charStack.append(c) c = self.stream.char() # Convert the set of characters consumed to an int. charAsInt = int("".join(charStack), radix) # Certain characters get replaced with others if charAsInt in replacementCharacters: char = replacementCharacters[charAsInt] self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "illegal-codepoint-for-numeric-entity", "datavars": {"charAsInt": charAsInt}}) elif ((0xD800 <= charAsInt <= 0xDFFF) or (charAsInt > 0x10FFFF)): char = "\uFFFD" self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "illegal-codepoint-for-numeric-entity", "datavars": {"charAsInt": charAsInt}}) else: # Should speed up this check somehow (e.g. move the set to a constant) if ((0x0001 <= charAsInt <= 0x0008) or (0x000E <= charAsInt <= 0x001F) or (0x007F <= charAsInt <= 0x009F) or (0xFDD0 <= charAsInt <= 0xFDEF) or charAsInt in frozenset([0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF])): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "illegal-codepoint-for-numeric-entity", "datavars": {"charAsInt": charAsInt}}) try: # Try/except needed as UCS-2 Python builds' unichar only works # within the BMP. char = chr(charAsInt) except ValueError: v = charAsInt - 0x10000 char = chr(0xD800 | (v >> 10)) + chr(0xDC00 | (v & 0x3FF)) # Discard the ; if present. Otherwise, put it back on the queue and # invoke parseError on parser. if c != ";": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "numeric-entity-without-semicolon"}) self.stream.unget(c) return char def consumeEntity(self, allowedChar=None, fromAttribute=False): # Initialise to the default output for when no entity is matched output = "&" charStack = [self.stream.char()] if (charStack[0] in spaceCharacters or charStack[0] in (EOF, "<", "&") or (allowedChar is not None and allowedChar == charStack[0])): self.stream.unget(charStack[0]) elif charStack[0] == "#": # Read the next character to see if it's hex or decimal hex = False charStack.append(self.stream.char()) if charStack[-1] in ("x", "X"): hex = True charStack.append(self.stream.char()) # charStack[-1] should be the first digit if (hex and charStack[-1] in hexDigits) \ or (not hex and charStack[-1] in digits): # At least one digit found, so consume the whole number self.stream.unget(charStack[-1]) output = self.consumeNumberEntity(hex) else: # No digits found self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-numeric-entity"}) self.stream.unget(charStack.pop()) output = "&" + "".join(charStack) else: # At this point in the process might have named entity. Entities # are stored in the global variable "entities". # # Consume characters and compare to these to a substring of the # entity names in the list until the substring no longer matches. while (charStack[-1] is not EOF): if not entitiesTrie.has_keys_with_prefix("".join(charStack)): break charStack.append(self.stream.char()) # At this point we have a string that starts with some characters # that may match an entity # Try to find the longest entity the string will match to take care # of &noti for instance. try: entityName = entitiesTrie.longest_prefix("".join(charStack[:-1])) entityLength = len(entityName) except KeyError: entityName = None if entityName is not None: if entityName[-1] != ";": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "named-entity-without-semicolon"}) if (entityName[-1] != ";" and fromAttribute and (charStack[entityLength] in asciiLetters or charStack[entityLength] in digits or charStack[entityLength] == "=")): self.stream.unget(charStack.pop()) output = "&" + "".join(charStack) else: output = entities[entityName] self.stream.unget(charStack.pop()) output += "".join(charStack[entityLength:]) else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-named-entity"}) self.stream.unget(charStack.pop()) output = "&" + "".join(charStack) if fromAttribute: self.currentToken["data"][-1][1] += output else: if output in spaceCharacters: tokenType = "SpaceCharacters" else: tokenType = "Characters" self.tokenQueue.append({"type": tokenTypes[tokenType], "data": output}) def processEntityInAttribute(self, allowedChar): """This method replaces the need for "entityInAttributeValueState". """ self.consumeEntity(allowedChar=allowedChar, fromAttribute=True) def emitCurrentToken(self): """This method is a generic handler for emitting the tags. It also sets the state to "data" because that's what's needed after a token has been emitted. """ token = self.currentToken # Add token to the queue to be yielded if (token["type"] in tagTokenTypes): if self.lowercaseElementName: token["name"] = token["name"].translate(asciiUpper2Lower) if token["type"] == tokenTypes["EndTag"]: if token["data"]: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "attributes-in-end-tag"}) if token["selfClosing"]: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "self-closing-flag-on-end-tag"}) self.tokenQueue.append(token) self.state = self.dataState # Below are the various tokenizer states worked out. def dataState(self): data = self.stream.char() if data == "&": self.state = self.entityDataState elif data == "<": self.state = self.tagOpenState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\u0000"}) elif data is EOF: # Tokenization ends. return False elif data in spaceCharacters: # Directly after emitting a token you switch back to the "data # state". At that point spaceCharacters are important so they are # emitted separately. self.tokenQueue.append({"type": tokenTypes["SpaceCharacters"], "data": data + self.stream.charsUntil(spaceCharacters, True)}) # No need to update lastFourChars here, since the first space will # have already been appended to lastFourChars and will have broken # any <!-- or --> sequences else: chars = self.stream.charsUntil(("&", "<", "\u0000")) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + chars}) return True def entityDataState(self): self.consumeEntity() self.state = self.dataState return True def rcdataState(self): data = self.stream.char() if data == "&": self.state = self.characterReferenceInRcdata elif data == "<": self.state = self.rcdataLessThanSignState elif data == EOF: # Tokenization ends. return False elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) elif data in spaceCharacters: # Directly after emitting a token you switch back to the "data # state". At that point spaceCharacters are important so they are # emitted separately. self.tokenQueue.append({"type": tokenTypes["SpaceCharacters"], "data": data + self.stream.charsUntil(spaceCharacters, True)}) # No need to update lastFourChars here, since the first space will # have already been appended to lastFourChars and will have broken # any <!-- or --> sequences else: chars = self.stream.charsUntil(("&", "<", "\u0000")) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + chars}) return True def characterReferenceInRcdata(self): self.consumeEntity() self.state = self.rcdataState return True def rawtextState(self): data = self.stream.char() if data == "<": self.state = self.rawtextLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) elif data == EOF: # Tokenization ends. return False else: chars = self.stream.charsUntil(("<", "\u0000")) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + chars}) return True def scriptDataState(self): data = self.stream.char() if data == "<": self.state = self.scriptDataLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) elif data == EOF: # Tokenization ends. return False else: chars = self.stream.charsUntil(("<", "\u0000")) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + chars}) return True def plaintextState(self): data = self.stream.char() if data == EOF: # Tokenization ends. return False elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + self.stream.charsUntil("\u0000")}) return True def tagOpenState(self): data = self.stream.char() if data == "!": self.state = self.markupDeclarationOpenState elif data == "/": self.state = self.closeTagOpenState elif data in asciiLetters: self.currentToken = {"type": tokenTypes["StartTag"], "name": data, "data": [], "selfClosing": False, "selfClosingAcknowledged": False} self.state = self.tagNameState elif data == ">": # XXX In theory it could be something besides a tag name. But # do we really care? self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-tag-name-but-got-right-bracket"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<>"}) self.state = self.dataState elif data == "?": # XXX In theory it could be something besides a tag name. But # do we really care? self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-tag-name-but-got-question-mark"}) self.stream.unget(data) self.state = self.bogusCommentState else: # XXX self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-tag-name"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.stream.unget(data) self.state = self.dataState return True def closeTagOpenState(self): data = self.stream.char() if data in asciiLetters: self.currentToken = {"type": tokenTypes["EndTag"], "name": data, "data": [], "selfClosing": False} self.state = self.tagNameState elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-closing-tag-but-got-right-bracket"}) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-closing-tag-but-got-eof"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</"}) self.state = self.dataState else: # XXX data can be _'_... self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-closing-tag-but-got-char", "datavars": {"data": data}}) self.stream.unget(data) self.state = self.bogusCommentState return True def tagNameState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeAttributeNameState elif data == ">": self.emitCurrentToken() elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-tag-name"}) self.state = self.dataState elif data == "/": self.state = self.selfClosingStartTagState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["name"] += "\uFFFD" else: self.currentToken["name"] += data # (Don't use charsUntil here, because tag names are # very short and it's faster to not do anything fancy) return True def rcdataLessThanSignState(self): data = self.stream.char() if data == "/": self.temporaryBuffer = "" self.state = self.rcdataEndTagOpenState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.stream.unget(data) self.state = self.rcdataState return True def rcdataEndTagOpenState(self): data = self.stream.char() if data in asciiLetters: self.temporaryBuffer += data self.state = self.rcdataEndTagNameState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</"}) self.stream.unget(data) self.state = self.rcdataState return True def rcdataEndTagNameState(self): appropriate = self.currentToken and self.currentToken["name"].lower() == self.temporaryBuffer.lower() data = self.stream.char() if data in spaceCharacters and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.beforeAttributeNameState elif data == "/" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.selfClosingStartTagState elif data == ">" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.emitCurrentToken() self.state = self.dataState elif data in asciiLetters: self.temporaryBuffer += data else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</" + self.temporaryBuffer}) self.stream.unget(data) self.state = self.rcdataState return True def rawtextLessThanSignState(self): data = self.stream.char() if data == "/": self.temporaryBuffer = "" self.state = self.rawtextEndTagOpenState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.stream.unget(data) self.state = self.rawtextState return True def rawtextEndTagOpenState(self): data = self.stream.char() if data in asciiLetters: self.temporaryBuffer += data self.state = self.rawtextEndTagNameState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</"}) self.stream.unget(data) self.state = self.rawtextState return True def rawtextEndTagNameState(self): appropriate = self.currentToken and self.currentToken["name"].lower() == self.temporaryBuffer.lower() data = self.stream.char() if data in spaceCharacters and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.beforeAttributeNameState elif data == "/" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.selfClosingStartTagState elif data == ">" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.emitCurrentToken() self.state = self.dataState elif data in asciiLetters: self.temporaryBuffer += data else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</" + self.temporaryBuffer}) self.stream.unget(data) self.state = self.rawtextState return True def scriptDataLessThanSignState(self): data = self.stream.char() if data == "/": self.temporaryBuffer = "" self.state = self.scriptDataEndTagOpenState elif data == "!": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<!"}) self.state = self.scriptDataEscapeStartState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.stream.unget(data) self.state = self.scriptDataState return True def scriptDataEndTagOpenState(self): data = self.stream.char() if data in asciiLetters: self.temporaryBuffer += data self.state = self.scriptDataEndTagNameState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</"}) self.stream.unget(data) self.state = self.scriptDataState return True def scriptDataEndTagNameState(self): appropriate = self.currentToken and self.currentToken["name"].lower() == self.temporaryBuffer.lower() data = self.stream.char() if data in spaceCharacters and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.beforeAttributeNameState elif data == "/" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.selfClosingStartTagState elif data == ">" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.emitCurrentToken() self.state = self.dataState elif data in asciiLetters: self.temporaryBuffer += data else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</" + self.temporaryBuffer}) self.stream.unget(data) self.state = self.scriptDataState return True def scriptDataEscapeStartState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataEscapeStartDashState else: self.stream.unget(data) self.state = self.scriptDataState return True def scriptDataEscapeStartDashState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataEscapedDashDashState else: self.stream.unget(data) self.state = self.scriptDataState return True def scriptDataEscapedState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataEscapedDashState elif data == "<": self.state = self.scriptDataEscapedLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) elif data == EOF: self.state = self.dataState else: chars = self.stream.charsUntil(("<", "-", "\u0000")) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data + chars}) return True def scriptDataEscapedDashState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataEscapedDashDashState elif data == "<": self.state = self.scriptDataEscapedLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) self.state = self.scriptDataEscapedState elif data == EOF: self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.state = self.scriptDataEscapedState return True def scriptDataEscapedDashDashState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) elif data == "<": self.state = self.scriptDataEscapedLessThanSignState elif data == ">": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": ">"}) self.state = self.scriptDataState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) self.state = self.scriptDataEscapedState elif data == EOF: self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.state = self.scriptDataEscapedState return True def scriptDataEscapedLessThanSignState(self): data = self.stream.char() if data == "/": self.temporaryBuffer = "" self.state = self.scriptDataEscapedEndTagOpenState elif data in asciiLetters: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<" + data}) self.temporaryBuffer = data self.state = self.scriptDataDoubleEscapeStartState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.stream.unget(data) self.state = self.scriptDataEscapedState return True def scriptDataEscapedEndTagOpenState(self): data = self.stream.char() if data in asciiLetters: self.temporaryBuffer = data self.state = self.scriptDataEscapedEndTagNameState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</"}) self.stream.unget(data) self.state = self.scriptDataEscapedState return True def scriptDataEscapedEndTagNameState(self): appropriate = self.currentToken and self.currentToken["name"].lower() == self.temporaryBuffer.lower() data = self.stream.char() if data in spaceCharacters and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.beforeAttributeNameState elif data == "/" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.state = self.selfClosingStartTagState elif data == ">" and appropriate: self.currentToken = {"type": tokenTypes["EndTag"], "name": self.temporaryBuffer, "data": [], "selfClosing": False} self.emitCurrentToken() self.state = self.dataState elif data in asciiLetters: self.temporaryBuffer += data else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "</" + self.temporaryBuffer}) self.stream.unget(data) self.state = self.scriptDataEscapedState return True def scriptDataDoubleEscapeStartState(self): data = self.stream.char() if data in (spaceCharacters | frozenset(("/", ">"))): self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) if self.temporaryBuffer.lower() == "script": self.state = self.scriptDataDoubleEscapedState else: self.state = self.scriptDataEscapedState elif data in asciiLetters: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.temporaryBuffer += data else: self.stream.unget(data) self.state = self.scriptDataEscapedState return True def scriptDataDoubleEscapedState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataDoubleEscapedDashState elif data == "<": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.state = self.scriptDataDoubleEscapedLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) elif data == EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-script-in-script"}) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) return True def scriptDataDoubleEscapedDashState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) self.state = self.scriptDataDoubleEscapedDashDashState elif data == "<": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.state = self.scriptDataDoubleEscapedLessThanSignState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) self.state = self.scriptDataDoubleEscapedState elif data == EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-script-in-script"}) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.state = self.scriptDataDoubleEscapedState return True def scriptDataDoubleEscapedDashDashState(self): data = self.stream.char() if data == "-": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "-"}) elif data == "<": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "<"}) self.state = self.scriptDataDoubleEscapedLessThanSignState elif data == ">": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": ">"}) self.state = self.scriptDataState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "\uFFFD"}) self.state = self.scriptDataDoubleEscapedState elif data == EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-script-in-script"}) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.state = self.scriptDataDoubleEscapedState return True def scriptDataDoubleEscapedLessThanSignState(self): data = self.stream.char() if data == "/": self.tokenQueue.append({"type": tokenTypes["Characters"], "data": "/"}) self.temporaryBuffer = "" self.state = self.scriptDataDoubleEscapeEndState else: self.stream.unget(data) self.state = self.scriptDataDoubleEscapedState return True def scriptDataDoubleEscapeEndState(self): data = self.stream.char() if data in (spaceCharacters | frozenset(("/", ">"))): self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) if self.temporaryBuffer.lower() == "script": self.state = self.scriptDataEscapedState else: self.state = self.scriptDataDoubleEscapedState elif data in asciiLetters: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.temporaryBuffer += data else: self.stream.unget(data) self.state = self.scriptDataDoubleEscapedState return True def beforeAttributeNameState(self): data = self.stream.char() if data in spaceCharacters: self.stream.charsUntil(spaceCharacters, True) elif data in asciiLetters: self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState elif data == ">": self.emitCurrentToken() elif data == "/": self.state = self.selfClosingStartTagState elif data in ("'", '"', "=", "<"): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-character-in-attribute-name"}) self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"].append(["\uFFFD", ""]) self.state = self.attributeNameState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-attribute-name-but-got-eof"}) self.state = self.dataState else: self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState return True def attributeNameState(self): data = self.stream.char() leavingThisState = True emitToken = False if data == "=": self.state = self.beforeAttributeValueState elif data in asciiLetters: self.currentToken["data"][-1][0] += data +\ self.stream.charsUntil(asciiLetters, True) leavingThisState = False elif data == ">": # XXX If we emit here the attributes are converted to a dict # without being checked and when the code below runs we error # because data is a dict not a list emitToken = True elif data in spaceCharacters: self.state = self.afterAttributeNameState elif data == "/": self.state = self.selfClosingStartTagState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"][-1][0] += "\uFFFD" leavingThisState = False elif data in ("'", '"', "<"): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-character-in-attribute-name"}) self.currentToken["data"][-1][0] += data leavingThisState = False elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-attribute-name"}) self.state = self.dataState else: self.currentToken["data"][-1][0] += data leavingThisState = False if leavingThisState: # Attributes are not dropped at this stage. That happens when the # start tag token is emitted so values can still be safely appended # to attributes, but we do want to report the parse error in time. if self.lowercaseAttrName: self.currentToken["data"][-1][0] = ( self.currentToken["data"][-1][0].translate(asciiUpper2Lower)) for name, value in self.currentToken["data"][:-1]: if self.currentToken["data"][-1][0] == name: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "duplicate-attribute"}) break # XXX Fix for above XXX if emitToken: self.emitCurrentToken() return True def afterAttributeNameState(self): data = self.stream.char() if data in spaceCharacters: self.stream.charsUntil(spaceCharacters, True) elif data == "=": self.state = self.beforeAttributeValueState elif data == ">": self.emitCurrentToken() elif data in asciiLetters: self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState elif data == "/": self.state = self.selfClosingStartTagState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"].append(["\uFFFD", ""]) self.state = self.attributeNameState elif data in ("'", '"', "<"): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-character-after-attribute-name"}) self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-end-of-tag-but-got-eof"}) self.state = self.dataState else: self.currentToken["data"].append([data, ""]) self.state = self.attributeNameState return True def beforeAttributeValueState(self): data = self.stream.char() if data in spaceCharacters: self.stream.charsUntil(spaceCharacters, True) elif data == "\"": self.state = self.attributeValueDoubleQuotedState elif data == "&": self.state = self.attributeValueUnQuotedState self.stream.unget(data) elif data == "'": self.state = self.attributeValueSingleQuotedState elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-attribute-value-but-got-right-bracket"}) self.emitCurrentToken() elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"][-1][1] += "\uFFFD" self.state = self.attributeValueUnQuotedState elif data in ("=", "<", "`"): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "equals-in-unquoted-attribute-value"}) self.currentToken["data"][-1][1] += data self.state = self.attributeValueUnQuotedState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-attribute-value-but-got-eof"}) self.state = self.dataState else: self.currentToken["data"][-1][1] += data self.state = self.attributeValueUnQuotedState return True def attributeValueDoubleQuotedState(self): data = self.stream.char() if data == "\"": self.state = self.afterAttributeValueState elif data == "&": self.processEntityInAttribute('"') elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"][-1][1] += "\uFFFD" elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-attribute-value-double-quote"}) self.state = self.dataState else: self.currentToken["data"][-1][1] += data +\ self.stream.charsUntil(("\"", "&", "\u0000")) return True def attributeValueSingleQuotedState(self): data = self.stream.char() if data == "'": self.state = self.afterAttributeValueState elif data == "&": self.processEntityInAttribute("'") elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"][-1][1] += "\uFFFD" elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-attribute-value-single-quote"}) self.state = self.dataState else: self.currentToken["data"][-1][1] += data +\ self.stream.charsUntil(("'", "&", "\u0000")) return True def attributeValueUnQuotedState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeAttributeNameState elif data == "&": self.processEntityInAttribute(">") elif data == ">": self.emitCurrentToken() elif data in ('"', "'", "=", "<", "`"): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-character-in-unquoted-attribute-value"}) self.currentToken["data"][-1][1] += data elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"][-1][1] += "\uFFFD" elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-attribute-value-no-quotes"}) self.state = self.dataState else: self.currentToken["data"][-1][1] += data + self.stream.charsUntil( frozenset(("&", ">", '"', "'", "=", "<", "`", "\u0000")) | spaceCharacters) return True def afterAttributeValueState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeAttributeNameState elif data == ">": self.emitCurrentToken() elif data == "/": self.state = self.selfClosingStartTagState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-EOF-after-attribute-value"}) self.stream.unget(data) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-character-after-attribute-value"}) self.stream.unget(data) self.state = self.beforeAttributeNameState return True def selfClosingStartTagState(self): data = self.stream.char() if data == ">": self.currentToken["selfClosing"] = True self.emitCurrentToken() elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-EOF-after-solidus-in-tag"}) self.stream.unget(data) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-character-after-solidus-in-tag"}) self.stream.unget(data) self.state = self.beforeAttributeNameState return True def bogusCommentState(self): # Make a new comment token and give it as value all the characters # until the first > or EOF (charsUntil checks for EOF automatically) # and emit it. data = self.stream.charsUntil(">") data = data.replace("\u0000", "\uFFFD") self.tokenQueue.append( {"type": tokenTypes["Comment"], "data": data}) # Eat the character directly after the bogus comment which is either a # ">" or an EOF. self.stream.char() self.state = self.dataState return True def markupDeclarationOpenState(self): charStack = [self.stream.char()] if charStack[-1] == "-": charStack.append(self.stream.char()) if charStack[-1] == "-": self.currentToken = {"type": tokenTypes["Comment"], "data": ""} self.state = self.commentStartState return True elif charStack[-1] in ('d', 'D'): matched = True for expected in (('o', 'O'), ('c', 'C'), ('t', 'T'), ('y', 'Y'), ('p', 'P'), ('e', 'E')): charStack.append(self.stream.char()) if charStack[-1] not in expected: matched = False break if matched: self.currentToken = {"type": tokenTypes["Doctype"], "name": "", "publicId": None, "systemId": None, "correct": True} self.state = self.doctypeState return True elif (charStack[-1] == "[" and self.parser is not None and self.parser.tree.openElements and self.parser.tree.openElements[-1].namespace != self.parser.tree.defaultNamespace): matched = True for expected in ["C", "D", "A", "T", "A", "["]: charStack.append(self.stream.char()) if charStack[-1] != expected: matched = False break if matched: self.state = self.cdataSectionState return True self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-dashes-or-doctype"}) while charStack: self.stream.unget(charStack.pop()) self.state = self.bogusCommentState return True def commentStartState(self): data = self.stream.char() if data == "-": self.state = self.commentStartDashState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "incorrect-comment"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["data"] += data self.state = self.commentState return True def commentStartDashState(self): data = self.stream.char() if data == "-": self.state = self.commentEndState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "-\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "incorrect-comment"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["data"] += "-" + data self.state = self.commentState return True def commentState(self): data = self.stream.char() if data == "-": self.state = self.commentEndDashState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "\uFFFD" elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["data"] += data + \ self.stream.charsUntil(("-", "\u0000")) return True def commentEndDashState(self): data = self.stream.char() if data == "-": self.state = self.commentEndState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "-\uFFFD" self.state = self.commentState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment-end-dash"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["data"] += "-" + data self.state = self.commentState return True def commentEndState(self): data = self.stream.char() if data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "--\uFFFD" self.state = self.commentState elif data == "!": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-bang-after-double-dash-in-comment"}) self.state = self.commentEndBangState elif data == "-": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-dash-after-double-dash-in-comment"}) self.currentToken["data"] += data elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment-double-dash"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: # XXX self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-comment"}) self.currentToken["data"] += "--" + data self.state = self.commentState return True def commentEndBangState(self): data = self.stream.char() if data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == "-": self.currentToken["data"] += "--!" self.state = self.commentEndDashState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["data"] += "--!\uFFFD" self.state = self.commentState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-comment-end-bang-state"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["data"] += "--!" + data self.state = self.commentState return True def doctypeState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeDoctypeNameState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-doctype-name-but-got-eof"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "need-space-after-doctype"}) self.stream.unget(data) self.state = self.beforeDoctypeNameState return True def beforeDoctypeNameState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-doctype-name-but-got-right-bracket"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["name"] = "\uFFFD" self.state = self.doctypeNameState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-doctype-name-but-got-eof"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["name"] = data self.state = self.doctypeNameState return True def doctypeNameState(self): data = self.stream.char() if data in spaceCharacters: self.currentToken["name"] = self.currentToken["name"].translate(asciiUpper2Lower) self.state = self.afterDoctypeNameState elif data == ">": self.currentToken["name"] = self.currentToken["name"].translate(asciiUpper2Lower) self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["name"] += "\uFFFD" self.state = self.doctypeNameState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype-name"}) self.currentToken["correct"] = False self.currentToken["name"] = self.currentToken["name"].translate(asciiUpper2Lower) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["name"] += data return True def afterDoctypeNameState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.currentToken["correct"] = False self.stream.unget(data) self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: if data in ("p", "P"): matched = True for expected in (("u", "U"), ("b", "B"), ("l", "L"), ("i", "I"), ("c", "C")): data = self.stream.char() if data not in expected: matched = False break if matched: self.state = self.afterDoctypePublicKeywordState return True elif data in ("s", "S"): matched = True for expected in (("y", "Y"), ("s", "S"), ("t", "T"), ("e", "E"), ("m", "M")): data = self.stream.char() if data not in expected: matched = False break if matched: self.state = self.afterDoctypeSystemKeywordState return True # All the characters read before the current 'data' will be # [a-zA-Z], so they're garbage in the bogus doctype and can be # discarded; only the latest character might be '>' or EOF # and needs to be ungetted self.stream.unget(data) self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "expected-space-or-right-bracket-in-doctype", "datavars": {"data": data}}) self.currentToken["correct"] = False self.state = self.bogusDoctypeState return True def afterDoctypePublicKeywordState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeDoctypePublicIdentifierState elif data in ("'", '"'): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.stream.unget(data) self.state = self.beforeDoctypePublicIdentifierState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.stream.unget(data) self.state = self.beforeDoctypePublicIdentifierState return True def beforeDoctypePublicIdentifierState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == "\"": self.currentToken["publicId"] = "" self.state = self.doctypePublicIdentifierDoubleQuotedState elif data == "'": self.currentToken["publicId"] = "" self.state = self.doctypePublicIdentifierSingleQuotedState elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-end-of-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["correct"] = False self.state = self.bogusDoctypeState return True def doctypePublicIdentifierDoubleQuotedState(self): data = self.stream.char() if data == "\"": self.state = self.afterDoctypePublicIdentifierState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["publicId"] += "\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-end-of-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["publicId"] += data return True def doctypePublicIdentifierSingleQuotedState(self): data = self.stream.char() if data == "'": self.state = self.afterDoctypePublicIdentifierState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["publicId"] += "\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-end-of-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["publicId"] += data return True def afterDoctypePublicIdentifierState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.betweenDoctypePublicAndSystemIdentifiersState elif data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == '"': self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierDoubleQuotedState elif data == "'": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierSingleQuotedState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["correct"] = False self.state = self.bogusDoctypeState return True def betweenDoctypePublicAndSystemIdentifiersState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data == '"': self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierDoubleQuotedState elif data == "'": self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierSingleQuotedState elif data == EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["correct"] = False self.state = self.bogusDoctypeState return True def afterDoctypeSystemKeywordState(self): data = self.stream.char() if data in spaceCharacters: self.state = self.beforeDoctypeSystemIdentifierState elif data in ("'", '"'): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.stream.unget(data) self.state = self.beforeDoctypeSystemIdentifierState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.stream.unget(data) self.state = self.beforeDoctypeSystemIdentifierState return True def beforeDoctypeSystemIdentifierState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == "\"": self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierDoubleQuotedState elif data == "'": self.currentToken["systemId"] = "" self.state = self.doctypeSystemIdentifierSingleQuotedState elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.currentToken["correct"] = False self.state = self.bogusDoctypeState return True def doctypeSystemIdentifierDoubleQuotedState(self): data = self.stream.char() if data == "\"": self.state = self.afterDoctypeSystemIdentifierState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["systemId"] += "\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-end-of-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["systemId"] += data return True def doctypeSystemIdentifierSingleQuotedState(self): data = self.stream.char() if data == "'": self.state = self.afterDoctypeSystemIdentifierState elif data == "\u0000": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) self.currentToken["systemId"] += "\uFFFD" elif data == ">": self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-end-of-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.currentToken["systemId"] += data return True def afterDoctypeSystemIdentifierState(self): data = self.stream.char() if data in spaceCharacters: pass elif data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "eof-in-doctype"}) self.currentToken["correct"] = False self.tokenQueue.append(self.currentToken) self.state = self.dataState else: self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "unexpected-char-in-doctype"}) self.state = self.bogusDoctypeState return True def bogusDoctypeState(self): data = self.stream.char() if data == ">": self.tokenQueue.append(self.currentToken) self.state = self.dataState elif data is EOF: # XXX EMIT self.stream.unget(data) self.tokenQueue.append(self.currentToken) self.state = self.dataState else: pass return True def cdataSectionState(self): data = [] while True: data.append(self.stream.charsUntil("]")) data.append(self.stream.charsUntil(">")) char = self.stream.char() if char == EOF: break else: assert char == ">" if data[-1][-2:] == "]]": data[-1] = data[-1][:-2] break else: data.append(char) data = "".join(data) # Deal with null here rather than in the parser nullCount = data.count("\u0000") if nullCount > 0: for i in range(nullCount): self.tokenQueue.append({"type": tokenTypes["ParseError"], "data": "invalid-codepoint"}) data = data.replace("\u0000", "\uFFFD") if data: self.tokenQueue.append({"type": tokenTypes["Characters"], "data": data}) self.state = self.dataState return True
gpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 893, 26, 272, 8678, 275, 17742, 327, 27510, 24, 26, 8151, 199, 2590, 12746, 26, 272, 986, 199, 199, 504, 5055, 492, 15782, 199, 199, 504, 1275, 5559, 492, 25431, 199, 504, 1275, 5559, 492, 9045, 199, 504, 1275, 5559, 492, 13294, 28760, 12, 13294, 19316, 18, 17846, 199, 504, 1275, 5559, 492, 7576, 12, 6318, 29371, 12, 9027, 199, 504, 1275, 5559, 492, 10042, 12, 1947, 3264, 4100, 199, 504, 1275, 5559, 492, 8343, 9272, 199, 199, 504, 1275, 1210, 1745, 492, 4163, 27611, 199, 199, 504, 1275, 599, 69, 492, 377, 11317, 199, 199, 8327, 6948, 69, 275, 377, 11317, 8, 8327, 9, 421, 199, 533, 4163, 21782, 8, 785, 304, 272, 408, 961, 1021, 6181, 10296, 402, 1526, 9147, 4163, 14, 339, 627, 291, 14, 11631, 489, 869, 8250, 314, 1526, 626, 365, 5544, 3769, 7686, 14, 339, 627, 291, 14, 929, 489, 869, 8250, 282, 3659, 370, 314, 1083, 370, 506, 10302, 1396, 5787, 339, 627, 291, 14, 1745, 489, 32598, 370, 4163, 27611, 909, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 2644, 29, 403, 12, 2198, 3396, 29, 549, 12, 675, 1610, 9886, 29, 549, 12, 326, 12141, 2162, 985, 29, 549, 12, 12141, 7144, 985, 29, 549, 12, 1798, 29, 403, 304, 398, 291, 14, 1745, 275, 4163, 27611, 8, 1745, 12, 2644, 12, 2198, 3396, 12, 675, 1610, 9886, 9, 267, 291, 14, 2087, 275, 1798, 398, 327, 14795, 1930, 24796, 31, 267, 291, 14, 21636, 2162, 985, 275, 12141, 2162, 985, 267, 291, 14, 21636, 7144, 985, 275, 12141, 7144, 985, 398, 327, 12439, 314, 2536, 14803, 1174, 267, 291, 14, 3765, 5318, 275, 756, 267, 291, 14, 2019, 24766, 11229, 275, 942, 267, 291, 14, 929, 275, 291, 14, 18694, 267, 291, 14, 3765, 275, 756, 398, 327, 710, 1453, 1526, 3769, 2737, 267, 291, 14, 11631, 275, 488, 267, 1613, 8, 4943, 21782, 12, 291, 2843, 826, 4533, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 961, 365, 2382, 314, 10628, 10986, 14, 398, 2136, 886, 4154, 9987, 6661, 4012, 314, 6363, 436, 1380, 781, 1172, 282, 1526, 267, 370, 372, 781, 1995, 314, 1526, 1314, 691, 5589, 6661, 5133, 314, 2163, 1526, 267, 365, 5839, 14, 267, 408, 267, 291, 14, 9690, 275, 15782, 4157, 267, 327, 7707, 6661, 14, 3979, 9027, 365, 13075, 291, 14, 929, 911, 372, 756, 267, 327, 3140, 402, 715, 436, 314, 4438, 911, 15095, 14, 267, 1830, 291, 14, 929, 837, 288, 1830, 291, 14, 1745, 14, 2550, 26, 355, 1995, 2420, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 291, 14, 1745, 14, 2550, 14, 1935, 8, 16, 6769, 288, 1830, 291, 14, 9690, 26, 355, 1995, 291, 14, 9690, 14, 25704, 342, 339, 347, 9451, 3259, 7302, 8, 277, 12, 365, 10373, 304, 267, 408, 2765, 805, 2529, 1902, 738, 11, 28050, 503, 314, 4528, 4079, 641, 314, 267, 6107, 503, 20379, 6025, 14, 2779, 2597, 4339, 5596, 28045, 340, 3451, 14, 267, 982, 440, 3451, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 21900, 365, 10302, 14, 267, 408, 398, 4370, 275, 7576, 267, 14070, 88, 275, 1616, 267, 340, 365, 10373, 26, 288, 4370, 275, 6318, 29371, 288, 14070, 88, 275, 3193, 398, 1495, 4851, 275, 942, 398, 327, 1448, 3639, 1006, 314, 4110, 626, 787, 315, 1425, 1830, 10663, 3238, 781, 267, 327, 2793, 1133, 9793, 376, 9027, 14, 267, 286, 275, 291, 14, 1745, 14, 1560, 342, 267, 1830, 286, 315, 4370, 436, 286, 365, 440, 9027, 26, 288, 1495, 4851, 14, 740, 8, 67, 9, 288, 286, 275, 291, 14, 1745, 14, 1560, 342, 398, 327, 7905, 314, 663, 402, 4110, 16949, 370, 376, 1109, 14, 267, 1495, 2822, 3241, 275, 1109, 31059, 904, 8, 1560, 4851, 395, 14070, 88, 9, 398, 327, 11002, 877, 4110, 664, 8717, 543, 11789, 267, 340, 1495, 2822, 3241, 315, 8343, 9272, 26, 288, 1495, 275, 8343, 9272, 59, 1560, 2822, 3241, 61, 288, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 2511, 298, 23375, 13, 19300, 13, 509, 13, 6677, 13, 4502, 401, 2511, 298, 576, 2936, 582, 2420, 1560, 2822, 3241, 582, 1495, 2822, 3241, 19575, 267, 916, 3666, 16, 8313, 6718, 2695, 1495, 2822, 3241, 2695, 378, 8313, 24254, 9, 503, 1598, 334, 1560, 2822, 3241, 690, 378, 88, 709, 6968, 2298, 288, 1495, 275, 1867, 24815, 2, 288, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 2511, 298, 23375, 13, 19300, 13, 509, 13, 6677, 13, 4502, 401, 2511, 298, 576, 2936, 582, 2420, 1560, 2822, 3241, 582, 1495, 2822, 3241, 19575, 267, 587, 26, 288, 327, 7719, 8112, 1536, 642, 1104, 29437, 334, 69, 14, 71, 14, 4057, 314, 663, 370, 282, 4413, 9, 288, 340, 3666, 16, 88, 4183, 2695, 1495, 2822, 3241, 2695, 378, 88, 19141, 9, 503, 355, 334, 16, 88, 1493, 37, 2695, 1495, 2822, 3241, 2695, 378, 88, 4587, 38, 9, 503, 355, 334, 16, 88, 8255, 38, 2695, 1495, 2822, 3241, 2695, 378, 88, 8581, 38, 9, 503, 355, 334, 16, 6287, 5745, 16, 2695, 1495, 2822, 3241, 2695, 378, 6287, 5638, 9, 503, 355, 1495, 2822, 3241, 315, 9522, 779, 16, 88, 1493, 34, 12, 378, 9039, 5100, 12, 378, 23973, 12, 378, 88, 17, 27897, 12, 3147, 378, 88, 17, 6968, 12, 378, 88, 18, 27897, 12, 378, 88, 18, 6968, 12, 378, 88, 19, 27897, 12, 3147, 378, 88, 19, 6968, 12, 378, 88, 20, 27897, 12, 378, 88, 20, 6968, 12, 378, 88, 21, 27897, 12, 3147, 378, 88, 21, 6968, 12, 378, 88, 22, 27897, 12, 378, 88, 22, 6968, 12, 378, 88, 23, 27897, 12, 3147, 378, 88, 23, 6968, 12, 378, 88, 24, 27897, 12, 378, 88, 24, 6968, 12, 378, 88, 25, 27897, 12, 3147, 378, 88, 25, 6968, 12, 378, 7471, 27897, 12, 378, 7471, 6968, 12, 378, 8094, 27897, 12, 3147, 378, 8094, 6968, 12, 378, 8163, 27897, 12, 378, 8163, 6968, 12 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 199, 893, 26, 272, 8678, 275, 17742, 327, 27510, 24, 26, 8151, 199, 2590, 12746, 26, 272, 986, 199, 199, 504, 5055, 492, 15782, 199, 199, 504, 1275, 5559, 492, 25431, 199, 504, 1275, 5559, 492, 9045, 199, 504, 1275, 5559, 492, 13294, 28760, 12, 13294, 19316, 18, 17846, 199, 504, 1275, 5559, 492, 7576, 12, 6318, 29371, 12, 9027, 199, 504, 1275, 5559, 492, 10042, 12, 1947, 3264, 4100, 199, 504, 1275, 5559, 492, 8343, 9272, 199, 199, 504, 1275, 1210, 1745, 492, 4163, 27611, 199, 199, 504, 1275, 599, 69, 492, 377, 11317, 199, 199, 8327, 6948, 69, 275, 377, 11317, 8, 8327, 9, 421, 199, 533, 4163, 21782, 8, 785, 304, 272, 408, 961, 1021, 6181, 10296, 402, 1526, 9147, 4163, 14, 339, 627, 291, 14, 11631, 489, 869, 8250, 314, 1526, 626, 365, 5544, 3769, 7686, 14, 339, 627, 291, 14, 929, 489, 869, 8250, 282, 3659, 370, 314, 1083, 370, 506, 10302, 1396, 5787, 339, 627, 291, 14, 1745, 489, 32598, 370, 4163, 27611, 909, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 2644, 29, 403, 12, 2198, 3396, 29, 549, 12, 675, 1610, 9886, 29, 549, 12, 326, 12141, 2162, 985, 29, 549, 12, 12141, 7144, 985, 29, 549, 12, 1798, 29, 403, 304, 398, 291, 14, 1745, 275, 4163, 27611, 8, 1745, 12, 2644, 12, 2198, 3396, 12, 675, 1610, 9886, 9, 267, 291, 14, 2087, 275, 1798, 398, 327, 14795, 1930, 24796, 31, 267, 291, 14, 21636, 2162, 985, 275, 12141, 2162, 985, 267, 291, 14, 21636, 7144, 985, 275, 12141, 7144, 985, 398, 327, 12439, 314, 2536, 14803, 1174, 267, 291, 14, 3765, 5318, 275, 756, 267, 291, 14, 2019, 24766, 11229, 275, 942, 267, 291, 14, 929, 275, 291, 14, 18694, 267, 291, 14, 3765, 275, 756, 398, 327, 710, 1453, 1526, 3769, 2737, 267, 291, 14, 11631, 275, 488, 267, 1613, 8, 4943, 21782, 12, 291, 2843, 826, 4533, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 961, 365, 2382, 314, 10628, 10986, 14, 398, 2136, 886, 4154, 9987, 6661, 4012, 314, 6363, 436, 1380, 781, 1172, 282, 1526, 267, 370, 372, 781, 1995, 314, 1526, 1314, 691, 5589, 6661, 5133, 314, 2163, 1526, 267, 365, 5839, 14, 267, 408, 267, 291, 14, 9690, 275, 15782, 4157, 267, 327, 7707, 6661, 14, 3979, 9027, 365, 13075, 291, 14, 929, 911, 372, 756, 267, 327, 3140, 402, 715, 436, 314, 4438, 911, 15095, 14, 267, 1830, 291, 14, 929, 837, 288, 1830, 291, 14, 1745, 14, 2550, 26, 355, 1995, 2420, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 291, 14, 1745, 14, 2550, 14, 1935, 8, 16, 6769, 288, 1830, 291, 14, 9690, 26, 355, 1995, 291, 14, 9690, 14, 25704, 342, 339, 347, 9451, 3259, 7302, 8, 277, 12, 365, 10373, 304, 267, 408, 2765, 805, 2529, 1902, 738, 11, 28050, 503, 314, 4528, 4079, 641, 314, 267, 6107, 503, 20379, 6025, 14, 2779, 2597, 4339, 5596, 28045, 340, 3451, 14, 267, 982, 440, 3451, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 21900, 365, 10302, 14, 267, 408, 398, 4370, 275, 7576, 267, 14070, 88, 275, 1616, 267, 340, 365, 10373, 26, 288, 4370, 275, 6318, 29371, 288, 14070, 88, 275, 3193, 398, 1495, 4851, 275, 942, 398, 327, 1448, 3639, 1006, 314, 4110, 626, 787, 315, 1425, 1830, 10663, 3238, 781, 267, 327, 2793, 1133, 9793, 376, 9027, 14, 267, 286, 275, 291, 14, 1745, 14, 1560, 342, 267, 1830, 286, 315, 4370, 436, 286, 365, 440, 9027, 26, 288, 1495, 4851, 14, 740, 8, 67, 9, 288, 286, 275, 291, 14, 1745, 14, 1560, 342, 398, 327, 7905, 314, 663, 402, 4110, 16949, 370, 376, 1109, 14, 267, 1495, 2822, 3241, 275, 1109, 31059, 904, 8, 1560, 4851, 395, 14070, 88, 9, 398, 327, 11002, 877, 4110, 664, 8717, 543, 11789, 267, 340, 1495, 2822, 3241, 315, 8343, 9272, 26, 288, 1495, 275, 8343, 9272, 59, 1560, 2822, 3241, 61, 288, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 2511, 298, 23375, 13, 19300, 13, 509, 13, 6677, 13, 4502, 401, 2511, 298, 576, 2936, 582, 2420, 1560, 2822, 3241, 582, 1495, 2822, 3241, 19575, 267, 916, 3666, 16, 8313, 6718, 2695, 1495, 2822, 3241, 2695, 378, 8313, 24254, 9, 503, 1598, 334, 1560, 2822, 3241, 690, 378, 88, 709, 6968, 2298, 288, 1495, 275, 1867, 24815, 2, 288, 291, 14, 9690, 14, 740, 6333, 466, 582, 10042, 905, 9123, 2255, 298, 576, 582, 2511, 298, 23375, 13, 19300, 13, 509, 13, 6677, 13, 4502, 401, 2511, 298, 576, 2936, 582, 2420, 1560, 2822, 3241, 582, 1495, 2822, 3241, 19575, 267, 587, 26, 288, 327, 7719, 8112, 1536, 642, 1104, 29437, 334, 69, 14, 71, 14, 4057, 314, 663, 370, 282, 4413, 9, 288, 340, 3666, 16, 88, 4183, 2695, 1495, 2822, 3241, 2695, 378, 88, 19141, 9, 503, 355, 334, 16, 88, 1493, 37, 2695, 1495, 2822, 3241, 2695, 378, 88, 4587, 38, 9, 503, 355, 334, 16, 88, 8255, 38, 2695, 1495, 2822, 3241, 2695, 378, 88, 8581, 38, 9, 503, 355, 334, 16, 6287, 5745, 16, 2695, 1495, 2822, 3241, 2695, 378, 6287, 5638, 9, 503, 355, 1495, 2822, 3241, 315, 9522, 779, 16, 88, 1493, 34, 12, 378, 9039, 5100, 12, 378, 23973, 12, 378, 88, 17, 27897, 12, 3147, 378, 88, 17, 6968, 12, 378, 88, 18, 27897, 12, 378, 88, 18, 6968, 12, 378, 88, 19, 27897, 12, 3147, 378, 88, 19, 6968, 12, 378, 88, 20, 27897, 12, 378, 88, 20, 6968, 12, 378, 88, 21, 27897, 12, 3147, 378, 88, 21, 6968, 12, 378, 88, 22, 27897, 12, 378, 88, 22, 6968, 12, 378, 88, 23, 27897, 12, 3147, 378, 88, 23, 6968, 12, 378, 88, 24, 27897, 12, 378, 88, 24, 6968, 12, 378, 88, 25, 27897, 12, 3147, 378, 88, 25, 6968, 12, 378, 7471, 27897, 12, 378, 7471, 6968, 12, 378, 8094, 27897, 12, 3147, 378, 8094, 6968, 12, 378, 8163, 27897, 12, 378, 8163, 6968, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TinLe/Diamond
src/collectors/ping/ping.py
6
2186
# coding=utf-8 """ Collect icmp round trip times Only valid for ipv4 hosts currently #### Dependencies * ping #### Configuration Configuration is done by: Create a file named: PingCollector.conf in the collectors_config_path * enabled = true * interval = 60 * target_1 = example.org * target_fw = 192.168.0.1 * target_localhost = localhost Test your configuration using the following command: diamond-setup --print -C PingCollector You should get a reponse back that indicates 'enabled': True and see entries for your targets in pairs like: 'target_1': 'example.org' We extract out the key after target_ and use it in the graphite node we push. """ import subprocess import diamond.collector import os from diamond.collector import str_to_bool class PingCollector(diamond.collector.ProcessCollector): def get_default_config_help(self): config_help = super(PingCollector, self).get_default_config_help() config_help.update({ 'bin': 'The path to the ping binary', }) return config_help def get_default_config(self): """ Returns the default collector settings """ config = super(PingCollector, self).get_default_config() config.update({ 'path': 'ping', 'bin': '/bin/ping', }) return config def collect(self): for key in self.config.keys(): if key[:7] == "target_": host = self.config[key] metric_name = host.replace('.', '_') ping = self.run_command(['-nq', '-c 1', host]) ping = ping[0].strip().split("\n")[-1] # Linux if ping.startswith('rtt'): ping = ping.split()[3].split('/')[0] metric_value = float(ping) # OS X elif ping.startswith('round-trip '): ping = ping.split()[3].split('/')[0] metric_value = float(ping) # Unknown else: metric_value = 10000 self.publish(metric_name, metric_value)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 20663, 6168, 18038, 5431, 199, 5903, 1686, 367, 3278, 20, 7057, 5544, 199, 199, 381, 1487, 3209, 421, 627, 18249, 199, 199, 381, 11595, 199, 199, 5688, 365, 4224, 701, 26, 199, 199, 2499, 282, 570, 4310, 26, 510, 316, 12852, 14, 2190, 315, 314, 14910, 83, 63, 888, 63, 515, 421, 627, 5223, 275, 2549, 199, 627, 6252, 275, 5212, 199, 627, 1347, 63, 17, 275, 2893, 14, 1308, 199, 627, 1347, 63, 8835, 275, 13567, 14, 6568, 14, 16, 14, 17, 199, 627, 1347, 63, 5967, 275, 11667, 199, 199, 774, 2195, 2897, 1808, 314, 2569, 1414, 26, 199, 199, 328, 24940, 13, 2758, 1553, 1361, 446, 35, 510, 316, 12852, 199, 199, 5556, 1077, 664, 282, 295, 732, 1771, 626, 9126, 283, 3827, 356, 715, 436, 1937, 4811, 199, 509, 2195, 4545, 315, 6342, 2839, 26, 199, 199, 1133, 839, 63, 17, 356, 283, 2694, 14, 1308, 7, 199, 199, 6004, 5536, 734, 314, 790, 2410, 1347, 63, 436, 675, 652, 315, 314, 3343, 1175, 1031, 781, 6675, 14, 199, 199, 624, 199, 199, 646, 3873, 199, 646, 487, 24940, 14, 10946, 199, 646, 747, 199, 504, 487, 24940, 14, 10946, 492, 620, 63, 475, 63, 2245, 421, 199, 533, 510, 316, 12852, 8, 328, 24940, 14, 10946, 14, 3498, 12852, 304, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 22638, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 1393, 356, 260, 283, 1918, 931, 370, 314, 18249, 3366, 297, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1803, 314, 849, 14910, 2202, 267, 408, 267, 1101, 275, 1613, 8, 22638, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 1101, 14, 873, 2561, 288, 283, 515, 356, 3777, 283, 4073, 297, 288, 283, 1393, 356, 4519, 1994, 1393, 15, 4073, 297, 267, 3828, 267, 372, 1101, 339, 347, 8775, 8, 277, 304, 267, 367, 790, 315, 291, 14, 888, 14, 1612, 837, 288, 340, 790, 1491, 23, 61, 508, 298, 1375, 63, 582, 355, 1591, 275, 291, 14, 888, 59, 498, 61, 355, 6370, 63, 354, 275, 1591, 14, 1814, 14078, 18962, 2234, 18249, 275, 291, 14, 1065, 63, 1531, 24829, 78, 81, 297, 2475, 67, 413, 297, 1591, 566, 355, 18249, 275, 18249, 59, 16, 1055, 1913, 1252, 1294, 4582, 78, 531, 1988, 17, 61, 2234, 327, 10130, 355, 340, 18249, 14, 2460, 360, 2591, 84, 735, 490, 18249, 275, 18249, 14, 1294, 3430, 19, 1055, 1294, 30746, 16, 61, 490, 6370, 63, 585, 275, 2069, 8, 4073, 9, 355, 327, 4403, 1323, 355, 916, 18249, 14, 2460, 360, 2363, 13, 7254, 18927, 490, 18249, 275, 18249, 14, 1294, 3430, 19, 1055, 1294, 30746, 16, 61, 490, 6370, 63, 585, 275, 2069, 8, 4073, 9, 355, 327, 14831, 355, 587, 26, 490, 6370, 63, 585, 275, 11630, 2234, 291, 14, 4763, 8, 5165, 63, 354, 12, 6370, 63, 585, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 20663, 6168, 18038, 5431, 199, 5903, 1686, 367, 3278, 20, 7057, 5544, 199, 199, 381, 1487, 3209, 421, 627, 18249, 199, 199, 381, 11595, 199, 199, 5688, 365, 4224, 701, 26, 199, 199, 2499, 282, 570, 4310, 26, 510, 316, 12852, 14, 2190, 315, 314, 14910, 83, 63, 888, 63, 515, 421, 627, 5223, 275, 2549, 199, 627, 6252, 275, 5212, 199, 627, 1347, 63, 17, 275, 2893, 14, 1308, 199, 627, 1347, 63, 8835, 275, 13567, 14, 6568, 14, 16, 14, 17, 199, 627, 1347, 63, 5967, 275, 11667, 199, 199, 774, 2195, 2897, 1808, 314, 2569, 1414, 26, 199, 199, 328, 24940, 13, 2758, 1553, 1361, 446, 35, 510, 316, 12852, 199, 199, 5556, 1077, 664, 282, 295, 732, 1771, 626, 9126, 283, 3827, 356, 715, 436, 1937, 4811, 199, 509, 2195, 4545, 315, 6342, 2839, 26, 199, 199, 1133, 839, 63, 17, 356, 283, 2694, 14, 1308, 7, 199, 199, 6004, 5536, 734, 314, 790, 2410, 1347, 63, 436, 675, 652, 315, 314, 3343, 1175, 1031, 781, 6675, 14, 199, 199, 624, 199, 199, 646, 3873, 199, 646, 487, 24940, 14, 10946, 199, 646, 747, 199, 504, 487, 24940, 14, 10946, 492, 620, 63, 475, 63, 2245, 421, 199, 533, 510, 316, 12852, 8, 328, 24940, 14, 10946, 14, 3498, 12852, 304, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 22638, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 1393, 356, 260, 283, 1918, 931, 370, 314, 18249, 3366, 297, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1803, 314, 849, 14910, 2202, 267, 408, 267, 1101, 275, 1613, 8, 22638, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 1101, 14, 873, 2561, 288, 283, 515, 356, 3777, 283, 4073, 297, 288, 283, 1393, 356, 4519, 1994, 1393, 15, 4073, 297, 267, 3828, 267, 372, 1101, 339, 347, 8775, 8, 277, 304, 267, 367, 790, 315, 291, 14, 888, 14, 1612, 837, 288, 340, 790, 1491, 23, 61, 508, 298, 1375, 63, 582, 355, 1591, 275, 291, 14, 888, 59, 498, 61, 355, 6370, 63, 354, 275, 1591, 14, 1814, 14078, 18962, 2234, 18249, 275, 291, 14, 1065, 63, 1531, 24829, 78, 81, 297, 2475, 67, 413, 297, 1591, 566, 355, 18249, 275, 18249, 59, 16, 1055, 1913, 1252, 1294, 4582, 78, 531, 1988, 17, 61, 2234, 327, 10130, 355, 340, 18249, 14, 2460, 360, 2591, 84, 735, 490, 18249, 275, 18249, 14, 1294, 3430, 19, 1055, 1294, 30746, 16, 61, 490, 6370, 63, 585, 275, 2069, 8, 4073, 9, 355, 327, 4403, 1323, 355, 916, 18249, 14, 2460, 360, 2363, 13, 7254, 18927, 490, 18249, 275, 18249, 14, 1294, 3430, 19, 1055, 1294, 30746, 16, 61, 490, 6370, 63, 585, 275, 2069, 8, 4073, 9, 355, 327, 14831, 355, 587, 26, 490, 6370, 63, 585, 275, 11630, 2234, 291, 14, 4763, 8, 5165, 63, 354, 12, 6370, 63, 585, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
tcwriting/tcwriting
vendor/cache/ruby/2.3.0/gems/nokogiri-1.7.0.1/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4/libxml2-2.9.4/python/tests/compareNodes.py
35
1516
#!/usr/bin/python -u import sys import libxml2 # Memory debug specific libxml2.debugMemory(1) # # Testing XML Node comparison and Node hash-value # doc = libxml2.parseDoc("""<root><foo/></root>""") root = doc.getRootElement() # Create two different objects which point to foo foonode1 = root.children foonode2 = root.children # Now check that [in]equality tests work ok if not ( foonode1 == foonode2 ): print("Error comparing nodes with ==, nodes should be equal but are unequal") sys.exit(1) if not ( foonode1 != root ): print("Error comparing nodes with ==, nodes should not be equal but are equal") sys.exit(1) if not ( foonode1 != root ): print("Error comparing nodes with !=, nodes should not be equal but are equal") if ( foonode1 != foonode2 ): print("Error comparing nodes with !=, nodes should be equal but are unequal") # Next check that the hash function for the objects also works ok if not (hash(foonode1) == hash(foonode2)): print("Error hash values for two equal nodes are different") sys.exit(1) if not (hash(foonode1) != hash(root)): print("Error hash values for two unequal nodes are not different") sys.exit(1) if hash(foonode1) == hash(root): print("Error hash values for two unequal nodes are equal") sys.exit(1) # Basic tests successful doc.freeDoc() # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: print("OK") else: print("Memory leak %d bytes" % (libxml2.debugMemory(1))) libxml2.dumpMemory()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 984, 199, 646, 15404, 18, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 199, 3, 199, 3, 11940, 4692, 5013, 9132, 436, 5013, 2631, 13, 585, 199, 3, 199, 1301, 275, 15404, 18, 14, 1122, 3768, 4852, 28, 1231, 2535, 1421, 15, 2957, 1231, 15366, 199, 1231, 275, 1382, 14, 362, 6405, 2162, 342, 199, 199, 3, 2790, 2877, 3365, 2251, 1314, 2376, 370, 3925, 199, 545, 29118, 17, 275, 1738, 14, 3223, 199, 545, 29118, 18, 275, 1738, 14, 3223, 199, 199, 3, 7356, 1104, 626, 359, 262, 61, 20982, 2295, 1736, 4112, 199, 692, 440, 334, 7090, 29118, 17, 508, 7090, 29118, 18, 3461, 272, 870, 480, 547, 20234, 3380, 543, 508, 12, 3380, 1077, 506, 4472, 1325, 787, 625, 1452, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 7090, 29118, 17, 1137, 1738, 3461, 272, 870, 480, 547, 20234, 3380, 543, 508, 12, 3380, 1077, 440, 506, 4472, 1325, 787, 4472, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 7090, 29118, 17, 1137, 1738, 3461, 272, 870, 480, 547, 20234, 3380, 543, 1137, 12, 3380, 1077, 440, 506, 4472, 1325, 787, 4472, 531, 199, 692, 334, 7090, 29118, 17, 1137, 7090, 29118, 18, 3461, 272, 870, 480, 547, 20234, 3380, 543, 1137, 12, 3380, 1077, 506, 4472, 1325, 787, 625, 1452, 531, 199, 199, 3, 16840, 1104, 626, 314, 2631, 805, 367, 314, 2251, 2597, 5419, 4112, 199, 692, 440, 334, 2227, 8, 545, 29118, 17, 9, 508, 2631, 8, 545, 29118, 18, 2298, 272, 870, 480, 547, 2631, 1338, 367, 2877, 4472, 3380, 787, 3365, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 2227, 8, 545, 29118, 17, 9, 1137, 2631, 8, 1231, 2298, 272, 870, 480, 547, 2631, 1338, 367, 2877, 625, 1452, 3380, 787, 440, 3365, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 2631, 8, 545, 29118, 17, 9, 508, 2631, 8, 1231, 304, 272, 870, 480, 547, 2631, 1338, 367, 2877, 625, 1452, 3380, 787, 4472, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 10082, 2295, 9512, 199, 1301, 14, 4624, 3768, 342, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 480, 3593, 531, 199, 2836, 26, 272, 870, 480, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 1724, 272, 15404, 18, 14, 2724, 8628, 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 ]
[ 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 984, 199, 646, 15404, 18, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 199, 3, 199, 3, 11940, 4692, 5013, 9132, 436, 5013, 2631, 13, 585, 199, 3, 199, 1301, 275, 15404, 18, 14, 1122, 3768, 4852, 28, 1231, 2535, 1421, 15, 2957, 1231, 15366, 199, 1231, 275, 1382, 14, 362, 6405, 2162, 342, 199, 199, 3, 2790, 2877, 3365, 2251, 1314, 2376, 370, 3925, 199, 545, 29118, 17, 275, 1738, 14, 3223, 199, 545, 29118, 18, 275, 1738, 14, 3223, 199, 199, 3, 7356, 1104, 626, 359, 262, 61, 20982, 2295, 1736, 4112, 199, 692, 440, 334, 7090, 29118, 17, 508, 7090, 29118, 18, 3461, 272, 870, 480, 547, 20234, 3380, 543, 508, 12, 3380, 1077, 506, 4472, 1325, 787, 625, 1452, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 7090, 29118, 17, 1137, 1738, 3461, 272, 870, 480, 547, 20234, 3380, 543, 508, 12, 3380, 1077, 440, 506, 4472, 1325, 787, 4472, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 7090, 29118, 17, 1137, 1738, 3461, 272, 870, 480, 547, 20234, 3380, 543, 1137, 12, 3380, 1077, 440, 506, 4472, 1325, 787, 4472, 531, 199, 692, 334, 7090, 29118, 17, 1137, 7090, 29118, 18, 3461, 272, 870, 480, 547, 20234, 3380, 543, 1137, 12, 3380, 1077, 506, 4472, 1325, 787, 625, 1452, 531, 199, 199, 3, 16840, 1104, 626, 314, 2631, 805, 367, 314, 2251, 2597, 5419, 4112, 199, 692, 440, 334, 2227, 8, 545, 29118, 17, 9, 508, 2631, 8, 545, 29118, 18, 2298, 272, 870, 480, 547, 2631, 1338, 367, 2877, 4472, 3380, 787, 3365, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 440, 334, 2227, 8, 545, 29118, 17, 9, 1137, 2631, 8, 1231, 2298, 272, 870, 480, 547, 2631, 1338, 367, 2877, 625, 1452, 3380, 787, 440, 3365, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 2631, 8, 545, 29118, 17, 9, 508, 2631, 8, 1231, 304, 272, 870, 480, 547, 2631, 1338, 367, 2877, 625, 1452, 3380, 787, 4472, 531, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 10082, 2295, 9512, 199, 1301, 14, 4624, 3768, 342, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 480, 3593, 531, 199, 2836, 26, 272, 870, 480, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 1724, 272, 15404, 18, 14, 2724, 8628, 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, 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 0, 0, 0, 0, 0 ]
callmeonlyashu/MEANJS
node_modules/node-gyp/gyp/pylib/gyp/input_test.py
1841
3207
#!/usr/bin/env python # Copyright 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Unit tests for the input.py file.""" import gyp.input import unittest import sys class TestFindCycles(unittest.TestCase): def setUp(self): self.nodes = {} for x in ('a', 'b', 'c', 'd', 'e'): self.nodes[x] = gyp.input.DependencyGraphNode(x) def _create_dependency(self, dependent, dependency): dependent.dependencies.append(dependency) dependency.dependents.append(dependent) def test_no_cycle_empty_graph(self): for label, node in self.nodes.iteritems(): self.assertEquals([], node.FindCycles()) def test_no_cycle_line(self): self._create_dependency(self.nodes['a'], self.nodes['b']) self._create_dependency(self.nodes['b'], self.nodes['c']) self._create_dependency(self.nodes['c'], self.nodes['d']) for label, node in self.nodes.iteritems(): self.assertEquals([], node.FindCycles()) def test_no_cycle_dag(self): self._create_dependency(self.nodes['a'], self.nodes['b']) self._create_dependency(self.nodes['a'], self.nodes['c']) self._create_dependency(self.nodes['b'], self.nodes['c']) for label, node in self.nodes.iteritems(): self.assertEquals([], node.FindCycles()) def test_cycle_self_reference(self): self._create_dependency(self.nodes['a'], self.nodes['a']) self.assertEquals([[self.nodes['a'], self.nodes['a']]], self.nodes['a'].FindCycles()) def test_cycle_two_nodes(self): self._create_dependency(self.nodes['a'], self.nodes['b']) self._create_dependency(self.nodes['b'], self.nodes['a']) self.assertEquals([[self.nodes['a'], self.nodes['b'], self.nodes['a']]], self.nodes['a'].FindCycles()) self.assertEquals([[self.nodes['b'], self.nodes['a'], self.nodes['b']]], self.nodes['b'].FindCycles()) def test_two_cycles(self): self._create_dependency(self.nodes['a'], self.nodes['b']) self._create_dependency(self.nodes['b'], self.nodes['a']) self._create_dependency(self.nodes['b'], self.nodes['c']) self._create_dependency(self.nodes['c'], self.nodes['b']) cycles = self.nodes['a'].FindCycles() self.assertTrue( [self.nodes['a'], self.nodes['b'], self.nodes['a']] in cycles) self.assertTrue( [self.nodes['b'], self.nodes['c'], self.nodes['b']] in cycles) self.assertEquals(2, len(cycles)) def test_big_cycle(self): self._create_dependency(self.nodes['a'], self.nodes['b']) self._create_dependency(self.nodes['b'], self.nodes['c']) self._create_dependency(self.nodes['c'], self.nodes['d']) self._create_dependency(self.nodes['d'], self.nodes['e']) self._create_dependency(self.nodes['e'], self.nodes['a']) self.assertEquals([[self.nodes['a'], self.nodes['b'], self.nodes['c'], self.nodes['d'], self.nodes['e'], self.nodes['a']]], self.nodes['a'].FindCycles()) if __name__ == '__main__': unittest.main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 5072, 2295, 367, 314, 1324, 14, 647, 570, 1041, 199, 199, 646, 4902, 14, 1210, 199, 646, 2882, 199, 646, 984, 421, 199, 533, 1379, 6591, 28016, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 2415, 275, 1052, 272, 367, 671, 315, 661, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 735, 489, 291, 14, 2415, 59, 88, 61, 275, 4902, 14, 1210, 14, 14403, 4578, 1716, 8, 88, 9, 819, 347, 485, 981, 63, 8575, 8, 277, 12, 11410, 12, 5936, 304, 272, 11410, 14, 5714, 14, 740, 8, 8575, 9, 272, 5936, 14, 32333, 14, 740, 8, 7106, 9, 819, 347, 511, 63, 889, 63, 7612, 63, 1667, 63, 2180, 8, 277, 304, 272, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 889, 63, 7612, 63, 604, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 68, 1105, 339, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 889, 63, 7612, 63, 7406, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 339, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 7612, 63, 277, 63, 4443, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 819, 347, 511, 63, 7612, 63, 5601, 63, 2415, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 272, 291, 14, 2947, 4038, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 4397, 1993, 291, 14, 2415, 459, 66, 2278, 6591, 28016, 1012, 819, 347, 511, 63, 5601, 63, 23356, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 66, 1105, 339, 19001, 275, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 342, 272, 291, 14, 1815, 8, 2126, 359, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 6538, 315, 19001, 9, 272, 291, 14, 1815, 8, 2126, 359, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 66, 6538, 315, 19001, 9, 272, 291, 14, 2947, 8, 18, 12, 822, 8, 23356, 430, 819, 347, 511, 63, 5076, 63, 7612, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 68, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 68, 995, 291, 14, 2415, 459, 69, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 69, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 717, 291, 14, 2415, 459, 66, 995, 717, 291, 14, 2415, 459, 67, 995, 717, 291, 14, 2415, 459, 68, 995, 717, 291, 14, 2415, 459, 69, 995, 717, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 5072, 2295, 367, 314, 1324, 14, 647, 570, 1041, 199, 199, 646, 4902, 14, 1210, 199, 646, 2882, 199, 646, 984, 421, 199, 533, 1379, 6591, 28016, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 2415, 275, 1052, 272, 367, 671, 315, 661, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 735, 489, 291, 14, 2415, 59, 88, 61, 275, 4902, 14, 1210, 14, 14403, 4578, 1716, 8, 88, 9, 819, 347, 485, 981, 63, 8575, 8, 277, 12, 11410, 12, 5936, 304, 272, 11410, 14, 5714, 14, 740, 8, 8575, 9, 272, 5936, 14, 32333, 14, 740, 8, 7106, 9, 819, 347, 511, 63, 889, 63, 7612, 63, 1667, 63, 2180, 8, 277, 304, 272, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 889, 63, 7612, 63, 604, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 68, 1105, 339, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 889, 63, 7612, 63, 7406, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 339, 367, 1768, 12, 1031, 315, 291, 14, 2415, 14, 4611, 837, 489, 291, 14, 2947, 8798, 1031, 14, 6591, 28016, 1012, 819, 347, 511, 63, 7612, 63, 277, 63, 4443, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 819, 347, 511, 63, 7612, 63, 5601, 63, 2415, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 272, 291, 14, 2947, 4038, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 4397, 1993, 291, 14, 2415, 459, 66, 2278, 6591, 28016, 1012, 819, 347, 511, 63, 5601, 63, 23356, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 66, 1105, 339, 19001, 275, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 342, 272, 291, 14, 1815, 8, 2126, 359, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 65, 6538, 315, 19001, 9, 272, 291, 14, 1815, 8, 2126, 359, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 66, 6538, 315, 19001, 9, 272, 291, 14, 2947, 8, 18, 12, 822, 8, 23356, 430, 819, 347, 511, 63, 5076, 63, 7612, 8, 277, 304, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 65, 995, 291, 14, 2415, 459, 66, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 66, 995, 291, 14, 2415, 459, 67, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 67, 995, 291, 14, 2415, 459, 68, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 68, 995, 291, 14, 2415, 459, 69, 1105, 272, 291, 423, 981, 63, 8575, 8, 277, 14, 2415, 459, 69, 995, 291, 14, 2415, 459, 65, 1105, 339, 291, 14, 2947, 4038, 277, 14, 2415, 459, 65, 995, 717, 291, 14, 2415, 459, 66, 995, 717, 291, 14, 2415, 459, 67, 995, 717, 291, 14, 2415, 459, 68, 995, 717, 291, 14, 2415, 459, 69, 995, 717, 291, 14, 2415, 459, 65, 4397, 1993, 291, 14, 2415, 459, 65, 2278, 6591, 28016, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
r39132/airflow
airflow/contrib/operators/vertica_to_mysql.py
4
6016
# -*- coding: utf-8 -*- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import MySQLdb from airflow.contrib.hooks.vertica_hook import VerticaHook from airflow.hooks.mysql_hook import MySqlHook from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults from contextlib import closing import unicodecsv as csv from tempfile import NamedTemporaryFile class VerticaToMySqlTransfer(BaseOperator): """ Moves data from Vertica to MySQL. :param sql: SQL query to execute against the Vertica database. (templated) :type sql: str :param vertica_conn_id: source Vertica connection :type vertica_conn_id: str :param mysql_table: target MySQL table, use dot notation to target a specific database. (templated) :type mysql_table: str :param mysql_conn_id: source mysql connection :type mysql_conn_id: str :param mysql_preoperator: sql statement to run against MySQL prior to import, typically use to truncate of delete in place of the data coming in, allowing the task to be idempotent (running the task twice won't double load data). (templated) :type mysql_preoperator: str :param mysql_postoperator: sql statement to run against MySQL after the import, typically used to move data from staging to production and issue cleanup commands. (templated) :type mysql_postoperator: str :param bulk_load: flag to use bulk_load option. This loads MySQL directly from a tab-delimited text file using the LOAD DATA LOCAL INFILE command. This option requires an extra connection parameter for the destination MySQL connection: {'local_infile': true}. :type bulk_load: bool """ template_fields = ('sql', 'mysql_table', 'mysql_preoperator', 'mysql_postoperator') template_ext = ('.sql',) ui_color = '#a0e08c' @apply_defaults def __init__( self, sql, mysql_table, vertica_conn_id='vertica_default', mysql_conn_id='mysql_default', mysql_preoperator=None, mysql_postoperator=None, bulk_load=False, *args, **kwargs): super(VerticaToMySqlTransfer, self).__init__(*args, **kwargs) self.sql = sql self.mysql_table = mysql_table self.mysql_conn_id = mysql_conn_id self.mysql_preoperator = mysql_preoperator self.mysql_postoperator = mysql_postoperator self.vertica_conn_id = vertica_conn_id self.bulk_load = bulk_load def execute(self, context): vertica = VerticaHook(vertica_conn_id=self.vertica_conn_id) mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id) tmpfile = None result = None selected_columns = [] count = 0 with closing(vertica.get_conn()) as conn: with closing(conn.cursor()) as cursor: cursor.execute(self.sql) selected_columns = [d.name for d in cursor.description] if self.bulk_load: tmpfile = NamedTemporaryFile("w") self.log.info( "Selecting rows from Vertica to local file %s...", tmpfile.name) self.log.info(self.sql) csv_writer = csv.writer(tmpfile, delimiter='\t', encoding='utf-8') for row in cursor.iterate(): csv_writer.writerow(row) count += 1 tmpfile.flush() else: self.log.info("Selecting rows from Vertica...") self.log.info(self.sql) result = cursor.fetchall() count = len(result) self.log.info("Selected rows from Vertica %s", count) if self.mysql_preoperator: self.log.info("Running MySQL preoperator...") mysql.run(self.mysql_preoperator) try: if self.bulk_load: self.log.info("Bulk inserting rows into MySQL...") with closing(mysql.get_conn()) as conn: with closing(conn.cursor()) as cursor: cursor.execute("LOAD DATA LOCAL INFILE '%s' INTO " "TABLE %s LINES TERMINATED BY '\r\n' (%s)" % (tmpfile.name, self.mysql_table, ", ".join(selected_columns))) conn.commit() tmpfile.close() else: self.log.info("Inserting rows into MySQL...") mysql.insert_rows(table=self.mysql_table, rows=result, target_fields=selected_columns) self.log.info("Inserted rows into MySQL %s", count) except (MySQLdb.Error, MySQLdb.Warning): self.log.info("Inserted rows into MySQL 0") raise if self.mysql_postoperator: self.log.info("Running MySQL postoperator...") mysql.run(self.mysql_postoperator) self.log.info("Done")
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 25709, 199, 199, 504, 16321, 14, 2828, 14, 7922, 14, 12101, 696, 63, 3664, 492, 5444, 15922, 8481, 199, 504, 16321, 14, 7922, 14, 8644, 63, 3664, 492, 4932, 16790, 8481, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 199, 199, 504, 15502, 492, 11261, 199, 199, 646, 2649, 4737, 465, 7392, 199, 504, 5549, 492, 31825, 421, 199, 533, 5444, 15922, 1378, 5713, 16790, 11761, 8, 1563, 7961, 304, 272, 408, 272, 3930, 2310, 666, 687, 5444, 15922, 370, 11200, 14, 339, 520, 635, 3875, 26, 5385, 1827, 370, 5341, 6169, 314, 5444, 15922, 3050, 14, 334, 1160, 68, 9, 272, 520, 466, 3875, 26, 620, 272, 520, 635, 809, 15922, 63, 1631, 63, 344, 26, 1350, 5444, 15922, 1950, 272, 520, 466, 809, 15922, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 1224, 26, 1347, 11200, 1817, 12, 675, 6308, 15843, 370, 1347, 282, 267, 2488, 3050, 14, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 1224, 26, 620, 272, 520, 635, 12896, 63, 1631, 63, 344, 26, 1350, 12896, 1950, 272, 520, 466, 12896, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 657, 3856, 26, 3875, 5164, 370, 1255, 6169, 11200, 6791, 370, 267, 492, 12, 13609, 675, 370, 14547, 402, 3145, 315, 4192, 402, 314, 666, 267, 17262, 315, 12, 17266, 314, 2120, 370, 506, 32122, 334, 5720, 314, 2120, 267, 13373, 7859, 1133, 4270, 2248, 666, 680, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 657, 3856, 26, 620, 272, 520, 635, 12896, 63, 1932, 3856, 26, 3875, 5164, 370, 1255, 6169, 11200, 2410, 314, 267, 492, 12, 13609, 1202, 370, 4057, 666, 687, 28512, 370, 9920, 267, 436, 4976, 9058, 3718, 14, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 1932, 3856, 26, 620, 272, 520, 635, 13137, 63, 912, 26, 3305, 370, 675, 13137, 63, 912, 945, 14, 221, 961, 14404, 11200, 5370, 267, 687, 282, 5174, 13, 25672, 1318, 570, 1808, 314, 3412, 1554, 7126, 20639, 1621, 3817, 1414, 14, 267, 961, 945, 5074, 376, 2402, 1950, 2725, 367, 314, 267, 5724, 11200, 1950, 26, 791, 1832, 63, 13880, 356, 2549, 5565, 272, 520, 466, 13137, 63, 912, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 3009, 297, 283, 8644, 63, 1224, 297, 283, 8644, 63, 657, 3856, 297, 2432, 283, 8644, 63, 1932, 3856, 358, 272, 1978, 63, 832, 275, 23500, 3009, 9538, 272, 8574, 63, 2326, 275, 3943, 65, 16, 69, 2036, 67, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 288, 291, 12, 288, 3875, 12, 288, 12896, 63, 1224, 12, 288, 809, 15922, 63, 1631, 63, 344, 534, 12101, 696, 63, 885, 297, 288, 12896, 63, 1631, 63, 344, 534, 8644, 63, 885, 297, 288, 12896, 63, 657, 3856, 29, 403, 12, 288, 12896, 63, 1932, 3856, 29, 403, 12, 288, 13137, 63, 912, 29, 797, 12, 288, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3673, 15922, 1378, 5713, 16790, 11761, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 8644, 63, 1224, 275, 12896, 63, 1224, 267, 291, 14, 8644, 63, 1631, 63, 344, 275, 12896, 63, 1631, 63, 344, 267, 291, 14, 8644, 63, 657, 3856, 275, 12896, 63, 657, 3856, 267, 291, 14, 8644, 63, 1932, 3856, 275, 12896, 63, 1932, 3856, 267, 291, 14, 12101, 696, 63, 1631, 63, 344, 275, 809, 15922, 63, 1631, 63, 344, 267, 291, 14, 9377, 63, 912, 275, 13137, 63, 912, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 809, 15922, 275, 5444, 15922, 8481, 8, 12101, 696, 63, 1631, 63, 344, 29, 277, 14, 12101, 696, 63, 1631, 63, 344, 9, 267, 12896, 275, 4932, 16790, 8481, 8, 8644, 63, 1631, 63, 344, 29, 277, 14, 8644, 63, 1631, 63, 344, 9, 398, 25137, 275, 488, 267, 754, 275, 488, 398, 4895, 63, 3406, 275, 942, 398, 2338, 275, 378, 267, 543, 11261, 8, 12101, 696, 14, 362, 63, 1631, 1012, 465, 2557, 26, 288, 543, 11261, 8, 1631, 14, 3937, 1012, 465, 3920, 26, 355, 3920, 14, 2526, 8, 277, 14, 3009, 9, 355, 4895, 63, 3406, 275, 359, 68, 14, 354, 367, 366, 315, 3920, 14, 1802, 61, 2234, 340, 291, 14, 9377, 63, 912, 26, 490, 25137, 275, 31825, 480, 87, 531, 4951, 291, 14, 793, 14, 815, 8, 717, 298, 5446, 316, 4730, 687, 5444, 15922, 370, 2257, 570, 450, 83, 23966, 717, 25137, 14, 354, 9, 490, 291, 14, 793, 14, 815, 8, 277, 14, 3009, 9, 4951, 7392, 63, 5491, 275, 7392, 14, 5491, 8, 21930, 12, 11172, 17115, 84, 297, 2644, 534, 1624, 13, 24, 358, 490, 367, 1962, 315, 3920, 14, 20627, 837, 717, 7392, 63, 5491, 14, 22686, 8, 1143, 9, 717, 2338, 847, 413, 4951, 25137, 14, 4939, 342, 355, 587, 26, 490, 291, 14, 793, 14, 815, 480 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 25709, 199, 199, 504, 16321, 14, 2828, 14, 7922, 14, 12101, 696, 63, 3664, 492, 5444, 15922, 8481, 199, 504, 16321, 14, 7922, 14, 8644, 63, 3664, 492, 4932, 16790, 8481, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 199, 199, 504, 15502, 492, 11261, 199, 199, 646, 2649, 4737, 465, 7392, 199, 504, 5549, 492, 31825, 421, 199, 533, 5444, 15922, 1378, 5713, 16790, 11761, 8, 1563, 7961, 304, 272, 408, 272, 3930, 2310, 666, 687, 5444, 15922, 370, 11200, 14, 339, 520, 635, 3875, 26, 5385, 1827, 370, 5341, 6169, 314, 5444, 15922, 3050, 14, 334, 1160, 68, 9, 272, 520, 466, 3875, 26, 620, 272, 520, 635, 809, 15922, 63, 1631, 63, 344, 26, 1350, 5444, 15922, 1950, 272, 520, 466, 809, 15922, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 1224, 26, 1347, 11200, 1817, 12, 675, 6308, 15843, 370, 1347, 282, 267, 2488, 3050, 14, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 1224, 26, 620, 272, 520, 635, 12896, 63, 1631, 63, 344, 26, 1350, 12896, 1950, 272, 520, 466, 12896, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 12896, 63, 657, 3856, 26, 3875, 5164, 370, 1255, 6169, 11200, 6791, 370, 267, 492, 12, 13609, 675, 370, 14547, 402, 3145, 315, 4192, 402, 314, 666, 267, 17262, 315, 12, 17266, 314, 2120, 370, 506, 32122, 334, 5720, 314, 2120, 267, 13373, 7859, 1133, 4270, 2248, 666, 680, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 657, 3856, 26, 620, 272, 520, 635, 12896, 63, 1932, 3856, 26, 3875, 5164, 370, 1255, 6169, 11200, 2410, 314, 267, 492, 12, 13609, 1202, 370, 4057, 666, 687, 28512, 370, 9920, 267, 436, 4976, 9058, 3718, 14, 334, 1160, 68, 9, 272, 520, 466, 12896, 63, 1932, 3856, 26, 620, 272, 520, 635, 13137, 63, 912, 26, 3305, 370, 675, 13137, 63, 912, 945, 14, 221, 961, 14404, 11200, 5370, 267, 687, 282, 5174, 13, 25672, 1318, 570, 1808, 314, 3412, 1554, 7126, 20639, 1621, 3817, 1414, 14, 267, 961, 945, 5074, 376, 2402, 1950, 2725, 367, 314, 267, 5724, 11200, 1950, 26, 791, 1832, 63, 13880, 356, 2549, 5565, 272, 520, 466, 13137, 63, 912, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 3009, 297, 283, 8644, 63, 1224, 297, 283, 8644, 63, 657, 3856, 297, 2432, 283, 8644, 63, 1932, 3856, 358, 272, 1978, 63, 832, 275, 23500, 3009, 9538, 272, 8574, 63, 2326, 275, 3943, 65, 16, 69, 2036, 67, 7, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 288, 291, 12, 288, 3875, 12, 288, 12896, 63, 1224, 12, 288, 809, 15922, 63, 1631, 63, 344, 534, 12101, 696, 63, 885, 297, 288, 12896, 63, 1631, 63, 344, 534, 8644, 63, 885, 297, 288, 12896, 63, 657, 3856, 29, 403, 12, 288, 12896, 63, 1932, 3856, 29, 403, 12, 288, 13137, 63, 912, 29, 797, 12, 288, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3673, 15922, 1378, 5713, 16790, 11761, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 8644, 63, 1224, 275, 12896, 63, 1224, 267, 291, 14, 8644, 63, 1631, 63, 344, 275, 12896, 63, 1631, 63, 344, 267, 291, 14, 8644, 63, 657, 3856, 275, 12896, 63, 657, 3856, 267, 291, 14, 8644, 63, 1932, 3856, 275, 12896, 63, 1932, 3856, 267, 291, 14, 12101, 696, 63, 1631, 63, 344, 275, 809, 15922, 63, 1631, 63, 344, 267, 291, 14, 9377, 63, 912, 275, 13137, 63, 912, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 809, 15922, 275, 5444, 15922, 8481, 8, 12101, 696, 63, 1631, 63, 344, 29, 277, 14, 12101, 696, 63, 1631, 63, 344, 9, 267, 12896, 275, 4932, 16790, 8481, 8, 8644, 63, 1631, 63, 344, 29, 277, 14, 8644, 63, 1631, 63, 344, 9, 398, 25137, 275, 488, 267, 754, 275, 488, 398, 4895, 63, 3406, 275, 942, 398, 2338, 275, 378, 267, 543, 11261, 8, 12101, 696, 14, 362, 63, 1631, 1012, 465, 2557, 26, 288, 543, 11261, 8, 1631, 14, 3937, 1012, 465, 3920, 26, 355, 3920, 14, 2526, 8, 277, 14, 3009, 9, 355, 4895, 63, 3406, 275, 359, 68, 14, 354, 367, 366, 315, 3920, 14, 1802, 61, 2234, 340, 291, 14, 9377, 63, 912, 26, 490, 25137, 275, 31825, 480, 87, 531, 4951, 291, 14, 793, 14, 815, 8, 717, 298, 5446, 316, 4730, 687, 5444, 15922, 370, 2257, 570, 450, 83, 23966, 717, 25137, 14, 354, 9, 490, 291, 14, 793, 14, 815, 8, 277, 14, 3009, 9, 4951, 7392, 63, 5491, 275, 7392, 14, 5491, 8, 21930, 12, 11172, 17115, 84, 297, 2644, 534, 1624, 13, 24, 358, 490, 367, 1962, 315, 3920, 14, 20627, 837, 717, 7392, 63, 5491, 14, 22686, 8, 1143, 9, 717, 2338, 847, 413, 4951, 25137, 14, 4939, 342, 355, 587, 26, 490, 291, 14, 793, 14, 815, 480, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ampax/edx-platform-backup
lms/djangoapps/shoppingcart/migrations/0013_auto__add_field_invoice_is_valid.py
114
13795
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Invoice.is_valid' db.add_column('shoppingcart_invoice', 'is_valid', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) def backwards(self, orm): # Deleting field 'Invoice.is_valid' db.delete_column('shoppingcart_invoice', 'is_valid') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'shoppingcart.certificateitem': { 'Meta': {'object_name': 'CertificateItem', '_ormbases': ['shoppingcart.OrderItem']}, 'course_enrollment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['student.CourseEnrollment']"}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.coupon': { 'Meta': {'object_name': 'Coupon'}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 20, 0, 0)'}), 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'percentage_discount': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'shoppingcart.couponredemption': { 'Meta': {'object_name': 'CouponRedemption'}, 'coupon': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Coupon']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.courseregistrationcode': { 'Meta': {'object_name': 'CourseRegistrationCode'}, 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 20, 0, 0)'}), 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_by_user'", 'to': "orm['auth.User']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'invoice': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Invoice']", 'null': 'True'}) }, 'shoppingcart.invoice': { 'Meta': {'object_name': 'Invoice'}, 'company_contact_email': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'company_contact_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'company_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'company_reference': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'internal_reference': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'is_valid': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'tax_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}), 'total_amount': ('django.db.models.fields.FloatField', [], {}) }, 'shoppingcart.order': { 'Meta': {'object_name': 'Order'}, 'bill_to_cardtype': ('django.db.models.fields.CharField', [], {'max_length': '32', 'blank': 'True'}), 'bill_to_ccnum': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_country': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_first': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_last': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), 'bill_to_postalcode': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), 'bill_to_state': ('django.db.models.fields.CharField', [], {'max_length': '8', 'blank': 'True'}), 'bill_to_street1': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'bill_to_street2': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'processor_reply_dump': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'purchase_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'refunded_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.orderitem': { 'Meta': {'object_name': 'OrderItem'}, 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'fulfilled_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'line_desc': ('django.db.models.fields.CharField', [], {'default': "'Misc. Item'", 'max_length': '1024'}), 'list_price': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '30', 'decimal_places': '2'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'qty': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'refund_requested_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}), 'report_comments': ('django.db.models.fields.TextField', [], {'default': "''"}), 'service_fee': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'cart'", 'max_length': '32', 'db_index': 'True'}), 'unit_cost': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '30', 'decimal_places': '2'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'shoppingcart.paidcourseregistration': { 'Meta': {'object_name': 'PaidCourseRegistration', '_ormbases': ['shoppingcart.OrderItem']}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '128', 'db_index': 'True'}), 'mode': ('django.db.models.fields.SlugField', [], {'default': "'honor'", 'max_length': '50'}), 'orderitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shoppingcart.OrderItem']", 'unique': 'True', 'primary_key': 'True'}) }, 'shoppingcart.paidcourseregistrationannotation': { 'Meta': {'object_name': 'PaidCourseRegistrationAnnotation'}, 'annotation': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'course_id': ('xmodule_django.models.CourseKeyField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'shoppingcart.registrationcoderedemption': { 'Meta': {'object_name': 'RegistrationCodeRedemption'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'order': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.Order']"}), 'redeemed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 20, 0, 0)', 'null': 'True'}), 'redeemed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'registration_code': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shoppingcart.CourseRegistrationCode']"}) }, 'student.courseenrollment': { 'Meta': {'ordering': "('user', 'course_id')", 'unique_together': "(('user', 'course_id'),)", 'object_name': 'CourseEnrollment'}, 'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'mode': ('django.db.models.fields.CharField', [], {'default': "'honor'", 'max_length': '100'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) } } complete_apps = ['shoppingcart']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 21092, 14, 374, 63, 1078, 7, 267, 1592, 14, 525, 63, 2301, 360, 17788, 63, 5404, 297, 283, 374, 63, 1078, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 21092, 14, 374, 63, 1078, 7, 267, 1592, 14, 1807, 63, 2301, 360, 17788, 63, 5404, 297, 283, 374, 63, 1078, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 17788, 14, 6999, 1053, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11414, 2081, 297, 2513, 31525, 356, 788, 17788, 14, 4738, 2081, 14949, 288, 283, 1972, 63, 12214, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 5500, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 21092, 14, 374, 63, 1078, 7, 267, 1592, 14, 525, 63, 2301, 360, 17788, 63, 5404, 297, 283, 374, 63, 1078, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 21092, 14, 374, 63, 1078, 7, 267, 1592, 14, 1807, 63, 2301, 360, 17788, 63, 5404, 297, 283, 374, 63, 1078, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 17788, 14, 6999, 1053, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11414, 2081, 297, 2513, 31525, 356, 788, 17788, 14, 4738, 2081, 14949, 288, 283, 1972, 63, 12214, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 5500, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dwitvliet/CATMAID
scripts/remote/example.py
6
1242
### Example for using CATMAID Frontend to retrieve a neuron's skeleton ### including the synaptic connectors import urllib, json import http.cookiejar as cj from catmaid_frontend import * remote_instance = None #Provide Credentials for CATMAID Server http_user = '' http_pw = '' catmaid_user = '' catmaid_pw = '' #Server URL is set for access from outside of Janelia remote_instance = None server_url = 'http://neurocean.janelia.org/catmaidL1' #skeleton ID to pull neuron from server example_skeleton_id = 11666771 #Create CATMAID instance remote_instance =CatmaidInstance( server_url, catmaid_user, catmaid_pw, http_user, http_pw ) #Decode and print response from Server print( json.loads( remote_instance.login().decode( 'utf-8' ) ) ) #Create URL for retrieving example skeleton from server remote_skeleton_for_3D_url = remote_instance.get_skeleton_for_3d_viewer_url( 1 , example_skeleton_id ) #Retrieve node_data for example skeleton skeleton_data = remote_instance.get_page( remote_skeleton_for_3D_url ) #Skeleton data is an array containg: #skeleton_data = [neuron_name,[nodes],{tags},[connectors] #[nodes] = treenode_id, parent_node_id, user_id, location_x, location_y, location_z, radius, confidence print(skeleton_data)
gpl-3.0
[ 5680, 5679, 367, 1808, 445, 619, 2054, 998, 481, 11537, 370, 8044, 282, 20242, 1159, 30537, 199, 5680, 5893, 314, 9560, 439, 764, 4907, 1384, 199, 199, 646, 4011, 12, 2022, 199, 646, 1455, 14, 30552, 465, 286, 74, 199, 504, 6230, 391, 344, 63, 18062, 492, 627, 199, 199, 3846, 63, 842, 275, 488, 199, 199, 3, 25107, 23934, 367, 445, 619, 2054, 998, 7146, 199, 1014, 63, 751, 275, 2125, 199, 1014, 63, 8796, 275, 2125, 199, 199, 3385, 391, 344, 63, 751, 275, 2125, 199, 3385, 391, 344, 63, 8796, 275, 2125, 199, 199, 3, 3120, 2851, 365, 663, 367, 2879, 687, 9682, 402, 1603, 5865, 21796, 199, 3846, 63, 842, 275, 488, 199, 1000, 63, 633, 275, 283, 1014, 921, 685, 9129, 20867, 14, 74, 5865, 21796, 14, 1308, 15, 3385, 391, 344, 44, 17, 7, 199, 199, 3, 29250, 2870, 370, 10299, 20242, 687, 1654, 199, 2694, 63, 29250, 63, 344, 275, 25186, 1272, 19371, 199, 199, 3, 2499, 445, 619, 2054, 998, 1256, 199, 3846, 63, 842, 275, 21548, 391, 344, 3244, 8, 1654, 63, 633, 12, 6230, 391, 344, 63, 751, 12, 6230, 391, 344, 63, 8796, 12, 1455, 63, 751, 12, 1455, 63, 8796, 776, 199, 3, 9400, 436, 870, 1177, 687, 7146, 199, 1361, 8, 2022, 14, 3640, 8, 3982, 63, 842, 14, 2886, 1252, 2708, 8, 283, 1624, 13, 24, 7, 776, 776, 776, 199, 199, 3, 2499, 2851, 367, 23812, 2893, 30537, 687, 1654, 199, 3846, 63, 29250, 63, 509, 63, 19, 36, 63, 633, 275, 3982, 63, 842, 14, 362, 63, 29250, 63, 509, 63, 19, 68, 63, 16645, 63, 633, 8, 413, 2360, 2893, 63, 29250, 63, 344, 776, 199, 199, 3, 15310, 1031, 63, 576, 367, 2893, 30537, 199, 29250, 63, 576, 275, 3982, 63, 842, 14, 362, 63, 1606, 8, 3982, 63, 29250, 63, 509, 63, 19, 36, 63, 633, 776, 199, 199, 3, 51, 415, 17589, 666, 365, 376, 1625, 406, 502, 316, 26, 199, 3, 29250, 63, 576, 275, 359, 32054, 63, 354, 14343, 2415, 467, 91, 2969, 1386, 59, 2242, 1384, 61, 199, 3, 59, 2415, 61, 275, 307, 3441, 380, 63, 344, 12, 1676, 63, 932, 63, 344, 12, 922, 63, 344, 12, 2909, 63, 88, 12, 2909, 63, 89, 12, 2909, 63, 90, 12, 9362, 12, 15197, 199, 1361, 8, 29250, 63, 576, 9, 28154, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5679, 367, 1808, 445, 619, 2054, 998, 481, 11537, 370, 8044, 282, 20242, 1159, 30537, 199, 5680, 5893, 314, 9560, 439, 764, 4907, 1384, 199, 199, 646, 4011, 12, 2022, 199, 646, 1455, 14, 30552, 465, 286, 74, 199, 504, 6230, 391, 344, 63, 18062, 492, 627, 199, 199, 3846, 63, 842, 275, 488, 199, 199, 3, 25107, 23934, 367, 445, 619, 2054, 998, 7146, 199, 1014, 63, 751, 275, 2125, 199, 1014, 63, 8796, 275, 2125, 199, 199, 3385, 391, 344, 63, 751, 275, 2125, 199, 3385, 391, 344, 63, 8796, 275, 2125, 199, 199, 3, 3120, 2851, 365, 663, 367, 2879, 687, 9682, 402, 1603, 5865, 21796, 199, 3846, 63, 842, 275, 488, 199, 1000, 63, 633, 275, 283, 1014, 921, 685, 9129, 20867, 14, 74, 5865, 21796, 14, 1308, 15, 3385, 391, 344, 44, 17, 7, 199, 199, 3, 29250, 2870, 370, 10299, 20242, 687, 1654, 199, 2694, 63, 29250, 63, 344, 275, 25186, 1272, 19371, 199, 199, 3, 2499, 445, 619, 2054, 998, 1256, 199, 3846, 63, 842, 275, 21548, 391, 344, 3244, 8, 1654, 63, 633, 12, 6230, 391, 344, 63, 751, 12, 6230, 391, 344, 63, 8796, 12, 1455, 63, 751, 12, 1455, 63, 8796, 776, 199, 3, 9400, 436, 870, 1177, 687, 7146, 199, 1361, 8, 2022, 14, 3640, 8, 3982, 63, 842, 14, 2886, 1252, 2708, 8, 283, 1624, 13, 24, 7, 776, 776, 776, 199, 199, 3, 2499, 2851, 367, 23812, 2893, 30537, 687, 1654, 199, 3846, 63, 29250, 63, 509, 63, 19, 36, 63, 633, 275, 3982, 63, 842, 14, 362, 63, 29250, 63, 509, 63, 19, 68, 63, 16645, 63, 633, 8, 413, 2360, 2893, 63, 29250, 63, 344, 776, 199, 199, 3, 15310, 1031, 63, 576, 367, 2893, 30537, 199, 29250, 63, 576, 275, 3982, 63, 842, 14, 362, 63, 1606, 8, 3982, 63, 29250, 63, 509, 63, 19, 36, 63, 633, 776, 199, 199, 3, 51, 415, 17589, 666, 365, 376, 1625, 406, 502, 316, 26, 199, 3, 29250, 63, 576, 275, 359, 32054, 63, 354, 14343, 2415, 467, 91, 2969, 1386, 59, 2242, 1384, 61, 199, 3, 59, 2415, 61, 275, 307, 3441, 380, 63, 344, 12, 1676, 63, 932, 63, 344, 12, 922, 63, 344, 12, 2909, 63, 88, 12, 2909, 63, 89, 12, 2909, 63, 90, 12, 9362, 12, 15197, 199, 1361, 8, 29250, 63, 576, 9, 28154, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
SmithsonianEnterprises/django-cms
cms/test_utils/project/bunch_of_plugins/migrations/0001_initial.py
66
1144
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import cms.test_utils.project.bunch_of_plugins.models class Migration(migrations.Migration): dependencies = [ ('cms', '0001_initial'), ] operations = [ migrations.CreateModel( name='TestPlugin1', fields=[ ('cmsplugin_ptr', models.OneToOneField(primary_key=True, to='cms.CMSPlugin', auto_created=True, parent_link=True, serialize=False)), ], options={ 'abstract': False, }, bases=('cms.cmsplugin',), ), migrations.CreateModel( name='TestPlugin2', fields=[ ('cmsplugin_ptr', models.OneToOneField(primary_key=True, to='cms.CMSPlugin', auto_created=True, parent_link=True, serialize=False)), ], options={ 'abstract': False, }, bases=(cms.test_utils.project.bunch_of_plugins.models.LeftMixin, 'cms.cmsplugin', cms.test_utils.project.bunch_of_plugins.models.RightMixin), ), ]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 19240, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10781, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 774, 5061, 17, 297, 288, 1504, 1524, 355, 661, 4400, 30873, 63, 4695, 297, 1709, 14, 14298, 8, 3327, 63, 498, 29, 549, 12, 370, 534, 10781, 14, 17834, 5061, 297, 2599, 63, 3966, 29, 549, 12, 1676, 63, 1073, 29, 549, 12, 8437, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 7782, 10781, 14, 4400, 30873, 5529, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 774, 5061, 18, 297, 288, 1504, 1524, 355, 661, 4400, 30873, 63, 4695, 297, 1709, 14, 14298, 8, 3327, 63, 498, 29, 549, 12, 370, 534, 10781, 14, 17834, 5061, 297, 2599, 63, 3966, 29, 549, 12, 1676, 63, 1073, 29, 549, 12, 8437, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 10781, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 14, 8185, 4256, 12, 283, 10781, 14, 4400, 30873, 297, 19240, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 14, 9121, 4256, 395, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 19240, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10781, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 774, 5061, 17, 297, 288, 1504, 1524, 355, 661, 4400, 30873, 63, 4695, 297, 1709, 14, 14298, 8, 3327, 63, 498, 29, 549, 12, 370, 534, 10781, 14, 17834, 5061, 297, 2599, 63, 3966, 29, 549, 12, 1676, 63, 1073, 29, 549, 12, 8437, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 7782, 10781, 14, 4400, 30873, 5529, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 774, 5061, 18, 297, 288, 1504, 1524, 355, 661, 4400, 30873, 63, 4695, 297, 1709, 14, 14298, 8, 3327, 63, 498, 29, 549, 12, 370, 534, 10781, 14, 17834, 5061, 297, 2599, 63, 3966, 29, 549, 12, 1676, 63, 1073, 29, 549, 12, 8437, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 10781, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 14, 8185, 4256, 12, 283, 10781, 14, 4400, 30873, 297, 19240, 14, 396, 63, 1208, 14, 1715, 14, 66, 4689, 63, 1618, 63, 5265, 14, 992, 14, 9121, 4256, 395, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kingofsystem/django-allauth
allauth/socialaccount/providers/stackexchange/provider.py
75
1254
from allauth.socialaccount import providers from allauth.socialaccount.providers.base import ProviderAccount from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider class StackExchangeAccount(ProviderAccount): def get_profile_url(self): return self.account.extra_data.get('html_url') def get_avatar_url(self): return self.account.extra_data.get('avatar_url') def to_str(self): dflt = super(StackExchangeAccount, self).to_str() return self.account.extra_data.get('name', dflt) class StackExchangeProvider(OAuth2Provider): id = 'stackexchange' name = 'Stack Exchange' package = 'allauth.socialaccount.providers.stackexchange' account_class = StackExchangeAccount def get_site(self): settings = self.get_settings() return settings.get('SITE', 'stackoverflow') def extract_uid(self, data): # `user_id` varies if you use the same account for # e.g. StackOverflow and ServerFault. Therefore, we pick # `account_id`. uid = str(data['account_id']) return uid def extract_common_fields(self, data): return dict(username=data.get('display_name')) providers.registry.register(StackExchangeProvider)
mit
[ 504, 741, 416, 762, 14, 31932, 492, 18032, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 1095, 492, 18489, 6009, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 6126, 18, 14, 3780, 492, 11715, 18, 6663, 421, 199, 533, 13894, 13188, 6009, 8, 6663, 6009, 304, 272, 347, 664, 63, 2913, 63, 633, 8, 277, 304, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 1360, 63, 633, 358, 339, 347, 664, 63, 14584, 63, 633, 8, 277, 304, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 14584, 63, 633, 358, 339, 347, 370, 63, 495, 8, 277, 304, 267, 366, 26057, 275, 1613, 8, 4851, 13188, 6009, 12, 291, 680, 475, 63, 495, 342, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 354, 297, 366, 26057, 9, 421, 199, 533, 13894, 13188, 6663, 8, 12906, 18, 6663, 304, 272, 1305, 275, 283, 2340, 14197, 7, 272, 536, 275, 283, 4851, 25655, 7, 272, 2559, 275, 283, 29339, 762, 14, 31932, 14, 9710, 14, 2340, 14197, 7, 272, 2933, 63, 533, 275, 13894, 13188, 6009, 339, 347, 664, 63, 2124, 8, 277, 304, 267, 2202, 275, 291, 14, 362, 63, 1751, 342, 267, 372, 2202, 14, 362, 360, 7917, 297, 283, 23153, 358, 339, 347, 5536, 63, 1535, 8, 277, 12, 666, 304, 267, 327, 658, 751, 63, 344, 64, 373, 3433, 340, 1265, 675, 314, 2011, 2933, 367, 267, 327, 325, 14, 71, 14, 13894, 5674, 1659, 436, 7146, 16665, 14, 21039, 12, 781, 3732, 267, 327, 658, 2048, 63, 344, 2313, 267, 1747, 275, 620, 8, 576, 459, 2048, 63, 344, 1105, 267, 372, 1747, 339, 347, 5536, 63, 2330, 63, 955, 8, 277, 12, 666, 304, 267, 372, 1211, 8, 2473, 29, 576, 14, 362, 360, 2918, 63, 354, 1333, 421, 199, 9710, 14, 5189, 14, 2683, 8, 4851, 13188, 6663, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 741, 416, 762, 14, 31932, 492, 18032, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 1095, 492, 18489, 6009, 199, 504, 741, 416, 762, 14, 31932, 14, 9710, 14, 6126, 18, 14, 3780, 492, 11715, 18, 6663, 421, 199, 533, 13894, 13188, 6009, 8, 6663, 6009, 304, 272, 347, 664, 63, 2913, 63, 633, 8, 277, 304, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 1360, 63, 633, 358, 339, 347, 664, 63, 14584, 63, 633, 8, 277, 304, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 14584, 63, 633, 358, 339, 347, 370, 63, 495, 8, 277, 304, 267, 366, 26057, 275, 1613, 8, 4851, 13188, 6009, 12, 291, 680, 475, 63, 495, 342, 267, 372, 291, 14, 2048, 14, 2911, 63, 576, 14, 362, 360, 354, 297, 366, 26057, 9, 421, 199, 533, 13894, 13188, 6663, 8, 12906, 18, 6663, 304, 272, 1305, 275, 283, 2340, 14197, 7, 272, 536, 275, 283, 4851, 25655, 7, 272, 2559, 275, 283, 29339, 762, 14, 31932, 14, 9710, 14, 2340, 14197, 7, 272, 2933, 63, 533, 275, 13894, 13188, 6009, 339, 347, 664, 63, 2124, 8, 277, 304, 267, 2202, 275, 291, 14, 362, 63, 1751, 342, 267, 372, 2202, 14, 362, 360, 7917, 297, 283, 23153, 358, 339, 347, 5536, 63, 1535, 8, 277, 12, 666, 304, 267, 327, 658, 751, 63, 344, 64, 373, 3433, 340, 1265, 675, 314, 2011, 2933, 367, 267, 327, 325, 14, 71, 14, 13894, 5674, 1659, 436, 7146, 16665, 14, 21039, 12, 781, 3732, 267, 327, 658, 2048, 63, 344, 2313, 267, 1747, 275, 620, 8, 576, 459, 2048, 63, 344, 1105, 267, 372, 1747, 339, 347, 5536, 63, 2330, 63, 955, 8, 277, 12, 666, 304, 267, 372, 1211, 8, 2473, 29, 576, 14, 362, 360, 2918, 63, 354, 1333, 421, 199, 9710, 14, 5189, 14, 2683, 8, 4851, 13188, 6663, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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test_classes import WebhookTestCase class StashHookTests(WebhookTestCase): STREAM_NAME = 'stash' URL_TEMPLATE = u"/api/v1/external/stash?stream={stream}" def test_stash_message(self): # type: () -> None """ Messages are generated by Stash on a `git push`. The subject describes the repo and Stash "project". The content describes the commits pushed. """ expected_subject = u"Secret project/Operation unicorn: master" expected_message = """`f259e90` was pushed to **master** in **Secret project/Operation unicorn** with: * `f259e90`: Updating poms ...""" self.send_and_test_stream_message('push', expected_subject, expected_message, content_type="application/x-www-form-urlencoded", **self.api_auth(self.TEST_USER_EMAIL)) def get_body(self, fixture_name): # type: (Text) -> Text return self.fixture_data("stash", fixture_name, file_type="json")
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 14090, 492, 4516, 199, 504, 19959, 14, 773, 14, 396, 63, 2888, 492, 6001, 3664, 1746, 199, 199, 533, 10126, 8481, 2925, 8, 5926, 3664, 1746, 304, 272, 4384, 8909, 63, 2339, 275, 283, 27145, 7, 272, 2851, 63, 7433, 275, 399, 15313, 1246, 15, 86, 17, 15, 5159, 15, 27145, 31, 1745, 3126, 1745, 7063, 339, 347, 511, 63, 27145, 63, 1188, 8, 277, 304, 267, 327, 730, 26, 6248, 1035, 488, 267, 408, 267, 27377, 787, 4046, 701, 10126, 641, 282, 658, 3187, 6675, 2313, 398, 710, 5420, 23369, 314, 3831, 436, 10126, 298, 1715, 1674, 710, 267, 1564, 23369, 314, 20835, 22319, 14, 267, 408, 267, 1420, 63, 5875, 275, 399, 2, 13790, 2199, 15, 6044, 625, 530, 6161, 26, 5288, 2, 267, 1420, 63, 1188, 275, 408, 64, 70, 11990, 69, 2710, 64, 1990, 22319, 370, 1011, 4133, 538, 315, 1011, 13790, 2199, 15, 6044, 625, 530, 6161, 538, 543, 26, 199, 199, 10, 658, 70, 11990, 69, 2710, 8340, 4949, 9239, 299, 22491, 2508, 1041, 267, 291, 14, 2254, 63, 460, 63, 396, 63, 1745, 63, 1188, 360, 5335, 297, 1420, 63, 5875, 12, 1420, 63, 1188, 12, 5101, 1564, 63, 466, 628, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 401, 5101, 1011, 277, 14, 1246, 63, 1178, 8, 277, 14, 2864, 63, 3791, 63, 10089, 430, 339, 347, 664, 63, 2030, 8, 277, 12, 10949, 63, 354, 304, 267, 327, 730, 26, 334, 1872, 9, 1035, 4516, 267, 372, 291, 14, 5997, 63, 576, 480, 27145, 401, 10949, 63, 354, 12, 570, 63, 466, 628, 1001, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14090, 492, 4516, 199, 504, 19959, 14, 773, 14, 396, 63, 2888, 492, 6001, 3664, 1746, 199, 199, 533, 10126, 8481, 2925, 8, 5926, 3664, 1746, 304, 272, 4384, 8909, 63, 2339, 275, 283, 27145, 7, 272, 2851, 63, 7433, 275, 399, 15313, 1246, 15, 86, 17, 15, 5159, 15, 27145, 31, 1745, 3126, 1745, 7063, 339, 347, 511, 63, 27145, 63, 1188, 8, 277, 304, 267, 327, 730, 26, 6248, 1035, 488, 267, 408, 267, 27377, 787, 4046, 701, 10126, 641, 282, 658, 3187, 6675, 2313, 398, 710, 5420, 23369, 314, 3831, 436, 10126, 298, 1715, 1674, 710, 267, 1564, 23369, 314, 20835, 22319, 14, 267, 408, 267, 1420, 63, 5875, 275, 399, 2, 13790, 2199, 15, 6044, 625, 530, 6161, 26, 5288, 2, 267, 1420, 63, 1188, 275, 408, 64, 70, 11990, 69, 2710, 64, 1990, 22319, 370, 1011, 4133, 538, 315, 1011, 13790, 2199, 15, 6044, 625, 530, 6161, 538, 543, 26, 199, 199, 10, 658, 70, 11990, 69, 2710, 8340, 4949, 9239, 299, 22491, 2508, 1041, 267, 291, 14, 2254, 63, 460, 63, 396, 63, 1745, 63, 1188, 360, 5335, 297, 1420, 63, 5875, 12, 1420, 63, 1188, 12, 5101, 1564, 63, 466, 628, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 401, 5101, 1011, 277, 14, 1246, 63, 1178, 8, 277, 14, 2864, 63, 3791, 63, 10089, 430, 339, 347, 664, 63, 2030, 8, 277, 12, 10949, 63, 354, 304, 267, 327, 730, 26, 334, 1872, 9, 1035, 4516, 267, 372, 291, 14, 5997, 63, 576, 480, 27145, 401, 10949, 63, 354, 12, 570, 63, 466, 628, 1001, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
kurikaesu/arsenalsuite
cpp/lib/PyQt4/examples/sql/connection.py
17
6103
#!/bin/env python ############################################################################# ## ## Copyright (C) 2010 Riverbank Computing Limited. ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ## All rights reserved. ## ## This file is part of the examples of PyQt. ## ## $QT_BEGIN_LICENSE:BSD$ ## You may use this file under the terms of the BSD license as follows: ## ## "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 Nokia Corporation and its Subsidiary(-ies) 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." ## $QT_END_LICENSE$ ## ############################################################################# from PyQt4 import QtSql, QtGui def createConnection(): db = QtSql.QSqlDatabase.addDatabase('QSQLITE') db.setDatabaseName(':memory:') if not db.open(): QtGui.QMessageBox.critical(None, QtGui.qApp.tr("Cannot open database"), QtGui.qApp.tr("Unable to establish a database connection.\n" "This example needs SQLite support. Please read " "the Qt SQL driver documentation for information " "how to build it.\n\n" "Click Cancel to exit."), QtGui.QMessageBox.Cancel) return False query = QtSql.QSqlQuery() query.exec_("create table person(id int primary key, " "firstname varchar(20), lastname varchar(20))") query.exec_("insert into person values(101, 'Danny', 'Young')") query.exec_("insert into person values(102, 'Christine', 'Holand')") query.exec_("insert into person values(103, 'Lars', 'Gordon')") query.exec_("insert into person values(104, 'Roberto', 'Robitaille')") query.exec_("insert into person values(105, 'Maria', 'Papadopoulos')") query.exec_("create table offices (id int primary key," "imagefile int," "location varchar(20)," "country varchar(20)," "description varchar(100))"); query.exec_("insert into offices " "values(0, 0, 'Oslo', 'Norway'," "'Oslo is home to more than 500 000 citizens and has a " "lot to offer.It has been called \"The city with the big " "heart\" and this is a nickname we are happy to live up to.')") query.exec_("insert into offices " "values(1, 1, 'Brisbane', 'Australia'," "'Brisbane is the capital of Queensland, the Sunshine State, " "where it is beautiful one day, perfect the next. " "Brisbane is Australia''s 3rd largest city, being home " "to almost 2 million people.')") query.exec_("insert into offices " "values(2, 2, 'Redwood City', 'US'," "'You find Redwood City in the heart of the Bay Area " "just north of Silicon Valley. The largest nearby city is " "San Jose which is the third largest city in California " "and the 10th largest in the US.')") query.exec_("insert into offices " "values(3, 3, 'Berlin', 'Germany'," "'Berlin, the capital of Germany is dynamic, cosmopolitan " "and creative, allowing for every kind of lifestyle. " "East meets West in the metropolis at the heart of a " "changing Europe.')") query.exec_("insert into offices " "values(4, 4, 'Munich', 'Germany'," "'Several technology companies are represented in Munich, " "and the city is often called the \"Bavarian Silicon Valley\". " "The exciting city is also filled with culture, " "art and music. ')") query.exec_("insert into offices " "values(5, 5, 'Beijing', 'China'," "'Beijing as a capital city has more than 3000 years of " "history. Today the city counts 12 million citizens, and " "is the political, economic and cultural centre of China.')") query.exec_("create table images (locationid int, file varchar(20))") query.exec_("insert into images values(0, 'images/oslo.png')") query.exec_("insert into images values(1, 'images/brisbane.png')") query.exec_("insert into images values(2, 'images/redwood.png')") query.exec_("insert into images values(3, 'images/berlin.png')") query.exec_("insert into images values(4, 'images/munich.png')") query.exec_("insert into images values(5, 'images/beijing.png')") return True
gpl-2.0
[ 3381, 1393, 15, 1813, 2366, 421, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 7129, 820, 4380, 9860, 27799, 23954, 14, 199, 309, 1898, 334, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 309, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 7251, 402, 14084, 14, 199, 309, 199, 309, 2672, 19229, 63, 15947, 63, 3961, 26, 15400, 4, 199, 309, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 309, 7647, 26, 199, 309, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 309, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 309, 258, 4084, 14, 199, 309, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 309, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 309, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 309, 258, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 309, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 309, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 309, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 309, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 309, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 309, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 309, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 309, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 2672, 19229, 63, 3902, 63, 3961, 4, 199, 309, 199, 31635, 421, 199, 504, 14084, 20, 492, 3959, 16790, 12, 5928, 421, 199, 318, 1218, 3225, 837, 272, 1592, 275, 3959, 16790, 14, 49, 16790, 7243, 14, 525, 7243, 360, 49, 4657, 4427, 358, 272, 1592, 14, 409, 7243, 985, 6176, 4844, 10993, 272, 340, 440, 1592, 14, 1490, 837, 267, 5928, 14, 30798, 14, 13138, 8, 403, 12, 5928, 14, 81, 2640, 14, 454, 480, 6612, 1551, 3050, 1288, 355, 5928, 14, 81, 2640, 14, 454, 480, 6005, 370, 16873, 282, 3050, 1950, 3134, 78, 2, 2892, 298, 2765, 2893, 4839, 19245, 2291, 14, 7754, 1586, 298, 2892, 298, 1589, 3959, 5385, 5253, 3794, 367, 2556, 298, 2892, 298, 1917, 370, 1900, 652, 3134, 78, 60, 78, 2, 2892, 298, 12040, 28374, 370, 4458, 7651, 355, 5928, 14, 30798, 14, 9083, 9, 267, 372, 756, 2286, 1827, 275, 3959, 16790, 14, 49, 16790, 3227, 342, 272, 1827, 14, 1628, 14332, 981, 1817, 4954, 8, 344, 1109, 5062, 790, 12, 298, 355, 298, 25603, 31044, 8, 1165, 395, 2061, 354, 31044, 8, 1165, 430, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 4893, 12, 283, 36, 1189, 89, 297, 283, 32154, 10335, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 7759, 12, 283, 1049, 18824, 1132, 297, 283, 40, 393, 460, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 8845, 12, 283, 44, 4291, 297, 283, 39, 2181, 265, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 6785, 12, 283, 3863, 605, 475, 297, 283, 3863, 2075, 1054, 274, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 7320, 12, 283, 45, 27957, 297, 283, 48, 439, 350, 411, 810, 11560, 26530, 339, 1827, 14, 1628, 14332, 981, 1817, 402, 329, 823, 334, 344, 1109, 5062, 790, 4589, 6163, 298, 1569, 493, 1109, 4589, 6163, 298, 1985, 31044, 8, 1165, 395, 2, 6163, 298, 6063, 31044, 8, 1165, 395, 2, 6163, 298, 1802, 31044, 8, 1960, 430, 3547, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 16, 12, 378, 12, 283, 24351, 320, 297, 283, 23008, 3316, 297, 2, 2049, 3546, 24351, 320, 365, 5629, 370, 1655, 2419, 6891, 21551, 286, 5277, 5193, 83, 436, 965, 282, 298, 2049, 298, 1653, 370, 19793, 14, 7940, 965, 2757, 2797, 8441, 1918, 14492, 543, 314, 7282, 298, 2049, 298, 426, 580, 4451, 436, 642, 365, 282, 24332, 781, 787, 394, 18869, 370, 12166, 1536, 370, 2659, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 17, 12, 413, 12, 283, 34, 5719, 66, 5865, 297, 283, 29459, 297, 2, 2049, 3546, 34, 5719, 66, 5865, 365, 314, 17094, 402, 1413, 310, 287, 2482, 460, 12, 314, 25625, 609, 1132, 8511, 12, 298, 2049, 298, 4509, 652, 365, 506, 25146, 1373, 5382, 12, 23668, 314, 2163, 14, 221, 298, 2049, 298, 34, 5719, 66, 5865, 365, 437, 22306, 891, 83, 650, 6883, 17451, 14492, 12, 3769, 5629, 298, 2049, 298, 475, 18871, 499, 15949, 265, 13135, 2659, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 18, 12, 499, 12, 283, 10858, 22736, 14753, 297, 283, 1668, 297, 2, 2049, 3546, 5556, 2342, 9572, 22736, 14753, 315, 314, 946, 580, 402, 314, 29434, 26280, 298, 2049, 298, 4764, 6590, 273, 402, 428, 1638, 388, 812, 4598, 89, 14, 710, 17451, 17429, 991, 14492, 365, 298, 2049, 298, 23906, 1603, 3362, 1314, 365, 314, 10919, 17451, 14492, 315, 8256, 73 ]
[ 1393, 15, 1813, 2366, 421, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 7129, 820, 4380, 9860, 27799, 23954, 14, 199, 309, 1898, 334, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 309, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 7251, 402, 14084, 14, 199, 309, 199, 309, 2672, 19229, 63, 15947, 63, 3961, 26, 15400, 4, 199, 309, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 309, 7647, 26, 199, 309, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 309, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 309, 258, 4084, 14, 199, 309, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 309, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 309, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 309, 258, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 309, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 309, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 309, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 309, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 309, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 309, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 309, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 309, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 2672, 19229, 63, 3902, 63, 3961, 4, 199, 309, 199, 31635, 421, 199, 504, 14084, 20, 492, 3959, 16790, 12, 5928, 421, 199, 318, 1218, 3225, 837, 272, 1592, 275, 3959, 16790, 14, 49, 16790, 7243, 14, 525, 7243, 360, 49, 4657, 4427, 358, 272, 1592, 14, 409, 7243, 985, 6176, 4844, 10993, 272, 340, 440, 1592, 14, 1490, 837, 267, 5928, 14, 30798, 14, 13138, 8, 403, 12, 5928, 14, 81, 2640, 14, 454, 480, 6612, 1551, 3050, 1288, 355, 5928, 14, 81, 2640, 14, 454, 480, 6005, 370, 16873, 282, 3050, 1950, 3134, 78, 2, 2892, 298, 2765, 2893, 4839, 19245, 2291, 14, 7754, 1586, 298, 2892, 298, 1589, 3959, 5385, 5253, 3794, 367, 2556, 298, 2892, 298, 1917, 370, 1900, 652, 3134, 78, 60, 78, 2, 2892, 298, 12040, 28374, 370, 4458, 7651, 355, 5928, 14, 30798, 14, 9083, 9, 267, 372, 756, 2286, 1827, 275, 3959, 16790, 14, 49, 16790, 3227, 342, 272, 1827, 14, 1628, 14332, 981, 1817, 4954, 8, 344, 1109, 5062, 790, 12, 298, 355, 298, 25603, 31044, 8, 1165, 395, 2061, 354, 31044, 8, 1165, 430, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 4893, 12, 283, 36, 1189, 89, 297, 283, 32154, 10335, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 7759, 12, 283, 1049, 18824, 1132, 297, 283, 40, 393, 460, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 8845, 12, 283, 44, 4291, 297, 283, 39, 2181, 265, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 6785, 12, 283, 3863, 605, 475, 297, 283, 3863, 2075, 1054, 274, 26530, 272, 1827, 14, 1628, 14332, 3176, 1901, 4954, 1338, 8, 7320, 12, 283, 45, 27957, 297, 283, 48, 439, 350, 411, 810, 11560, 26530, 339, 1827, 14, 1628, 14332, 981, 1817, 402, 329, 823, 334, 344, 1109, 5062, 790, 4589, 6163, 298, 1569, 493, 1109, 4589, 6163, 298, 1985, 31044, 8, 1165, 395, 2, 6163, 298, 6063, 31044, 8, 1165, 395, 2, 6163, 298, 1802, 31044, 8, 1960, 430, 3547, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 16, 12, 378, 12, 283, 24351, 320, 297, 283, 23008, 3316, 297, 2, 2049, 3546, 24351, 320, 365, 5629, 370, 1655, 2419, 6891, 21551, 286, 5277, 5193, 83, 436, 965, 282, 298, 2049, 298, 1653, 370, 19793, 14, 7940, 965, 2757, 2797, 8441, 1918, 14492, 543, 314, 7282, 298, 2049, 298, 426, 580, 4451, 436, 642, 365, 282, 24332, 781, 787, 394, 18869, 370, 12166, 1536, 370, 2659, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 17, 12, 413, 12, 283, 34, 5719, 66, 5865, 297, 283, 29459, 297, 2, 2049, 3546, 34, 5719, 66, 5865, 365, 314, 17094, 402, 1413, 310, 287, 2482, 460, 12, 314, 25625, 609, 1132, 8511, 12, 298, 2049, 298, 4509, 652, 365, 506, 25146, 1373, 5382, 12, 23668, 314, 2163, 14, 221, 298, 2049, 298, 34, 5719, 66, 5865, 365, 437, 22306, 891, 83, 650, 6883, 17451, 14492, 12, 3769, 5629, 298, 2049, 298, 475, 18871, 499, 15949, 265, 13135, 2659, 531, 272, 1827, 14, 1628, 14332, 3176, 1901, 402, 329, 823, 298, 2049, 298, 1459, 8, 18, 12, 499, 12, 283, 10858, 22736, 14753, 297, 283, 1668, 297, 2, 2049, 3546, 5556, 2342, 9572, 22736, 14753, 315, 314, 946, 580, 402, 314, 29434, 26280, 298, 2049, 298, 4764, 6590, 273, 402, 428, 1638, 388, 812, 4598, 89, 14, 710, 17451, 17429, 991, 14492, 365, 298, 2049, 298, 23906, 1603, 3362, 1314, 365, 314, 10919, 17451, 14492, 315, 8256, 73, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eul-721/The-Perfect-Pokemon-Team-Balancer
libs/env/Lib/encodings/iso8859_9.py
593
13412
""" Python Character Mapping Codec iso8859_9 generated from 'MAPPINGS/ISO8859/8859-9.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='iso8859-9', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\x80' # 0x80 -> <control> u'\x81' # 0x81 -> <control> u'\x82' # 0x82 -> <control> u'\x83' # 0x83 -> <control> u'\x84' # 0x84 -> <control> u'\x85' # 0x85 -> <control> u'\x86' # 0x86 -> <control> u'\x87' # 0x87 -> <control> u'\x88' # 0x88 -> <control> u'\x89' # 0x89 -> <control> u'\x8a' # 0x8A -> <control> u'\x8b' # 0x8B -> <control> u'\x8c' # 0x8C -> <control> u'\x8d' # 0x8D -> <control> u'\x8e' # 0x8E -> <control> u'\x8f' # 0x8F -> <control> u'\x90' # 0x90 -> <control> u'\x91' # 0x91 -> <control> u'\x92' # 0x92 -> <control> u'\x93' # 0x93 -> <control> u'\x94' # 0x94 -> <control> u'\x95' # 0x95 -> <control> u'\x96' # 0x96 -> <control> u'\x97' # 0x97 -> <control> u'\x98' # 0x98 -> <control> u'\x99' # 0x99 -> <control> u'\x9a' # 0x9A -> <control> u'\x9b' # 0x9B -> <control> u'\x9c' # 0x9C -> <control> u'\x9d' # 0x9D -> <control> u'\x9e' # 0x9E -> <control> u'\x9f' # 0x9F -> <control> u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK u'\xa2' # 0xA2 -> CENT SIGN u'\xa3' # 0xA3 -> POUND SIGN u'\xa4' # 0xA4 -> CURRENCY SIGN u'\xa5' # 0xA5 -> YEN SIGN u'\xa6' # 0xA6 -> BROKEN BAR u'\xa7' # 0xA7 -> SECTION SIGN u'\xa8' # 0xA8 -> DIAERESIS u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xac' # 0xAC -> NOT SIGN u'\xad' # 0xAD -> SOFT HYPHEN u'\xae' # 0xAE -> REGISTERED SIGN u'\xaf' # 0xAF -> MACRON u'\xb0' # 0xB0 -> DEGREE SIGN u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\xb2' # 0xB2 -> SUPERSCRIPT TWO u'\xb3' # 0xB3 -> SUPERSCRIPT THREE u'\xb4' # 0xB4 -> ACUTE ACCENT u'\xb5' # 0xB5 -> MICRO SIGN u'\xb6' # 0xB6 -> PILCROW SIGN u'\xb7' # 0xB7 -> MIDDLE DOT u'\xb8' # 0xB8 -> CEDILLA u'\xb9' # 0xB9 -> SUPERSCRIPT ONE u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS u'\xbf' # 0xBF -> INVERTED QUESTION MARK u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS u'\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xd7' # 0xD7 -> MULTIPLICATION SIGN u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE u'\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS u'\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf7' # 0xF7 -> DIVISION SIGN u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS u'\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I u'\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-2.0
[ 624, 2018, 17660, 12340, 13732, 11601, 4830, 63, 25, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 25, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 25, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221 ]
[ 2018, 17660, 12340, 13732, 11601, 4830, 63, 25, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 25, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 25, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
huchoi/edx-platform
common/djangoapps/edxmako/tests.py
30
1489
from django.test import TestCase from django.test.utils import override_settings from django.core.urlresolvers import reverse from edxmako import add_lookup, LOOKUP from edxmako.shortcuts import marketing_link from mock import patch from util.testing import UrlResetMixin class ShortcutsTests(UrlResetMixin, TestCase): """ Test the edxmako shortcuts file """ @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'}) @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'login'}) def test_marketing_link(self): # test marketing site on with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): expected_link = 'dummy-root/about-us' link = marketing_link('ABOUT') self.assertEquals(link, expected_link) # test marketing site off with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): # we are using login because it is common across both cms and lms expected_link = reverse('login') link = marketing_link('ABOUT') self.assertEquals(link, expected_link) class AddLookupTests(TestCase): """ Test the `add_lookup` function. """ @patch('edxmako.LOOKUP', {}) def test_with_package(self): add_lookup('test', 'management', __name__) dirs = LOOKUP['test'].directories self.assertEqual(len(dirs), 1) self.assertTrue(dirs[0].endswith('management'))
agpl-3.0
[ 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 22435, 19491, 492, 1050, 63, 3892, 12, 3412, 3593, 2160, 199, 504, 22435, 19491, 14, 17469, 492, 2216, 13800, 63, 1073, 199, 504, 1683, 492, 3371, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 421, 199, 533, 20124, 12946, 2925, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 22435, 19491, 3974, 12946, 570, 272, 408, 272, 768, 4415, 63, 1751, 8, 18379, 6332, 63, 31582, 3713, 5441, 356, 283, 5869, 13, 1231, 297, 283, 1217, 1877, 356, 1994, 10254, 13, 527, 3071, 272, 768, 4415, 63, 1751, 8, 18379, 6332, 63, 2632, 63, 7916, 63, 5443, 3713, 1217, 1877, 356, 283, 2886, 3071, 272, 347, 511, 63, 1657, 13800, 63, 1073, 8, 277, 304, 267, 327, 511, 2216, 13800, 4770, 641, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 18379, 6332, 63, 7917, 356, 715, 22558, 288, 1420, 63, 1073, 275, 283, 5869, 13, 1231, 15, 10254, 13, 527, 7, 288, 2142, 275, 2216, 13800, 63, 1073, 360, 1217, 1877, 358, 288, 291, 14, 2947, 8, 1073, 12, 1420, 63, 1073, 9, 267, 327, 511, 2216, 13800, 4770, 2331, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 18379, 6332, 63, 7917, 356, 756, 22558, 288, 327, 781, 787, 1808, 4676, 2952, 652, 365, 2863, 9371, 3865, 19240, 436, 21577, 288, 1420, 63, 1073, 275, 3837, 360, 2886, 358, 288, 2142, 275, 2216, 13800, 63, 1073, 360, 1217, 1877, 358, 288, 291, 14, 2947, 8, 1073, 12, 1420, 63, 1073, 9, 421, 199, 533, 2654, 7521, 2925, 8, 1746, 304, 272, 408, 272, 1379, 314, 658, 525, 63, 3892, 64, 805, 14, 272, 408, 272, 768, 2068, 360, 8268, 19491, 14, 29149, 297, 5009, 272, 347, 511, 63, 1045, 63, 2491, 8, 277, 304, 267, 1050, 63, 3892, 360, 396, 297, 283, 8110, 297, 636, 354, 3368, 267, 7606, 275, 3412, 3593, 2160, 459, 396, 2278, 12629, 267, 291, 14, 629, 8, 552, 8, 3220, 395, 413, 9, 267, 291, 14, 1815, 8, 3220, 59, 16, 1055, 4130, 360, 8110, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 22435, 19491, 492, 1050, 63, 3892, 12, 3412, 3593, 2160, 199, 504, 22435, 19491, 14, 17469, 492, 2216, 13800, 63, 1073, 199, 504, 1683, 492, 3371, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 421, 199, 533, 20124, 12946, 2925, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 22435, 19491, 3974, 12946, 570, 272, 408, 272, 768, 4415, 63, 1751, 8, 18379, 6332, 63, 31582, 3713, 5441, 356, 283, 5869, 13, 1231, 297, 283, 1217, 1877, 356, 1994, 10254, 13, 527, 3071, 272, 768, 4415, 63, 1751, 8, 18379, 6332, 63, 2632, 63, 7916, 63, 5443, 3713, 1217, 1877, 356, 283, 2886, 3071, 272, 347, 511, 63, 1657, 13800, 63, 1073, 8, 277, 304, 267, 327, 511, 2216, 13800, 4770, 641, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 18379, 6332, 63, 7917, 356, 715, 22558, 288, 1420, 63, 1073, 275, 283, 5869, 13, 1231, 15, 10254, 13, 527, 7, 288, 2142, 275, 2216, 13800, 63, 1073, 360, 1217, 1877, 358, 288, 291, 14, 2947, 8, 1073, 12, 1420, 63, 1073, 9, 267, 327, 511, 2216, 13800, 4770, 2331, 267, 543, 3371, 14, 807, 360, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 791, 8898, 63, 18379, 6332, 63, 7917, 356, 756, 22558, 288, 327, 781, 787, 1808, 4676, 2952, 652, 365, 2863, 9371, 3865, 19240, 436, 21577, 288, 1420, 63, 1073, 275, 3837, 360, 2886, 358, 288, 2142, 275, 2216, 13800, 63, 1073, 360, 1217, 1877, 358, 288, 291, 14, 2947, 8, 1073, 12, 1420, 63, 1073, 9, 421, 199, 533, 2654, 7521, 2925, 8, 1746, 304, 272, 408, 272, 1379, 314, 658, 525, 63, 3892, 64, 805, 14, 272, 408, 272, 768, 2068, 360, 8268, 19491, 14, 29149, 297, 5009, 272, 347, 511, 63, 1045, 63, 2491, 8, 277, 304, 267, 1050, 63, 3892, 360, 396, 297, 283, 8110, 297, 636, 354, 3368, 267, 7606, 275, 3412, 3593, 2160, 459, 396, 2278, 12629, 267, 291, 14, 629, 8, 552, 8, 3220, 395, 413, 9, 267, 291, 14, 1815, 8, 3220, 59, 16, 1055, 4130, 360, 8110, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ProfessorKaos64/ds4drv
ds4drv/device.py
3
7173
from struct import Struct from sys import version_info as sys_version class StructHack(Struct): """Python <2.7.4 doesn't support struct unpack from bytearray.""" def unpack_from(self, buf, offset=0): buf = buffer(buf) return Struct.unpack_from(self, buf, offset) if sys_version[0] == 2 and sys_version[1] <= 7 and sys_version[2] <= 4: S16LE = StructHack("<h") else: S16LE = Struct("<h") class DS4Report(object): __slots__ = ["left_analog_x", "left_analog_y", "right_analog_x", "right_analog_y", "l2_analog", "r2_analog", "dpad_up", "dpad_down", "dpad_left", "dpad_right", "button_cross", "button_circle", "button_square", "button_triangle", "button_l1", "button_l2", "button_l3", "button_r1", "button_r2", "button_r3", "button_share", "button_options", "button_trackpad", "button_ps", "motion_y", "motion_x", "motion_z", "orientation_roll", "orientation_yaw", "orientation_pitch", "trackpad_touch0_id", "trackpad_touch0_active", "trackpad_touch0_x", "trackpad_touch0_y", "trackpad_touch1_id", "trackpad_touch1_active", "trackpad_touch1_x", "trackpad_touch1_y", "timestamp", "battery", "plug_usb", "plug_audio", "plug_mic"] def __init__(self, *args, **kwargs): for i, value in enumerate(args): setattr(self, self.__slots__[i], value) class DS4Device(object): """A DS4 controller object. Used to control the device functions and reading HID reports. """ def __init__(self, device_name, device_addr, type): self.device_name = device_name self.device_addr = device_addr self.type = type self._led = (0, 0, 0) self._led_flash = (0, 0) self._led_flashing = False self.set_operational() def _control(self, **kwargs): self.control(led_red=self._led[0], led_green=self._led[1], led_blue=self._led[2], flash_led1=self._led_flash[0], flash_led2=self._led_flash[1], **kwargs) def rumble(self, small=0, big=0): """Sets the intensity of the rumble motors. Valid range is 0-255.""" self._control(small_rumble=small, big_rumble=big) def set_led(self, red=0, green=0, blue=0): """Sets the LED color. Values are RGB between 0-255.""" self._led = (red, green, blue) self._control() def start_led_flash(self, on, off): """Starts flashing the LED.""" if not self._led_flashing: self._led_flash = (on, off) self._led_flashing = True self._control() def stop_led_flash(self): """Stops flashing the LED.""" if self._led_flashing: self._led_flash = (0, 0) self._led_flashing = False # Call twice, once to stop flashing... self._control() # ...and once more to make sure the LED is on. self._control() def control(self, big_rumble=0, small_rumble=0, led_red=0, led_green=0, led_blue=0, flash_led1=0, flash_led2=0): if self.type == "bluetooth": pkt = bytearray(77) pkt[0] = 128 pkt[2] = 255 offset = 2 report_id = 0x11 elif self.type == "usb": pkt = bytearray(31) pkt[0] = 255 offset = 0 report_id = 0x05 # Rumble pkt[offset+3] = min(small_rumble, 255) pkt[offset+4] = min(big_rumble, 255) # LED (red, green, blue) pkt[offset+5] = min(led_red, 255) pkt[offset+6] = min(led_green, 255) pkt[offset+7] = min(led_blue, 255) # Time to flash bright (255 = 2.5 seconds) pkt[offset+8] = min(flash_led1, 255) # Time to flash dark (255 = 2.5 seconds) pkt[offset+9] = min(flash_led2, 255) self.write_report(report_id, pkt) def parse_report(self, buf): """Parse a buffer containing a HID report.""" dpad = buf[5] % 16 return DS4Report( # Left analog stick buf[1], buf[2], # Right analog stick buf[3], buf[4], # L2 and R2 analog buf[8], buf[9], # DPad up, down, left, right (dpad in (0, 1, 7)), (dpad in (3, 4, 5)), (dpad in (5, 6, 7)), (dpad in (1, 2, 3)), # Buttons cross, circle, square, triangle (buf[5] & 32) != 0, (buf[5] & 64) != 0, (buf[5] & 16) != 0, (buf[5] & 128) != 0, # L1, L2 and L3 buttons (buf[6] & 1) != 0, (buf[6] & 4) != 0, (buf[6] & 64) != 0, # R1, R2,and R3 buttons (buf[6] & 2) != 0, (buf[6] & 8) != 0, (buf[6] & 128) != 0, # Share and option buttons (buf[6] & 16) != 0, (buf[6] & 32) != 0, # Trackpad and PS buttons (buf[7] & 2) != 0, (buf[7] & 1) != 0, # Acceleration S16LE.unpack_from(buf, 13)[0], S16LE.unpack_from(buf, 15)[0], S16LE.unpack_from(buf, 17)[0], # Orientation -(S16LE.unpack_from(buf, 19)[0]), S16LE.unpack_from(buf, 21)[0], S16LE.unpack_from(buf, 23)[0], # Trackpad touch 1: id, active, x, y buf[35] & 0x7f, (buf[35] >> 7) == 0, ((buf[37] & 0x0f) << 8) | buf[36], buf[38] << 4 | ((buf[37] & 0xf0) >> 4), # Trackpad touch 2: id, active, x, y buf[39] & 0x7f, (buf[39] >> 7) == 0, ((buf[41] & 0x0f) << 8) | buf[40], buf[42] << 4 | ((buf[41] & 0xf0) >> 4), # Timestamp and battery buf[7] >> 2, buf[30] % 16, # External inputs (usb, audio, mic) (buf[30] & 16) != 0, (buf[30] & 32) != 0, (buf[30] & 64) != 0 ) def read_report(self): """Read and parse a HID report.""" pass def write_report(self, report_id, data): """Writes a HID report to the control channel.""" pass def set_operational(self): """Tells the DS4 controller we want full HID reports.""" pass def close(self): """Disconnects from the device.""" pass @property def name(self): if self.type == "bluetooth": type_name = "Bluetooth" elif self.type == "usb": type_name = "USB" return "{0} Controller ({1})".format(type_name, self.device_name)
mit
[ 504, 2702, 492, 13039, 199, 504, 984, 492, 1015, 63, 815, 465, 984, 63, 1023, 421, 199, 533, 13039, 40, 564, 8, 4836, 304, 272, 408, 4718, 665, 18, 14, 23, 14, 20, 3181, 1133, 2291, 2702, 7787, 687, 11640, 1041, 272, 347, 7787, 63, 504, 8, 277, 12, 4123, 12, 3268, 29, 16, 304, 267, 4123, 275, 3335, 8, 1436, 9, 398, 372, 13039, 14, 5301, 63, 504, 8, 277, 12, 4123, 12, 3268, 9, 421, 199, 692, 984, 63, 1023, 59, 16, 61, 508, 499, 436, 984, 63, 1023, 59, 17, 61, 2695, 1520, 436, 984, 63, 1023, 59, 18, 61, 2695, 841, 26, 272, 428, 975, 906, 275, 13039, 40, 564, 6757, 72, 531, 199, 2836, 26, 272, 428, 975, 906, 275, 13039, 6757, 72, 531, 421, 199, 533, 577, 51, 20, 7457, 8, 785, 304, 272, 636, 7257, 363, 275, 2097, 3039, 63, 290, 2548, 63, 88, 401, 326, 298, 3039, 63, 290, 2548, 63, 89, 401, 326, 298, 1019, 63, 290, 2548, 63, 88, 401, 326, 298, 1019, 63, 290, 2548, 63, 89, 401, 326, 298, 76, 18, 63, 290, 2548, 401, 326, 298, 82, 18, 63, 290, 2548, 401, 326, 298, 5780, 350, 63, 384, 401, 326, 298, 5780, 350, 63, 2110, 401, 326, 298, 5780, 350, 63, 3039, 401, 326, 298, 5780, 350, 63, 1019, 401, 326, 298, 3887, 63, 7925, 401, 326, 298, 3887, 63, 11001, 401, 326, 298, 3887, 63, 9646, 401, 326, 298, 3887, 63, 21584, 401, 326, 298, 3887, 63, 76, 17, 401, 326, 298, 3887, 63, 76, 18, 401, 326, 298, 3887, 63, 76, 19, 401, 326, 298, 3887, 63, 82, 17, 401, 326, 298, 3887, 63, 82, 18, 401, 326, 298, 3887, 63, 82, 19, 401, 326, 298, 3887, 63, 6251, 401, 326, 298, 3887, 63, 1419, 401, 326, 298, 3887, 63, 3885, 6226, 401, 326, 298, 3887, 63, 1190, 401, 326, 298, 15335, 63, 89, 401, 326, 298, 15335, 63, 88, 401, 326, 298, 15335, 63, 90, 401, 326, 298, 17001, 63, 2827, 401, 326, 298, 17001, 63, 89, 10084, 401, 326, 298, 17001, 63, 16966, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 344, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 2682, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 88, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 89, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 344, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 2682, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 88, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 89, 401, 326, 298, 3954, 401, 326, 298, 21113, 401, 326, 298, 13963, 63, 17411, 401, 326, 298, 13963, 63, 8130, 401, 326, 298, 13963, 63, 15003, 937, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 284, 12, 574, 315, 3874, 8, 589, 304, 288, 5371, 8, 277, 12, 291, 855, 7257, 12298, 73, 467, 574, 9, 421, 199, 533, 577, 51, 20, 2510, 8, 785, 304, 272, 408, 33, 577, 51, 20, 7614, 909, 14, 339, 8051, 370, 3304, 314, 2243, 3423, 436, 7664, 869, 998, 13924, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2243, 63, 354, 12, 2243, 63, 2697, 12, 730, 304, 267, 291, 14, 1782, 63, 354, 275, 2243, 63, 354, 267, 291, 14, 1782, 63, 2697, 275, 2243, 63, 2697, 267, 291, 14, 466, 275, 730, 398, 291, 423, 1146, 275, 334, 16, 12, 378, 12, 378, 9, 267, 291, 423, 1146, 63, 11331, 275, 334, 16, 12, 378, 9, 267, 291, 423, 1146, 63, 11331, 316, 275, 756, 398, 291, 14, 409, 63, 5735, 279, 342, 339, 347, 485, 2785, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 2785, 8, 1146, 63, 581, 29, 277, 423, 1146, 59, 16, 467, 29239, 63, 7731, 29, 277, 423, 1146, 59, 17, 467, 2151, 29239, 63, 6304, 29, 277, 423, 1146, 59, 18, 467, 14775, 63, 1146, 17, 29, 277, 423, 1146, 63, 11331, 59, 16, 467, 2151, 14775, 63, 1146, 18, 29, 277, 423, 1146, 63, 11331, 59, 17, 467, 1011, 958, 9, 339, 347, 519, 453, 830, 8, 277, 12, 7425, 29, 16, 12, 7282, 29, 16, 304, 267, 408, 9899, 314, 28873, 402, 314, 519, 453, 830, 333, 357, 1384, 14, 4821, 1425, 365, 378, 13, 2299, 1041, 267, 291, 423, 2785, 8, 7241, 63, 28430, 830, 29, 7241, 12, 7282, 63, 28430, 830, 29, 5076, 9, 339, 347, 663, 63, 1146, 8, 277, 12, 8992, 29, 16, 12, 12431, 29, 16, 12, 10030, 29, 16, 304, 267, 408, 9899, 314, 491, 1149, 3164, 14, 13468, 787, 19013, 3382, 378, 13, 2299, 1041, 267, 291, 423, 1146, 275, 334, 581, 12, 12431, 12, 10030, 9, 267, 291, 423, 2785, 342, 339, 347, 1343, 63, 1146, 63, 11331, 8, 277, 12, 641, 12, 2331, 304, 267, 408, 32142, 14775, 316, 314, 491, 1149, 1041, 267, 340, 440, 291, 423, 1146, 63, 11331, 316, 26, 288, 291, 423, 1146, 63, 11331, 275, 334, 265, 12, 2331, 9, 288, 291, 423, 1146, 63, 11331, 316, 275, 715, 288, 291, 423, 2785, 342, 339, 347, 3631, 63, 1146, 63, 11331, 8, 277, 304, 267, 408, 933, 1483, 14775, 316, 314, 491, 1149, 1041, 267, 340, 291, 423, 1146, 63, 11331, 316, 26, 288, 291, 423, 1146, 63, 11331, 275, 334, 16, 12, 378, 9, 288, 291, 423, 1146, 63, 11331, 316, 275, 756, 288, 327, 6523, 13373, 12, 5403, 370, 3631, 14775, 316, 1396, 288, 291, 423, 2785, 342, 288, 327, 2263, 460, 5403, 1655, 370, 1852, 3238, 314, 491, 1149, 365, 641, 14, 288, 291, 423, 2785, 342, 339, 347, 3304, 8, 277, 12, 7282, 63, 28430, 830, 29, 16, 12, 7425, 63, 28430, 830, 29, 16, 12, 355, 29239, 63, 581, 29, 16, 12, 29239, 63, 7731, 29, 16, 12, 29239, 63, 6304, 29, 16, 12, 355, 14775, 63, 1146, 17, 29, 16, 12, 14775, 63, 1146, 18, 29, 16, 304, 267, 340, 291, 14, 466, 508, 298, 27172, 582, 288, 19927, 275, 11640, 8, 1138, 9, 288, 19927, 59, 16, 61, 275, 7960, 288, 19927, 59, 18, 61, 275 ]
[ 2702, 492, 13039, 199, 504, 984, 492, 1015, 63, 815, 465, 984, 63, 1023, 421, 199, 533, 13039, 40, 564, 8, 4836, 304, 272, 408, 4718, 665, 18, 14, 23, 14, 20, 3181, 1133, 2291, 2702, 7787, 687, 11640, 1041, 272, 347, 7787, 63, 504, 8, 277, 12, 4123, 12, 3268, 29, 16, 304, 267, 4123, 275, 3335, 8, 1436, 9, 398, 372, 13039, 14, 5301, 63, 504, 8, 277, 12, 4123, 12, 3268, 9, 421, 199, 692, 984, 63, 1023, 59, 16, 61, 508, 499, 436, 984, 63, 1023, 59, 17, 61, 2695, 1520, 436, 984, 63, 1023, 59, 18, 61, 2695, 841, 26, 272, 428, 975, 906, 275, 13039, 40, 564, 6757, 72, 531, 199, 2836, 26, 272, 428, 975, 906, 275, 13039, 6757, 72, 531, 421, 199, 533, 577, 51, 20, 7457, 8, 785, 304, 272, 636, 7257, 363, 275, 2097, 3039, 63, 290, 2548, 63, 88, 401, 326, 298, 3039, 63, 290, 2548, 63, 89, 401, 326, 298, 1019, 63, 290, 2548, 63, 88, 401, 326, 298, 1019, 63, 290, 2548, 63, 89, 401, 326, 298, 76, 18, 63, 290, 2548, 401, 326, 298, 82, 18, 63, 290, 2548, 401, 326, 298, 5780, 350, 63, 384, 401, 326, 298, 5780, 350, 63, 2110, 401, 326, 298, 5780, 350, 63, 3039, 401, 326, 298, 5780, 350, 63, 1019, 401, 326, 298, 3887, 63, 7925, 401, 326, 298, 3887, 63, 11001, 401, 326, 298, 3887, 63, 9646, 401, 326, 298, 3887, 63, 21584, 401, 326, 298, 3887, 63, 76, 17, 401, 326, 298, 3887, 63, 76, 18, 401, 326, 298, 3887, 63, 76, 19, 401, 326, 298, 3887, 63, 82, 17, 401, 326, 298, 3887, 63, 82, 18, 401, 326, 298, 3887, 63, 82, 19, 401, 326, 298, 3887, 63, 6251, 401, 326, 298, 3887, 63, 1419, 401, 326, 298, 3887, 63, 3885, 6226, 401, 326, 298, 3887, 63, 1190, 401, 326, 298, 15335, 63, 89, 401, 326, 298, 15335, 63, 88, 401, 326, 298, 15335, 63, 90, 401, 326, 298, 17001, 63, 2827, 401, 326, 298, 17001, 63, 89, 10084, 401, 326, 298, 17001, 63, 16966, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 344, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 2682, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 88, 401, 326, 298, 3885, 6226, 63, 12376, 16, 63, 89, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 344, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 2682, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 88, 401, 326, 298, 3885, 6226, 63, 12376, 17, 63, 89, 401, 326, 298, 3954, 401, 326, 298, 21113, 401, 326, 298, 13963, 63, 17411, 401, 326, 298, 13963, 63, 8130, 401, 326, 298, 13963, 63, 15003, 937, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 284, 12, 574, 315, 3874, 8, 589, 304, 288, 5371, 8, 277, 12, 291, 855, 7257, 12298, 73, 467, 574, 9, 421, 199, 533, 577, 51, 20, 2510, 8, 785, 304, 272, 408, 33, 577, 51, 20, 7614, 909, 14, 339, 8051, 370, 3304, 314, 2243, 3423, 436, 7664, 869, 998, 13924, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2243, 63, 354, 12, 2243, 63, 2697, 12, 730, 304, 267, 291, 14, 1782, 63, 354, 275, 2243, 63, 354, 267, 291, 14, 1782, 63, 2697, 275, 2243, 63, 2697, 267, 291, 14, 466, 275, 730, 398, 291, 423, 1146, 275, 334, 16, 12, 378, 12, 378, 9, 267, 291, 423, 1146, 63, 11331, 275, 334, 16, 12, 378, 9, 267, 291, 423, 1146, 63, 11331, 316, 275, 756, 398, 291, 14, 409, 63, 5735, 279, 342, 339, 347, 485, 2785, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 2785, 8, 1146, 63, 581, 29, 277, 423, 1146, 59, 16, 467, 29239, 63, 7731, 29, 277, 423, 1146, 59, 17, 467, 2151, 29239, 63, 6304, 29, 277, 423, 1146, 59, 18, 467, 14775, 63, 1146, 17, 29, 277, 423, 1146, 63, 11331, 59, 16, 467, 2151, 14775, 63, 1146, 18, 29, 277, 423, 1146, 63, 11331, 59, 17, 467, 1011, 958, 9, 339, 347, 519, 453, 830, 8, 277, 12, 7425, 29, 16, 12, 7282, 29, 16, 304, 267, 408, 9899, 314, 28873, 402, 314, 519, 453, 830, 333, 357, 1384, 14, 4821, 1425, 365, 378, 13, 2299, 1041, 267, 291, 423, 2785, 8, 7241, 63, 28430, 830, 29, 7241, 12, 7282, 63, 28430, 830, 29, 5076, 9, 339, 347, 663, 63, 1146, 8, 277, 12, 8992, 29, 16, 12, 12431, 29, 16, 12, 10030, 29, 16, 304, 267, 408, 9899, 314, 491, 1149, 3164, 14, 13468, 787, 19013, 3382, 378, 13, 2299, 1041, 267, 291, 423, 1146, 275, 334, 581, 12, 12431, 12, 10030, 9, 267, 291, 423, 2785, 342, 339, 347, 1343, 63, 1146, 63, 11331, 8, 277, 12, 641, 12, 2331, 304, 267, 408, 32142, 14775, 316, 314, 491, 1149, 1041, 267, 340, 440, 291, 423, 1146, 63, 11331, 316, 26, 288, 291, 423, 1146, 63, 11331, 275, 334, 265, 12, 2331, 9, 288, 291, 423, 1146, 63, 11331, 316, 275, 715, 288, 291, 423, 2785, 342, 339, 347, 3631, 63, 1146, 63, 11331, 8, 277, 304, 267, 408, 933, 1483, 14775, 316, 314, 491, 1149, 1041, 267, 340, 291, 423, 1146, 63, 11331, 316, 26, 288, 291, 423, 1146, 63, 11331, 275, 334, 16, 12, 378, 9, 288, 291, 423, 1146, 63, 11331, 316, 275, 756, 288, 327, 6523, 13373, 12, 5403, 370, 3631, 14775, 316, 1396, 288, 291, 423, 2785, 342, 288, 327, 2263, 460, 5403, 1655, 370, 1852, 3238, 314, 491, 1149, 365, 641, 14, 288, 291, 423, 2785, 342, 339, 347, 3304, 8, 277, 12, 7282, 63, 28430, 830, 29, 16, 12, 7425, 63, 28430, 830, 29, 16, 12, 355, 29239, 63, 581, 29, 16, 12, 29239, 63, 7731, 29, 16, 12, 29239, 63, 6304, 29, 16, 12, 355, 14775, 63, 1146, 17, 29, 16, 12, 14775, 63, 1146, 18, 29, 16, 304, 267, 340, 291, 14, 466, 508, 298, 27172, 582, 288, 19927, 275, 11640, 8, 1138, 9, 288, 19927, 59, 16, 61, 275, 7960, 288, 19927, 59, 18, 61, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
diego-d5000/MisValesMd
env/lib/python2.7/site-packages/django/db/backends/oracle/base.py
1
25877
""" Oracle database backend for Django. Requires cx_Oracle: http://cx-oracle.sourceforge.net/ """ from __future__ import unicode_literals import datetime import decimal import os import platform import sys import warnings from django.conf import settings from django.db import utils from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.validation import BaseDatabaseValidation from django.utils import six, timezone from django.utils.duration import duration_string from django.utils.encoding import force_bytes, force_text from django.utils.functional import cached_property def _setup_environment(environ): # Cygwin requires some special voodoo to set the environment variables # properly so that Oracle will see them. if platform.system().upper().startswith('CYGWIN'): try: import ctypes except ImportError as e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading ctypes: %s; " "the Oracle backend requires ctypes to " "operate correctly under Cygwin." % e) kernel32 = ctypes.CDLL('kernel32') for name, value in environ: kernel32.SetEnvironmentVariableA(name, value) else: os.environ.update(environ) _setup_environment([ # Oracle takes client-side character set encoding from the environment. ('NLS_LANG', '.UTF8'), # This prevents unicode from getting mangled by getting encoded into the # potentially non-unicode database character set. ('ORA_NCHAR_LITERAL_REPLACE', 'TRUE'), ]) try: import cx_Oracle as Database except ImportError as e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e) # Some of these import cx_Oracle, so import them after checking if it's installed. from .client import DatabaseClient # isort:skip from .creation import DatabaseCreation # isort:skip from .features import DatabaseFeatures # isort:skip from .introspection import DatabaseIntrospection # isort:skip from .operations import DatabaseOperations # isort:skip from .schema import DatabaseSchemaEditor # isort:skip from .utils import Oracle_datetime, convert_unicode # isort:skip DatabaseError = Database.DatabaseError IntegrityError = Database.IntegrityError class _UninitializedOperatorsDescriptor(object): def __get__(self, instance, owner): # If connection.operators is looked up before a connection has been # created, transparently initialize connection.operators to avert an # AttributeError. if instance is None: raise AttributeError("operators not available as class attribute") # Creating a cursor will initialize the operators. instance.cursor().close() return instance.__dict__['operators'] class DatabaseWrapper(BaseDatabaseWrapper): vendor = 'oracle' # This dictionary maps Field objects to their associated Oracle column # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. # # Any format strings starting with "qn_" are quoted before being used in the # output (the "qn_" prefix is stripped before the lookup is performed. data_types = { 'AutoField': 'NUMBER(11)', 'BinaryField': 'BLOB', 'BooleanField': 'NUMBER(1)', 'CharField': 'NVARCHAR2(%(max_length)s)', 'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)', 'DateField': 'DATE', 'DateTimeField': 'TIMESTAMP', 'DecimalField': 'NUMBER(%(max_digits)s, %(decimal_places)s)', 'DurationField': 'INTERVAL DAY(9) TO SECOND(6)', 'FileField': 'NVARCHAR2(%(max_length)s)', 'FilePathField': 'NVARCHAR2(%(max_length)s)', 'FloatField': 'DOUBLE PRECISION', 'IntegerField': 'NUMBER(11)', 'BigIntegerField': 'NUMBER(19)', 'IPAddressField': 'VARCHAR2(15)', 'GenericIPAddressField': 'VARCHAR2(39)', 'NullBooleanField': 'NUMBER(1)', 'OneToOneField': 'NUMBER(11)', 'PositiveIntegerField': 'NUMBER(11)', 'PositiveSmallIntegerField': 'NUMBER(11)', 'SlugField': 'NVARCHAR2(%(max_length)s)', 'SmallIntegerField': 'NUMBER(11)', 'TextField': 'NCLOB', 'TimeField': 'TIMESTAMP', 'URLField': 'VARCHAR2(%(max_length)s)', 'UUIDField': 'VARCHAR2(32)', } data_type_check_constraints = { 'BooleanField': '%(qn_column)s IN (0,1)', 'NullBooleanField': '(%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL)', 'PositiveIntegerField': '%(qn_column)s >= 0', 'PositiveSmallIntegerField': '%(qn_column)s >= 0', } operators = _UninitializedOperatorsDescriptor() _standard_operators = { 'exact': '= %s', 'iexact': '= UPPER(%s)', 'contains': "LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", 'icontains': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", 'gt': '> %s', 'gte': '>= %s', 'lt': '< %s', 'lte': '<= %s', 'startswith': "LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", 'endswith': "LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", 'istartswith': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", 'iendswith': "LIKE UPPER(TRANSLATE(%s USING NCHAR_CS)) ESCAPE TRANSLATE('\\' USING NCHAR_CS)", } _likec_operators = _standard_operators.copy() _likec_operators.update({ 'contains': "LIKEC %s ESCAPE '\\'", 'icontains': "LIKEC UPPER(%s) ESCAPE '\\'", 'startswith': "LIKEC %s ESCAPE '\\'", 'endswith': "LIKEC %s ESCAPE '\\'", 'istartswith': "LIKEC UPPER(%s) ESCAPE '\\'", 'iendswith': "LIKEC UPPER(%s) ESCAPE '\\'", }) # The patterns below are used to generate SQL pattern lookup clauses when # the right-hand side of the lookup isn't a raw string (it might be an expression # or the result of a bilateral transformation). # In those cases, special characters for LIKE operators (e.g. \, *, _) should be # escaped on database side. # # Note: we use str.format() here for readability as '%' is used as a wildcard for # the LIKE operator. pattern_esc = r"REPLACE(REPLACE(REPLACE({}, '\', '\\'), '%%', '\%%'), '_', '\_')" _pattern_ops = { 'contains': "'%%' || {} || '%%'", 'icontains': "'%%' || UPPER({}) || '%%'", 'startswith': "{} || '%%'", 'istartswith': "UPPER({}) || '%%'", 'endswith': "'%%' || {}", 'iendswith': "'%%' || UPPER({})", } _standard_pattern_ops = {k: "LIKE TRANSLATE( " + v + " USING NCHAR_CS)" " ESCAPE TRANSLATE('\\' USING NCHAR_CS)" for k, v in _pattern_ops.items()} _likec_pattern_ops = {k: "LIKEC " + v + " ESCAPE '\\'" for k, v in _pattern_ops.items()} Database = Database SchemaEditorClass = DatabaseSchemaEditor def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.features = DatabaseFeatures(self) use_returning_into = self.settings_dict["OPTIONS"].get('use_returning_into', True) self.features.can_return_id_from_insert = use_returning_into self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) def _connect_string(self): settings_dict = self.settings_dict if not settings_dict['HOST'].strip(): settings_dict['HOST'] = 'localhost' if settings_dict['PORT'].strip(): dsn = Database.makedsn(settings_dict['HOST'], int(settings_dict['PORT']), settings_dict['NAME']) else: dsn = settings_dict['NAME'] return "%s/%s@%s" % (settings_dict['USER'], settings_dict['PASSWORD'], dsn) def get_connection_params(self): conn_params = self.settings_dict['OPTIONS'].copy() if 'use_returning_into' in conn_params: del conn_params['use_returning_into'] return conn_params def get_new_connection(self, conn_params): conn_string = convert_unicode(self._connect_string()) return Database.connect(conn_string, **conn_params) def init_connection_state(self): cursor = self.create_cursor() # Set the territory first. The territory overrides NLS_DATE_FORMAT # and NLS_TIMESTAMP_FORMAT to the territory default. When all of # these are set in single statement it isn't clear what is supposed # to happen. cursor.execute("ALTER SESSION SET NLS_TERRITORY = 'AMERICA'") # Set Oracle date to ANSI date format. This only needs to execute # once when we create a new connection. We also set the Territory # to 'AMERICA' which forces Sunday to evaluate to a '1' in # TO_CHAR(). cursor.execute( "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'" " NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'" + (" TIME_ZONE = 'UTC'" if settings.USE_TZ else '')) cursor.close() if 'operators' not in self.__dict__: # Ticket #14149: Check whether our LIKE implementation will # work for this connection or we need to fall back on LIKEC. # This check is performed only once per DatabaseWrapper # instance per thread, since subsequent connections will use # the same settings. cursor = self.create_cursor() try: cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s" % self._standard_operators['contains'], ['X']) except DatabaseError: self.operators = self._likec_operators self.pattern_ops = self._likec_pattern_ops else: self.operators = self._standard_operators self.pattern_ops = self._standard_pattern_ops cursor.close() try: self.connection.stmtcachesize = 20 except AttributeError: # Django docs specify cx_Oracle version 4.3.1 or higher, but # stmtcachesize is available only in 4.3.2 and up. pass # Ensure all changes are preserved even when AUTOCOMMIT is False. if not self.get_autocommit(): self.commit() def create_cursor(self): return FormatStylePlaceholderCursor(self.connection) def _commit(self): if self.connection is not None: try: return self.connection.commit() except Database.DatabaseError as e: # cx_Oracle 5.0.4 raises a cx_Oracle.DatabaseError exception # with the following attributes and values: # code = 2091 # message = 'ORA-02091: transaction rolled back # 'ORA-02291: integrity constraint (TEST_DJANGOTEST.SYS # _C00102056) violated - parent key not found' # We convert that particular case to our IntegrityError exception x = e.args[0] if hasattr(x, 'code') and hasattr(x, 'message') \ and x.code == 2091 and 'ORA-02291' in x.message: six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) raise # Oracle doesn't support releasing savepoints. But we fake them when query # logging is enabled to keep query counts consistent with other backends. def _savepoint_commit(self, sid): if self.queries_logged: self.queries_log.append({ 'sql': '-- RELEASE SAVEPOINT %s (faked)' % self.ops.quote_name(sid), 'time': '0.000', }) def _set_autocommit(self, autocommit): with self.wrap_database_errors: self.connection.autocommit = autocommit def check_constraints(self, table_names=None): """ To check constraints, we set constraints to immediate. Then, when, we're done we must ensure they are returned to deferred. """ self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE') self.cursor().execute('SET CONSTRAINTS ALL DEFERRED') def is_usable(self): try: self.connection.ping() except Database.Error: return False else: return True @cached_property def oracle_full_version(self): with self.temporary_connection(): return self.connection.version @cached_property def oracle_version(self): try: return int(self.oracle_full_version.split('.')[0]) except ValueError: return None class OracleParam(object): """ Wrapper object for formatting parameters for Oracle. If the string representation of the value is large enough (greater than 4000 characters) the input size needs to be set as CLOB. Alternatively, if the parameter has an `input_size` attribute, then the value of the `input_size` attribute will be used instead. Otherwise, no input size will be set for the parameter when executing the query. """ def __init__(self, param, cursor, strings_only=False): # With raw SQL queries, datetimes can reach this function # without being converted by DateTimeField.get_db_prep_value. if settings.USE_TZ and (isinstance(param, datetime.datetime) and not isinstance(param, Oracle_datetime)): if timezone.is_naive(param): warnings.warn("Oracle received a naive datetime (%s)" " while time zone support is active." % param, RuntimeWarning) default_timezone = timezone.get_default_timezone() param = timezone.make_aware(param, default_timezone) param = Oracle_datetime.from_datetime(param.astimezone(timezone.utc)) if isinstance(param, datetime.timedelta): param = duration_string(param) if ' ' not in param: param = '0 ' + param string_size = 0 # Oracle doesn't recognize True and False correctly in Python 3. # The conversion done below works both in 2 and 3. if param is True: param = 1 elif param is False: param = 0 if hasattr(param, 'bind_parameter'): self.force_bytes = param.bind_parameter(cursor) elif isinstance(param, Database.Binary): self.force_bytes = param else: # To transmit to the database, we need Unicode if supported # To get size right, we must consider bytes. self.force_bytes = convert_unicode(param, cursor.charset, strings_only) if isinstance(self.force_bytes, six.string_types): # We could optimize by only converting up to 4000 bytes here string_size = len(force_bytes(param, cursor.charset, strings_only)) if hasattr(param, 'input_size'): # If parameter has `input_size` attribute, use that. self.input_size = param.input_size elif string_size > 4000: # Mark any string param greater than 4000 characters as a CLOB. self.input_size = Database.CLOB else: self.input_size = None class VariableWrapper(object): """ An adapter class for cursor variables that prevents the wrapped object from being converted into a string when used to instantiate an OracleParam. This can be used generally for any other object that should be passed into Cursor.execute as-is. """ def __init__(self, var): self.var = var def bind_parameter(self, cursor): return self.var def __getattr__(self, key): return getattr(self.var, key) def __setattr__(self, key, value): if key == 'var': self.__dict__[key] = value else: setattr(self.var, key, value) class FormatStylePlaceholderCursor(object): """ Django uses "format" (e.g. '%s') style placeholders, but Oracle uses ":var" style. This fixes it -- but note that if you want to use a literal "%s" in a query, you'll need to use "%%s". We also do automatic conversion between Unicode on the Python side and UTF-8 -- for talking to Oracle -- in here. """ charset = 'utf-8' def __init__(self, connection): self.cursor = connection.cursor() # Necessary to retrieve decimal values without rounding error. self.cursor.numbersAsStrings = True # Default arraysize of 1 is highly sub-optimal. self.cursor.arraysize = 100 def _format_params(self, params): try: return {k: OracleParam(v, self, True) for k, v in params.items()} except AttributeError: return tuple(OracleParam(p, self, True) for p in params) def _guess_input_sizes(self, params_list): # Try dict handling; if that fails, treat as sequence if hasattr(params_list[0], 'keys'): sizes = {} for params in params_list: for k, value in params.items(): if value.input_size: sizes[k] = value.input_size self.setinputsizes(**sizes) else: # It's not a list of dicts; it's a list of sequences sizes = [None] * len(params_list[0]) for params in params_list: for i, value in enumerate(params): if value.input_size: sizes[i] = value.input_size self.setinputsizes(*sizes) def _param_generator(self, params): # Try dict handling; if that fails, treat as sequence if hasattr(params, 'items'): return {k: v.force_bytes for k, v in params.items()} else: return [p.force_bytes for p in params] def _fix_for_params(self, query, params): # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it # it does want a trailing ';' but not a trailing '/'. However, these # characters must be included in the original query in case the query # is being passed to SQL*Plus. if query.endswith(';') or query.endswith('/'): query = query[:-1] if params is None: params = [] query = convert_unicode(query, self.charset) elif hasattr(params, 'keys'): # Handle params as dict args = {k: ":%s" % k for k in params.keys()} query = convert_unicode(query % args, self.charset) else: # Handle params as sequence args = [(':arg%d' % i) for i in range(len(params))] query = convert_unicode(query % tuple(args), self.charset) return query, self._format_params(params) def execute(self, query, params=None): query, params = self._fix_for_params(query, params) self._guess_input_sizes([params]) try: return self.cursor.execute(query, self._param_generator(params)) except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) raise def executemany(self, query, params=None): if not params: # No params given, nothing to do return None # uniform treatment for sequences and iterables params_iter = iter(params) query, firstparams = self._fix_for_params(query, next(params_iter)) # we build a list of formatted params; as we're going to traverse it # more than once, we can't make it lazy by using a generator formatted = [firstparams] + [self._format_params(p) for p in params_iter] self._guess_input_sizes(formatted) try: return self.cursor.executemany(query, [self._param_generator(p) for p in formatted]) except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) raise def fetchone(self): row = self.cursor.fetchone() if row is None: return row return _rowfactory(row, self.cursor) def fetchmany(self, size=None): if size is None: size = self.arraysize return tuple(_rowfactory(r, self.cursor) for r in self.cursor.fetchmany(size)) def fetchall(self): return tuple(_rowfactory(r, self.cursor) for r in self.cursor.fetchall()) def close(self): try: self.cursor.close() except Database.InterfaceError: # already closed pass def var(self, *args): return VariableWrapper(self.cursor.var(*args)) def arrayvar(self, *args): return VariableWrapper(self.cursor.arrayvar(*args)) def __getattr__(self, attr): if attr in self.__dict__: return self.__dict__[attr] else: return getattr(self.cursor, attr) def __iter__(self): return CursorIterator(self.cursor) class CursorIterator(six.Iterator): """Cursor iterator wrapper that invokes our custom row factory.""" def __init__(self, cursor): self.cursor = cursor self.iter = iter(cursor) def __iter__(self): return self def __next__(self): return _rowfactory(next(self.iter), self.cursor) def _rowfactory(row, cursor): # Cast numeric values as the appropriate Python type based upon the # cursor description, and convert strings to unicode. casted = [] for value, desc in zip(row, cursor.description): if value is not None and desc[1] is Database.NUMBER: precision, scale = desc[4:6] if scale == -127: if precision == 0: # NUMBER column: decimal-precision floating point # This will normally be an integer from a sequence, # but it could be a decimal value. if '.' in value: value = decimal.Decimal(value) else: value = int(value) else: # FLOAT column: binary-precision floating point. # This comes from FloatField columns. value = float(value) elif precision > 0: # NUMBER(p,s) column: decimal-precision fixed point. # This comes from IntField and DecimalField columns. if scale == 0: value = int(value) else: value = decimal.Decimal(value) elif '.' in value: # No type information. This normally comes from a # mathematical expression in the SELECT list. Guess int # or Decimal based on whether it has a decimal point. value = decimal.Decimal(value) else: value = int(value) # datetimes are returned as TIMESTAMP, except the results # of "dates" queries, which are returned as DATETIME. elif desc[1] in (Database.TIMESTAMP, Database.DATETIME): # Confirm that dt is naive before overwriting its tzinfo. if settings.USE_TZ and value is not None and timezone.is_naive(value): value = value.replace(tzinfo=timezone.utc) elif desc[1] in (Database.STRING, Database.FIXED_CHAR, Database.LONG_STRING): value = to_unicode(value) casted.append(value) return tuple(casted) def to_unicode(s): """ Convert strings to Unicode objects (and return all other data types unchanged). """ if isinstance(s, six.string_types): return force_text(s) return s
mit
[ 624, 202, 199, 21202, 3050, 4865, 367, 5634, 14, 2999, 199, 18153, 17280, 63, 21202, 26, 1455, 921, 11859, 13, 16404, 14, 22943, 14, 846, 15, 202, 199, 624, 202, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 2999, 199, 646, 2197, 202, 199, 646, 6107, 202, 199, 646, 747, 202, 199, 646, 4298, 202, 199, 646, 984, 202, 199, 646, 3598, 2999, 199, 504, 1639, 14, 2190, 492, 2202, 202, 199, 504, 1639, 14, 697, 492, 3778, 202, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 1095, 492, 29103, 4590, 202, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 6136, 492, 29103, 13816, 202, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 202, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 202, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 202, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 8065, 199, 318, 485, 2758, 63, 5418, 8, 2314, 304, 1128, 327, 445, 18313, 5074, 2005, 4539, 14164, 22058, 370, 663, 314, 3734, 2860, 1128, 327, 7684, 880, 626, 15309, 911, 1937, 3062, 14, 1128, 340, 4298, 14, 2253, 1252, 4142, 1252, 2460, 360, 15068, 39, 7941, 735, 1039, 862, 26, 1675, 492, 5577, 1039, 871, 3545, 465, 325, 26, 1675, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 1675, 746, 11897, 480, 547, 8697, 5577, 26, 450, 83, 27, 298, 202, 4318, 298, 1589, 15309, 4865, 5074, 5577, 370, 298, 202, 4318, 298, 2262, 323, 6657, 1334, 445, 18313, 2122, 450, 325, 9, 1039, 5114, 708, 275, 5577, 14, 7695, 4464, 360, 4989, 708, 358, 1039, 367, 536, 12, 574, 315, 6160, 26, 1675, 5114, 708, 14, 1084, 8263, 2773, 33, 8, 354, 12, 574, 9, 1128, 587, 26, 1039, 747, 14, 2314, 14, 873, 8, 2314, 9, 2999, 199, 63, 2758, 63, 5418, 779, 1128, 327, 15309, 6181, 1890, 13, 2441, 4528, 663, 2644, 687, 314, 3734, 14, 1128, 661, 46, 5296, 63, 7442, 297, 1987, 6610, 24, 659, 1128, 327, 961, 21925, 2649, 687, 10232, 333, 22183, 701, 10232, 5737, 1901, 314, 1128, 327, 18994, 2222, 13, 2975, 3050, 4528, 663, 14, 1128, 661, 726, 33, 63, 46, 5901, 63, 21692, 63, 27010, 297, 283, 15064, 659, 202, 199, 566, 8065, 199, 893, 26, 1128, 492, 17280, 63, 21202, 465, 8692, 202, 199, 2590, 3545, 465, 325, 26, 1128, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 1128, 746, 11897, 480, 547, 8697, 17280, 63, 21202, 859, 26, 450, 83, 2, 450, 325, 9, 2999, 199, 3, 6601, 402, 3520, 492, 17280, 63, 21202, 12, 880, 492, 3062, 2410, 7907, 340, 652, 1159, 4903, 14, 202, 199, 504, 1275, 1258, 492, 8692, 3041, 14516, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 8782, 492, 8692, 13921, 10473, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 3179, 492, 8692, 10807, 10473, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 21627, 492, 8692, 30516, 3322, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 8170, 492, 8692, 12929, 8295, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 3629, 492, 8692, 6700, 10423, 8540, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 1208, 492, 15309, 63, 2083, 12, 3957, 63, 2975, 260, 327, 365, 361, 26, 2759, 2999, 199, 25198, 275, 8692, 14, 25198, 202, 199, 24823, 275, 8692, 14, 24823, 8065, 199, 533, 485, 1358, 12486, 3632, 2750, 4311, 8, 785, 304, 2958, 347, 636, 362, 721, 277, 12, 1256, 12, 5771, 304, 1039, 327, 982, 1950, 14, 12688, 365, 21182, 1536, 2544, 282, 1950, 965, 2757, 1039, 327, 2737, 12, 17265, 590, 8265, 1950, 14, 12688, 370, 282, 1884, 376, 1039, 327, 4281, 14, 1039, 340, 1256, 365, 488, 26, 1675, 746, 4281, 480, 12688, 440, 2808, 465, 1021, 2225, 531, 1039, 327, 20507, 282, 3920, 911, 8265, 314, 10211, 14, 1039, 1256, 14, 3937, 1252, 1600, 342, 1039, 372, 1256, 855, 807, 23010, 12688, 418, 8065, 199, 533, 8692, 4590, 8, 1563, 7243, 4590, 304, 1128, 20868, 275, 283, 16404, 7, 1128, 327, 961, 2600, 9033, 5024, 2251, 370, 3932, 4568, 15309, 2763, 1128, 327, 2943, 12, 465, 3326, 14, 4996, 13, 466, 3326, 883, 1395, 1475, 3326, 27, 2985, 7171, 1128, 327, 506, 23005, 972, 6169, 314, 1338, 402, 5024, 855, 807, 363, 2544, 3769, 1072, 14, 1128, 327, 982, 282, 2763, 730, 365, 663, 370, 488, 12, 652, 7859, 1133, 506, 5120, 315, 314, 1072, 14, 1128, 327, 1128, 327, 6184, 1475, 3326, 6617, 543, 298, 15156, 12172, 787, 10999, 2544, 3769, 1202, 315, 314, 1128, 327, 1072, 334, 1589, 298, 15156, 12172, 2403, 365, 14489, 2544, 314, 4237, 365, 10585, 14, 1128, 666, 63, 1313, 275, 469, 1039, 283, 4378, 356, 283, 9190, 8, 845, 3196, 1039, 283, 6636, 792, 356, 283, 26275, 297, 1039, 283, 5036, 356, 283, 9190, 8, 17, 3196, 1039, 283, 2183, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 25732, 20727, 3901, 356, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 14071, 356, 283, 5390, 297, 1039, 283, 4626, 356, 283, 20277, 297, 1039, 283, 15975, 356, 283, 9190, 12473, 988, 63, 7022, 9, 83, 12, 2818, 6355, 63, 10696, 9, 83, 3196, 1039, 283, 13283, 792, 356, 283, 17359, 577, 3448, 8, 25, 9, 2296, 5795, 1864, 36, 8, 22, 3196, 1039, 283, 23252, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 14225, 792, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 13019, 356, 283, 14989, 510, 9481, 30011, 297, 1039, 283, 3901, 356, 283, 9190, 8, 845, 3196, 1039, 283, 25175, 356, 283, 9190, 8, 1167, 3196, 1039, 283, 26969, 356, 283, 24800, 18, 8, 1046, 3196, 1039, 283, 9417, 26969, 356, 283, 24800, 18, 8, 1355, 3196, 1039, 283, 29068, 356, 283, 9190, 8, 17, 3196, 1039, 283, 14298, 356, 283, 9190, 8, 845, 3196, 1039, 283, 8591, 356, 283, 9190, 8, 845, 3196, 1039, 283, 25197, 356, 283, 9190, 8, 845, 3196, 1039, 283, 17315, 356, 283, 46, 24800, 18, 12473, 988, 63 ]
[ 202, 199, 21202, 3050, 4865, 367, 5634, 14, 2999, 199, 18153, 17280, 63, 21202, 26, 1455, 921, 11859, 13, 16404, 14, 22943, 14, 846, 15, 202, 199, 624, 202, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 2999, 199, 646, 2197, 202, 199, 646, 6107, 202, 199, 646, 747, 202, 199, 646, 4298, 202, 199, 646, 984, 202, 199, 646, 3598, 2999, 199, 504, 1639, 14, 2190, 492, 2202, 202, 199, 504, 1639, 14, 697, 492, 3778, 202, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 1095, 492, 29103, 4590, 202, 199, 504, 1639, 14, 697, 14, 7765, 14, 1095, 14, 6136, 492, 29103, 13816, 202, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 202, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 202, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 202, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 8065, 199, 318, 485, 2758, 63, 5418, 8, 2314, 304, 1128, 327, 445, 18313, 5074, 2005, 4539, 14164, 22058, 370, 663, 314, 3734, 2860, 1128, 327, 7684, 880, 626, 15309, 911, 1937, 3062, 14, 1128, 340, 4298, 14, 2253, 1252, 4142, 1252, 2460, 360, 15068, 39, 7941, 735, 1039, 862, 26, 1675, 492, 5577, 1039, 871, 3545, 465, 325, 26, 1675, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 1675, 746, 11897, 480, 547, 8697, 5577, 26, 450, 83, 27, 298, 202, 4318, 298, 1589, 15309, 4865, 5074, 5577, 370, 298, 202, 4318, 298, 2262, 323, 6657, 1334, 445, 18313, 2122, 450, 325, 9, 1039, 5114, 708, 275, 5577, 14, 7695, 4464, 360, 4989, 708, 358, 1039, 367, 536, 12, 574, 315, 6160, 26, 1675, 5114, 708, 14, 1084, 8263, 2773, 33, 8, 354, 12, 574, 9, 1128, 587, 26, 1039, 747, 14, 2314, 14, 873, 8, 2314, 9, 2999, 199, 63, 2758, 63, 5418, 779, 1128, 327, 15309, 6181, 1890, 13, 2441, 4528, 663, 2644, 687, 314, 3734, 14, 1128, 661, 46, 5296, 63, 7442, 297, 1987, 6610, 24, 659, 1128, 327, 961, 21925, 2649, 687, 10232, 333, 22183, 701, 10232, 5737, 1901, 314, 1128, 327, 18994, 2222, 13, 2975, 3050, 4528, 663, 14, 1128, 661, 726, 33, 63, 46, 5901, 63, 21692, 63, 27010, 297, 283, 15064, 659, 202, 199, 566, 8065, 199, 893, 26, 1128, 492, 17280, 63, 21202, 465, 8692, 202, 199, 2590, 3545, 465, 325, 26, 1128, 687, 1639, 14, 1018, 14, 3924, 492, 11897, 1128, 746, 11897, 480, 547, 8697, 17280, 63, 21202, 859, 26, 450, 83, 2, 450, 325, 9, 2999, 199, 3, 6601, 402, 3520, 492, 17280, 63, 21202, 12, 880, 492, 3062, 2410, 7907, 340, 652, 1159, 4903, 14, 202, 199, 504, 1275, 1258, 492, 8692, 3041, 14516, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 8782, 492, 8692, 13921, 10473, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 3179, 492, 8692, 10807, 10473, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 21627, 492, 8692, 30516, 3322, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 8170, 492, 8692, 12929, 8295, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 3629, 492, 8692, 6700, 10423, 8540, 327, 365, 361, 26, 2759, 202, 199, 504, 1275, 1208, 492, 15309, 63, 2083, 12, 3957, 63, 2975, 260, 327, 365, 361, 26, 2759, 2999, 199, 25198, 275, 8692, 14, 25198, 202, 199, 24823, 275, 8692, 14, 24823, 8065, 199, 533, 485, 1358, 12486, 3632, 2750, 4311, 8, 785, 304, 2958, 347, 636, 362, 721, 277, 12, 1256, 12, 5771, 304, 1039, 327, 982, 1950, 14, 12688, 365, 21182, 1536, 2544, 282, 1950, 965, 2757, 1039, 327, 2737, 12, 17265, 590, 8265, 1950, 14, 12688, 370, 282, 1884, 376, 1039, 327, 4281, 14, 1039, 340, 1256, 365, 488, 26, 1675, 746, 4281, 480, 12688, 440, 2808, 465, 1021, 2225, 531, 1039, 327, 20507, 282, 3920, 911, 8265, 314, 10211, 14, 1039, 1256, 14, 3937, 1252, 1600, 342, 1039, 372, 1256, 855, 807, 23010, 12688, 418, 8065, 199, 533, 8692, 4590, 8, 1563, 7243, 4590, 304, 1128, 20868, 275, 283, 16404, 7, 1128, 327, 961, 2600, 9033, 5024, 2251, 370, 3932, 4568, 15309, 2763, 1128, 327, 2943, 12, 465, 3326, 14, 4996, 13, 466, 3326, 883, 1395, 1475, 3326, 27, 2985, 7171, 1128, 327, 506, 23005, 972, 6169, 314, 1338, 402, 5024, 855, 807, 363, 2544, 3769, 1072, 14, 1128, 327, 982, 282, 2763, 730, 365, 663, 370, 488, 12, 652, 7859, 1133, 506, 5120, 315, 314, 1072, 14, 1128, 327, 1128, 327, 6184, 1475, 3326, 6617, 543, 298, 15156, 12172, 787, 10999, 2544, 3769, 1202, 315, 314, 1128, 327, 1072, 334, 1589, 298, 15156, 12172, 2403, 365, 14489, 2544, 314, 4237, 365, 10585, 14, 1128, 666, 63, 1313, 275, 469, 1039, 283, 4378, 356, 283, 9190, 8, 845, 3196, 1039, 283, 6636, 792, 356, 283, 26275, 297, 1039, 283, 5036, 356, 283, 9190, 8, 17, 3196, 1039, 283, 2183, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 25732, 20727, 3901, 356, 283, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 14071, 356, 283, 5390, 297, 1039, 283, 4626, 356, 283, 20277, 297, 1039, 283, 15975, 356, 283, 9190, 12473, 988, 63, 7022, 9, 83, 12, 2818, 6355, 63, 10696, 9, 83, 3196, 1039, 283, 13283, 792, 356, 283, 17359, 577, 3448, 8, 25, 9, 2296, 5795, 1864, 36, 8, 22, 3196, 1039, 283, 23252, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 14225, 792, 356, 283, 46, 24800, 18, 12473, 988, 63, 1267, 9, 83, 3196, 1039, 283, 13019, 356, 283, 14989, 510, 9481, 30011, 297, 1039, 283, 3901, 356, 283, 9190, 8, 845, 3196, 1039, 283, 25175, 356, 283, 9190, 8, 1167, 3196, 1039, 283, 26969, 356, 283, 24800, 18, 8, 1046, 3196, 1039, 283, 9417, 26969, 356, 283, 24800, 18, 8, 1355, 3196, 1039, 283, 29068, 356, 283, 9190, 8, 17, 3196, 1039, 283, 14298, 356, 283, 9190, 8, 845, 3196, 1039, 283, 8591, 356, 283, 9190, 8, 845, 3196, 1039, 283, 25197, 356, 283, 9190, 8, 845, 3196, 1039, 283, 17315, 356, 283, 46, 24800, 18, 12473, 988, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jellysheep/pyload
module/plugins/hoster/FilepostCom.py
12
4821
# -*- coding: utf-8 -*- import re import time from module.common.json_layer import json_loads from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilepostCom(SimpleHoster): __name__ = "FilepostCom" __type__ = "hoster" __version__ = "0.35" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/(?P<ID>[^/]+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Filepost.com hoster plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] INFO_PATTERN = r'<input type="text" id="url" value=\'<a href.*?>(?P<N>[^>]+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>' OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>|<div class="file_info file_info_deleted">' PREMIUM_ONLY_PATTERN = r'members only. Please upgrade to premium|a premium membership is required to download this file' RECAPTCHA_PATTERN = r'Captcha.init\({\s*key:\s*\'(.+?)\'' FLP_TOKEN_PATTERN = r'set_store_options\({token: \'(.+?)\'' def handle_free(self, pyfile): m = re.search(self.FLP_TOKEN_PATTERN, self.html) if m is None: self.error(_("Token")) flp_token = m.group(1) m = re.search(self.RECAPTCHA_PATTERN, self.html) if m is None: self.error(_("Captcha key")) captcha_key = m.group(1) #: Get wait time get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time.time() * 10000)) + '-xml'} post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']} wait_time = int(self.get_json_response(get_dict, post_dict, 'wait_time')) if wait_time > 0: self.wait(wait_time) post_dict = {'token': flp_token, 'code': self.info['pattern']['ID'], 'file_pass': ''} if 'var is_pass_exists = true;' in self.html: #: Solve password password = self.get_password() if password: self.log_info(_("Password protected link, trying ") + file_pass) get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml' post_dict['file_pass'] = file_pass self.link = self.get_json_response(get_dict, post_dict, 'link') if not self.link: self.fail(_("Incorrect password")) else: self.fail(_("No password found")) else: #: Solve recaptcha recaptcha = ReCaptcha(self) for i in xrange(5): get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml' if i: post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge( captcha_key) self.log_debug(u"RECAPTCHA: %s : %s : %s" % ( captcha_key, post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'])) self.link = self.get_json_response(get_dict, post_dict, 'link') else: self.fail(_("Invalid captcha")) def get_json_response(self, get_dict, post_dict, field): res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) self.log_debug(res) if not 'js' in res: self.error(_("JSON %s 1") % field) #: I changed js_answer to res['js'] since js_answer is nowhere set. #: I don't know the JSON-HTTP specs in detail, but the previous author #: Accessed res['js']['error'] as well as js_answer['error']. #: See the two lines commented out with "# ~?". if 'error' in res['js']: if res['js']['error'] == "download_delay": self.retry(wait_time=res['js']['params']['next_download']) #: ~? self.retry(wait_time=js_answer['params']['next_download']) elif 'Wrong file password' in res['js']['error'] \ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ or 'CAPTCHA Code nicht korrekt' in res['js']['error']: return None elif 'CAPTCHA' in res['js']['error']: self.log_debug("Error response is unknown, but mentions CAPTCHA") return None else: self.fail(res['js']['error']) if not 'answer' in res['js'] or not field in res['js']['answer']: self.error(_("JSON %s 2") % field) return res['js']['answer'][field] getInfo = create_getInfo(FilepostCom)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 295, 199, 646, 900, 199, 199, 504, 859, 14, 2330, 14, 1001, 63, 1897, 492, 2022, 63, 3640, 199, 504, 859, 14, 5265, 14, 20559, 14, 497, 13519, 9518, 492, 799, 13519, 9518, 199, 504, 859, 14, 5265, 14, 4672, 14, 3184, 40, 29895, 492, 5870, 40, 29895, 12, 1218, 63, 362, 2354, 421, 199, 533, 3814, 1932, 4373, 8, 3184, 40, 29895, 304, 272, 636, 354, 363, 259, 275, 298, 1173, 1932, 4373, 2, 272, 636, 466, 363, 259, 275, 298, 526, 11652, 2, 272, 636, 1023, 363, 275, 298, 16, 14, 1276, 2, 272, 636, 1205, 363, 221, 275, 298, 4776, 2, 339, 636, 3401, 363, 275, 519, 7, 2859, 24524, 1544, 20316, 5169, 493, 1932, 4537, 957, 15, 1725, 92, 3997, 4537, 2308, 2447, 2229, 48, 28, 998, 26906, 3171, 272, 636, 888, 363, 221, 275, 10003, 1180, 63, 657, 23481, 401, 298, 2245, 401, 298, 6119, 876, 23481, 2933, 340, 2808, 401, 715, 1874, 339, 636, 1802, 363, 275, 408, 1173, 1932, 14, 957, 394, 29895, 3589, 624, 272, 636, 1682, 363, 258, 275, 298, 28863, 19, 2, 272, 636, 8149, 363, 258, 275, 10003, 90, 1170, 14630, 401, 298, 90, 1170, 14630, 32, 6553, 74, 1198, 14, 16823, 11323, 2378, 24008, 63, 10764, 275, 519, 7601, 1210, 730, 628, 505, 2, 1305, 628, 633, 2, 574, 25641, 28, 65, 4369, 6697, 30, 2229, 48, 28, 46, 13489, 30, 2807, 17076, 446, 7558, 48, 28, 51, 24693, 68, 2020, 11896, 7558, 48, 28, 53, 24693, 87, 62, 63, 11896, 1108, 65, 3072, 7, 1021, 628, 11416, 63, 505, 7897, 7, 272, 1634, 3143, 3565, 63, 10764, 275, 519, 7, 533, 628, 705, 63, 1328, 63, 1213, 1743, 6378, 503, 1487, 3496, 3814, 14, 3068, 3015, 21521, 28, 3015, 1021, 628, 493, 63, 815, 570, 63, 815, 63, 6062, 15603, 339, 19924, 10709, 2639, 63, 10452, 63, 10764, 275, 519, 6704, 69, 976, 83, 1454, 14, 7754, 10754, 370, 876, 23481, 92, 65, 876, 23481, 14616, 365, 1415, 370, 5235, 642, 570, 7, 272, 19461, 26086, 26363, 63, 10764, 275, 519, 7, 13519, 9518, 14, 826, 60, 2561, 60, 83, 10, 498, 3427, 83, 10, 3985, 28149, 2862, 891, 272, 481, 9257, 63, 8803, 63, 10764, 275, 519, 1159, 386, 63, 1617, 63, 1419, 60, 2561, 1418, 26, 971, 6774, 11198, 2862, 891, 2378, 347, 2429, 63, 4624, 8, 277, 12, 1134, 493, 304, 267, 333, 275, 295, 14, 1733, 8, 277, 14, 3143, 48, 63, 8803, 63, 10764, 12, 291, 14, 1360, 9, 267, 340, 333, 365, 488, 26, 288, 291, 14, 705, 6115, 3264, 2237, 267, 2717, 80, 63, 1418, 275, 333, 14, 923, 8, 17, 9, 398, 333, 275, 295, 14, 1733, 8, 277, 14, 907, 28342, 26363, 63, 10764, 12, 291, 14, 1360, 9, 267, 340, 333, 365, 488, 26, 288, 291, 14, 705, 6115, 13519, 9518, 790, 2237, 267, 12162, 9518, 63, 498, 275, 333, 14, 923, 8, 17, 9, 398, 6079, 2372, 3618, 900, 267, 664, 63, 807, 275, 791, 19514, 356, 291, 14, 2103, 14, 24862, 14, 362, 7810, 360, 19514, 659, 283, 16633, 10441, 356, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 936, 267, 2963, 63, 807, 275, 791, 1287, 356, 283, 409, 63, 4249, 297, 283, 1418, 356, 2717, 80, 63, 1418, 12, 283, 600, 356, 291, 14, 815, 459, 3401, 2545, 998, 12074, 267, 3618, 63, 521, 275, 1109, 8, 277, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 2573, 63, 521, 1333, 398, 340, 3618, 63, 521, 690, 378, 26, 288, 291, 14, 2573, 8, 2573, 63, 521, 9, 398, 2963, 63, 807, 275, 791, 1418, 356, 2717, 80, 63, 1418, 12, 283, 600, 356, 291, 14, 815, 459, 3401, 2545, 998, 995, 283, 493, 63, 1529, 356, 28174, 398, 340, 283, 1391, 365, 63, 1529, 63, 2444, 275, 2549, 8942, 315, 291, 14, 1360, 26, 288, 6079, 428, 3344, 2505, 288, 2505, 275, 291, 14, 362, 63, 2060, 342, 953, 340, 2505, 26, 355, 291, 14, 793, 63, 815, 6115, 6139, 17819, 2142, 12, 9936, 6099, 435, 570, 63, 1529, 9, 2234, 664, 63, 807, 459, 16633, 10441, 418, 275, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 7, 355, 2963, 63, 807, 459, 493, 63, 1529, 418, 275, 570, 63, 1529, 2234, 291, 14, 1073, 275, 291, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 1073, 358, 2234, 340, 440, 291, 14, 1073, 26, 490, 291, 14, 1633, 6115, 18298, 2505, 2237, 288, 587, 26, 355, 291, 14, 1633, 6115, 1944, 2505, 1911, 2237, 398, 587, 26, 288, 6079, 428, 3344, 295, 20559, 288, 295, 20559, 275, 799, 13519, 9518, 8, 277, 9, 953, 367, 284, 315, 4945, 8, 21, 304, 355, 664, 63, 807, 459, 16633, 10441, 418, 275, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 7, 355, 340, 284, 26, 490, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 1310, 63, 698, 995, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 13911, 63, 698, 418, 275, 295, 20559, 14, 13911, 8, 717, 12162, 9518, 63, 498, 9, 490, 291, 14, 793, 63, 1757, 8, 85, 2, 907, 28342, 26363, 26, 450, 83, 520, 450, 83, 520, 450, 83, 2, 450, 334, 717, 12162, 9518, 63, 498, 12, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 13911, 63, 698, 995, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 1310, 63, 698, 5156, 2234, 291, 14, 1073, 275, 291, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 1073, 358, 953, 587, 26, 355, 291, 14, 1633, 6115, 3364, 12162, 9518, 2237, 2378, 347, 664, 63, 1001, 63, 1310, 8, 277, 12, 664, 63, 807, 12, 2963, 63, 807, 12, 901, 304, 267, 522, 275, 2022, 63, 3640, 8, 277, 14, 912, 360, 2859, 921, 493, 1932, 14, 957, 15, 1725, 15, 362, 3678, 664, 29, 362, 63, 807, 12, 2963, 29, 1932, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 295, 199, 646, 900, 199, 199, 504, 859, 14, 2330, 14, 1001, 63, 1897, 492, 2022, 63, 3640, 199, 504, 859, 14, 5265, 14, 20559, 14, 497, 13519, 9518, 492, 799, 13519, 9518, 199, 504, 859, 14, 5265, 14, 4672, 14, 3184, 40, 29895, 492, 5870, 40, 29895, 12, 1218, 63, 362, 2354, 421, 199, 533, 3814, 1932, 4373, 8, 3184, 40, 29895, 304, 272, 636, 354, 363, 259, 275, 298, 1173, 1932, 4373, 2, 272, 636, 466, 363, 259, 275, 298, 526, 11652, 2, 272, 636, 1023, 363, 275, 298, 16, 14, 1276, 2, 272, 636, 1205, 363, 221, 275, 298, 4776, 2, 339, 636, 3401, 363, 275, 519, 7, 2859, 24524, 1544, 20316, 5169, 493, 1932, 4537, 957, 15, 1725, 92, 3997, 4537, 2308, 2447, 2229, 48, 28, 998, 26906, 3171, 272, 636, 888, 363, 221, 275, 10003, 1180, 63, 657, 23481, 401, 298, 2245, 401, 298, 6119, 876, 23481, 2933, 340, 2808, 401, 715, 1874, 339, 636, 1802, 363, 275, 408, 1173, 1932, 14, 957, 394, 29895, 3589, 624, 272, 636, 1682, 363, 258, 275, 298, 28863, 19, 2, 272, 636, 8149, 363, 258, 275, 10003, 90, 1170, 14630, 401, 298, 90, 1170, 14630, 32, 6553, 74, 1198, 14, 16823, 11323, 2378, 24008, 63, 10764, 275, 519, 7601, 1210, 730, 628, 505, 2, 1305, 628, 633, 2, 574, 25641, 28, 65, 4369, 6697, 30, 2229, 48, 28, 46, 13489, 30, 2807, 17076, 446, 7558, 48, 28, 51, 24693, 68, 2020, 11896, 7558, 48, 28, 53, 24693, 87, 62, 63, 11896, 1108, 65, 3072, 7, 1021, 628, 11416, 63, 505, 7897, 7, 272, 1634, 3143, 3565, 63, 10764, 275, 519, 7, 533, 628, 705, 63, 1328, 63, 1213, 1743, 6378, 503, 1487, 3496, 3814, 14, 3068, 3015, 21521, 28, 3015, 1021, 628, 493, 63, 815, 570, 63, 815, 63, 6062, 15603, 339, 19924, 10709, 2639, 63, 10452, 63, 10764, 275, 519, 6704, 69, 976, 83, 1454, 14, 7754, 10754, 370, 876, 23481, 92, 65, 876, 23481, 14616, 365, 1415, 370, 5235, 642, 570, 7, 272, 19461, 26086, 26363, 63, 10764, 275, 519, 7, 13519, 9518, 14, 826, 60, 2561, 60, 83, 10, 498, 3427, 83, 10, 3985, 28149, 2862, 891, 272, 481, 9257, 63, 8803, 63, 10764, 275, 519, 1159, 386, 63, 1617, 63, 1419, 60, 2561, 1418, 26, 971, 6774, 11198, 2862, 891, 2378, 347, 2429, 63, 4624, 8, 277, 12, 1134, 493, 304, 267, 333, 275, 295, 14, 1733, 8, 277, 14, 3143, 48, 63, 8803, 63, 10764, 12, 291, 14, 1360, 9, 267, 340, 333, 365, 488, 26, 288, 291, 14, 705, 6115, 3264, 2237, 267, 2717, 80, 63, 1418, 275, 333, 14, 923, 8, 17, 9, 398, 333, 275, 295, 14, 1733, 8, 277, 14, 907, 28342, 26363, 63, 10764, 12, 291, 14, 1360, 9, 267, 340, 333, 365, 488, 26, 288, 291, 14, 705, 6115, 13519, 9518, 790, 2237, 267, 12162, 9518, 63, 498, 275, 333, 14, 923, 8, 17, 9, 398, 6079, 2372, 3618, 900, 267, 664, 63, 807, 275, 791, 19514, 356, 291, 14, 2103, 14, 24862, 14, 362, 7810, 360, 19514, 659, 283, 16633, 10441, 356, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 936, 267, 2963, 63, 807, 275, 791, 1287, 356, 283, 409, 63, 4249, 297, 283, 1418, 356, 2717, 80, 63, 1418, 12, 283, 600, 356, 291, 14, 815, 459, 3401, 2545, 998, 12074, 267, 3618, 63, 521, 275, 1109, 8, 277, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 2573, 63, 521, 1333, 398, 340, 3618, 63, 521, 690, 378, 26, 288, 291, 14, 2573, 8, 2573, 63, 521, 9, 398, 2963, 63, 807, 275, 791, 1418, 356, 2717, 80, 63, 1418, 12, 283, 600, 356, 291, 14, 815, 459, 3401, 2545, 998, 995, 283, 493, 63, 1529, 356, 28174, 398, 340, 283, 1391, 365, 63, 1529, 63, 2444, 275, 2549, 8942, 315, 291, 14, 1360, 26, 288, 6079, 428, 3344, 2505, 288, 2505, 275, 291, 14, 362, 63, 2060, 342, 953, 340, 2505, 26, 355, 291, 14, 793, 63, 815, 6115, 6139, 17819, 2142, 12, 9936, 6099, 435, 570, 63, 1529, 9, 2234, 664, 63, 807, 459, 16633, 10441, 418, 275, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 7, 355, 2963, 63, 807, 459, 493, 63, 1529, 418, 275, 570, 63, 1529, 2234, 291, 14, 1073, 275, 291, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 1073, 358, 2234, 340, 440, 291, 14, 1073, 26, 490, 291, 14, 1633, 6115, 18298, 2505, 2237, 288, 587, 26, 355, 291, 14, 1633, 6115, 1944, 2505, 1911, 2237, 398, 587, 26, 288, 6079, 428, 3344, 295, 20559, 288, 295, 20559, 275, 799, 13519, 9518, 8, 277, 9, 953, 367, 284, 315, 4945, 8, 21, 304, 355, 664, 63, 807, 459, 16633, 10441, 418, 275, 620, 8, 442, 8, 521, 14, 521, 342, 627, 11630, 430, 435, 2475, 1652, 7, 355, 340, 284, 26, 490, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 1310, 63, 698, 995, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 13911, 63, 698, 418, 275, 295, 20559, 14, 13911, 8, 717, 12162, 9518, 63, 498, 9, 490, 291, 14, 793, 63, 1757, 8, 85, 2, 907, 28342, 26363, 26, 450, 83, 520, 450, 83, 520, 450, 83, 2, 450, 334, 717, 12162, 9518, 63, 498, 12, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 13911, 63, 698, 995, 2963, 63, 807, 459, 2761, 6182, 9518, 63, 1310, 63, 698, 5156, 2234, 291, 14, 1073, 275, 291, 14, 362, 63, 1001, 63, 1310, 8, 362, 63, 807, 12, 2963, 63, 807, 12, 283, 1073, 358, 953, 587, 26, 355, 291, 14, 1633, 6115, 3364, 12162, 9518, 2237, 2378, 347, 664, 63, 1001, 63, 1310, 8, 277, 12, 664, 63, 807, 12, 2963, 63, 807, 12, 901, 304, 267, 522, 275, 2022, 63, 3640, 8, 277, 14, 912, 360, 2859, 921, 493, 1932, 14, 957, 15, 1725, 15, 362, 3678, 664, 29, 362, 63, 807, 12, 2963, 29, 1932, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
City-of-Bloomington/green-rental
building/migrations/0015_auto__chg_field_building_energy_score.py
2
24390
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'Building.energy_score' db.alter_column(u'building_building', 'energy_score', self.gf('django.db.models.fields.FloatField')()) def backwards(self, orm): # Changing field 'Building.energy_score' db.alter_column(u'building_building', 'energy_score', self.gf('django.db.models.fields.IntegerField')()) models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'building.building': { 'Meta': {'object_name': 'Building'}, 'active_listings': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'address': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'air_conditioning': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'amenities': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'average_electricity': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_gas': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_trash': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_water': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'bike_friendly': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'bike_friendly_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}), 'bike_friendly_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'bike_score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'built_year': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'city': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['city.City']"}), 'composting': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'energy_average': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'energy_saving_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'energy_saving_features': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'energy_saving_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'energy_score': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'estimated_total_max': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'estimated_total_min': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'game_room': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'garden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'garden_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'garden_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'geocoder': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'gym': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'heat_source_details': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20', 'blank': 'True'}), 'heat_source_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'latitude': ('django.db.models.fields.FloatField', [], {}), 'laundry': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}), 'longitude': ('django.db.models.fields.FloatField', [], {}), 'max_rent': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'max_rent_listing': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'min_rent': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'min_rent_listing': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '80', 'blank': 'True'}), 'number_of_units': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'parcel': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['building.Parcel']"}), 'parking_options': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'pets': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'pets_options': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'pets_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'pool': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'recycling': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'renewable_energy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'renewable_energy_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'renewable_energy_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'smart_living': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['source.Source']"}), 'sqft': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'state': ('django.db.models.fields.CharField', [], {'max_length': '2'}), 'tag': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200'}), 'total_average': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'transit_friendly': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'transit_friendly_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'transit_friendly_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'transit_score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'type': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30', 'blank': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'utility_data_updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'value': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'walk_friendly': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'walk_friendly_details': ('rentrocket.helpers.MultiSelectField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}), 'walk_friendly_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'walk_score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'website': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), 'who_pays_cable': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}), 'who_pays_electricity': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}), 'who_pays_gas': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}), 'who_pays_internet': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}), 'who_pays_trash': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}), 'who_pays_water': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}) }, u'building.buildingcomment': { 'Meta': {'object_name': 'BuildingComment'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': u"orm['building.Building']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'message': ('django.db.models.fields.TextField', [], {}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}) }, u'building.buildingdocument': { 'Meta': {'object_name': 'BuildingDocument'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'blob_key': ('django.db.models.fields.TextField', [], {}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'documents'", 'to': u"orm['building.Building']"}), 'description': ('django.db.models.fields.TextField', [], {}), 'filename': ('django.db.models.fields.CharField', [], {'max_length': '50'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'documents'", 'null': 'True', 'to': u"orm['building.Unit']"}) }, u'building.buildingperson': { 'Meta': {'object_name': 'BuildingPerson'}, 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'people'", 'to': u"orm['building.Building']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'person': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['person.Person']"}), 'relation': ('django.db.models.fields.CharField', [], {'default': "'Unknown'", 'max_length': '50'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['building.Unit']", 'null': 'True', 'blank': 'True'}), 'visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, u'building.buildingphoto': { 'Meta': {'object_name': 'BuildingPhoto'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'blob_key': ('django.db.models.fields.TextField', [], {}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'photos'", 'to': u"orm['building.Building']"}), 'description': ('django.db.models.fields.TextField', [], {}), 'filename': ('django.db.models.fields.CharField', [], {'max_length': '50'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'photos'", 'null': 'True', 'to': u"orm['building.Unit']"}) }, u'building.changedetails': { 'Meta': {'object_name': 'ChangeDetails'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'changes'", 'to': u"orm['building.Building']"}), 'diffs': ('jsonfield.fields.JSONField', [], {'default': "''", 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), 'note': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'changes'", 'null': 'True', 'to': u"orm['building.Unit']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}) }, u'building.listing': { 'Meta': {'object_name': 'Listing'}, 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'available_end': ('django.db.models.fields.DateTimeField', [], {}), 'available_start': ('django.db.models.fields.DateTimeField', [], {}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'listings'", 'null': 'True', 'to': u"orm['building.Building']"}), 'cost': ('django.db.models.fields.FloatField', [], {}), 'cost_cycle': ('django.db.models.fields.CharField', [], {'default': "'month'", 'max_length': '10'}), 'deposit': ('django.db.models.fields.FloatField', [], {}), 'description': ('django.db.models.fields.TextField', [], {}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'lease_term': ('django.db.models.fields.CharField', [], {'default': "'12 Months'", 'max_length': '200'}), 'lease_type': ('django.db.models.fields.CharField', [], {'default': "'Standard'", 'max_length': '200'}), 'pets': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'unit': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'listings'", 'to': u"orm['building.Unit']"}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}) }, u'building.parcel': { 'Meta': {'object_name': 'Parcel'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'custom_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}), 'from_st': ('django.db.models.fields.CharField', [], {'max_length': '12'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'shape': ('django.db.models.fields.TextField', [], {}), 'street': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'street_type': ('django.db.models.fields.CharField', [], {'max_length': '10'}), 'to_st': ('django.db.models.fields.CharField', [], {'max_length': '12', 'blank': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) }, u'building.permit': { 'Meta': {'object_name': 'Permit'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, u'building.unit': { 'Meta': {'ordering': "['number']", 'object_name': 'Unit'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'address': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}), 'average_electricity': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_gas': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_trash': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'average_water': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'bathrooms': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'bedrooms': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'building': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'units'", 'to': u"orm['building.Building']"}), 'current_rent': ('django.db.models.fields.FloatField', [], {'default': '0'}), 'floor': ('django.db.models.fields.IntegerField', [], {'default': '0'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'max_occupants': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'number': ('django.db.models.fields.CharField', [], {'max_length': '20'}), 'sqft': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20', 'blank': 'True'}), 'tag': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, u'building.unittype': { 'Meta': {'object_name': 'UnitType'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, u'city.city': { 'Meta': {'object_name': 'City'}, 'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'latitude': ('django.db.models.fields.FloatField', [], {}), 'longitude': ('django.db.models.fields.FloatField', [], {}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'state': ('django.db.models.fields.CharField', [], {'max_length': '2'}), 'tag': ('django.db.models.fields.CharField', [], {'default': "'<django.db.models.fields.charfield>'", 'unique': 'True', 'max_length': '200'}), 'type': ('django.db.models.fields.CharField', [], {'default': "'city'", 'max_length': '50'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'url': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}) }, u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, u'person.person': { 'Meta': {'object_name': 'Person'}, 'address': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), 'city': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['city.City']", 'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), 'website': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}) }, u'source.feedinfo': { 'Meta': {'object_name': 'FeedInfo'}, 'added': ('django.db.models.fields.DateTimeField', [], {}), 'building_id_definition': ('django.db.models.fields.TextField', [], {}), 'city': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['city.City']"}), 'contact_email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'parcel_id_definition': ('django.db.models.fields.TextField', [], {}), 'version': ('django.db.models.fields.CharField', [], {'max_length': '12'}) }, u'source.source': { 'Meta': {'object_name': 'Source'}, 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['source.FeedInfo']", 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'person': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['person.Person']", 'blank': 'True'}) } } complete_apps = ['building']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 16461, 14, 8443, 63, 3397, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 17952, 63, 17952, 297, 283, 8443, 63, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 16461, 14, 8443, 63, 3397, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 17952, 63, 17952, 297, 283, 8443, 63, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 1012, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 17952, 14, 17952, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 16461, 2267, 288, 283, 2682, 63, 513, 780, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 3270, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1562, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 1604, 288, 283, 8387, 63, 5394, 316, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 313, 8445, 1417, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 8536, 63, 26334, 322, 3690, 356 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 16461, 14, 8443, 63, 3397, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 17952, 63, 17952, 297, 283, 8443, 63, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 16461, 14, 8443, 63, 3397, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 17952, 63, 17952, 297, 283, 8443, 63, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 1012, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 17952, 14, 17952, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 16461, 2267, 288, 283, 2682, 63, 513, 780, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 3270, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1562, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 1604, 288, 283, 8387, 63, 5394, 316, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 313, 8445, 1417, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 8536, 63, 26334, 322, 3690, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zhhf/charging
charging/services/loadbalancer/agent/agent_api.py
13
3086
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2013 New Dream Network, LLC (DreamHost) # # 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. # # @author: Mark McClain, DreamHost from neutron.openstack.common.rpc import proxy class LbaasAgentApi(proxy.RpcProxy): """Agent side of the Agent to Plugin RPC API.""" API_VERSION = '2.0' # history # 1.0 Initial version # 2.0 Generic API for agent based drivers # - get_logical_device() handling changed on plugin side; # - pool_deployed() and update_status() methods added; def __init__(self, topic, context, host): super(LbaasAgentApi, self).__init__(topic, self.API_VERSION) self.context = context self.host = host def get_ready_devices(self): return self.call( self.context, self.make_msg('get_ready_devices', host=self.host), topic=self.topic ) def pool_destroyed(self, pool_id): return self.call( self.context, self.make_msg('pool_destroyed', pool_id=pool_id), topic=self.topic ) def pool_deployed(self, pool_id): return self.call( self.context, self.make_msg('pool_deployed', pool_id=pool_id), topic=self.topic ) def get_logical_device(self, pool_id): return self.call( self.context, self.make_msg( 'get_logical_device', pool_id=pool_id ), topic=self.topic ) def update_status(self, obj_type, obj_id, status): return self.call( self.context, self.make_msg('update_status', obj_type=obj_type, obj_id=obj_id, status=status), topic=self.topic ) def plug_vip_port(self, port_id): return self.call( self.context, self.make_msg('plug_vip_port', port_id=port_id, host=self.host), topic=self.topic ) def unplug_vip_port(self, port_id): return self.call( self.context, self.make_msg('unplug_vip_port', port_id=port_id, host=self.host), topic=self.topic ) def update_pool_stats(self, pool_id, stats): return self.call( self.context, self.make_msg( 'update_pool_stats', pool_id=pool_id, stats=stats, host=self.host ), topic=self.topic )
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 3, 199, 3, 1898, 6171, 7053, 577, 1091, 7220, 12, 20376, 334, 36, 1091, 4965, 9, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 3, 768, 2502, 26, 7173, 22895, 35, 3993, 12, 577, 1091, 4965, 199, 199, 504, 8224, 14, 8512, 14, 2330, 14, 4354, 492, 4566, 421, 199, 533, 491, 2470, 305, 7788, 7394, 8, 3280, 14, 15569, 4936, 304, 272, 408, 7788, 5366, 402, 314, 19866, 370, 11349, 11785, 3261, 1041, 339, 3261, 63, 4612, 275, 283, 18, 14, 16, 7, 272, 327, 7994, 272, 327, 257, 413, 14, 16, 6026, 1015, 272, 327, 257, 499, 14, 16, 8307, 3261, 367, 6631, 4079, 19016, 272, 327, 755, 446, 664, 63, 7954, 63, 1782, 342, 7252, 2896, 641, 3589, 5366, 27, 272, 327, 755, 446, 4203, 63, 11060, 379, 342, 436, 1678, 63, 1205, 342, 3102, 3483, 27, 339, 347, 636, 826, 721, 277, 12, 7482, 12, 1067, 12, 1591, 304, 267, 1613, 8, 44, 2470, 305, 7788, 7394, 12, 291, 2843, 826, 721, 5746, 12, 291, 14, 3735, 63, 4612, 9, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 1102, 275, 1591, 339, 347, 664, 63, 2179, 63, 6410, 8, 277, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 362, 63, 2179, 63, 6410, 297, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 4203, 63, 7237, 379, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 2293, 63, 7237, 379, 297, 4203, 63, 344, 29, 2293, 63, 344, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 4203, 63, 11060, 379, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 2293, 63, 11060, 379, 297, 4203, 63, 344, 29, 2293, 63, 344, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 664, 63, 7954, 63, 1782, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 8, 355, 283, 362, 63, 7954, 63, 1782, 297, 355, 4203, 63, 344, 29, 2293, 63, 344, 288, 2318, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 1678, 63, 1205, 8, 277, 12, 1559, 63, 466, 12, 1559, 63, 344, 12, 2004, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 873, 63, 1205, 297, 1559, 63, 466, 29, 1113, 63, 466, 12, 1559, 63, 344, 29, 1113, 63, 344, 12, 2079, 2004, 29, 1205, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 14202, 63, 18607, 63, 719, 8, 277, 12, 1844, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 13963, 63, 18607, 63, 719, 297, 1844, 63, 344, 29, 719, 63, 344, 12, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 625, 13963, 63, 18607, 63, 719, 8, 277, 12, 1844, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 324, 13963, 63, 18607, 63, 719, 297, 1844, 63, 344, 29, 719, 63, 344, 12, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 1678, 63, 2293, 63, 3200, 8, 277, 12, 4203, 63, 344, 12, 5020, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 8, 355, 283, 873, 63, 2293, 63, 3200, 297, 355, 4203, 63, 344, 29, 2293, 63, 344, 12, 355, 5020, 29, 3200, 12, 355, 1591, 29, 277, 14, 1102, 288, 2318, 288, 7482, 29, 277, 14, 5746, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 3, 199, 3, 1898, 6171, 7053, 577, 1091, 7220, 12, 20376, 334, 36, 1091, 4965, 9, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 3, 768, 2502, 26, 7173, 22895, 35, 3993, 12, 577, 1091, 4965, 199, 199, 504, 8224, 14, 8512, 14, 2330, 14, 4354, 492, 4566, 421, 199, 533, 491, 2470, 305, 7788, 7394, 8, 3280, 14, 15569, 4936, 304, 272, 408, 7788, 5366, 402, 314, 19866, 370, 11349, 11785, 3261, 1041, 339, 3261, 63, 4612, 275, 283, 18, 14, 16, 7, 272, 327, 7994, 272, 327, 257, 413, 14, 16, 6026, 1015, 272, 327, 257, 499, 14, 16, 8307, 3261, 367, 6631, 4079, 19016, 272, 327, 755, 446, 664, 63, 7954, 63, 1782, 342, 7252, 2896, 641, 3589, 5366, 27, 272, 327, 755, 446, 4203, 63, 11060, 379, 342, 436, 1678, 63, 1205, 342, 3102, 3483, 27, 339, 347, 636, 826, 721, 277, 12, 7482, 12, 1067, 12, 1591, 304, 267, 1613, 8, 44, 2470, 305, 7788, 7394, 12, 291, 2843, 826, 721, 5746, 12, 291, 14, 3735, 63, 4612, 9, 267, 291, 14, 1100, 275, 1067, 267, 291, 14, 1102, 275, 1591, 339, 347, 664, 63, 2179, 63, 6410, 8, 277, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 362, 63, 2179, 63, 6410, 297, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 4203, 63, 7237, 379, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 2293, 63, 7237, 379, 297, 4203, 63, 344, 29, 2293, 63, 344, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 4203, 63, 11060, 379, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 2293, 63, 11060, 379, 297, 4203, 63, 344, 29, 2293, 63, 344, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 664, 63, 7954, 63, 1782, 8, 277, 12, 4203, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 8, 355, 283, 362, 63, 7954, 63, 1782, 297, 355, 4203, 63, 344, 29, 2293, 63, 344, 288, 2318, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 1678, 63, 1205, 8, 277, 12, 1559, 63, 466, 12, 1559, 63, 344, 12, 2004, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 873, 63, 1205, 297, 1559, 63, 466, 29, 1113, 63, 466, 12, 1559, 63, 344, 29, 1113, 63, 344, 12, 2079, 2004, 29, 1205, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 14202, 63, 18607, 63, 719, 8, 277, 12, 1844, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 13963, 63, 18607, 63, 719, 297, 1844, 63, 344, 29, 719, 63, 344, 12, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 625, 13963, 63, 18607, 63, 719, 8, 277, 12, 1844, 63, 344, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 360, 324, 13963, 63, 18607, 63, 719, 297, 1844, 63, 344, 29, 719, 63, 344, 12, 1591, 29, 277, 14, 1102, 395, 288, 7482, 29, 277, 14, 5746, 267, 776, 339, 347, 1678, 63, 2293, 63, 3200, 8, 277, 12, 4203, 63, 344, 12, 5020, 304, 267, 372, 291, 14, 1250, 8, 288, 291, 14, 1100, 12, 288, 291, 14, 1875, 63, 1328, 8, 355, 283, 873, 63, 2293, 63, 3200, 297, 355, 4203, 63, 344, 29, 2293, 63, 344, 12, 355, 5020, 29, 3200, 12, 355, 1591, 29, 277, 14, 1102, 288, 2318, 288, 7482, 29, 277, 14, 5746, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
oliverhr/odoo
addons/pos_restaurant/__openerp__.py
311
2001
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Restaurant', 'version': '1.0', 'category': 'Point of Sale', 'sequence': 6, 'summary': 'Restaurant extensions for the Point of Sale ', 'description': """ ======================= This module adds several restaurant features to the Point of Sale: - Bill Printing: Allows you to print a receipt before the order is paid - Bill Splitting: Allows you to split an order into different orders - Kitchen Order Printing: allows you to print orders updates to kitchen or bar printers """, 'author': 'OpenERP SA', 'depends': ['point_of_sale'], 'website': 'https://www.odoo.com/page/point-of-sale', 'data': [ 'restaurant_view.xml', 'security/ir.model.access.csv', 'views/templates.xml', ], 'qweb':[ 'static/src/xml/multiprint.xml', 'static/src/xml/splitbill.xml', 'static/src/xml/printbill.xml', ], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 32075, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 3428, 402, 428, 1895, 297, 272, 283, 4041, 356, 1227, 12, 272, 283, 4705, 356, 283, 32075, 5478, 367, 314, 7584, 402, 428, 1895, 1656, 272, 283, 1802, 356, 408, 199, 199, 1280, 18673, 199, 199, 2765, 859, 9584, 9978, 295, 14436, 4534, 370, 314, 7584, 402, 428, 1895, 26, 199, 13, 699, 778, 9101, 316, 26, 22819, 1265, 370, 870, 282, 31594, 2544, 314, 1865, 365, 30677, 199, 13, 699, 778, 11740, 1337, 26, 22819, 1265, 370, 3715, 376, 1865, 1901, 3365, 15460, 199, 13, 1804, 9414, 287, 9240, 9101, 316, 26, 6127, 1265, 370, 870, 15460, 7029, 370, 1022, 9414, 287, 503, 4681, 5448, 11005, 199, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1403, 63, 1618, 63, 8515, 995, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1403, 13, 1618, 13, 8515, 297, 272, 283, 576, 356, 359, 267, 283, 25646, 63, 1345, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 5876, 14, 1652, 297, 272, 2156, 272, 283, 22600, 15211, 267, 283, 1986, 15, 2164, 15, 1652, 15, 3029, 1361, 14, 1652, 297, 267, 283, 1986, 15, 2164, 15, 1652, 15, 1294, 19815, 14, 1652, 297, 267, 283, 1986, 15, 2164, 15, 1652, 15, 1361, 19815, 14, 1652, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 32075, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 3428, 402, 428, 1895, 297, 272, 283, 4041, 356, 1227, 12, 272, 283, 4705, 356, 283, 32075, 5478, 367, 314, 7584, 402, 428, 1895, 1656, 272, 283, 1802, 356, 408, 199, 199, 1280, 18673, 199, 199, 2765, 859, 9584, 9978, 295, 14436, 4534, 370, 314, 7584, 402, 428, 1895, 26, 199, 13, 699, 778, 9101, 316, 26, 22819, 1265, 370, 870, 282, 31594, 2544, 314, 1865, 365, 30677, 199, 13, 699, 778, 11740, 1337, 26, 22819, 1265, 370, 3715, 376, 1865, 1901, 3365, 15460, 199, 13, 1804, 9414, 287, 9240, 9101, 316, 26, 6127, 1265, 370, 870, 15460, 7029, 370, 1022, 9414, 287, 503, 4681, 5448, 11005, 199, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 1403, 63, 1618, 63, 8515, 995, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1403, 13, 1618, 13, 8515, 297, 272, 283, 576, 356, 359, 267, 283, 25646, 63, 1345, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 5876, 14, 1652, 297, 272, 2156, 272, 283, 22600, 15211, 267, 283, 1986, 15, 2164, 15, 1652, 15, 3029, 1361, 14, 1652, 297, 267, 283, 1986, 15, 2164, 15, 1652, 15, 1294, 19815, 14, 1652, 297, 267, 283, 1986, 15, 2164, 15, 1652, 15, 1361, 19815, 14, 1652, 297, 272, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
catapult-project/catapult
third_party/gsutil/gslib/commands/cat.py
4
5134
# -*- coding: utf-8 -*- # Copyright 2011 Google Inc. All Rights Reserved. # Copyright 2011, Nexenta Systems 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. """Implementation of Unix-like cat command for cloud storage providers.""" from __future__ import absolute_import from __future__ import print_function from __future__ import division from __future__ import unicode_literals import re import six from gslib.command import Command from gslib.command_argument import CommandArgument from gslib.cs_api_map import ApiSelector from gslib.exception import CommandException from gslib.utils import cat_helper from gslib.utils import constants if six.PY3: long = int _SYNOPSIS = """ gsutil cat [-h] url... """ _DETAILED_HELP_TEXT = (""" <B>SYNOPSIS</B> """ + _SYNOPSIS + """ <B>DESCRIPTION</B> The cat command outputs the contents of one or more URLs to stdout. While the cat command does not compute a checksum, it is otherwise equivalent to doing: gsutil cp url... - (The final '-' causes gsutil to stream the output to stdout.) <B>WARNING: DATA INTEGRITY CHECKING NOT DONE</B> The gsutil cat command does not compute a checksum of the downloaded data. Therefore, we recommend that users either perform their own validation of the output of gsutil cat or use gsutil cp or rsync (both of which perform integrity checking automatically). <B>OPTIONS</B> -h Prints short header for each object. For example: gsutil cat -h gs://bucket/meeting_notes/2012_Feb/*.txt This would print a header with the object name before the contents of each text object that matched the wildcard. -r range Causes gsutil to output just the specified byte range of the object. Ranges are can be of these forms: start-end (e.g., -r 256-5939) start- (e.g., -r 256-) -numbytes (e.g., -r -5) where offsets start at 0, start-end means to return bytes start through end (inclusive), start- means to return bytes start through the end of the object, and -numbytes means to return the last numbytes of the object. For example: gsutil cat -r 256-939 gs://bucket/object returns bytes 256 through 939, while: gsutil cat -r -5 gs://bucket/object returns the final 5 bytes of the object. """) class CatCommand(Command): """Implementation of gsutil cat command.""" # Command specification. See base class for documentation. command_spec = Command.CreateCommandSpec( 'cat', command_name_aliases=[], usage_synopsis=_SYNOPSIS, min_args=1, max_args=constants.NO_MAX, supported_sub_args='hr:', file_url_ok=False, provider_url_ok=False, urls_start_arg=0, gs_api_support=[ApiSelector.XML, ApiSelector.JSON], gs_default_api=ApiSelector.JSON, argparse_arguments=[CommandArgument.MakeZeroOrMoreCloudURLsArgument()]) # Help specification. See help_provider.py for documentation. help_spec = Command.HelpSpec( help_name='cat', help_name_aliases=[], help_type='command_help', help_one_line_summary='Concatenate object content to stdout', help_text=_DETAILED_HELP_TEXT, subcommand_help_text={}, ) # Command entry point. def RunCommand(self): """Command entry point for the cat command.""" show_header = False request_range = None start_byte = 0 end_byte = None if self.sub_opts: for o, a in self.sub_opts: if o == '-h': show_header = True elif o == '-r': request_range = a.strip() range_matcher = re.compile( '^(?P<start>[0-9]+)-(?P<end>[0-9]*)$|^(?P<endslice>-[0-9]+)$') range_match = range_matcher.match(request_range) if not range_match: raise CommandException('Invalid range (%s)' % request_range) if range_match.group('start'): start_byte = long(range_match.group('start')) if range_match.group('end'): end_byte = long(range_match.group('end')) if range_match.group('endslice'): start_byte = long(range_match.group('endslice')) else: self.RaiseInvalidArgumentException() return cat_helper.CatHelper(self).CatUrlStrings(self.args, show_header=show_header, start_byte=start_byte, end_byte=end_byte)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 1898, 7760, 12, 653, 476, 21335, 15285, 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, 624, 7921, 402, 13074, 13, 2930, 6230, 1414, 367, 8002, 4887, 18032, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 646, 3816, 199, 199, 504, 29563, 14, 1531, 492, 5817, 199, 504, 29563, 14, 1531, 63, 2094, 492, 5817, 5201, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 13986, 11212, 199, 504, 29563, 14, 1971, 492, 5817, 1726, 199, 504, 29563, 14, 1208, 492, 6230, 63, 3676, 199, 504, 29563, 14, 1208, 492, 5262, 199, 199, 692, 3816, 14, 4521, 19, 26, 523, 1846, 275, 1109, 199, 199, 63, 31802, 21665, 1311, 275, 408, 523, 24986, 6230, 5243, 72, 61, 1166, 1396, 199, 624, 199, 199, 63, 17442, 25349, 63, 17930, 63, 3876, 275, 334, 624, 199, 28, 34, 30, 31802, 21665, 1311, 1108, 34, 30, 199, 624, 435, 485, 31802, 21665, 1311, 435, 408, 421, 199, 28, 34, 30, 17705, 1108, 34, 30, 523, 710, 6230, 1414, 4704, 314, 4072, 402, 1373, 503, 1655, 10867, 370, 3839, 14, 523, 22117, 314, 6230, 1414, 1630, 440, 4526, 282, 9040, 12, 652, 365, 4257, 523, 7353, 370, 9689, 26, 339, 24986, 7667, 1166, 1396, 446, 819, 334, 1918, 4242, 10791, 14486, 24986, 370, 2547, 314, 1072, 370, 3839, 4959, 421, 199, 28, 34, 30, 9171, 26, 7126, 14985, 3975, 1922, 17654, 1206, 2845, 577, 4817, 1108, 34, 30, 523, 710, 24986, 6230, 1414, 1630, 440, 4526, 282, 9040, 402, 314, 13557, 666, 14, 523, 21039, 12, 781, 27747, 626, 4390, 1902, 5147, 3932, 5705, 6411, 402, 314, 523, 1072, 402, 24986, 6230, 503, 675, 24986, 7667, 503, 27633, 334, 10727, 402, 1314, 5147, 523, 4661, 12997, 7907, 5847, 680, 421, 199, 28, 34, 30, 8808, 1108, 34, 30, 523, 446, 72, 3515, 9101, 83, 3974, 1406, 367, 1924, 909, 14, 2104, 2893, 26, 2234, 24986, 6230, 446, 72, 8763, 921, 4623, 15, 278, 13800, 63, 5983, 15, 7409, 63, 27717, 20362, 2424, 25841, 961, 3955, 870, 282, 1406, 543, 314, 909, 536, 2544, 314, 4072, 1598, 402, 1924, 1318, 909, 626, 7838, 314, 16792, 14, 819, 446, 82, 1425, 259, 445, 3844, 874, 24986, 370, 1072, 2951, 314, 2013, 3696, 1425, 402, 314, 1598, 909, 14, 13114, 83, 787, 883, 506, 402, 3520, 4513, 26, 2234, 1343, 13, 500, 334, 69, 14, 71, 2020, 446, 82, 7633, 13, 1427, 1355, 9, 355, 1343, 13, 259, 334, 69, 14, 71, 2020, 446, 82, 7633, 13, 9, 355, 446, 1507, 2394, 334, 69, 14, 71, 2020, 446, 82, 446, 21, 9, 25841, 2382, 15340, 1343, 737, 378, 12, 1343, 13, 500, 4910, 370, 372, 2783, 1343, 1598, 4012, 1284, 334, 26062, 395, 1343, 13, 4910, 370, 372, 2783, 1343, 1598, 4012, 314, 1284, 402, 314, 909, 12, 436, 446, 1507, 2394, 4910, 370, 372, 314, 1598, 2061, 1967, 2394, 402, 314, 909, 14, 2104, 2893, 26, 2234, 24986, 6230, 446, 82, 7633, 13, 31281, 8763, 921, 4623, 15, 785, 25841, 2529, 2783, 7633, 4012, 1749, 1355, 12, 1830, 26, 2234, 24986, 6230, 446, 82, 446, 21, 8763, 921, 4623, 15, 785, 25841, 2529, 314, 4242, 959, 2783, 402, 314, 909, 14, 199, 6141, 421, 199, 533, 445, 292, 3110, 8, 3110, 304, 523, 408, 7921, 402, 24986, 6230, 1414, 1041, 819, 327, 5817, 8929, 14, 1666, 1300, 1021, 367, 3794, 14, 523, 1414, 63, 1650, 275, 5817, 14, 2499, 3110, 5307, 8, 489, 283, 3385, 297, 489, 1414, 63, 354, 63, 8602, 6034, 489, 4503, 63, 9466, 27573, 3699, 31802, 21665, 1311, 12, 489, 1748, 63, 589, 29, 17, 12, 489, 1390, 63, 589, 29, 5559, 14, 2826, 63, 4283, 12, 489, 3748, 63, 954, 63, 589, 534, 6271, 6536, 489, 570, 63, 633, 63, 745, 29, 797, 12, 489, 5022, 63, 633, 63, 745, 29, 797, 12, 489, 8187, 63, 928, 63, 1273, 29, 16, 12, 489, 8763, 63, 1246, 63, 4058, 1524, 7394, 11212, 14, 4317, 12, 13986, 11212, 14, 6243, 467, 489, 8763, 63, 885, 63, 1246, 29, 7394, 11212, 14, 6243, 12, 489, 7534, 63, 4958, 1524, 3110, 5201, 14, 5483, 8681, 18231, 9089, 2632, 83, 5201, 9383, 523, 327, 15456, 8929, 14, 1666, 1720, 63, 3780, 14, 647, 367, 3794, 14, 523, 1720, 63, 1650, 275, 5817, 14, 8673, 5307, 8, 489, 1720, 63, 354, 534, 3385, 297, 489, 1720, 63, 354, 63, 8602, 6034, 489, 1720, 63, 466, 534, 1531, 63, 3437, 297, 489, 1720, 63, 368, 63, 604, 63, 4705, 534, 714, 10592, 909, 1564, 370, 3839, 297, 489, 1720, 63, 505, 3699, 17442, 25349, 63, 17930, 63, 3876, 12, 489, 21474, 63, 3437, 63, 505, 10324, 523, 776, 819, 327, 5817, 2397, 2376, 14, 523, 347, 3378, 3110, 8, 277, 304, 272, 408, 3110, 2397, 2376, 367, 314, 6230, 1414, 1041, 272, 2498, 63, 1291, 275, 756, 272, 1056, 63, 1842, 275, 488, 272, 1343, 63, 4414, 275, 378, 272, 1284, 63, 4414, 275, 488, 272, 340, 291, 14, 954, 63, 3291, 26, 489, 367, 312, 12, 282, 315, 291, 14, 954, 63, 3291, 26, 267, 340, 312, 508, 2475, 72 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 1898, 7760, 12, 653, 476, 21335, 15285, 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, 624, 7921, 402, 13074, 13, 2930, 6230, 1414, 367, 8002, 4887, 18032, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 646, 3816, 199, 199, 504, 29563, 14, 1531, 492, 5817, 199, 504, 29563, 14, 1531, 63, 2094, 492, 5817, 5201, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 13986, 11212, 199, 504, 29563, 14, 1971, 492, 5817, 1726, 199, 504, 29563, 14, 1208, 492, 6230, 63, 3676, 199, 504, 29563, 14, 1208, 492, 5262, 199, 199, 692, 3816, 14, 4521, 19, 26, 523, 1846, 275, 1109, 199, 199, 63, 31802, 21665, 1311, 275, 408, 523, 24986, 6230, 5243, 72, 61, 1166, 1396, 199, 624, 199, 199, 63, 17442, 25349, 63, 17930, 63, 3876, 275, 334, 624, 199, 28, 34, 30, 31802, 21665, 1311, 1108, 34, 30, 199, 624, 435, 485, 31802, 21665, 1311, 435, 408, 421, 199, 28, 34, 30, 17705, 1108, 34, 30, 523, 710, 6230, 1414, 4704, 314, 4072, 402, 1373, 503, 1655, 10867, 370, 3839, 14, 523, 22117, 314, 6230, 1414, 1630, 440, 4526, 282, 9040, 12, 652, 365, 4257, 523, 7353, 370, 9689, 26, 339, 24986, 7667, 1166, 1396, 446, 819, 334, 1918, 4242, 10791, 14486, 24986, 370, 2547, 314, 1072, 370, 3839, 4959, 421, 199, 28, 34, 30, 9171, 26, 7126, 14985, 3975, 1922, 17654, 1206, 2845, 577, 4817, 1108, 34, 30, 523, 710, 24986, 6230, 1414, 1630, 440, 4526, 282, 9040, 402, 314, 13557, 666, 14, 523, 21039, 12, 781, 27747, 626, 4390, 1902, 5147, 3932, 5705, 6411, 402, 314, 523, 1072, 402, 24986, 6230, 503, 675, 24986, 7667, 503, 27633, 334, 10727, 402, 1314, 5147, 523, 4661, 12997, 7907, 5847, 680, 421, 199, 28, 34, 30, 8808, 1108, 34, 30, 523, 446, 72, 3515, 9101, 83, 3974, 1406, 367, 1924, 909, 14, 2104, 2893, 26, 2234, 24986, 6230, 446, 72, 8763, 921, 4623, 15, 278, 13800, 63, 5983, 15, 7409, 63, 27717, 20362, 2424, 25841, 961, 3955, 870, 282, 1406, 543, 314, 909, 536, 2544, 314, 4072, 1598, 402, 1924, 1318, 909, 626, 7838, 314, 16792, 14, 819, 446, 82, 1425, 259, 445, 3844, 874, 24986, 370, 1072, 2951, 314, 2013, 3696, 1425, 402, 314, 1598, 909, 14, 13114, 83, 787, 883, 506, 402, 3520, 4513, 26, 2234, 1343, 13, 500, 334, 69, 14, 71, 2020, 446, 82, 7633, 13, 1427, 1355, 9, 355, 1343, 13, 259, 334, 69, 14, 71, 2020, 446, 82, 7633, 13, 9, 355, 446, 1507, 2394, 334, 69, 14, 71, 2020, 446, 82, 446, 21, 9, 25841, 2382, 15340, 1343, 737, 378, 12, 1343, 13, 500, 4910, 370, 372, 2783, 1343, 1598, 4012, 1284, 334, 26062, 395, 1343, 13, 4910, 370, 372, 2783, 1343, 1598, 4012, 314, 1284, 402, 314, 909, 12, 436, 446, 1507, 2394, 4910, 370, 372, 314, 1598, 2061, 1967, 2394, 402, 314, 909, 14, 2104, 2893, 26, 2234, 24986, 6230, 446, 82, 7633, 13, 31281, 8763, 921, 4623, 15, 785, 25841, 2529, 2783, 7633, 4012, 1749, 1355, 12, 1830, 26, 2234, 24986, 6230, 446, 82, 446, 21, 8763, 921, 4623, 15, 785, 25841, 2529, 314, 4242, 959, 2783, 402, 314, 909, 14, 199, 6141, 421, 199, 533, 445, 292, 3110, 8, 3110, 304, 523, 408, 7921, 402, 24986, 6230, 1414, 1041, 819, 327, 5817, 8929, 14, 1666, 1300, 1021, 367, 3794, 14, 523, 1414, 63, 1650, 275, 5817, 14, 2499, 3110, 5307, 8, 489, 283, 3385, 297, 489, 1414, 63, 354, 63, 8602, 6034, 489, 4503, 63, 9466, 27573, 3699, 31802, 21665, 1311, 12, 489, 1748, 63, 589, 29, 17, 12, 489, 1390, 63, 589, 29, 5559, 14, 2826, 63, 4283, 12, 489, 3748, 63, 954, 63, 589, 534, 6271, 6536, 489, 570, 63, 633, 63, 745, 29, 797, 12, 489, 5022, 63, 633, 63, 745, 29, 797, 12, 489, 8187, 63, 928, 63, 1273, 29, 16, 12, 489, 8763, 63, 1246, 63, 4058, 1524, 7394, 11212, 14, 4317, 12, 13986, 11212, 14, 6243, 467, 489, 8763, 63, 885, 63, 1246, 29, 7394, 11212, 14, 6243, 12, 489, 7534, 63, 4958, 1524, 3110, 5201, 14, 5483, 8681, 18231, 9089, 2632, 83, 5201, 9383, 523, 327, 15456, 8929, 14, 1666, 1720, 63, 3780, 14, 647, 367, 3794, 14, 523, 1720, 63, 1650, 275, 5817, 14, 8673, 5307, 8, 489, 1720, 63, 354, 534, 3385, 297, 489, 1720, 63, 354, 63, 8602, 6034, 489, 1720, 63, 466, 534, 1531, 63, 3437, 297, 489, 1720, 63, 368, 63, 604, 63, 4705, 534, 714, 10592, 909, 1564, 370, 3839, 297, 489, 1720, 63, 505, 3699, 17442, 25349, 63, 17930, 63, 3876, 12, 489, 21474, 63, 3437, 63, 505, 10324, 523, 776, 819, 327, 5817, 2397, 2376, 14, 523, 347, 3378, 3110, 8, 277, 304, 272, 408, 3110, 2397, 2376, 367, 314, 6230, 1414, 1041, 272, 2498, 63, 1291, 275, 756, 272, 1056, 63, 1842, 275, 488, 272, 1343, 63, 4414, 275, 378, 272, 1284, 63, 4414, 275, 488, 272, 340, 291, 14, 954, 63, 3291, 26, 489, 367, 312, 12, 282, 315, 291, 14, 954, 63, 3291, 26, 267, 340, 312, 508, 2475, 72, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sahlinet/fastapp
fastapp/south_migrations/0011_auto__chg_field_instance_last_beat.py
2
8409
# -*- 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 'Instance.last_beat' db.alter_column(u'fastapp_instance', 'last_beat', self.gf('django.db.models.fields.DateTimeField')(null=True)) def backwards(self, orm): # User chose to not deal with backwards NULL issues for 'Instance.last_beat' #raise RuntimeError("Cannot reverse this migration. 'Instance.last_beat' and its values cannot be restored.") # The following code is provided here to aid in writing a correct migration # Changing field 'Instance.last_beat' db.alter_column(u'fastapp_instance', 'last_beat', self.gf('django.db.models.fields.DateTimeField')(auto_now=True)) models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, u'auth.permission': { 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, u'fastapp.apy': { 'Meta': {'object_name': 'Apy'}, 'base': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'apys'", 'null': 'True', 'to': u"orm['fastapp.Base']"}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'module': ('django.db.models.fields.CharField', [], {'default': "'def func(self):\\n pass'", 'max_length': '8192'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}) }, u'fastapp.authprofile': { 'Meta': {'object_name': 'AuthProfile'}, 'access_token': ('django.db.models.fields.CharField', [], {'max_length': '72'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'authprofile'", 'unique': 'True', 'to': u"orm['auth.User']"}) }, u'fastapp.base': { 'Meta': {'object_name': 'Base'}, 'content': ('django.db.models.fields.CharField', [], {'default': '\'{% extends "fastapp/index.html" %}\\n{% block content %}\\n{% endblock %}\\n\'', 'max_length': '8192', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'}), 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': '0', 'related_name': "'+'", 'blank': 'True', 'to': u"orm['auth.User']"}), 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) }, u'fastapp.counter': { 'Meta': {'object_name': 'Counter'}, 'apy': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'counter'", 'unique': 'True', 'to': u"orm['fastapp.Apy']"}), 'executed': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'failed': ('django.db.models.fields.IntegerField', [], {'default': '0'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, u'fastapp.executor': { 'Meta': {'object_name': 'Executor'}, 'base': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'executor'", 'unique': 'True', 'to': u"orm['fastapp.Base']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'num_instances': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'pid': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}) }, u'fastapp.host': { 'Meta': {'object_name': 'Host'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, u'fastapp.instance': { 'Meta': {'object_name': 'Instance'}, 'executor': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'instances'", 'to': u"orm['fastapp.Executor']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_alive': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_beat': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '36', 'blank': 'True'}) }, u'fastapp.setting': { 'Meta': {'object_name': 'Setting'}, 'base': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'setting'", 'to': u"orm['fastapp.Base']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'key': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'value': ('django.db.models.fields.CharField', [], {'max_length': '8192'}) } } complete_apps = ['fastapp']
mit
[ 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, 3244, 14, 2019, 63, 12522, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 7015, 571, 63, 842, 297, 283, 2019, 63, 12522, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2307, 29, 549, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 2876, 2468, 261, 370, 440, 7962, 543, 8552, 5962, 10876, 367, 283, 3244, 14, 2019, 63, 12522, 7, 267, 327, 3730, 6064, 480, 6612, 3837, 642, 8367, 14, 283, 3244, 14, 2019, 63, 12522, 7, 436, 2399, 1338, 3913, 506, 14429, 2685, 2728, 327, 710, 2569, 1233, 365, 2741, 2348, 370, 23939, 315, 3575, 282, 3211, 8367, 267, 327, 27854, 901, 283, 3244, 14, 2019, 63, 12522, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 7015, 571, 63, 842, 297, 283, 2019, 63, 12522, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 399, 7, 344 ]
[ 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, 3244, 14, 2019, 63, 12522, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 7015, 571, 63, 842, 297, 283, 2019, 63, 12522, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2307, 29, 549, 430, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 2876, 2468, 261, 370, 440, 7962, 543, 8552, 5962, 10876, 367, 283, 3244, 14, 2019, 63, 12522, 7, 267, 327, 3730, 6064, 480, 6612, 3837, 642, 8367, 14, 283, 3244, 14, 2019, 63, 12522, 7, 436, 2399, 1338, 3913, 506, 14429, 2685, 2728, 327, 710, 2569, 1233, 365, 2741, 2348, 370, 23939, 315, 3575, 282, 3211, 8367, 267, 327, 27854, 901, 283, 3244, 14, 2019, 63, 12522, 7, 267, 1592, 14, 11858, 63, 2301, 8, 85, 7, 7015, 571, 63, 842, 297, 283, 2019, 63, 12522, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 339, 1709, 275, 469, 267, 399, 7, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 399, 7, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 7340, 85, 7, 1317, 63, 466, 363, 571, 63, 1302, 297, 399, 7, 1317, 63, 466, 363, 1238, 297, 399, 7, 11879, 18106, 283, 3235, 63, 6314, 356, 298, 1332, 85, 7, 1317, 63, 466, 297, 399, 7, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 399, 2, 1025, 459, 10778, 14, 11282, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 399, 7, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 2448, 6097, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 10247, 356, 283, 797, 297, 283, 2407, 63, 354, 356, 298, 85, 7, 751, 63, 409, 4662, 283, 2500, 356, 283, 549, 297, 283, 475, 356, 399, 2, 1025, 459, 1178, 14, 7980, 6097, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 399, 7, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 399, 7, 344, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xbezdick/packstack
packstack/plugins/nova_300.py
1
35617
# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. """ Installs and configures Nova """ import os import platform import socket from packstack.installer import basedefs from packstack.installer import exceptions from packstack.installer import processors from packstack.installer import utils from packstack.installer import validators from packstack.modules import common from packstack.modules.documentation import update_params_usage from packstack.modules.shortcuts import get_mq from packstack.modules.ospluginutils import appendManifestFile from packstack.modules.ospluginutils import createFirewallResources from packstack.modules.ospluginutils import deliver_ssl_file from packstack.modules.ospluginutils import getManifestTemplate from packstack.modules.ospluginutils import generate_ssl_cert from packstack.modules.ospluginutils import manifestfiles # ------------- Nova Packstack Plugin Initialization -------------- PLUGIN_NAME = "OS-Nova" PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') def initConfig(controller): if platform.linux_distribution()[0] == "Fedora": primary_netif = "em1" secondary_netif = "em2" else: primary_netif = "eth0" secondary_netif = "eth1" nova_params = { "NOVA": [ {"CMD_OPTION": 'nova-db-purge-enable', "PROMPT": ( "Enter y if cron job for removing soft deleted DB rows " "should be created" ), "OPTION_LIST": ['y', 'n'], "VALIDATORS": [validators.validate_not_empty], "PROCESSORS": [processors.process_bool], "DEFAULT_VALUE": 'y', "MASK_INPUT": False, "LOOSE_VALIDATION": False, "CONF_NAME": 'CONFIG_NOVA_DB_PURGE_ENABLE', "USE_DEFAULT": False, "NEED_CONFIRM": True, "CONDITION": False}, {"CMD_OPTION": "nova-db-passwd", "PROMPT": "Enter the password for the Nova DB access", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": "PW_PLACEHOLDER", "PROCESSORS": [processors.process_password], "MASK_INPUT": True, "LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_NOVA_DB_PW", "USE_DEFAULT": False, "NEED_CONFIRM": True, "CONDITION": False}, {"CMD_OPTION": "nova-ks-passwd", "PROMPT": "Enter the password for the Nova Keystone access", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": "PW_PLACEHOLDER", "PROCESSORS": [processors.process_password], "MASK_INPUT": True, "LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_NOVA_KS_PW", "USE_DEFAULT": False, "NEED_CONFIRM": True, "CONDITION": False}, {"CMD_OPTION": "novasched-cpu-allocation-ratio", "PROMPT": "Enter the CPU overcommitment ratio. Set to 1.0 to " "disable CPU overcommitment", "OPTION_LIST": [], "VALIDATORS": [validators.validate_float], "DEFAULT_VALUE": 16.0, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novasched-ram-allocation-ratio", "PROMPT": ("Enter the RAM overcommitment ratio. Set to 1.0 to " "disable RAM overcommitment"), "OPTION_LIST": [], "VALIDATORS": [validators.validate_float], "DEFAULT_VALUE": 1.5, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novacompute-migrate-protocol", "PROMPT": ("Enter protocol which will be used for instance " "migration"), "OPTION_LIST": ['tcp', 'ssh'], "VALIDATORS": [validators.validate_options], "DEFAULT_VALUE": 'tcp', "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_COMPUTE_MIGRATE_PROTOCOL", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "nova-compute-manager", "PROMPT": ("Enter the compute manager for nova " "migration"), "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": "nova.compute.manager.ComputeManager", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_COMPUTE_MANAGER", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "nova-ssl-cert", "PROMPT": ("Enter the path to a PEM encoded certificate to be used " "on the https server, leave blank if one should be " "generated, this certificate should not require " "a passphrase"), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": '', "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_VNC_SSL_CERT", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "nova-ssl-key", "PROMPT": ("Enter the SSL keyfile corresponding to the certificate " "if one was entered"), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": "", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_VNC_SSL_KEY", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "nova-pci-alias", "PROMPT": ("Enter the PCI passthrough array of hash in JSON style for controller eg. " "[{'vendor_id':'1234', 'product_id':'5678', " "'name':'default'}, {...}] "), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": "", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_PCI_ALIAS", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "nova-pci-passthrough-whitelist", "PROMPT": ("Enter the PCI passthrough whitelist as array of hash in JSON style for " "controller eg. " "[{'vendor_id':'1234', 'product_id':'5678', " "'name':'default'}, {...}]"), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": "", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_PCI_PASSTHROUGH_WHITELIST", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, ], "NOVA_NETWORK": [ {"CMD_OPTION": "novacompute-privif", "PROMPT": ("Enter the Private interface for Flat DHCP on the Nova" " compute servers"), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": '', "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_COMPUTE_PRIVIF", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-manager", "PROMPT": "Enter the Nova network manager", "OPTION_LIST": [r'^nova\.network\.manager\.\w+Manager$'], "VALIDATORS": [validators.validate_regexp], "DEFAULT_VALUE": "nova.network.manager.FlatDHCPManager", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_MANAGER", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-pubif", "PROMPT": "Enter the Public interface on the Nova network server", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": primary_netif, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_PUBIF", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-privif", "PROMPT": ("Enter the Private interface for network manager on " "the Nova network server"), "OPTION_LIST": [], "VALIDATORS": [], "DEFAULT_VALUE": '', "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_PRIVIF", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-fixed-range", "PROMPT": "Enter the IP Range for network manager", "OPTION_LIST": ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"], "PROCESSORS": [processors.process_cidr], "VALIDATORS": [validators.validate_regexp], "DEFAULT_VALUE": "192.168.32.0/22", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_FIXEDRANGE", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-floating-range", "PROMPT": "Enter the IP Range for Floating IP's", "OPTION_LIST": ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"], "PROCESSORS": [processors.process_cidr], "VALIDATORS": [validators.validate_regexp], "DEFAULT_VALUE": "10.3.4.0/22", "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_FLOATRANGE", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-auto-assign-floating-ip", "PROMPT": ("Should new instances automatically have a floating " "IP assigned?"), "OPTION_LIST": ["y", "n"], "VALIDATORS": [validators.validate_options], "DEFAULT_VALUE": "n", "MASK_INPUT": False, "LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, ], "NOVA_NETWORK_VLAN": [ {"CMD_OPTION": "novanetwork-vlan-start", "PROMPT": "Enter first VLAN for private networks", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": 100, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_VLAN_START", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-num-networks", "PROMPT": "How many networks should be supported", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": 1, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_NUMBER", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, {"CMD_OPTION": "novanetwork-network-size", "PROMPT": "How many addresses should be in each private subnet", "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": 255, "MASK_INPUT": False, "LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_SIZE", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, ], } update_params_usage(basedefs.PACKSTACK_DOC, nova_params) def use_nova_network(config): return (config['CONFIG_NOVA_INSTALL'] == 'y' and config['CONFIG_NEUTRON_INSTALL'] != 'y') def use_nova_network_vlan(config): manager = 'nova.network.manager.VlanManager' return (config['CONFIG_NOVA_INSTALL'] == 'y' and config['CONFIG_NEUTRON_INSTALL'] != 'y' and config['CONFIG_NOVA_NETWORK_MANAGER'] == manager) nova_groups = [ {"GROUP_NAME": "NOVA", "DESCRIPTION": "Nova Options", "PRE_CONDITION": "CONFIG_NOVA_INSTALL", "PRE_CONDITION_MATCH": "y", "POST_CONDITION": False, "POST_CONDITION_MATCH": True}, {"GROUP_NAME": "NOVA_NETWORK", "DESCRIPTION": "Nova Network Options", "PRE_CONDITION": use_nova_network, "PRE_CONDITION_MATCH": True, "POST_CONDITION": False, "POST_CONDITION_MATCH": True}, {"GROUP_NAME": "NOVA_NETWORK_VLAN", "DESCRIPTION": "Nova Network VLAN Options", "PRE_CONDITION": use_nova_network_vlan, "PRE_CONDITION_MATCH": True, "POST_CONDITION": False, "POST_CONDITION_MATCH": True}, ] for group in nova_groups: params = nova_params[group["GROUP_NAME"]] controller.addGroup(group, params) def initSequences(controller): if controller.CONF['CONFIG_NOVA_INSTALL'] != 'y': return if controller.CONF['CONFIG_NEUTRON_INSTALL'] == 'y': network_title = ('Adding OpenStack Network-related ' 'Nova manifest entries') network_function = create_neutron_manifest else: network_title = 'Adding Nova Network manifest entries' network_function = create_network_manifest novaapisteps = [ {'title': 'Adding Nova API manifest entries', 'functions': [create_api_manifest]}, {'title': 'Adding Nova Keystone manifest entries', 'functions': [create_keystone_manifest]}, {'title': 'Adding Nova Cert manifest entries', 'functions': [create_cert_manifest]}, {'title': 'Adding Nova Conductor manifest entries', 'functions': [create_conductor_manifest]}, {'title': 'Creating ssh keys for Nova migration', 'functions': [create_ssh_keys]}, {'title': 'Gathering ssh host keys for Nova migration', 'functions': [gather_host_keys]}, {'title': 'Adding Nova Compute manifest entries', 'functions': [create_compute_manifest]}, {'title': 'Adding Nova Scheduler manifest entries', 'functions': [create_sched_manifest]}, {'title': 'Adding Nova VNC Proxy manifest entries', 'functions': [create_vncproxy_manifest]}, {'title': network_title, 'functions': [network_function]}, {'title': 'Adding Nova Common manifest entries', 'functions': [create_common_manifest]}, ] controller.addSequence("Installing OpenStack Nova API", [], [], novaapisteps) # ------------------------- helper functions ------------------------- def check_ifcfg(host, device): """ Raises ScriptRuntimeError if given host does not have give device. """ server = utils.ScriptRunner(host) cmd = "ip addr show dev %s || ( echo Device %s does not exist && exit 1 )" server.append(cmd % (device, device)) server.execute() def bring_up_ifcfg(host, device): """ Brings given device up if it's down. Raises ScriptRuntimeError in case of failure. """ server = utils.ScriptRunner(host) server.append('ip link show up | grep "%s"' % device) try: server.execute() except exceptions.ScriptRuntimeError: server.clear() cmd = 'ip link set dev %s up' server.append(cmd % device) try: server.execute() except exceptions.ScriptRuntimeError: msg = ('Failed to bring up network interface %s on host %s.' ' Interface should be up so OpenStack can work' ' properly.' % (device, host)) raise exceptions.ScriptRuntimeError(msg) def dummy_interface(host): """Creates dummy interface on given hosts. Returns interface name. """ # Only single dummy interface will be created, hence the name is hardcoded ifname = 'dummy' script = ( 'DEVICE={0}\n' 'BOOTPROTO=none\n' 'ONBOOT=yes\n' 'TYPE=Ethernet\n' 'NM_CONTROLLED=no\n'.format(ifname) ) server = utils.ScriptRunner(host) server.append( 'ip link show {ifname} || (' 'modprobe dummy && ' 'ip link set name {ifname} dev dummy0 && ' 'ip link set dev dummy address 06:66:DE:AF:66:60' ')'.format(**locals()) ) server.append( 'cat > /etc/sysconfig/network-scripts/ifcfg-{ifname} ' '<<EOF\n{script}EOF'.format(**locals()) ) server.execute() return ifname # ------------------------ Step Functions ------------------------- def create_ssh_keys(config, messages): migration_key = os.path.join(basedefs.VAR_DIR, 'nova_migration_key') # Generate key if it does not exist if not os.path.exists(migration_key): local = utils.ScriptRunner() local.append('ssh-keygen -t rsa -b 2048 -f "%s" -N ""' % migration_key) local.execute() with open(migration_key) as fp: secret = fp.read().strip() with open('%s.pub' % migration_key) as fp: public = fp.read().strip() config['NOVA_MIGRATION_KEY_TYPE'] = 'ssh-rsa' config['NOVA_MIGRATION_KEY_PUBLIC'] = public.split()[1] config['NOVA_MIGRATION_KEY_SECRET'] = secret def gather_host_keys(config, messages): global compute_hosts for host in compute_hosts: local = utils.ScriptRunner() local.append('ssh-keyscan %s' % host) retcode, hostkey = local.execute() config['HOST_KEYS_%s' % host] = hostkey def create_api_manifest(config, messages): # Since this step is running first, let's create necessary variables here # and make them global global compute_hosts, network_hosts com_var = config.get("CONFIG_COMPUTE_HOSTS", "") compute_hosts = set([i.strip() for i in com_var.split(",") if i.strip()]) net_var = config.get("CONFIG_NETWORK_HOSTS", "") network_hosts = set([i.strip() for i in net_var.split(",") if i.strip()]) # This is a hack around us needing to generate the neutron metadata # password, but the nova puppet plugin uses the existence of that # password to determine whether or not to configure neutron metadata # proxy support. So the nova_api.pp template needs to be set to None # to disable metadata support if neutron is not being installed. if config['CONFIG_NEUTRON_INSTALL'] != 'y': config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = None else: config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = "%s" % config['CONFIG_NEUTRON_METADATA_PW'] manifestfile = "%s_api_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("nova_api") fw_details = dict() key = "nova_api" fw_details.setdefault(key, {}) fw_details[key]['host'] = "ALL" fw_details[key]['service_name'] = "nova api" fw_details[key]['chain'] = "INPUT" fw_details[key]['ports'] = ['8773', '8774', '8775'] fw_details[key]['proto'] = "tcp" config['FIREWALL_NOVA_API_RULES'] = fw_details manifestdata += createFirewallResources('FIREWALL_NOVA_API_RULES') appendManifestFile(manifestfile, manifestdata, 'novaapi') def create_keystone_manifest(config, messages): manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("keystone_nova") appendManifestFile(manifestfile, manifestdata) def create_cert_manifest(config, messages): manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("nova_cert") appendManifestFile(manifestfile, manifestdata) def create_conductor_manifest(config, messages): manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("nova_conductor") appendManifestFile(manifestfile, manifestdata) def create_compute_manifest(config, messages): global compute_hosts, network_hosts if config["CONFIG_HORIZON_SSL"] == 'y': config["CONFIG_VNCPROXY_PROTOCOL"] = "https" else: config["CONFIG_VNCPROXY_PROTOCOL"] = "http" migrate_protocol = config['CONFIG_NOVA_COMPUTE_MIGRATE_PROTOCOL'] if migrate_protocol == 'ssh': config['CONFIG_NOVA_COMPUTE_MIGRATE_URL'] = ( 'qemu+ssh://nova@%s/system?no_verify=1&' 'keyfile=/etc/nova/ssh/nova_migration_key' ) else: config['CONFIG_NOVA_COMPUTE_MIGRATE_URL'] = ( 'qemu+tcp://nova@%s/system' ) ssh_hostkeys = '' ssh_keys_details = {} for host in compute_hosts: try: hostname, aliases, addrs = socket.gethostbyaddr(host) except socket.herror: hostname, aliases, addrs = (host, [], []) for hostkey in config['HOST_KEYS_%s' % host].split('\n'): hostkey = hostkey.strip() if not hostkey: continue _, host_key_type, host_key_data = hostkey.split() key = "%s.%s" % (host_key_type, hostname) ssh_keys_details.setdefault(key, {}) ssh_keys_details[key]['ensure'] = 'present' ssh_keys_details[key]['host_aliases'] = aliases + addrs ssh_keys_details[key]['key'] = host_key_data ssh_keys_details[key]['type'] = host_key_type config['SSH_KEYS'] = ssh_keys_details ssh_hostkeys += getManifestTemplate("sshkey") if config['CONFIG_VMWARE_BACKEND'] == 'y': vcenters = [i.strip() for i in config['CONFIG_VCENTER_CLUSTER_NAMES'].split(',') if i.strip()] if not vcenters: raise exceptions.ParamValidationError( "Please specify at least one VMware vCenter cluster in" " CONFIG_VCENTER_CLUSTER_NAMES" ) if len(vcenters) != len(compute_hosts): if len(vcenters) > 1: raise exceptions.ParamValidationError( "Number of vmware clusters %s is not same" " as number of nova computes %s", (vcenters, compute_hosts) ) else: vcenters = len(compute_hosts) * [vcenters[0]] vmware_clusters = dict(zip(compute_hosts, vcenters)) for host in compute_hosts: if config['CONFIG_IRONIC_INSTALL'] == 'y': cm = 'ironic.nova.compute.manager.ClusteredComputeManager' config['CONFIG_NOVA_COMPUTE_MANAGER'] = cm manifestdata = getManifestTemplate("nova_compute") fw_details = dict() cf_fw_qemu_mig_key = "FIREWALL_NOVA_QEMU_MIG_RULES_%s" % host for c_host in compute_hosts: key = "nova_qemu_migration_%s_%s" % (host, c_host) fw_details.setdefault(key, {}) fw_details[key]['host'] = "%s" % c_host fw_details[key]['service_name'] = "nova qemu migration" fw_details[key]['chain'] = "INPUT" fw_details[key]['ports'] = ['16509', '49152-49215'] fw_details[key]['proto'] = "tcp" config[cf_fw_qemu_mig_key] = fw_details manifestdata += createFirewallResources(cf_fw_qemu_mig_key) if config['CONFIG_VMWARE_BACKEND'] == 'y': manifestdata += ("\n$nova_vcenter_cluster_name = '%s'\n" % vmware_clusters[host]) manifestdata += getManifestTemplate("nova_compute_vmware.pp") elif config['CONFIG_IRONIC_INSTALL'] == 'y': manifestdata += getManifestTemplate("nova_compute_ironic.pp") else: manifestdata += getManifestTemplate("nova_compute_libvirt.pp") if (config['CONFIG_VMWARE_BACKEND'] != 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and 'gluster' in config['CONFIG_CINDER_BACKEND']): manifestdata += getManifestTemplate("nova_gluster") if (config['CONFIG_VMWARE_BACKEND'] != 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and 'nfs' in config['CONFIG_CINDER_BACKEND']): manifestdata += getManifestTemplate("nova_nfs") manifestfile = "%s_nova.pp" % host if config['CONFIG_NEUTRON_INSTALL'] != 'y': if host not in network_hosts: manifestdata += getManifestTemplate('nova_compute_flat') key = 'CONFIG_NOVA_COMPUTE_PRIVIF' if not config[key].strip(): config[key] = dummy_interface(host) if config['CONFIG_USE_SUBNETS'] == 'y': netface = common.cidr_to_ifname( config[key], host, config ) else: netface = config[key] check_ifcfg(host, netface) try: bring_up_ifcfg(host, netface) except exceptions.ScriptRuntimeError as ex: # just warn user to do it by himself messages.append(str(ex)) if config['CONFIG_CEILOMETER_INSTALL'] == 'y': if config['CONFIG_AMQP_ENABLE_SSL'] == 'y': ssl_cert_file = config['CONFIG_CEILOMETER_SSL_CERT'] = ( '/etc/pki/tls/certs/ssl_amqp_ceilometer.crt' ) ssl_key_file = config['CONFIG_CEILOMETER_SSL_KEY'] = ( '/etc/pki/tls/private/ssl_amqp_ceilometer.key' ) ssl_host = config['CONFIG_CONTROLLER_HOST'] service = 'ceilometer' generate_ssl_cert(config, host, service, ssl_key_file, ssl_cert_file) mq_template = get_mq(config, "nova_ceilometer") manifestdata += getManifestTemplate(mq_template) manifestdata += getManifestTemplate("nova_ceilometer") fw_details = dict() key = "nova_compute" fw_details.setdefault(key, {}) fw_details[key]['host'] = "%s" % config['CONFIG_CONTROLLER_HOST'] fw_details[key]['service_name'] = "nova compute" fw_details[key]['chain'] = "INPUT" fw_details[key]['ports'] = ['5900-5999'] fw_details[key]['proto'] = "tcp" config['FIREWALL_NOVA_COMPUTE_RULES'] = fw_details manifestdata += "\n" + createFirewallResources( 'FIREWALL_NOVA_COMPUTE_RULES' ) manifestdata += "\n" + ssh_hostkeys appendManifestFile(manifestfile, manifestdata) def create_network_manifest(config, messages): global compute_hosts, network_hosts if config['CONFIG_NEUTRON_INSTALL'] == "y": return # set default values for VlanManager in case this values are not in config for key, value in [('CONFIG_NOVA_NETWORK_VLAN_START', 100), ('CONFIG_NOVA_NETWORK_SIZE', 255), ('CONFIG_NOVA_NETWORK_NUMBER', 1)]: config[key] = config.get(key, value) api_host = config['CONFIG_CONTROLLER_HOST'] multihost = len(network_hosts) > 1 config['CONFIG_NOVA_NETWORK_MULTIHOST'] = multihost and 'true' or 'false' for host in network_hosts: for i in ('CONFIG_NOVA_NETWORK_PRIVIF', 'CONFIG_NOVA_NETWORK_PUBIF'): if not config[i].strip(): config[i] = dummy_interface(host) netface = config[i] if config['CONFIG_USE_SUBNETS'] == 'y': netface = common.cidr_to_ifname(netface, host, config) check_ifcfg(host, netface) try: bring_up_ifcfg(host, netface) except exceptions.ScriptRuntimeError as ex: # just warn user to do it by himself messages.append(str(ex)) key = 'CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP' config[key] = config[key] == "y" # We need to explicitly set the network size routing_prefix = config['CONFIG_NOVA_NETWORK_FIXEDRANGE'].split('/')[1] net_size = 2 ** (32 - int(routing_prefix)) config['CONFIG_NOVA_NETWORK_FIXEDSIZE'] = str(net_size) manifestfile = "%s_nova.pp" % host manifestdata = getManifestTemplate("nova_network") # Restart libvirt if we deploy nova network on compute if host in compute_hosts: manifestdata += getManifestTemplate("nova_network_libvirt") # in multihost mode each compute host runs nova-api-metadata if multihost and host != api_host and host in compute_hosts: manifestdata += getManifestTemplate("nova_metadata") appendManifestFile(manifestfile, manifestdata) def create_sched_manifest(config, messages): manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST'] if config['CONFIG_IRONIC_INSTALL'] == 'y': manifestdata = getManifestTemplate("nova_sched_ironic.pp") ram_alloc = '1.0' config['CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO'] = ram_alloc manifestdata += getManifestTemplate("nova_sched.pp") else: manifestdata = getManifestTemplate("nova_sched.pp") appendManifestFile(manifestfile, manifestdata) def create_vncproxy_manifest(config, messages): if config["CONFIG_HORIZON_SSL"] == 'y': if config["CONFIG_VNC_SSL_CERT"]: ssl_cert_file = config["CONFIG_VNC_SSL_CERT"] ssl_key_file = config["CONFIG_VNC_SSL_KEY"] if not os.path.exists(ssl_cert_file): raise exceptions.ParamValidationError( "The file %s doesn't exist" % ssl_cert_file) if not os.path.exists(ssl_key_file): raise exceptions.ParamValidationError( "The file %s doesn't exist" % ssl_key_file) final_cert = open(ssl_cert_file, 'rt').read() final_key = open(ssl_key_file, 'rt').read() deliver_ssl_file(final_cert, ssl_cert_file, config['CONFIG_CONTROLLER_HOST']) deliver_ssl_file(final_key, ssl_key_file, config['CONFIG_CONTROLLER_HOST']) else: config["CONFIG_VNC_SSL_CERT"] = '/etc/pki/tls/certs/ssl_vnc.crt' config["CONFIG_VNC_SSL_KEY"] = '/etc/pki/tls/private/ssl_vnc.key' ssl_key_file = config["CONFIG_VNC_SSL_KEY"] ssl_cert_file = config["CONFIG_VNC_SSL_CERT"] ssl_host = config['CONFIG_CONTROLLER_HOST'] service = 'vnc' generate_ssl_cert(config, ssl_host, service, ssl_key_file, ssl_cert_file) manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("nova_vncproxy") appendManifestFile(manifestfile, manifestdata) def create_common_manifest(config, messages): global compute_hosts, network_hosts network_type = (config['CONFIG_NEUTRON_INSTALL'] == "y" and 'neutron' or 'nova') network_multi = len(network_hosts) > 1 dbacces_hosts = set([config.get('CONFIG_CONTROLLER_HOST')]) dbacces_hosts |= network_hosts for manifestfile, marker in manifestfiles.getFiles(): pw_in_sqlconn = False if manifestfile.endswith("_nova.pp"): host, manifest = manifestfile.split('_', 1) host = host.strip() if host in compute_hosts and host not in dbacces_hosts: # we should omit password in case we are installing only # nova-compute to the host perms = "nova" pw_in_sqlconn = False else: perms = "nova:%s" % config['CONFIG_NOVA_DB_PW'] pw_in_sqlconn = True mariadb_host_url = config['CONFIG_MARIADB_HOST_URL'] sqlconn = "mysql+pymysql://%s@%s/nova" % (perms, mariadb_host_url) if pw_in_sqlconn: config['CONFIG_NOVA_SQL_CONN_PW'] = sqlconn else: config['CONFIG_NOVA_SQL_CONN_NOPW'] = sqlconn # for nova-network in multihost mode each compute host is metadata # host otherwise we use api host if (network_type == 'nova' and network_multi and host in compute_hosts): metadata = host else: metadata = config['CONFIG_CONTROLLER_HOST'] config['CONFIG_NOVA_METADATA_HOST'] = metadata data = getManifestTemplate(get_mq(config, "nova_common")) if pw_in_sqlconn: data += getManifestTemplate("nova_common_pw") else: data += getManifestTemplate("nova_common_nopw") appendManifestFile(os.path.split(manifestfile)[1], data) if config['CONFIG_AMQP_ENABLE_SSL'] == 'y': nova_hosts = compute_hosts nova_hosts |= set([config.get('CONFIG_CONTROLLER_HOST')]) ssl_cert_file = config['CONFIG_NOVA_SSL_CERT'] = ( '/etc/pki/tls/certs/ssl_amqp_nova.crt' ) ssl_key_file = config['CONFIG_NOVA_SSL_KEY'] = ( '/etc/pki/tls/private/ssl_amqp_nova.key' ) service = 'nova' for host in nova_hosts: generate_ssl_cert(config, host, service, ssl_key_file, ssl_cert_file) def create_neutron_manifest(config, messages): if config['CONFIG_NEUTRON_INSTALL'] != "y": return if config['CONFIG_IRONIC_INSTALL'] == 'y': virt_driver = 'nova.virt.firewall.NoopFirewallDriver' config['CONFIG_NOVA_LIBVIRT_VIF_DRIVER'] = virt_driver else: virt_driver = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver' config['CONFIG_NOVA_LIBVIRT_VIF_DRIVER'] = virt_driver for manifestfile, marker in manifestfiles.getFiles(): if manifestfile.endswith("_nova.pp"): data = getManifestTemplate("nova_neutron") appendManifestFile(os.path.split(manifestfile)[1], data)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 8154, 83, 436, 1101, 1482, 28184, 199, 624, 199, 199, 646, 747, 199, 646, 4298, 199, 646, 2838, 199, 199, 504, 1706, 2340, 14, 17047, 492, 1300, 8710, 199, 504, 1706, 2340, 14, 17047, 492, 4967, 199, 504, 1706, 2340, 14, 17047, 492, 21620, 199, 504, 1706, 2340, 14, 17047, 492, 3778, 199, 504, 1706, 2340, 14, 17047, 492, 14370, 199, 199, 504, 1706, 2340, 14, 3112, 492, 2863, 199, 504, 1706, 2340, 14, 3112, 14, 9970, 492, 1678, 63, 1162, 63, 3807, 199, 504, 1706, 2340, 14, 3112, 14, 17469, 492, 664, 63, 8334, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 5666, 11038, 1173, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 1218, 24260, 13745, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 28503, 63, 4266, 63, 493, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 664, 11038, 4231, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 3550, 63, 4266, 63, 4736, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 7712, 1725, 199, 199, 3, 3001, 9858, 28184, 9954, 2340, 11349, 6026, 2072, 3001, 8648, 199, 199, 19108, 63, 2339, 275, 298, 3100, 13, 19884, 2, 199, 19108, 63, 2339, 63, 7134, 1149, 275, 3778, 14, 2326, 63, 505, 8, 19108, 63, 2339, 12, 283, 6304, 358, 421, 199, 318, 4205, 2028, 8, 5538, 304, 272, 340, 4298, 14, 5135, 63, 4972, 3430, 16, 61, 508, 298, 38, 379, 11131, 582, 267, 5062, 63, 20869, 275, 298, 5633, 17, 2, 267, 13851, 63, 20869, 275, 298, 5633, 18, 2, 272, 587, 26, 267, 5062, 63, 20869, 275, 298, 12391, 16, 2, 267, 13851, 63, 20869, 275, 298, 12391, 17, 2, 339, 5913, 63, 1162, 275, 469, 267, 298, 2826, 15162, 582, 359, 288, 2420, 9744, 63, 13352, 582, 283, 6765, 13, 697, 13, 18254, 13, 4296, 297, 1467, 298, 2514, 26178, 582, 334, 326, 298, 8468, 612, 340, 19818, 3906, 367, 12881, 11620, 5463, 6249, 4730, 298, 326, 298, 5626, 506, 2737, 2, 1467, 2318, 1467, 298, 13352, 63, 4924, 582, 788, 89, 297, 283, 78, 995, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2245, 467, 1467, 298, 3472, 63, 7041, 582, 283, 89, 297, 1467, 298, 12880, 63, 7321, 582, 756, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 283, 5569, 63, 2826, 15162, 63, 2846, 63, 48, 1230, 4962, 63, 8898, 297, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 6765, 13, 697, 13, 12671, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 2505, 367, 314, 28184, 6249, 2879, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 3472, 63, 7041, 582, 298, 10780, 63, 23068, 40, 15744, 401, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2060, 467, 1467, 298, 12880, 63, 7321, 582, 715, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 2846, 63, 10780, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 6765, 13, 6080, 13, 12671, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 2505, 367, 314, 28184, 2606, 8361, 2879, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 3472, 63, 7041, 582, 298, 10780, 63, 23068, 40, 15744, 401, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2060, 467, 1467, 298, 12880, 63, 7321, 582, 715, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 19982, 63, 10780, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 889, 4755, 1809, 13, 3541, 13, 14940, 13, 6884, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 11952, 1806, 3543, 434, 10463, 14, 2494, 370, 413, 14, 16, 370, 298, 2432, 298, 5993, 11952, 1806, 3543, 434, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1609, 467, 1467, 298, 3472, 63, 7041, 582, 3193, 14, 16, 12, 1467, 298, 12880, 63, 7321, 582, 756, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 715, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 27944, 63, 11011, 63, 28605, 63, 26566, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 756, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 889, 4755, 1809, 13, 5975, 13, 14940, 13, 6884, 401, 1467, 298, 2514, 26178 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 8154, 83, 436, 1101, 1482, 28184, 199, 624, 199, 199, 646, 747, 199, 646, 4298, 199, 646, 2838, 199, 199, 504, 1706, 2340, 14, 17047, 492, 1300, 8710, 199, 504, 1706, 2340, 14, 17047, 492, 4967, 199, 504, 1706, 2340, 14, 17047, 492, 21620, 199, 504, 1706, 2340, 14, 17047, 492, 3778, 199, 504, 1706, 2340, 14, 17047, 492, 14370, 199, 199, 504, 1706, 2340, 14, 3112, 492, 2863, 199, 504, 1706, 2340, 14, 3112, 14, 9970, 492, 1678, 63, 1162, 63, 3807, 199, 504, 1706, 2340, 14, 3112, 14, 17469, 492, 664, 63, 8334, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 5666, 11038, 1173, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 1218, 24260, 13745, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 28503, 63, 4266, 63, 493, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 664, 11038, 4231, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 3550, 63, 4266, 63, 4736, 199, 504, 1706, 2340, 14, 3112, 14, 79, 30873, 1208, 492, 7712, 1725, 199, 199, 3, 3001, 9858, 28184, 9954, 2340, 11349, 6026, 2072, 3001, 8648, 199, 199, 19108, 63, 2339, 275, 298, 3100, 13, 19884, 2, 199, 19108, 63, 2339, 63, 7134, 1149, 275, 3778, 14, 2326, 63, 505, 8, 19108, 63, 2339, 12, 283, 6304, 358, 421, 199, 318, 4205, 2028, 8, 5538, 304, 272, 340, 4298, 14, 5135, 63, 4972, 3430, 16, 61, 508, 298, 38, 379, 11131, 582, 267, 5062, 63, 20869, 275, 298, 5633, 17, 2, 267, 13851, 63, 20869, 275, 298, 5633, 18, 2, 272, 587, 26, 267, 5062, 63, 20869, 275, 298, 12391, 16, 2, 267, 13851, 63, 20869, 275, 298, 12391, 17, 2, 339, 5913, 63, 1162, 275, 469, 267, 298, 2826, 15162, 582, 359, 288, 2420, 9744, 63, 13352, 582, 283, 6765, 13, 697, 13, 18254, 13, 4296, 297, 1467, 298, 2514, 26178, 582, 334, 326, 298, 8468, 612, 340, 19818, 3906, 367, 12881, 11620, 5463, 6249, 4730, 298, 326, 298, 5626, 506, 2737, 2, 1467, 2318, 1467, 298, 13352, 63, 4924, 582, 788, 89, 297, 283, 78, 995, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2245, 467, 1467, 298, 3472, 63, 7041, 582, 283, 89, 297, 1467, 298, 12880, 63, 7321, 582, 756, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 283, 5569, 63, 2826, 15162, 63, 2846, 63, 48, 1230, 4962, 63, 8898, 297, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 6765, 13, 697, 13, 12671, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 2505, 367, 314, 28184, 6249, 2879, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 3472, 63, 7041, 582, 298, 10780, 63, 23068, 40, 15744, 401, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2060, 467, 1467, 298, 12880, 63, 7321, 582, 715, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 2846, 63, 10780, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 6765, 13, 6080, 13, 12671, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 2505, 367, 314, 28184, 2606, 8361, 2879, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1397, 63, 1667, 467, 1467, 298, 3472, 63, 7041, 582, 298, 10780, 63, 23068, 40, 15744, 401, 1467, 298, 10494, 4149, 582, 359, 10547, 14, 1412, 63, 2060, 467, 1467, 298, 12880, 63, 7321, 582, 715, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 756, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 19982, 63, 10780, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 715, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 889, 4755, 1809, 13, 3541, 13, 14940, 13, 6884, 401, 1467, 298, 2514, 26178, 582, 298, 8468, 314, 11952, 1806, 3543, 434, 10463, 14, 2494, 370, 413, 14, 16, 370, 298, 2432, 298, 5993, 11952, 1806, 3543, 434, 401, 1467, 298, 13352, 63, 4924, 582, 990, 1467, 298, 5600, 19033, 582, 359, 11346, 14, 3502, 63, 1609, 467, 1467, 298, 3472, 63, 7041, 582, 3193, 14, 16, 12, 1467, 298, 12880, 63, 7321, 582, 756, 12, 1467, 298, 1484, 47, 899, 63, 5600, 2594, 582, 715, 12, 1467, 298, 3103, 63, 2339, 582, 298, 5569, 63, 2826, 15162, 63, 27944, 63, 11011, 63, 28605, 63, 26566, 401, 1467, 298, 4701, 63, 3472, 582, 756, 12, 1467, 298, 28888, 63, 1864, 28830, 582, 756, 12, 1467, 298, 1864, 31247, 582, 756, 1386, 953, 2420, 9744, 63, 13352, 582, 298, 889, 4755, 1809, 13, 5975, 13, 14940, 13, 6884, 401, 1467, 298, 2514, 26178, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file import os,shutil,sys,platform from waflib import TaskGen,Task,Build,Options,Utils,Errors from waflib.TaskGen import taskgen_method,feature,after_method,before_method app_info=''' <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="0.9"> <dict> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleGetInfoString</key> <string>Created by Waf</string> <key>CFBundleSignature</key> <string>????</string> <key>NOTE</key> <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> <key>CFBundleExecutable</key> <string>%s</string> </dict> </plist> ''' @feature('c','cxx') def set_macosx_deployment_target(self): if self.env['MACOSX_DEPLOYMENT_TARGET']: os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env['MACOSX_DEPLOYMENT_TARGET'] elif'MACOSX_DEPLOYMENT_TARGET'not in os.environ: if Utils.unversioned_sys_platform()=='darwin': os.environ['MACOSX_DEPLOYMENT_TARGET']='.'.join(platform.mac_ver()[0].split('.')[:2]) @taskgen_method def create_bundle_dirs(self,name,out): bld=self.bld dir=out.parent.find_or_declare(name) dir.mkdir() macos=dir.find_or_declare(['Contents','MacOS']) macos.mkdir() return dir def bundle_name_for_output(out): name=out.name k=name.rfind('.') if k>=0: name=name[:k]+'.app' else: name=name+'.app' return name @feature('cprogram','cxxprogram') @after_method('apply_link') def create_task_macapp(self): if self.env['MACAPP']or getattr(self,'mac_app',False): out=self.link_task.outputs[0] name=bundle_name_for_output(out) dir=self.create_bundle_dirs(name,out) n1=dir.find_or_declare(['Contents','MacOS',out.name]) self.apptask=self.create_task('macapp',self.link_task.outputs,n1) inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/MacOS/'%name self.bld.install_files(inst_to,n1,chmod=Utils.O755) if getattr(self,'mac_resources',None): res_dir=n1.parent.parent.make_node('Resources') inst_to=getattr(self,'install_path','/Applications')+'/%s/Resources'%name for x in self.to_list(self.mac_resources): node=self.path.find_node(x) if not node: raise Errors.WafError('Missing mac_resource %r in %r'%(x,self)) parent=node.parent if os.path.isdir(node.abspath()): nodes=node.ant_glob('**') else: nodes=[node] for node in nodes: rel=node.path_from(parent) tsk=self.create_task('macapp',node,res_dir.make_node(rel)) self.bld.install_as(inst_to+'/%s'%rel,node) if getattr(self.bld,'is_install',None): self.install_task.hasrun=Task.SKIP_ME @feature('cprogram','cxxprogram') @after_method('apply_link') def create_task_macplist(self): if self.env['MACAPP']or getattr(self,'mac_app',False): out=self.link_task.outputs[0] name=bundle_name_for_output(out) dir=self.create_bundle_dirs(name,out) n1=dir.find_or_declare(['Contents','Info.plist']) self.plisttask=plisttask=self.create_task('macplist',[],n1) if getattr(self,'mac_plist',False): node=self.path.find_resource(self.mac_plist) if node: plisttask.inputs.append(node) else: plisttask.code=self.mac_plist else: plisttask.code=app_info%self.link_task.outputs[0].name inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/'%name self.bld.install_files(inst_to,n1) @feature('cshlib','cxxshlib') @before_method('apply_link','propagate_uselib_vars') def apply_bundle(self): if self.env['MACBUNDLE']or getattr(self,'mac_bundle',False): self.env['LINKFLAGS_cshlib']=self.env['LINKFLAGS_cxxshlib']=[] self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN'] use=self.use=self.to_list(getattr(self,'use',[])) if not'MACBUNDLE'in use: use.append('MACBUNDLE') app_dirs=['Contents','Contents/MacOS','Contents/Resources'] class macapp(Task.Task): color='PINK' def run(self): self.outputs[0].parent.mkdir() shutil.copy2(self.inputs[0].srcpath(),self.outputs[0].abspath()) class macplist(Task.Task): color='PINK' ext_in=['.bin'] def run(self): if getattr(self,'code',None): txt=self.code else: txt=self.inputs[0].read() self.outputs[0].write(txt)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 20938, 12, 1274, 12, 3246, 199, 504, 31380, 492, 8495, 8168, 12, 4476, 12, 3425, 12, 4558, 12, 7535, 12, 9298, 199, 504, 31380, 14, 4476, 8168, 492, 2120, 2268, 63, 765, 12, 4445, 12, 4399, 63, 765, 12, 5182, 63, 765, 199, 571, 63, 815, 19938, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 11230, 16556, 14459, 20859, 298, 493, 921, 5967, 15, 3989, 15, 7424, 15, 21156, 83, 15, 3697, 1296, 14, 15662, 1743, 199, 28, 10265, 1015, 628, 16, 14, 25, 1743, 199, 28, 807, 30, 199, 198, 28, 498, 30, 5487, 12320, 8599, 804, 1108, 498, 30, 199, 198, 28, 875, 30, 1282, 2749, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 1002, 2354, 1558, 1108, 498, 30, 199, 198, 28, 875, 30, 10502, 701, 644, 2756, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 10014, 1108, 498, 30, 199, 198, 28, 875, 30, 10674, 10674, 1108, 875, 30, 199, 198, 28, 498, 30, 19855, 1108, 498, 30, 199, 198, 28, 875, 30, 24571, 2281, 437, 29087, 6989, 13024, 12, 3506, 2845, 10362, 1914, 18114, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 18039, 1108, 498, 30, 199, 198, 28, 875, 6598, 83, 1108, 875, 30, 199, 1108, 807, 30, 199, 1108, 10265, 30, 199, 2344, 199, 32, 4445, 360, 67, 1673, 9634, 358, 199, 318, 663, 63, 28546, 63, 13605, 63, 1375, 8, 277, 304, 199, 198, 692, 291, 14, 1813, 459, 9410, 25160, 63, 32304, 63, 9268, 2565, 507, 198, 736, 14, 2314, 459, 9410, 25160, 63, 32304, 63, 9268, 13784, 277, 14, 1813, 459, 9410, 25160, 63, 32304, 63, 9268, 418, 199, 198, 4164, 7, 9410, 25160, 63, 32304, 63, 9268, 7, 1397, 315, 747, 14, 2314, 26, 507, 198, 692, 17397, 14, 324, 24155, 63, 1274, 63, 3246, 342, 6803, 13245, 356, 686, 198, 736, 14, 2314, 459, 9410, 25160, 63, 32304, 63, 9268, 418, 15637, 1370, 904, 8, 3246, 14, 3088, 63, 422, 3430, 16, 1055, 1294, 7563, 1491, 18, 566, 199, 32, 1765, 2268, 63, 765, 199, 318, 1218, 63, 6469, 63, 3220, 8, 277, 12, 354, 12, 548, 304, 199, 198, 14341, 29, 277, 14, 14341, 199, 198, 694, 29, 548, 14, 1708, 14, 1623, 63, 269, 63, 16536, 8, 354, 9, 199, 198, 694, 14, 8215, 342, 199, 198, 391, 5197, 29, 694, 14, 1623, 63, 269, 63, 16536, 2941, 11383, 1673, 3399, 3100, 1105, 199, 198, 391, 5197, 14, 8215, 342, 199, 198, 1107, 2935, 199, 318, 8844, 63, 354, 63, 509, 63, 1199, 8, 548, 304, 199, 198, 354, 29, 548, 14, 354, 199, 198, 75, 29, 354, 14, 14542, 7563, 199, 198, 692, 1022, 8119, 16, 26, 507, 198, 354, 29, 354, 1491, 75, 2807, 1370, 571, 7, 199, 198, 2836, 26, 507, 198, 354, 29, 354, 18098, 571, 7, 199, 198, 1107, 536, 199, 32, 4445, 360, 67, 6815, 1673, 9634, 6815, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1218, 63, 1765, 63, 3088, 571, 8, 277, 304, 199, 198, 692, 291, 14, 1813, 459, 9410, 7121, 418, 269, 2519, 8, 277, 2584, 3088, 63, 571, 297, 797, 304, 507, 198, 548, 29, 277, 14, 1073, 63, 1765, 14, 4467, 59, 16, 61, 507, 198, 354, 29, 6469, 63, 354, 63, 509, 63, 1199, 8, 548, 9, 507, 198, 694, 29, 277, 14, 981, 63, 6469, 63, 3220, 8, 354, 12, 548, 9, 507, 198, 78, 17, 29, 694, 14, 1623, 63, 269, 63, 16536, 2941, 11383, 1673, 3399, 3100, 297, 548, 14, 354, 566, 507, 198, 277, 14, 439, 541, 813, 29, 277, 14, 981, 63, 1765, 360, 3088, 571, 297, 277, 14, 1073, 63, 1765, 14, 4467, 12, 78, 17, 9, 507, 198, 3615, 63, 475, 29, 5675, 8, 277, 2584, 3174, 63, 515, 32381, 31907, 358, 4786, 3149, 83, 15, 11383, 15, 3399, 3100, 4805, 5, 354, 507, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 3615, 63, 475, 12, 78, 17, 12, 11693, 29, 7535, 14, 47, 12315, 9, 507, 198, 692, 2519, 8, 277, 2584, 3088, 63, 4435, 297, 403, 304, 686, 198, 470, 63, 694, 29, 78, 17, 14, 1708, 14, 1708, 14, 1875, 63, 932, 360, 13745, 358, 686, 198, 3615, 63, 475, 29, 5675, 8, 277, 2584, 3174, 63, 515, 32381, 31907, 358, 4786, 3149, 83, 15, 13745, 5956, 354, 686, 198, 509, 671, 315, 291, 14, 475, 63, 513, 8, 277, 14, 3088, 63, 4435, 304, 1585, 198, 932, 29, 277, 14, 515, 14, 1623, 63, 932, 8, 88, 9, 1585, 198, 692, 440, 1031, 26, 1871, 198, 3730, 20456, 14, 55, 2756, 547, 360, 7718, 4497, 63, 1927, 450, 82, 315, 450, 82, 13328, 88, 12, 277, 430, 1585, 198, 1708, 29, 932, 14, 1708, 1585, 198, 692, 747, 14, 515, 14, 6027, 8, 932, 14, 4832, 5109, 1871, 198, 2415, 29, 932, 14, 867, 63, 6463, 31260, 358, 1585, 198, 2836, 26, 1871, 198, 2415, 1524, 932, 61, 1585, 198, 509, 1031, 315, 3380, 26, 1871, 198, 3369, 29, 932, 14, 515, 63, 504, 8, 1708, 9, 1871, 198, 21563, 29, 277, 14, 981, 63, 1765, 360, 3088, 571, 297, 932, 12, 470, 63, 694, 14, 1875, 63, 932, 8, 3369, 430, 1871, 198, 277, 14, 14341, 14, 3174, 63, 305, 8, 3615, 63, 475, 4786, 3149, 83, 5956, 3369, 12, 932, 9, 507, 198, 692, 2519, 8, 277, 14, 14341, 2584, 374, 63, 3174, 297, 403, 304, 686, 198, 277, 14, 3174, 63, 1765, 14, 1989, 1065, 29, 4476, 14, 13525, 63, 3635, 199, 32, 4445, 360, 67, 6815, 1673, 9634, 6815, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1218, 63, 1765, 63, 391, 1850, 513, 8, 277, 304, 199, 198, 692, 291 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 20938, 12, 1274, 12, 3246, 199, 504, 31380, 492, 8495, 8168, 12, 4476, 12, 3425, 12, 4558, 12, 7535, 12, 9298, 199, 504, 31380, 14, 4476, 8168, 492, 2120, 2268, 63, 765, 12, 4445, 12, 4399, 63, 765, 12, 5182, 63, 765, 199, 571, 63, 815, 19938, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 11230, 16556, 14459, 20859, 298, 493, 921, 5967, 15, 3989, 15, 7424, 15, 21156, 83, 15, 3697, 1296, 14, 15662, 1743, 199, 28, 10265, 1015, 628, 16, 14, 25, 1743, 199, 28, 807, 30, 199, 198, 28, 498, 30, 5487, 12320, 8599, 804, 1108, 498, 30, 199, 198, 28, 875, 30, 1282, 2749, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 1002, 2354, 1558, 1108, 498, 30, 199, 198, 28, 875, 30, 10502, 701, 644, 2756, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 10014, 1108, 498, 30, 199, 198, 28, 875, 30, 10674, 10674, 1108, 875, 30, 199, 198, 28, 498, 30, 19855, 1108, 498, 30, 199, 198, 28, 875, 30, 24571, 2281, 437, 29087, 6989, 13024, 12, 3506, 2845, 10362, 1914, 18114, 1108, 875, 30, 199, 198, 28, 498, 30, 5487, 12320, 18039, 1108, 498, 30, 199, 198, 28, 875, 6598, 83, 1108, 875, 30, 199, 1108, 807, 30, 199, 1108, 10265, 30, 199, 2344, 199, 32, 4445, 360, 67, 1673, 9634, 358, 199, 318, 663, 63, 28546, 63, 13605, 63, 1375, 8, 277, 304, 199, 198, 692, 291, 14, 1813, 459, 9410, 25160, 63, 32304, 63, 9268, 2565, 507, 198, 736, 14, 2314, 459, 9410, 25160, 63, 32304, 63, 9268, 13784, 277, 14, 1813, 459, 9410, 25160, 63, 32304, 63, 9268, 418, 199, 198, 4164, 7, 9410, 25160, 63, 32304, 63, 9268, 7, 1397, 315, 747, 14, 2314, 26, 507, 198, 692, 17397, 14, 324, 24155, 63, 1274, 63, 3246, 342, 6803, 13245, 356, 686, 198, 736, 14, 2314, 459, 9410, 25160, 63, 32304, 63, 9268, 418, 15637, 1370, 904, 8, 3246, 14, 3088, 63, 422, 3430, 16, 1055, 1294, 7563, 1491, 18, 566, 199, 32, 1765, 2268, 63, 765, 199, 318, 1218, 63, 6469, 63, 3220, 8, 277, 12, 354, 12, 548, 304, 199, 198, 14341, 29, 277, 14, 14341, 199, 198, 694, 29, 548, 14, 1708, 14, 1623, 63, 269, 63, 16536, 8, 354, 9, 199, 198, 694, 14, 8215, 342, 199, 198, 391, 5197, 29, 694, 14, 1623, 63, 269, 63, 16536, 2941, 11383, 1673, 3399, 3100, 1105, 199, 198, 391, 5197, 14, 8215, 342, 199, 198, 1107, 2935, 199, 318, 8844, 63, 354, 63, 509, 63, 1199, 8, 548, 304, 199, 198, 354, 29, 548, 14, 354, 199, 198, 75, 29, 354, 14, 14542, 7563, 199, 198, 692, 1022, 8119, 16, 26, 507, 198, 354, 29, 354, 1491, 75, 2807, 1370, 571, 7, 199, 198, 2836, 26, 507, 198, 354, 29, 354, 18098, 571, 7, 199, 198, 1107, 536, 199, 32, 4445, 360, 67, 6815, 1673, 9634, 6815, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1218, 63, 1765, 63, 3088, 571, 8, 277, 304, 199, 198, 692, 291, 14, 1813, 459, 9410, 7121, 418, 269, 2519, 8, 277, 2584, 3088, 63, 571, 297, 797, 304, 507, 198, 548, 29, 277, 14, 1073, 63, 1765, 14, 4467, 59, 16, 61, 507, 198, 354, 29, 6469, 63, 354, 63, 509, 63, 1199, 8, 548, 9, 507, 198, 694, 29, 277, 14, 981, 63, 6469, 63, 3220, 8, 354, 12, 548, 9, 507, 198, 78, 17, 29, 694, 14, 1623, 63, 269, 63, 16536, 2941, 11383, 1673, 3399, 3100, 297, 548, 14, 354, 566, 507, 198, 277, 14, 439, 541, 813, 29, 277, 14, 981, 63, 1765, 360, 3088, 571, 297, 277, 14, 1073, 63, 1765, 14, 4467, 12, 78, 17, 9, 507, 198, 3615, 63, 475, 29, 5675, 8, 277, 2584, 3174, 63, 515, 32381, 31907, 358, 4786, 3149, 83, 15, 11383, 15, 3399, 3100, 4805, 5, 354, 507, 198, 277, 14, 14341, 14, 3174, 63, 1725, 8, 3615, 63, 475, 12, 78, 17, 12, 11693, 29, 7535, 14, 47, 12315, 9, 507, 198, 692, 2519, 8, 277, 2584, 3088, 63, 4435, 297, 403, 304, 686, 198, 470, 63, 694, 29, 78, 17, 14, 1708, 14, 1708, 14, 1875, 63, 932, 360, 13745, 358, 686, 198, 3615, 63, 475, 29, 5675, 8, 277, 2584, 3174, 63, 515, 32381, 31907, 358, 4786, 3149, 83, 15, 13745, 5956, 354, 686, 198, 509, 671, 315, 291, 14, 475, 63, 513, 8, 277, 14, 3088, 63, 4435, 304, 1585, 198, 932, 29, 277, 14, 515, 14, 1623, 63, 932, 8, 88, 9, 1585, 198, 692, 440, 1031, 26, 1871, 198, 3730, 20456, 14, 55, 2756, 547, 360, 7718, 4497, 63, 1927, 450, 82, 315, 450, 82, 13328, 88, 12, 277, 430, 1585, 198, 1708, 29, 932, 14, 1708, 1585, 198, 692, 747, 14, 515, 14, 6027, 8, 932, 14, 4832, 5109, 1871, 198, 2415, 29, 932, 14, 867, 63, 6463, 31260, 358, 1585, 198, 2836, 26, 1871, 198, 2415, 1524, 932, 61, 1585, 198, 509, 1031, 315, 3380, 26, 1871, 198, 3369, 29, 932, 14, 515, 63, 504, 8, 1708, 9, 1871, 198, 21563, 29, 277, 14, 981, 63, 1765, 360, 3088, 571, 297, 932, 12, 470, 63, 694, 14, 1875, 63, 932, 8, 3369, 430, 1871, 198, 277, 14, 14341, 14, 3174, 63, 305, 8, 3615, 63, 475, 4786, 3149, 83, 5956, 3369, 12, 932, 9, 507, 198, 692, 2519, 8, 277, 14, 14341, 2584, 374, 63, 3174, 297, 403, 304, 686, 198, 277, 14, 3174, 63, 1765, 14, 1989, 1065, 29, 4476, 14, 13525, 63, 3635, 199, 32, 4445, 360, 67, 6815, 1673, 9634, 6815, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1218, 63, 1765, 63, 391, 1850, 513, 8, 277, 304, 199, 198, 692, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
naturali/tensorflow
tensorflow/python/kernel_tests/batchtospace_op_test.py
21
10783
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Functional tests for BatchToSpace op. Additional tests are included in spacetobatch_op_test.py, where the BatchToSpace op is tested in tandem with its reverse SpaceToBatch op. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf from tensorflow.python.ops import gen_array_ops class PythonOpImpl(object): @staticmethod def batch_to_space(*args, **kwargs): return tf.batch_to_space(*args, **kwargs) class CppOpImpl(object): @staticmethod def batch_to_space(*args, **kwargs): return gen_array_ops._batch_to_space(*args, **kwargs) class BatchToSpaceDepthToSpace(tf.test.TestCase, PythonOpImpl): # Verifies that: batch_to_space(x) = transpose(depth_to_space(transpose(x))) def testDepthToSpaceTranspose(self): x = np.arange(20 * 5 * 8 * 7, dtype=np.float32).reshape([20, 5, 8, 7]) block_size = 2 crops = np.zeros((2, 2), dtype=np.int32) y1 = self.batch_to_space(x, crops, block_size=block_size) y2 = tf.transpose( tf.depth_to_space( tf.transpose(x, [3, 1, 2, 0]), block_size=block_size), [3, 1, 2, 0]) with self.test_session(): self.assertAllEqual(y1.eval(), y2.eval()) class BatchToSpaceDepthToSpaceCpp(BatchToSpaceDepthToSpace, CppOpImpl): pass class BatchToSpaceErrorHandlingTest(tf.test.TestCase, PythonOpImpl): def testInputWrongDimMissingBatch(self): # The input is missing the first dimension ("batch") x_np = [[[1], [2]], [[3], [4]]] crops = np.zeros((2, 2), dtype=np.int32) block_size = 2 with self.assertRaises(ValueError): _ = self.batch_to_space(x_np, crops, block_size) def testBlockSize0(self): # The block size is 0. x_np = [[[[1], [2]], [[3], [4]]]] crops = np.zeros((2, 2), dtype=np.int32) block_size = 0 with self.assertRaises(ValueError): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() def testBlockSizeOne(self): # The block size is 1. The block size needs to be > 1. x_np = [[[[1], [2]], [[3], [4]]]] crops = np.zeros((2, 2), dtype=np.int32) block_size = 1 with self.assertRaises(ValueError): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() def testBlockSizeLarger(self): # The block size is too large for this input. x_np = [[[[1], [2]], [[3], [4]]]] crops = np.zeros((2, 2), dtype=np.int32) block_size = 10 with self.assertRaises(ValueError): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() def testBlockSizeSquaredNotDivisibleBatch(self): # The block size squared does not divide the batch. x_np = [[[[1], [2], [3]], [[3], [4], [7]]]] crops = np.zeros((2, 2), dtype=np.int32) block_size = 3 with self.assertRaises(ValueError): _ = self.batch_to_space(x_np, crops, block_size) def testUnknownShape(self): t = self.batch_to_space( tf.placeholder(tf.float32), tf.placeholder(tf.int32), block_size=4) self.assertEqual(4, t.get_shape().ndims) class BatchToSpaceErrorHandlingCppTest(BatchToSpaceErrorHandlingTest, CppOpImpl): pass class BatchToSpaceNDErrorHandlingTest(tf.test.TestCase): def _testStaticShape(self, input_shape, block_shape, paddings, error): block_shape = np.array(block_shape) paddings = np.array(paddings) # Try with sizes known at graph construction time. with self.assertRaises(error): _ = tf.batch_to_space_nd( np.zeros(input_shape, np.float32), block_shape, paddings) def _testDynamicShape(self, input_shape, block_shape, paddings): block_shape = np.array(block_shape) paddings = np.array(paddings) # Try with sizes unknown at graph construction time. input_placeholder = tf.placeholder(tf.float32) block_shape_placeholder = tf.placeholder(tf.int32, shape=block_shape.shape) paddings_placeholder = tf.placeholder(tf.int32) t = tf.batch_to_space_nd(input_placeholder, block_shape_placeholder, paddings_placeholder) with self.assertRaises(ValueError): _ = t.eval({input_placeholder: np.zeros(input_shape, np.float32), block_shape_placeholder: block_shape, paddings_placeholder: paddings}) def _testShape(self, input_shape, block_shape, paddings, error): self._testStaticShape(input_shape, block_shape, paddings, error) self._testDynamicShape(input_shape, block_shape, paddings) def testInputWrongDimMissingBatch(self): self._testShape([2, 2], [2, 2], [[0, 0], [0, 0]], ValueError) self._testShape([2, 2, 3], [2, 2, 3], [[0, 0], [0, 0]], ValueError) def testBlockSize0(self): # The block size is 0. self._testShape([1, 2, 2, 1], [0, 1], [[0, 0], [0, 0]], ValueError) def testBlockSizeNegative(self): self._testShape([1, 2, 2, 1], [-1, 1], [[0, 0], [0, 0]], ValueError) def testNegativePadding(self): self._testShape([1, 2, 2], [1, 1], [[0, -1], [0, 0]], ValueError) def testCropTooLarge(self): # The amount to crop exceeds the padded size. self._testShape([1 * 2 * 2, 2, 3, 1], [2, 2], [[3, 2], [0, 0]], ValueError) def testBlockSizeSquaredNotDivisibleBatch(self): # The batch dimension is not divisible by the product of the block_shape. self._testShape([3, 1, 1, 1], [2, 3], [[0, 0], [0, 0]], ValueError) def testUnknownShape(self): # Verify that input shape and paddings shape can be unknown. _ = tf.batch_to_space_nd( tf.placeholder(tf.float32), tf.placeholder(tf.int32, shape=(2,)), tf.placeholder(tf.int32)) # Only number of input dimensions is known. t = tf.batch_to_space_nd( tf.placeholder(tf.float32, shape=(None, None, None, None)), tf.placeholder(tf.int32, shape=(2,)), tf.placeholder(tf.int32)) self.assertEqual(4, t.get_shape().ndims) # Dimensions are partially known. t = tf.batch_to_space_nd( tf.placeholder(tf.float32, shape=(None, None, None, 2)), tf.placeholder(tf.int32, shape=(2,)), tf.placeholder(tf.int32)) self.assertEqual([None, None, None, 2], t.get_shape().as_list()) # Dimensions are partially known. t = tf.batch_to_space_nd( tf.placeholder(tf.float32, shape=(3 * 2 * 3, None, None, 2)), [2, 3], tf.placeholder(tf.int32)) self.assertEqual([3, None, None, 2], t.get_shape().as_list()) # Dimensions are partially known. t = tf.batch_to_space_nd( tf.placeholder(tf.float32, shape=(3 * 2 * 3, None, 2, 2)), [2, 3], [[1, 1], [0, 1]]) self.assertEqual([3, None, 5, 2], t.get_shape().as_list()) # Dimensions are fully known. t = tf.batch_to_space_nd( tf.placeholder(tf.float32, shape=(3 * 2 * 3, 2, 1, 2)), [2, 3], [[1, 1], [0, 0]]) self.assertEqual([3, 2, 3, 2], t.get_shape().as_list()) class BatchToSpaceGradientTest(tf.test.TestCase, PythonOpImpl): # Check the gradients. def _checkGrad(self, x, crops, block_size): assert 4 == x.ndim with self.test_session(): tf_x = tf.convert_to_tensor(x) tf_y = self.batch_to_space(tf_x, crops, block_size) epsilon = 1e-5 ((x_jacob_t, x_jacob_n)) = tf.test.compute_gradient( tf_x, x.shape, tf_y, tf_y.get_shape().as_list(), x_init_value=x, delta=epsilon) self.assertAllClose(x_jacob_t, x_jacob_n, rtol=1e-2, atol=epsilon) # Tests a gradient for batch_to_space of x which is a four dimensional # tensor of shape [b * block_size * block_size, h, w, d]. def _compare(self, b, h, w, d, block_size, crop_beg, crop_end): block_size_sq = block_size * block_size x = np.random.normal(0, 1, b * h * w * d * block_size_sq).astype(np.float32).reshape( [b * block_size * block_size, h, w, d]) crops = np.array([[crop_beg, crop_end], [crop_beg, crop_end]], dtype=np.int32) self._checkGrad(x, crops, block_size) # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. def testSmall(self): block_size = 2 crop_beg = 0 crop_end = 0 self._compare(1, 2, 3, 5, block_size, crop_beg, crop_end) def testSmall2(self): block_size = 2 crop_beg = 0 crop_end = 0 self._compare(2, 4, 3, 2, block_size, crop_beg, crop_end) def testSmallCrop1x1(self): block_size = 2 crop_beg = 1 crop_end = 1 self._compare(1, 2, 3, 5, block_size, crop_beg, crop_end) class BatchToSpaceGradientCppTest(BatchToSpaceGradientTest, CppOpImpl): pass class BatchToSpaceNDGradientTest(tf.test.TestCase): # Check the gradients. def _checkGrad(self, x, block_shape, crops): block_shape = np.array(block_shape) crops = np.array(crops).reshape((len(block_shape), 2)) with self.test_session(): tf_x = tf.convert_to_tensor(x) tf_y = tf.batch_to_space_nd(tf_x, block_shape, crops) epsilon = 1e-5 ((x_jacob_t, x_jacob_n)) = tf.test.compute_gradient( tf_x, x.shape, tf_y, tf_y.get_shape().as_list(), x_init_value=x, delta=epsilon) self.assertAllClose(x_jacob_t, x_jacob_n, rtol=1e-2, atol=epsilon) def _compare(self, input_shape, block_shape, crops): input_shape = list(input_shape) input_shape[0] *= np.prod(block_shape) x = np.random.normal( 0, 1, np.prod(input_shape)).astype(np.float32).reshape(input_shape) self._checkGrad(x, block_shape, crops) # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. def testSmall(self): self._compare([1, 2, 3, 5], [2, 2], [[0, 0], [0, 0]]) def testSmall2(self): self._compare([2, 4, 3, 2], [2, 2], [[0, 0], [0, 0]]) def testSmallCrop1x1(self): self._compare([1, 2, 3, 5], [2, 2], [[1, 1], [1, 1]]) if __name__ == "__main__": tf.test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3481, 279, 2295, 367, 17206, 1378, 7643, 1687, 14, 199, 199, 8824, 2295, 787, 5120, 315, 4601, 475, 2912, 63, 411, 63, 396, 14, 647, 12, 2382, 314, 17206, 1378, 7643, 199, 411, 365, 12470, 315, 20162, 23522, 543, 2399, 3837, 19326, 1378, 8842, 1687, 14, 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, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 421, 199, 533, 2018, 4619, 4748, 8, 785, 304, 819, 768, 4639, 523, 347, 3522, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 304, 272, 372, 2833, 14, 2912, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 445, 802, 4619, 4748, 8, 785, 304, 819, 768, 4639, 523, 347, 3522, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 304, 272, 372, 3805, 63, 1144, 63, 1483, 423, 2912, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 17206, 1378, 7643, 14125, 1378, 7643, 8, 3249, 14, 396, 14, 1746, 12, 2018, 4619, 4748, 304, 819, 327, 26114, 626, 26, 3522, 63, 475, 63, 2638, 8, 88, 9, 275, 16992, 8, 4631, 63, 475, 63, 2638, 8, 10483, 8, 88, 1724, 523, 347, 511, 14125, 1378, 7643, 3188, 4070, 8, 277, 304, 272, 671, 275, 980, 14, 5605, 8, 1165, 627, 959, 627, 1695, 627, 1520, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 779, 1165, 12, 959, 12, 1695, 12, 1520, 566, 272, 1853, 63, 890, 275, 499, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 612, 17, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 12, 286, 26307, 12, 1853, 63, 890, 29, 1457, 63, 890, 9, 272, 612, 18, 275, 2833, 14, 10483, 8, 267, 2833, 14, 4631, 63, 475, 63, 2638, 8, 288, 2833, 14, 10483, 8, 88, 12, 359, 19, 12, 413, 12, 499, 12, 378, 2522, 288, 1853, 63, 890, 29, 1457, 63, 890, 395, 359, 19, 12, 413, 12, 499, 12, 378, 566, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7069, 8, 89, 17, 14, 2579, 1062, 612, 18, 14, 2579, 1012, 421, 199, 533, 17206, 1378, 7643, 14125, 1378, 7643, 19705, 8, 8842, 1378, 7643, 14125, 1378, 7643, 12, 445, 802, 4619, 4748, 304, 523, 986, 421, 199, 533, 17206, 1378, 7643, 547, 26443, 774, 8, 3249, 14, 396, 14, 1746, 12, 2018, 4619, 4748, 304, 819, 347, 511, 3205, 14858, 19156, 7718, 8842, 8, 277, 304, 272, 327, 710, 1324, 365, 4124, 314, 1642, 6240, 1689, 2912, 531, 272, 671, 63, 1590, 275, 19819, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 20737, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 499, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 485, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 819, 347, 511, 29843, 16, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 378, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 378, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 4395, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 413, 14, 710, 1853, 1568, 4839, 370, 506, 690, 413, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 413, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 44, 285, 836, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 4634, 7031, 367, 642, 1324, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 1616, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 51, 30458, 1763, 1341, 6604, 8842, 8, 277, 304, 272, 327, 710, 1853, 1568, 20478, 1630, 440, 23003, 314, 3522, 14, 272, 671 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3481, 279, 2295, 367, 17206, 1378, 7643, 1687, 14, 199, 199, 8824, 2295, 787, 5120, 315, 4601, 475, 2912, 63, 411, 63, 396, 14, 647, 12, 2382, 314, 17206, 1378, 7643, 199, 411, 365, 12470, 315, 20162, 23522, 543, 2399, 3837, 19326, 1378, 8842, 1687, 14, 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, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 1144, 63, 1483, 421, 199, 533, 2018, 4619, 4748, 8, 785, 304, 819, 768, 4639, 523, 347, 3522, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 304, 272, 372, 2833, 14, 2912, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 445, 802, 4619, 4748, 8, 785, 304, 819, 768, 4639, 523, 347, 3522, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 304, 272, 372, 3805, 63, 1144, 63, 1483, 423, 2912, 63, 475, 63, 2638, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 17206, 1378, 7643, 14125, 1378, 7643, 8, 3249, 14, 396, 14, 1746, 12, 2018, 4619, 4748, 304, 819, 327, 26114, 626, 26, 3522, 63, 475, 63, 2638, 8, 88, 9, 275, 16992, 8, 4631, 63, 475, 63, 2638, 8, 10483, 8, 88, 1724, 523, 347, 511, 14125, 1378, 7643, 3188, 4070, 8, 277, 304, 272, 671, 275, 980, 14, 5605, 8, 1165, 627, 959, 627, 1695, 627, 1520, 12, 2152, 29, 1590, 14, 1609, 708, 680, 5217, 779, 1165, 12, 959, 12, 1695, 12, 1520, 566, 272, 1853, 63, 890, 275, 499, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 612, 17, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 12, 286, 26307, 12, 1853, 63, 890, 29, 1457, 63, 890, 9, 272, 612, 18, 275, 2833, 14, 10483, 8, 267, 2833, 14, 4631, 63, 475, 63, 2638, 8, 288, 2833, 14, 10483, 8, 88, 12, 359, 19, 12, 413, 12, 499, 12, 378, 2522, 288, 1853, 63, 890, 29, 1457, 63, 890, 395, 359, 19, 12, 413, 12, 499, 12, 378, 566, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7069, 8, 89, 17, 14, 2579, 1062, 612, 18, 14, 2579, 1012, 421, 199, 533, 17206, 1378, 7643, 14125, 1378, 7643, 19705, 8, 8842, 1378, 7643, 14125, 1378, 7643, 12, 445, 802, 4619, 4748, 304, 523, 986, 421, 199, 533, 17206, 1378, 7643, 547, 26443, 774, 8, 3249, 14, 396, 14, 1746, 12, 2018, 4619, 4748, 304, 819, 347, 511, 3205, 14858, 19156, 7718, 8842, 8, 277, 304, 272, 327, 710, 1324, 365, 4124, 314, 1642, 6240, 1689, 2912, 531, 272, 671, 63, 1590, 275, 19819, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 20737, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 499, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 485, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 819, 347, 511, 29843, 16, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 378, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 378, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 4395, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 413, 14, 710, 1853, 1568, 4839, 370, 506, 690, 413, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 413, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 44, 285, 836, 8, 277, 304, 272, 327, 710, 1853, 1568, 365, 4634, 7031, 367, 642, 1324, 14, 272, 671, 63, 1590, 275, 3474, 9046, 17, 467, 359, 18, 2365, 3474, 19, 467, 359, 20, 2677, 2677, 272, 286, 26307, 275, 980, 14, 4250, 1332, 18, 12, 499, 395, 2152, 29, 1590, 14, 442, 708, 9, 272, 1853, 63, 890, 275, 1616, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 734, 63, 3249, 275, 291, 14, 2912, 63, 475, 63, 2638, 8, 88, 63, 1590, 12, 286, 26307, 12, 1853, 63, 890, 9, 489, 734, 63, 3249, 14, 2579, 342, 819, 347, 511, 29843, 51, 30458, 1763, 1341, 6604, 8842, 8, 277, 304, 272, 327, 710, 1853, 1568, 20478, 1630, 440, 23003, 314, 3522, 14, 272, 671, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
onsightit/solarcoin
share/qt/extract_strings_qt.py
95
2709
#!/usr/bin/env python # Copyright (c) 2012-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' Extract _("...") strings for translation and convert to Qt stringdefs so that they can be picked up by Qt linguist. ''' from __future__ import division,print_function,unicode_literals from subprocess import Popen, PIPE import operator import os import sys OUT_CPP="qt/bitcoinstrings.cpp" EMPTY=['""'] def parse_po(text): """ Parse 'po' format produced by xgettext. Return a list of (msgid,msgstr) tuples. """ messages = [] msgid = [] msgstr = [] in_msgid = False in_msgstr = False for line in text.split('\n'): line = line.rstrip('\r') if line.startswith('msgid '): if in_msgstr: messages.append((msgid, msgstr)) in_msgstr = False # message start in_msgid = True msgid = [line[6:]] elif line.startswith('msgstr '): in_msgid = False in_msgstr = True msgstr = [line[7:]] elif line.startswith('"'): if in_msgid: msgid.append(line) if in_msgstr: msgstr.append(line) if in_msgstr: messages.append((msgid, msgstr)) return messages files = sys.argv[1:] # xgettext -n --keyword=_ $FILES XGETTEXT=os.getenv('XGETTEXT', 'xgettext') if not XGETTEXT: print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr) print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr) exit(1) child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE) (out, err) = child.communicate() messages = parse_po(out.decode('utf-8')) f = open(OUT_CPP, 'w') f.write(""" #include <QtGlobal> // Automatically generated by extract_strings_qt.py #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else #define UNUSED #endif """) f.write('static const char UNUSED *bitcoin_strings[] = {\n') f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('PACKAGE_NAME'),)) f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS'),)) if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'): f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),)) messages.sort(key=operator.itemgetter(0)) for (msgid, msgstr) in messages: if msgid != EMPTY: f.write('QT_TRANSLATE_NOOP("bitcoin-core", %s),\n' % ('\n'.join(msgid))) f.write('};\n') f.close()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 13, 9261, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 12, 1361, 63, 1593, 12, 2975, 63, 5955, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 953, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 692, 440, 1323, 2970, 3876, 26, 272, 870, 360, 6612, 5536, 3326, 26, 671, 5152, 11420, 365, 440, 4903, 503, 440, 7526, 3130, 493, 29, 1274, 14, 3083, 9, 272, 870, 360, 8254, 3907, 2559, 298, 5152, 2, 436, 295, 13, 1065, 971, 1370, 15, 6472, 60, 1370, 297, 493, 29, 1274, 14, 3083, 9, 272, 4458, 8, 17, 9, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 14, 2708, 360, 1624, 13, 24, 1333, 199, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 63, 8440, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 19265, 63, 2339, 659, 430, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 659, 430, 199, 692, 747, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 358, 1137, 747, 14, 12959, 360, 19265, 63, 2339, 735, 272, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 659, 430, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 13, 9261, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 12, 1361, 63, 1593, 12, 2975, 63, 5955, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 953, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 692, 440, 1323, 2970, 3876, 26, 272, 870, 360, 6612, 5536, 3326, 26, 671, 5152, 11420, 365, 440, 4903, 503, 440, 7526, 3130, 493, 29, 1274, 14, 3083, 9, 272, 870, 360, 8254, 3907, 2559, 298, 5152, 2, 436, 295, 13, 1065, 971, 1370, 15, 6472, 60, 1370, 297, 493, 29, 1274, 14, 3083, 9, 272, 4458, 8, 17, 9, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 14, 2708, 360, 1624, 13, 24, 1333, 199, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 63, 8440, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 19265, 63, 2339, 659, 430, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 659, 430, 199, 692, 747, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 358, 1137, 747, 14, 12959, 360, 19265, 63, 2339, 735, 272, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 659, 430, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aniavasq/uncertaintyServerComponentsKUL
dispatcher.py
1
4477
############################################################################### # MIT License (MIT) # # Copyright (c) # # 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. # ############################################################################### from fe_process import * from json import dumps as json_dumps from clusterer import AcademicClusterer from classifier_estimator import AcademicFailureEstimator def get_structures( programs_path='./data/_cs_program.txt', core_courses_path='./data/_cs_courses.txt', conval_dict_path='./data/_conval_dict.txt', factors_dict_path='./data/_cs_factors.txt', program='Computer Science' ): _PROGRAM = data_structure_from_file(programs_path) _COURSES = data_structure_from_file(core_courses_path) _CONVALD = data_structure_from_file(conval_dict_path) _FACTORS = data_structure_from_file(factors_dict_path) _STUDENTS = population_IDs_by_program( data_loader.co_df, _PROGRAM ) structures_d = {'_programs':_PROGRAM, 'core_courses':_COURSES, 'conval_dict':_CONVALD, 'factors_dict':_FACTORS, 'population_IDs':_STUDENTS, } return structures_d class WSDispatcher(): _structures = None """ """ def __init__(self): self._structures = get_structures() self.academic_clusterer = AcademicClusterer( self._structures['core_courses'], self._structures['conval_dict'], self._structures['factors_dict'], self._structures['_programs'] ) self._start_year = -1 self._end_year = 1 self.init_estimator() def init_estimator(self): self.academic_estimator = AcademicFailureEstimator(self.academic_clusterer) self.academic_estimator.init_semesters_classifier_fn() self.academic_estimator.init_students_classifier_fn() @property def structures(self): return self._structures """ """ @property def students(self): return json_dumps( list( self.structures['population_IDs'] ) ) """ """ def risk(self, json_input): try: _root = json_input semester = [course['id'] for course in _root['courses']] student_ID = int( _root['student'][0]['id'] ) start_year = _root['data'][0]['from'] end_year = _root['data'][0]['to'] if self._start_year != start_year or self._end_year != end_year: self._start_year = start_year self._end_year = end_year self.academic_clusterer.set_ha_df(start_year=start_year, end_year=end_year) self.init_estimator() #print(self.academic_clusterer.rates) risk, quality = self.academic_estimator.predict( student_ID=student_ID, semester=semester ) except: import traceback traceback.print_exc() risk, quality = (0,0) return json_dumps( {'risk':risk,'quality':quality} )
mit
[ 11490, 199, 3, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 504, 1964, 63, 1412, 492, 627, 199, 504, 2022, 492, 16864, 465, 2022, 63, 4180, 199, 504, 824, 527, 266, 3859, 492, 437, 9490, 15003, 1968, 527, 266, 3859, 199, 504, 12429, 63, 8627, 492, 437, 9490, 15003, 6782, 13183, 199, 199, 318, 664, 63, 13547, 8, 18572, 63, 515, 534, 13186, 576, 15607, 1259, 63, 6815, 14, 2424, 297, 490, 6170, 63, 11653, 63, 515, 534, 13186, 576, 15607, 1259, 63, 11653, 14, 2424, 297, 490, 406, 637, 63, 807, 63, 515, 534, 13186, 576, 15607, 388, 637, 63, 807, 14, 2424, 297, 490, 17704, 63, 807, 63, 515, 534, 13186, 576, 15607, 1259, 63, 16125, 14, 2424, 297, 490, 2240, 534, 2404, 2699, 27491, 7, 3461, 272, 485, 15605, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 28464, 63, 515, 9, 272, 485, 1439, 28746, 654, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 1018, 63, 11653, 63, 515, 9, 272, 485, 1864, 3204, 36, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 388, 637, 63, 807, 63, 515, 9, 272, 485, 18164, 4149, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 16125, 63, 807, 63, 515, 9, 272, 485, 840, 29317, 51, 275, 16423, 63, 12818, 63, 991, 63, 6815, 8, 666, 63, 3422, 14, 331, 63, 1587, 12, 485, 15605, 776, 2286, 13955, 63, 68, 275, 32136, 28464, 356, 63, 15605, 12, 490, 283, 1018, 63, 11653, 356, 63, 1439, 28746, 654, 12, 490, 283, 388, 637, 63, 807, 356, 63, 1864, 3204, 36, 12, 490, 283, 16125, 63, 807, 356, 63, 18164, 4149, 12, 490, 283, 16003, 63, 12818, 356, 63, 840, 29317, 51, 12, 490, 789, 14821, 372, 13955, 63, 68, 1362, 199, 533, 644, 51, 15461, 837, 339, 485, 13547, 275, 488, 2286, 408, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 13547, 275, 664, 63, 13547, 342, 2728, 291, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 275, 437, 9490, 15003, 1968, 527, 266, 3859, 8, 291, 423, 13547, 459, 1018, 63, 11653, 995, 9349, 291, 423, 13547, 459, 388, 637, 63, 807, 995, 9349, 291, 423, 13547, 459, 16125, 63, 807, 995, 221, 9349, 291, 423, 13547, 8680, 28464, 418, 776, 267, 291, 423, 928, 63, 3403, 275, 446, 17, 4960, 291, 423, 500, 63, 3403, 275, 413, 2728, 291, 14, 826, 63, 8627, 342, 5493, 347, 4205, 63, 8627, 8, 277, 304, 267, 291, 14, 645, 9587, 15003, 63, 8627, 275, 437, 9490, 15003, 6782, 13183, 8, 277, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 9, 267, 291, 14, 645, 9587, 15003, 63, 8627, 14, 826, 63, 261, 6415, 878, 63, 14720, 63, 2324, 342, 267, 291, 14, 645, 9587, 15003, 63, 8627, 14, 826, 63, 17921, 63, 14720, 63, 2324, 342, 5493, 768, 1829, 272, 347, 13955, 8, 277, 304, 267, 372, 291, 423, 13547, 2286, 408, 272, 408, 272, 768, 1829, 272, 347, 18557, 8, 277, 304, 267, 372, 2022, 63, 4180, 8, 769, 8, 291, 14, 13547, 459, 16003, 63, 12818, 418, 776, 776, 2286, 408, 272, 408, 272, 347, 22633, 8, 277, 12, 2022, 63, 1210, 304, 267, 862, 26, 288, 485, 1231, 275, 2022, 63, 1210, 288, 542, 6415, 351, 275, 359, 1972, 459, 344, 418, 221, 367, 2518, 315, 485, 1231, 459, 11653, 6538, 288, 6474, 63, 998, 275, 1109, 8, 485, 1231, 459, 5500, 3488, 16, 2733, 344, 418, 776, 7846, 1343, 63, 3403, 275, 485, 1231, 459, 576, 3488, 16, 2733, 504, 418, 288, 1284, 63, 3403, 275, 485, 1231, 459, 576, 3488, 16, 2733, 475, 418, 288, 340, 291, 423, 928, 63, 3403, 1137, 1343, 63, 3403, 503, 291, 423, 500, 63, 3403, 1137, 1284, 63, 3403, 26, 355, 291, 423, 928, 63, 3403, 275, 1343, 63, 3403, 355, 291, 423, 500, 63, 3403, 275, 1284, 63, 3403, 355, 291, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 14, 409, 63, 2411, 63, 1587, 8, 928, 63, 3403, 29, 928, 63, 3403, 12, 1284, 63, 3403, 29, 500, 63, 3403, 9, 355, 291, 14, 826, 63, 8627, 342, 355, 327, 1361, 8, 277, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 14, 17153, 9, 326, 7846, 22633, 12, 11030, 275, 291, 14, 645, 9587, 15003, 63, 8627, 14, 6892, 8, 6474, 63, 998, 29, 5500, 63, 998, 12, 18193, 542, 6415, 351, 29, 261, 6415, 351, 18193, 776, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 22633, 12, 11030, 275, 334, 16, 12, 16, 9, 267, 372, 2022, 63, 4180, 8, 791, 27473, 356, 27473, 2584, 9161, 356, 9161, 93, 776, 27844, 32768, 32768, 32768 ]
[ 199, 3, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 504, 1964, 63, 1412, 492, 627, 199, 504, 2022, 492, 16864, 465, 2022, 63, 4180, 199, 504, 824, 527, 266, 3859, 492, 437, 9490, 15003, 1968, 527, 266, 3859, 199, 504, 12429, 63, 8627, 492, 437, 9490, 15003, 6782, 13183, 199, 199, 318, 664, 63, 13547, 8, 18572, 63, 515, 534, 13186, 576, 15607, 1259, 63, 6815, 14, 2424, 297, 490, 6170, 63, 11653, 63, 515, 534, 13186, 576, 15607, 1259, 63, 11653, 14, 2424, 297, 490, 406, 637, 63, 807, 63, 515, 534, 13186, 576, 15607, 388, 637, 63, 807, 14, 2424, 297, 490, 17704, 63, 807, 63, 515, 534, 13186, 576, 15607, 1259, 63, 16125, 14, 2424, 297, 490, 2240, 534, 2404, 2699, 27491, 7, 3461, 272, 485, 15605, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 28464, 63, 515, 9, 272, 485, 1439, 28746, 654, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 1018, 63, 11653, 63, 515, 9, 272, 485, 1864, 3204, 36, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 388, 637, 63, 807, 63, 515, 9, 272, 485, 18164, 4149, 275, 666, 63, 6976, 63, 504, 63, 493, 8, 16125, 63, 807, 63, 515, 9, 272, 485, 840, 29317, 51, 275, 16423, 63, 12818, 63, 991, 63, 6815, 8, 666, 63, 3422, 14, 331, 63, 1587, 12, 485, 15605, 776, 2286, 13955, 63, 68, 275, 32136, 28464, 356, 63, 15605, 12, 490, 283, 1018, 63, 11653, 356, 63, 1439, 28746, 654, 12, 490, 283, 388, 637, 63, 807, 356, 63, 1864, 3204, 36, 12, 490, 283, 16125, 63, 807, 356, 63, 18164, 4149, 12, 490, 283, 16003, 63, 12818, 356, 63, 840, 29317, 51, 12, 490, 789, 14821, 372, 13955, 63, 68, 1362, 199, 533, 644, 51, 15461, 837, 339, 485, 13547, 275, 488, 2286, 408, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 13547, 275, 664, 63, 13547, 342, 2728, 291, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 275, 437, 9490, 15003, 1968, 527, 266, 3859, 8, 291, 423, 13547, 459, 1018, 63, 11653, 995, 9349, 291, 423, 13547, 459, 388, 637, 63, 807, 995, 9349, 291, 423, 13547, 459, 16125, 63, 807, 995, 221, 9349, 291, 423, 13547, 8680, 28464, 418, 776, 267, 291, 423, 928, 63, 3403, 275, 446, 17, 4960, 291, 423, 500, 63, 3403, 275, 413, 2728, 291, 14, 826, 63, 8627, 342, 5493, 347, 4205, 63, 8627, 8, 277, 304, 267, 291, 14, 645, 9587, 15003, 63, 8627, 275, 437, 9490, 15003, 6782, 13183, 8, 277, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 9, 267, 291, 14, 645, 9587, 15003, 63, 8627, 14, 826, 63, 261, 6415, 878, 63, 14720, 63, 2324, 342, 267, 291, 14, 645, 9587, 15003, 63, 8627, 14, 826, 63, 17921, 63, 14720, 63, 2324, 342, 5493, 768, 1829, 272, 347, 13955, 8, 277, 304, 267, 372, 291, 423, 13547, 2286, 408, 272, 408, 272, 768, 1829, 272, 347, 18557, 8, 277, 304, 267, 372, 2022, 63, 4180, 8, 769, 8, 291, 14, 13547, 459, 16003, 63, 12818, 418, 776, 776, 2286, 408, 272, 408, 272, 347, 22633, 8, 277, 12, 2022, 63, 1210, 304, 267, 862, 26, 288, 485, 1231, 275, 2022, 63, 1210, 288, 542, 6415, 351, 275, 359, 1972, 459, 344, 418, 221, 367, 2518, 315, 485, 1231, 459, 11653, 6538, 288, 6474, 63, 998, 275, 1109, 8, 485, 1231, 459, 5500, 3488, 16, 2733, 344, 418, 776, 7846, 1343, 63, 3403, 275, 485, 1231, 459, 576, 3488, 16, 2733, 504, 418, 288, 1284, 63, 3403, 275, 485, 1231, 459, 576, 3488, 16, 2733, 475, 418, 288, 340, 291, 423, 928, 63, 3403, 1137, 1343, 63, 3403, 503, 291, 423, 500, 63, 3403, 1137, 1284, 63, 3403, 26, 355, 291, 423, 928, 63, 3403, 275, 1343, 63, 3403, 355, 291, 423, 500, 63, 3403, 275, 1284, 63, 3403, 355, 291, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 14, 409, 63, 2411, 63, 1587, 8, 928, 63, 3403, 29, 928, 63, 3403, 12, 1284, 63, 3403, 29, 500, 63, 3403, 9, 355, 291, 14, 826, 63, 8627, 342, 355, 327, 1361, 8, 277, 14, 645, 9587, 15003, 63, 429, 527, 266, 3859, 14, 17153, 9, 326, 7846, 22633, 12, 11030, 275, 291, 14, 645, 9587, 15003, 63, 8627, 14, 6892, 8, 6474, 63, 998, 29, 5500, 63, 998, 12, 18193, 542, 6415, 351, 29, 261, 6415, 351, 18193, 776, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 22633, 12, 11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 1, 1, 1, 1, 1, 1, 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 ]
bikong2/django
django/template/exceptions.py
483
1392
""" This module contains generic exceptions used by template backends. Although, due to historical reasons, the Django template language also internally uses these exceptions, other exceptions specific to the DTL should not be added here. """ class TemplateDoesNotExist(Exception): """ The exception used when a template does not exist. Accepts the following optional arguments: backend The template backend class used when raising this exception. tried A list of sources that were tried when finding the template. This is formatted as a list of tuples containing (origin, status), where origin is an Origin object or duck type and status is a string with the reason the template wasn't found. chain A list of intermediate TemplateDoesNotExist exceptions. This is used to encapsulate multiple exceptions when loading templates from multiple engines. """ def __init__(self, msg, tried=None, backend=None, chain=None): self.backend = backend if tried is None: tried = [] self.tried = tried if chain is None: chain = [] self.chain = chain super(TemplateDoesNotExist, self).__init__(msg) class TemplateSyntaxError(Exception): """ The exception used for syntax errors during parsing or rendering. """ pass
bsd-3-clause
[ 624, 199, 2765, 859, 3509, 7809, 4967, 1202, 701, 1978, 14745, 14, 4580, 15401, 12, 199, 11933, 370, 32530, 14872, 12, 314, 5634, 1978, 2637, 2597, 14448, 4440, 199, 29032, 4967, 12, 1163, 4967, 2488, 370, 314, 577, 7308, 1077, 440, 506, 3483, 199, 1681, 14, 199, 624, 421, 199, 533, 27193, 8, 1726, 304, 272, 408, 272, 710, 1919, 1202, 1380, 282, 1978, 1630, 440, 2187, 14, 15506, 83, 314, 2569, 272, 2716, 2368, 26, 339, 4865, 267, 710, 1978, 4865, 1021, 1202, 1380, 17026, 642, 1919, 14, 339, 16416, 267, 437, 769, 402, 5274, 626, 4898, 16416, 1380, 17196, 314, 1978, 14, 961, 267, 365, 7871, 465, 282, 769, 402, 6346, 3035, 334, 6493, 12, 2004, 395, 2382, 267, 6330, 365, 376, 31534, 909, 503, 366, 10112, 730, 436, 2004, 365, 282, 1059, 543, 314, 267, 4499, 314, 1978, 17373, 1133, 1911, 14, 339, 6036, 267, 437, 769, 402, 13197, 27193, 4967, 14, 961, 365, 1202, 370, 267, 22667, 5434, 3663, 4967, 1380, 8697, 7009, 687, 3663, 267, 28156, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 16416, 29, 403, 12, 4865, 29, 403, 12, 6036, 29, 403, 304, 267, 291, 14, 4620, 275, 4865, 267, 340, 16416, 365, 488, 26, 288, 16416, 275, 942, 267, 291, 14, 599, 379, 275, 16416, 267, 340, 6036, 365, 488, 26, 288, 6036, 275, 942, 267, 291, 14, 4429, 275, 6036, 267, 1613, 8, 4231, 7400, 12, 291, 2843, 826, 721, 1328, 9, 421, 199, 533, 17762, 8, 1726, 304, 272, 408, 272, 710, 1919, 1202, 367, 6302, 2552, 5309, 6057, 503, 14066, 14, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2765, 859, 3509, 7809, 4967, 1202, 701, 1978, 14745, 14, 4580, 15401, 12, 199, 11933, 370, 32530, 14872, 12, 314, 5634, 1978, 2637, 2597, 14448, 4440, 199, 29032, 4967, 12, 1163, 4967, 2488, 370, 314, 577, 7308, 1077, 440, 506, 3483, 199, 1681, 14, 199, 624, 421, 199, 533, 27193, 8, 1726, 304, 272, 408, 272, 710, 1919, 1202, 1380, 282, 1978, 1630, 440, 2187, 14, 15506, 83, 314, 2569, 272, 2716, 2368, 26, 339, 4865, 267, 710, 1978, 4865, 1021, 1202, 1380, 17026, 642, 1919, 14, 339, 16416, 267, 437, 769, 402, 5274, 626, 4898, 16416, 1380, 17196, 314, 1978, 14, 961, 267, 365, 7871, 465, 282, 769, 402, 6346, 3035, 334, 6493, 12, 2004, 395, 2382, 267, 6330, 365, 376, 31534, 909, 503, 366, 10112, 730, 436, 2004, 365, 282, 1059, 543, 314, 267, 4499, 314, 1978, 17373, 1133, 1911, 14, 339, 6036, 267, 437, 769, 402, 13197, 27193, 4967, 14, 961, 365, 1202, 370, 267, 22667, 5434, 3663, 4967, 1380, 8697, 7009, 687, 3663, 267, 28156, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 16416, 29, 403, 12, 4865, 29, 403, 12, 6036, 29, 403, 304, 267, 291, 14, 4620, 275, 4865, 267, 340, 16416, 365, 488, 26, 288, 16416, 275, 942, 267, 291, 14, 599, 379, 275, 16416, 267, 340, 6036, 365, 488, 26, 288, 6036, 275, 942, 267, 291, 14, 4429, 275, 6036, 267, 1613, 8, 4231, 7400, 12, 291, 2843, 826, 721, 1328, 9, 421, 199, 533, 17762, 8, 1726, 304, 272, 408, 272, 710, 1919, 1202, 367, 6302, 2552, 5309, 6057, 503, 14066, 14, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AkA84/edx-platform
common/lib/xmodule/xmodule/modulestore/xml.py
25
41945
import hashlib import itertools import json import logging import os import re import sys import glob from collections import defaultdict from cStringIO import StringIO from fs.osfs import OSFS from importlib import import_module from lxml import etree from path import path from contextlib import contextmanager from lazy import lazy from xmodule.error_module import ErrorDescriptor from xmodule.errortracker import make_error_tracker, exc_info_to_str from xmodule.mako_module import MakoDescriptorSystem from xmodule.x_module import ( XMLParsingSystem, policy_key, OpaqueKeyReader, AsideKeyGenerator, DEPRECATION_VSCOMPAT_EVENT ) from xmodule.modulestore.xml_exporter import DEFAULT_CONTENT_FIELDS from xmodule.modulestore import ModuleStoreEnum, ModuleStoreReadBase, LIBRARY_ROOT, COURSE_ROOT from xmodule.tabs import CourseTabList from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location from opaque_keys.edx.locator import CourseLocator, LibraryLocator from xblock.field_data import DictFieldData from xblock.runtime import DictKeyValueStore from xblock.fields import ScopeIds import dogstats_wrapper as dog_stats_api from .exceptions import ItemNotFoundError from .inheritance import compute_inherited_metadata, inheriting_field_data, InheritanceKeyValueStore edx_xml_parser = etree.XMLParser(dtd_validation=False, load_dtd=False, remove_comments=True, remove_blank_text=True) etree.set_default_parser(edx_xml_parser) log = logging.getLogger(__name__) # VS[compat] # TODO (cpennington): Remove this once all fall 2012 courses have been imported # into the cms from xml def clean_out_mako_templating(xml_string): orig_xml = xml_string xml_string = xml_string.replace('%include', 'include') xml_string = re.sub(r"(?m)^\s*%.*$", '', xml_string) if orig_xml != xml_string: dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=["location:xml_clean_out_mako_templating"] ) return xml_string class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): def __init__(self, xmlstore, course_id, course_dir, error_tracker, load_error_modules=True, target_course_id=None, **kwargs): """ A class that handles loading from xml. Does some munging to ensure that all elements have unique slugs. xmlstore: the XMLModuleStore to store the loaded modules in """ self.unnamed = defaultdict(int) # category -> num of new url_names for that category self.used_names = defaultdict(set) # category -> set of used url_names # Adding the course_id as passed in for later reference rather than # having to recombine the org/course/url_name self.course_id = course_id self.load_error_modules = load_error_modules self.modulestore = xmlstore def process_xml(xml): """Takes an xml string, and returns a XBlock created from that xml. """ def make_name_unique(xml_data): """ Make sure that the url_name of xml_data is unique. If a previously loaded unnamed descriptor stole this element's url_name, create a new one. Removes 'slug' attribute if present, and adds or overwrites the 'url_name' attribute. """ # VS[compat]. Take this out once course conversion is done (perhaps leave the uniqueness check) # tags that really need unique names--they store (or should store) state. need_uniq_names = ('problem', 'sequential', 'video', 'course', 'chapter', 'videosequence', 'poll_question', 'vertical') attr = xml_data.attrib tag = xml_data.tag id = lambda x: x # Things to try to get a name, in order (key, cleaning function, remove key after reading?) lookups = [('url_name', id, False), ('slug', id, True), ('name', Location.clean, False), ('display_name', Location.clean, False)] url_name = None for key, clean, remove in lookups: if key in attr: url_name = clean(attr[key]) if remove: del attr[key] break def looks_like_fallback(url_name): """Does this look like something that came from fallback_name()?""" return (url_name is not None and url_name.startswith(tag) and re.search('[0-9a-fA-F]{12}$', url_name)) def fallback_name(orig_name=None): """Return the fallback name for this module. This is a function instead of a variable because we want it to be lazy.""" dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=( "location:import_system_fallback_name", u"name:{}".format(orig_name), ) ) if looks_like_fallback(orig_name): # We're about to re-hash, in case something changed, so get rid of the tag_ and hash orig_name = orig_name[len(tag) + 1:-12] # append the hash of the content--the first 12 bytes should be plenty. orig_name = "_" + orig_name if orig_name not in (None, "") else "" xml_bytes = xml.encode('utf8') return tag + orig_name + "_" + hashlib.sha1(xml_bytes).hexdigest()[:12] # Fallback if there was nothing we could use: if url_name is None or url_name == "": url_name = fallback_name() # Don't log a warning--we don't need this in the log. Do # put it in the error tracker--content folks need to see it. if tag in need_uniq_names: error_tracker(u"PROBLEM: no name of any kind specified for {tag}. Student " u"state will not be properly tracked for this module. Problem xml:" u" '{xml}...'".format(tag=tag, xml=xml[:100])) else: # TODO (vshnayder): We may want to enable this once course repos are cleaned up. # (or we may want to give up on the requirement for non-state-relevant issues...) # error_tracker("WARNING: no name specified for module. xml='{0}...'".format(xml[:100])) pass # Make sure everything is unique if url_name in self.used_names[tag]: # Always complain about modules that store state. If it # doesn't store state, don't complain about things that are # hashed. if tag in need_uniq_names: msg = (u"Non-unique url_name in xml. This may break state tracking for content." u" url_name={0}. Content={1}".format(url_name, xml[:100])) error_tracker("PROBLEM: " + msg) log.warning(msg) # Just set name to fallback_name--if there are multiple things with the same fallback name, # they are actually identical, so it's fragile, but not immediately broken. # TODO (vshnayder): if the tag is a pointer tag, this will # break the content because we won't have the right link. # That's also a legitimate attempt to reuse the same content # from multiple places. Once we actually allow that, we'll # need to update this to complain about non-unique names for # definitions, but allow multiple uses. url_name = fallback_name(url_name) self.used_names[tag].add(url_name) xml_data.set('url_name', url_name) try: # VS[compat] # TODO (cpennington): Remove this once all fall 2012 courses # have been imported into the cms from xml xml = clean_out_mako_templating(xml) xml_data = etree.fromstring(xml) make_name_unique(xml_data) descriptor = self.xblock_from_node( xml_data, None, # parent_id id_manager, ) except Exception as err: # pylint: disable=broad-except if not self.load_error_modules: raise # Didn't load properly. Fall back on loading as an error # descriptor. This should never error due to formatting. msg = "Error loading from xml. %s" log.warning( msg, unicode(err)[:200], # Normally, we don't want lots of exception traces in our logs from common # content problems. But if you're debugging the xml loading code itself, # uncomment the next line. # exc_info=True ) msg = msg % (unicode(err)[:200]) self.error_tracker(msg) err_msg = msg + "\n" + exc_info_to_str(sys.exc_info()) descriptor = ErrorDescriptor.from_xml( xml, self, id_manager, err_msg ) descriptor.data_dir = course_dir if descriptor.scope_ids.usage_id in xmlstore.modules[course_id]: # keep the parent pointer if any but allow everything else to overwrite other_copy = xmlstore.modules[course_id][descriptor.scope_ids.usage_id] descriptor.parent = other_copy.parent if descriptor != other_copy: log.warning("%s has more than one definition", descriptor.scope_ids.usage_id) xmlstore.modules[course_id][descriptor.scope_ids.usage_id] = descriptor if descriptor.has_children: for child in descriptor.get_children(): # parent is alphabetically least if child.parent is None or child.parent > descriptor.scope_ids.usage_id: child.parent = descriptor.location child.save() # After setting up the descriptor, save any changes that we have # made to attributes on the descriptor to the underlying KeyValueStore. descriptor.save() return descriptor render_template = lambda template, context: u'' # TODO (vshnayder): we are somewhat architecturally confused in the loading code: # load_item should actually be get_instance, because it expects the course-specific # policy to be loaded. For now, just add the course_id here... def load_item(usage_key, for_parent=None): """Return the XBlock for the specified location""" return xmlstore.get_item(usage_key, for_parent=for_parent) resources_fs = OSFS(xmlstore.data_dir / course_dir) id_manager = CourseImportLocationManager(course_id, target_course_id) super(ImportSystem, self).__init__( load_item=load_item, resources_fs=resources_fs, render_template=render_template, error_tracker=error_tracker, process_xml=process_xml, id_generator=id_manager, id_reader=id_manager, **kwargs ) # id_generator is ignored, because each ImportSystem is already local to # a course, and has it's own id_generator already in place def add_node_as_child(self, block, node, id_generator): child_block = self.process_xml(etree.tostring(node)) block.children.append(child_block.scope_ids.usage_id) class CourseLocationManager(OpaqueKeyReader, AsideKeyGenerator): """ IdGenerator for Location-based definition ids and usage ids based within a course """ def __init__(self, course_id): super(CourseLocationManager, self).__init__() self.course_id = course_id self.autogen_ids = itertools.count(0) def create_usage(self, def_id): return def_id def create_definition(self, block_type, slug=None): assert block_type is not None if slug is None: slug = 'autogen_{}_{}'.format(block_type, self.autogen_ids.next()) return self.course_id.make_usage_key(block_type, slug) def get_definition_id(self, usage_id): """Retrieve the definition that a usage is derived from. Args: usage_id: The id of the usage to query Returns: The `definition_id` the usage is derived from """ return usage_id class CourseImportLocationManager(CourseLocationManager): """ IdGenerator for Location-based definition ids and usage ids based within a course, for use during course import. In addition to the functionality provided by CourseLocationManager, this class also contains the target_course_id for the course import process. Note: This is a temporary solution to workaround the fact that the from_xml method is passed the source course_id instead of the target course_id in the import process. For a more ideal solution, see https://openedx.atlassian.net/browse/MA-417 as a pending TODO. """ def __init__(self, course_id, target_course_id): super(CourseImportLocationManager, self).__init__(course_id=course_id) self.target_course_id = target_course_id class XMLModuleStore(ModuleStoreReadBase): """ An XML backed ModuleStore """ parent_xml = COURSE_ROOT def __init__( self, data_dir, default_class=None, source_dirs=None, course_ids=None, load_error_modules=True, i18n_service=None, fs_service=None, user_service=None, signal_handler=None, target_course_id=None, **kwargs # pylint: disable=unused-argument ): """ Initialize an XMLModuleStore from data_dir Args: data_dir (str): path to data directory containing the course directories default_class (str): dot-separated string defining the default descriptor class to use if none is specified in entry_points source_dirs or course_ids (list of str): If specified, the list of source_dirs or course_ids to load. Otherwise, load all courses. Note, providing both """ super(XMLModuleStore, self).__init__(**kwargs) self.data_dir = path(data_dir) self.modules = defaultdict(dict) # course_id -> dict(location -> XBlock) self.courses = {} # course_dir -> XBlock for the course self.errored_courses = {} # course_dir -> errorlog, for dirs that failed to load if course_ids is not None: course_ids = [SlashSeparatedCourseKey.from_deprecated_string(course_id) for course_id in course_ids] self.load_error_modules = load_error_modules if default_class is None: self.default_class = None else: module_path, _, class_name = default_class.rpartition('.') class_ = getattr(import_module(module_path), class_name) self.default_class = class_ # All field data will be stored in an inheriting field data. self.field_data = inheriting_field_data(kvs=DictKeyValueStore()) self.i18n_service = i18n_service self.fs_service = fs_service self.user_service = user_service # If we are specifically asked for missing courses, that should # be an error. If we are asked for "all" courses, find the ones # that have a course.xml. We sort the dirs in alpha order so we always # read things in the same order (OS differences in load order have # bitten us in the past.) if source_dirs is None: source_dirs = sorted([d for d in os.listdir(self.data_dir) if os.path.exists(self.data_dir / d / self.parent_xml)]) for course_dir in source_dirs: self.try_load_course(course_dir, course_ids, target_course_id) def try_load_course(self, course_dir, course_ids=None, target_course_id=None): ''' Load a course, keeping track of errors as we go along. If course_ids is not None, then reject the course unless its id is in course_ids. ''' # Special-case code here, since we don't have a location for the # course before it loads. # So, make a tracker to track load-time errors, then put in the right # place after the course loads and we have its location errorlog = make_error_tracker() course_descriptor = None try: course_descriptor = self.load_course(course_dir, course_ids, errorlog.tracker, target_course_id) except Exception as exc: # pylint: disable=broad-except msg = "ERROR: Failed to load courselike '{0}': {1}".format( course_dir.encode("utf-8"), unicode(exc) ) log.exception(msg) errorlog.tracker(msg) self.errored_courses[course_dir] = errorlog if course_descriptor is None: pass elif isinstance(course_descriptor, ErrorDescriptor): # Didn't load course. Instead, save the errors elsewhere. self.errored_courses[course_dir] = errorlog else: self.courses[course_dir] = course_descriptor course_descriptor.parent = None course_id = self.id_from_descriptor(course_descriptor) self._course_errors[course_id] = errorlog def __unicode__(self): ''' String representation - for debugging ''' return '<%s data_dir=%r, %d courselikes, %d modules>' % ( self.__class__.__name__, self.data_dir, len(self.courses), len(self.modules) ) @staticmethod def id_from_descriptor(descriptor): """ Grab the course ID from the descriptor """ return descriptor.id def load_policy(self, policy_path, tracker): """ Attempt to read a course policy from policy_path. If the file exists, but is invalid, log an error and return {}. If the policy loads correctly, returns the deserialized version. """ if not os.path.exists(policy_path): return {} try: with open(policy_path) as f: return json.load(f) except (IOError, ValueError) as err: msg = "ERROR: loading courselike policy from {0}".format(policy_path) tracker(msg) log.warning(msg + " " + str(err)) return {} def load_course(self, course_dir, course_ids, tracker, target_course_id=None): """ Load a course into this module store course_path: Course directory name returns a CourseDescriptor for the course """ log.debug('========> Starting courselike import from %s', course_dir) with open(self.data_dir / course_dir / self.parent_xml) as course_file: # VS[compat] # TODO (cpennington): Remove this once all fall 2012 courses have # been imported into the cms from xml course_file = StringIO(clean_out_mako_templating(course_file.read())) course_data = etree.parse(course_file, parser=edx_xml_parser).getroot() org = course_data.get('org') if org is None: msg = ("No 'org' attribute set for courselike in {dir}. " "Using default 'edx'".format(dir=course_dir)) log.warning(msg) tracker(msg) org = 'edx' # Parent XML should be something like 'library.xml' or 'course.xml' courselike_label = self.parent_xml.split('.')[0] course = course_data.get(courselike_label) if course is None: msg = ( "No '{courselike_label}' attribute set for course in {dir}." " Using default '{default}'".format( courselike_label=courselike_label, dir=course_dir, default=course_dir ) ) log.warning(msg) tracker(msg) course = course_dir url_name = course_data.get('url_name', course_data.get('slug')) if url_name: policy_dir = self.data_dir / course_dir / 'policies' / url_name policy_path = policy_dir / 'policy.json' policy = self.load_policy(policy_path, tracker) # VS[compat]: remove once courses use the policy dirs. if policy == {}: dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=( "location:xml_load_course_policy_dir", u"course:{}".format(course), ) ) old_policy_path = self.data_dir / course_dir / 'policies' / '{0}.json'.format(url_name) policy = self.load_policy(old_policy_path, tracker) else: policy = {} # VS[compat] : 'name' is deprecated, but support it for now... if course_data.get('name'): dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=( "location:xml_load_course_course_data_name", u"course:{}".format(course_data.get('course')), u"org:{}".format(course_data.get('org')), u"name:{}".format(course_data.get('name')), ) ) url_name = Location.clean(course_data.get('name')) tracker("'name' is deprecated for module xml. Please use " "display_name and url_name.") else: url_name = None course_id = self.get_id(org, course, url_name) if course_ids is not None and course_id not in course_ids: return None def get_policy(usage_id): """ Return the policy dictionary to be applied to the specified XBlock usage """ return policy.get(policy_key(usage_id), {}) services = {} if self.i18n_service: services['i18n'] = self.i18n_service if self.fs_service: services['fs'] = self.fs_service if self.user_service: services['user'] = self.user_service system = ImportSystem( xmlstore=self, course_id=course_id, course_dir=course_dir, error_tracker=tracker, load_error_modules=self.load_error_modules, get_policy=get_policy, mixins=self.xblock_mixins, default_class=self.default_class, select=self.xblock_select, field_data=self.field_data, services=services, target_course_id=target_course_id, ) course_descriptor = system.process_xml(etree.tostring(course_data, encoding='unicode')) # If we fail to load the course, then skip the rest of the loading steps if isinstance(course_descriptor, ErrorDescriptor): return course_descriptor self.content_importers(system, course_descriptor, course_dir, url_name) log.debug('========> Done with courselike import from %s', course_dir) return course_descriptor def content_importers(self, system, course_descriptor, course_dir, url_name): """ Load all extra non-course content, and calculate metadata inheritance. """ # NOTE: The descriptors end up loading somewhat bottom up, which # breaks metadata inheritance via get_children(). Instead # (actually, in addition to, for now), we do a final inheritance pass # after we have the course descriptor. compute_inherited_metadata(course_descriptor) # now import all pieces of course_info which is expected to be stored # in <content_dir>/info or <content_dir>/info/<url_name> self.load_extra_content( system, course_descriptor, 'course_info', self.data_dir / course_dir / 'info', course_dir, url_name ) # now import all static tabs which are expected to be stored in # in <content_dir>/tabs or <content_dir>/tabs/<url_name> self.load_extra_content( system, course_descriptor, 'static_tab', self.data_dir / course_dir / 'tabs', course_dir, url_name ) self.load_extra_content( system, course_descriptor, 'custom_tag_template', self.data_dir / course_dir / 'custom_tags', course_dir, url_name ) self.load_extra_content( system, course_descriptor, 'about', self.data_dir / course_dir / 'about', course_dir, url_name ) @staticmethod def get_id(org, course, url_name): """ Validate and return an ID for a course if given org, course, and url_name. """ if not url_name: raise ValueError("Can't load a course without a 'url_name' " "(or 'name') set. Set url_name.") # Have to use SlashSeparatedCourseKey here because it makes sure the same format is # always used, preventing duplicate keys. return SlashSeparatedCourseKey(org, course, url_name) def load_extra_content(self, system, course_descriptor, category, base_dir, course_dir, url_name): self._load_extra_content(system, course_descriptor, category, base_dir, course_dir) # then look in a override folder based on the course run if os.path.isdir(base_dir / url_name): self._load_extra_content(system, course_descriptor, category, base_dir / url_name, course_dir) def _import_field_content(self, course_descriptor, category, file_path): """ Import field data content for field other than 'data' or 'metadata' form json file and return field data content as dictionary """ slug, location, data_content = None, None, None try: # try to read json file # file_path format: {dirname}.{field_name}.json dirname, field, file_suffix = file_path.split('/')[-1].split('.') if file_suffix == 'json' and field not in DEFAULT_CONTENT_FIELDS: slug = os.path.splitext(os.path.basename(dirname))[0] location = course_descriptor.scope_ids.usage_id.replace(category=category, name=slug) with open(file_path) as field_content_file: field_data = json.load(field_content_file) data_content = {field: field_data} except (IOError, ValueError): # ignore this exception # only new exported courses which use content fields other than 'metadata' and 'data' # will have this file '{dirname}.{field_name}.json' data_content = None return slug, location, data_content def _load_extra_content(self, system, course_descriptor, category, content_path, course_dir): """ Import fields data content from files """ for filepath in glob.glob(content_path / '*'): if not os.path.isfile(filepath): continue if filepath.endswith('~'): # skip *~ files continue with open(filepath) as f: try: if filepath.find('.json') != -1: # json file with json data content slug, loc, data_content = self._import_field_content(course_descriptor, category, filepath) if data_content is None: continue else: try: # get and update data field in xblock runtime module = system.load_item(loc) for key, value in data_content.iteritems(): setattr(module, key, value) module.save() except ItemNotFoundError: module = None data_content['location'] = loc data_content['category'] = category else: slug = os.path.splitext(os.path.basename(filepath))[0] loc = course_descriptor.scope_ids.usage_id.replace(category=category, name=slug) # html file with html data content html = f.read().decode('utf-8') try: module = system.load_item(loc) module.data = html module.save() except ItemNotFoundError: module = None data_content = {'data': html, 'location': loc, 'category': category} if module is None: module = system.construct_xblock( category, # We're loading a descriptor, so student_id is meaningless # We also don't have separate notions of definition and usage ids yet, # so we use the location for both ScopeIds(None, category, loc, loc), DictFieldData(data_content), ) # VS[compat]: # Hack because we need to pull in the 'display_name' for static tabs (because we need to edit them) # from the course policy if category == "static_tab": dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=( "location:xml_load_extra_content_static_tab", u"course_dir:{}".format(course_dir), ) ) tab = CourseTabList.get_tab_by_slug(tab_list=course_descriptor.tabs, url_slug=slug) if tab: module.display_name = tab.name module.data_dir = course_dir module.save() self.modules[course_descriptor.id][module.scope_ids.usage_id] = module except Exception as exc: # pylint: disable=broad-except logging.exception("Failed to load %s. Skipping... \ Exception: %s", filepath, unicode(exc)) system.error_tracker("ERROR: " + unicode(exc)) def has_item(self, usage_key): """ Returns True if location exists in this ModuleStore. """ return usage_key in self.modules[usage_key.course_key] def get_item(self, usage_key, depth=0, **kwargs): """ Returns an XBlock instance for the item for this UsageKey. If any segment of the location is None except revision, raises xmodule.modulestore.exceptions.InsufficientSpecificationError If no object is found at that location, raises xmodule.modulestore.exceptions.ItemNotFoundError usage_key: a UsageKey that matches the module we are looking for. """ try: return self.modules[usage_key.course_key][usage_key] except KeyError: raise ItemNotFoundError(usage_key) def get_items(self, course_id, settings=None, content=None, revision=None, qualifiers=None, **kwargs): """ Returns: list of XModuleDescriptor instances for the matching items within the course with the given course_id NOTE: don't use this to look for courses as the course_id is required. Use get_courses. Args: course_id (CourseKey): the course identifier settings (dict): fields to look for which have settings scope. Follows same syntax and rules as qualifiers below content (dict): fields to look for which have content scope. Follows same syntax and rules as qualifiers below. qualifiers (dict): what to look for within the course. Common qualifiers are ``category`` or any field name. if the target field is a list, then it searches for the given value in the list not list equivalence. Substring matching pass a regex object. For this modulestore, ``name`` is another commonly provided key (Location based stores) (but not revision!) For this modulestore, you can search dates by providing either a datetime for == (probably useless) or a tuple (">"|"<" datetime) for after or before, etc. """ if revision == ModuleStoreEnum.RevisionOption.draft_only: return [] items = [] qualifiers = qualifiers.copy() if qualifiers else {} # copy the qualifiers (destructively manipulated here) category = qualifiers.pop('category', None) name = qualifiers.pop('name', None) def _block_matches_all(mod_loc, module): if category and mod_loc.category != category: return False if name and mod_loc.name != name: return False return all( self._block_matches(module, fields or {}) for fields in [settings, content, qualifiers] ) for mod_loc, module in self.modules[course_id].iteritems(): if _block_matches_all(mod_loc, module): items.append(module) return items def make_course_key(self, org, course, run): """ Return a valid :class:`~opaque_keys.edx.locator.CourseLocator` for this modulestore that matches the supplied `org`, `course`, and `run`. This key may represent a course that doesn't exist in this modulestore. """ return CourseLocator(org, course, run, deprecated=True) def get_courses(self, **kwargs): """ Returns a list of course descriptors. If there were errors on loading, some of these may be ErrorDescriptors instead. """ return self.courses.values() def get_errored_courses(self): """ Return a dictionary of course_dir -> [(msg, exception_str)], for each course_dir where course loading failed. """ return dict((k, self.errored_courses[k].errors) for k in self.errored_courses) def get_orphans(self, course_key, **kwargs): """ Get all of the xblocks in the given course which have no parents and are not of types which are usually orphaned. NOTE: may include xblocks which still have references via xblocks which don't use children to point to their dependents. """ # here just to quell the abstractmethod. someone could write the impl if needed raise NotImplementedError def get_parent_location(self, location, **kwargs): '''Find the location that is the parent of this location in this course. Needed for path_to_location(). ''' block = self.get_item(location, 0) return block.parent def get_modulestore_type(self, course_key=None): """ Returns an enumeration-like type reflecting the type of this modulestore, per ModuleStoreEnum.Type Args: course_key: just for signature compatibility """ return ModuleStoreEnum.Type.xml def get_courses_for_wiki(self, wiki_slug, **kwargs): """ Return the list of courses which use this wiki_slug :param wiki_slug: the course wiki root slug :return: list of course locations """ courses = self.get_courses() return [course.location.course_key for course in courses if course.wiki_slug == wiki_slug] def heartbeat(self): """ Ensure that every known course is loaded and ready to go. Really, just return b/c if this gets called the __init__ finished which means the courses are loaded. Returns the course count """ return {ModuleStoreEnum.Type.xml: True} @contextmanager def branch_setting(self, branch_setting, course_id=None): # pylint: disable=unused-argument """ A context manager for temporarily setting the branch value for the store to the given branch_setting. """ if branch_setting != ModuleStoreEnum.Branch.published_only: raise ValueError(u"Cannot set branch setting to {} on a ReadOnly store".format(branch_setting)) yield def _find_course_asset(self, asset_key): """ For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ log.warning("_find_course_asset request of XML modulestore - not implemented.") return (None, None) def find_asset_metadata(self, asset_key, **kwargs): """ For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ log.warning("find_asset_metadata request of XML modulestore - not implemented.") return None def get_all_asset_metadata(self, course_key, asset_type, start=0, maxresults=-1, sort=None, **kwargs): """ For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ log.warning("get_all_asset_metadata request of XML modulestore - not implemented.") return [] class LibraryXMLModuleStore(XMLModuleStore): """ A modulestore for importing Libraries from XML. """ parent_xml = LIBRARY_ROOT @staticmethod def get_id(org, library, url_name): """ Create a LibraryLocator given an org and library. url_name is ignored, but left in for compatibility with the parent signature. """ return LibraryLocator(org=org, library=library) @staticmethod def patch_descriptor_kvs(library_descriptor): """ Metadata inheritance can be done purely through XBlocks, but in the import phase a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy. This should change in the future, but as XBlocks don't have this KVS, we have to patch it here manually. """ init_dict = {key: getattr(library_descriptor, key) for key in library_descriptor.fields.keys()} # if set, invalidate '_unwrapped_field_data' so it will be reset # the next time it will be called lazy.invalidate(library_descriptor, '_unwrapped_field_data') # pylint: disable=protected-access library_descriptor._field_data = inheriting_field_data(InheritanceKeyValueStore(init_dict)) def content_importers(self, system, course_descriptor, course_dir, url_name): """ Handle Metadata inheritance for Libraries. """ self.patch_descriptor_kvs(course_descriptor) compute_inherited_metadata(course_descriptor) def get_library(self, library_id, depth=0, **kwargs): # pylint: disable=unused-argument """ Get a library from this modulestore or return None if it does not exist. """ assert isinstance(library_id, LibraryLocator) for library in self.get_courses(**kwargs): if library.location.library_key == library_id: return library return None @staticmethod def id_from_descriptor(descriptor): """ Get the Library Key from the Library descriptor. """ return descriptor.location.library_key def get_orphans(self, course_key, **kwargs): """ Get all of the xblocks in the given course which have no parents and are not of types which are usually orphaned. NOTE: may include xblocks which still have references via xblocks which don't use children to point to their dependents. """ # here just to quell the abstractmethod. someone could write the impl if needed raise NotImplementedError
agpl-3.0
[ 646, 8337, 199, 646, 7975, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5739, 199, 199, 504, 5055, 492, 10018, 199, 504, 15073, 492, 5228, 199, 504, 7449, 14, 736, 2319, 492, 4403, 7079, 199, 504, 14802, 492, 492, 63, 578, 199, 504, 14490, 492, 7559, 199, 504, 931, 492, 931, 199, 504, 15502, 492, 27608, 199, 504, 9617, 492, 9617, 199, 199, 504, 9872, 14, 705, 63, 578, 492, 4520, 4311, 199, 504, 9872, 14, 1508, 361, 8085, 281, 492, 1852, 63, 705, 63, 8877, 12, 3178, 63, 815, 63, 475, 63, 495, 199, 504, 9872, 14, 19491, 63, 578, 492, 603, 23564, 4311, 3989, 199, 504, 9872, 14, 88, 63, 578, 492, 334, 272, 4692, 17412, 3989, 12, 4592, 63, 498, 12, 272, 593, 10578, 1197, 5929, 12, 437, 2441, 1197, 7599, 12, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 199, 9, 199, 504, 9872, 14, 10012, 14, 1652, 63, 30305, 492, 6186, 63, 9663, 63, 12767, 199, 504, 9872, 14, 10012, 492, 23431, 12, 17996, 3284, 1563, 12, 25764, 50, 4392, 63, 5441, 12, 5099, 14302, 63, 5441, 199, 504, 9872, 14, 8741, 492, 5531, 7690, 1296, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 12, 12625, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 12, 11243, 10725, 199, 199, 504, 12971, 14, 698, 63, 576, 492, 7448, 792, 1451, 199, 504, 12971, 14, 7726, 492, 7448, 25720, 5502, 199, 504, 12971, 14, 955, 492, 20488, 11506, 199, 199, 646, 23454, 3200, 63, 5029, 465, 23454, 63, 3200, 63, 1246, 199, 199, 504, 1275, 3924, 492, 7020, 10870, 199, 504, 1275, 13136, 492, 4526, 63, 17571, 63, 2343, 12, 29927, 63, 698, 63, 576, 12, 27502, 554, 25720, 5502, 421, 199, 8268, 63, 1652, 63, 2087, 275, 7559, 14, 4317, 2842, 8, 15662, 63, 6136, 29, 797, 12, 2248, 63, 15662, 29, 797, 12, 639, 2813, 63, 6223, 29, 549, 12, 2813, 63, 2500, 63, 505, 29, 549, 9, 199, 199, 9464, 14, 409, 63, 885, 63, 2087, 8, 8268, 63, 1652, 63, 2087, 9, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 3, 21685, 59, 5819, 61, 199, 3, 3254, 334, 67, 897, 1835, 1860, 304, 5852, 642, 5403, 1006, 11264, 6029, 13588, 1172, 2757, 8439, 199, 3, 1901, 314, 19240, 687, 2748, 199, 318, 3633, 63, 548, 63, 19491, 63, 808, 24615, 8, 1652, 63, 875, 304, 272, 2306, 63, 1652, 275, 2748, 63, 875, 272, 2748, 63, 875, 275, 2748, 63, 875, 14, 1814, 3508, 2613, 297, 283, 2613, 358, 272, 2748, 63, 875, 275, 295, 14, 954, 8, 82, 24726, 77, 9, 12773, 83, 32639, 2795, 11918, 3260, 2748, 63, 875, 9, 272, 340, 2306, 63, 1652, 1137, 2748, 63, 875, 26, 267, 23454, 63, 3200, 63, 1246, 14, 9728, 8, 288, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 12, 288, 3762, 6270, 1985, 26, 1652, 63, 3118, 63, 548, 63, 19491, 63, 808, 24615, 937, 267, 776, 272, 372, 2748, 63, 875, 421, 199, 533, 3161, 3989, 8, 4317, 17412, 3989, 12, 603, 23564, 4311, 3989, 304, 272, 347, 636, 826, 721, 277, 12, 2748, 1617, 12, 2518, 63, 344, 12, 2518, 63, 694, 12, 326, 1125, 63, 8877, 12, 326, 2248, 63, 705, 63, 3112, 29, 549, 12, 1347, 63, 1972, 63, 344, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 437, 1021, 626, 10022, 8697, 687, 2748, 14, 221, 12078, 2005, 333, 324, 1540, 370, 4868, 626, 267, 1006, 4008, 1172, 3747, 5340, 85, 458, 14, 398, 2748, 1617, 26, 314, 4692, 14389, 370, 3877, 314, 6511, 4621, 315, 267, 408, 267, 291, 14, 9703, 275, 10018, 8, 442, 9, 221, 327, 4637, 1035, 1967, 402, 892, 1166, 63, 1247, 367, 626, 4637, 267, 291, 14, 2972, 63, 1247, 275, 10018, 8, 409, 9, 221, 327, 4637, 1035, 663, 402, 1202, 1166, 63, 1247, 398, 327, 12934, 314, 2518, 63, 344, 465, 3032, 315, 367, 2945, 3659, 7830, 2419, 267, 327, 9445, 370, 295, 13307, 314, 5981, 15, 1972, 15, 633, 63, 354, 267, 291, 14, 1972, 63, 344, 275, 2518, 63, 344, 267, 291, 14, 912, 63, 705, 63, 3112, 275, 2248, 63, 705, 63, 3112, 267, 291, 14, 10012, 275, 2748, 1617, 398, 347, 2112, 63, 1652, 8, 1652, 304, 288, 408, 32488, 376, 2748, 1059, 12, 436, 2529, 282, 15398, 2737, 687, 288, 626, 2748, 14, 288, 408, 953, 347, 1852, 63, 354, 63, 3235, 8, 1652, 63, 576, 304, 355, 408, 355, 4155, 3238, 626, 314, 1166, 63, 354, 402, 2748, 63, 576, 365, 3747, 14, 221, 982, 282, 10889, 6511, 355, 625, 4579, 5872, 410, 16721, 642, 1819, 1159, 1166, 63, 354, 12, 1218, 282, 892, 1373, 14, 2234, 23169, 283, 5464, 7, 2225, 340, 3451, 12, 436, 9584, 503, 1806, 16334, 314, 283, 633, 63, 354, 7, 2225, 14, 355, 408, 355, 327, 21685, 59, 5819, 1055, 18146, 642, 734, 5403, 2518, 8603, 365, 4224, 334, 529, 17396, 10137, 314, 15439, 31820, 1104, 9, 2234, 327, 3762, 626, 7710, 1929, 3747, 1561, 306, 29002, 3877, 334, 269, 1077, 3877, 9, 1174, 14, 355, 1929, 63, 22484, 63, 1247, 275, 661, 6462, 297, 283, 16211, 297, 283, 3722, 297, 283, 1972, 297, 283, 11316, 297, 3521, 283, 3722, 4041, 297, 283, 6843, 63, 4790, 297, 283, 7870, 358, 2234, 1921, 275, 2748, 63, 576, 14, 6640, 355, 1947, 275, 2748, 63, 576, 14, 1450, 355, 1305, 275, 2400, 671, 26, 671, 355, 327, 3868, 780, 370, 862, 370, 664, 282, 536, 12, 315, 1865, 221, 334, 498, 12, 29579, 805, 12, 2813, 790, 2410, 7664, 17076, 355, 16807, 275, 4274, 633, 63, 354, 297, 1305, 12, 756, 395, 2574, 661, 5464, 297, 1305, 12, 715, 395, 2574, 661, 354, 297, 12625, 14, 3118, 12, 756, 395, 2574, 661, 2918, 63, 354, 297, 12625, 14, 3118, 12, 756, 1874, 2234, 1166, 63, 354, 275, 488, 355, 367, 790, 12, 3633, 12, 2813, 315, 16807, 26, 490, 340, 790, 315, 1921, 26, 717, 1166, 63, 354, 275, 3633, 8, 962, 59, 498, 566, 717, 340, 2813, 26, 1169, 2150 ]
[ 8337, 199, 646, 7975, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 5739, 199, 199, 504, 5055, 492, 10018, 199, 504, 15073, 492, 5228, 199, 504, 7449, 14, 736, 2319, 492, 4403, 7079, 199, 504, 14802, 492, 492, 63, 578, 199, 504, 14490, 492, 7559, 199, 504, 931, 492, 931, 199, 504, 15502, 492, 27608, 199, 504, 9617, 492, 9617, 199, 199, 504, 9872, 14, 705, 63, 578, 492, 4520, 4311, 199, 504, 9872, 14, 1508, 361, 8085, 281, 492, 1852, 63, 705, 63, 8877, 12, 3178, 63, 815, 63, 475, 63, 495, 199, 504, 9872, 14, 19491, 63, 578, 492, 603, 23564, 4311, 3989, 199, 504, 9872, 14, 88, 63, 578, 492, 334, 272, 4692, 17412, 3989, 12, 4592, 63, 498, 12, 272, 593, 10578, 1197, 5929, 12, 437, 2441, 1197, 7599, 12, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 199, 9, 199, 504, 9872, 14, 10012, 14, 1652, 63, 30305, 492, 6186, 63, 9663, 63, 12767, 199, 504, 9872, 14, 10012, 492, 23431, 12, 17996, 3284, 1563, 12, 25764, 50, 4392, 63, 5441, 12, 5099, 14302, 63, 5441, 199, 504, 9872, 14, 8741, 492, 5531, 7690, 1296, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 12, 12625, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 12, 11243, 10725, 199, 199, 504, 12971, 14, 698, 63, 576, 492, 7448, 792, 1451, 199, 504, 12971, 14, 7726, 492, 7448, 25720, 5502, 199, 504, 12971, 14, 955, 492, 20488, 11506, 199, 199, 646, 23454, 3200, 63, 5029, 465, 23454, 63, 3200, 63, 1246, 199, 199, 504, 1275, 3924, 492, 7020, 10870, 199, 504, 1275, 13136, 492, 4526, 63, 17571, 63, 2343, 12, 29927, 63, 698, 63, 576, 12, 27502, 554, 25720, 5502, 421, 199, 8268, 63, 1652, 63, 2087, 275, 7559, 14, 4317, 2842, 8, 15662, 63, 6136, 29, 797, 12, 2248, 63, 15662, 29, 797, 12, 639, 2813, 63, 6223, 29, 549, 12, 2813, 63, 2500, 63, 505, 29, 549, 9, 199, 199, 9464, 14, 409, 63, 885, 63, 2087, 8, 8268, 63, 1652, 63, 2087, 9, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 3, 21685, 59, 5819, 61, 199, 3, 3254, 334, 67, 897, 1835, 1860, 304, 5852, 642, 5403, 1006, 11264, 6029, 13588, 1172, 2757, 8439, 199, 3, 1901, 314, 19240, 687, 2748, 199, 318, 3633, 63, 548, 63, 19491, 63, 808, 24615, 8, 1652, 63, 875, 304, 272, 2306, 63, 1652, 275, 2748, 63, 875, 272, 2748, 63, 875, 275, 2748, 63, 875, 14, 1814, 3508, 2613, 297, 283, 2613, 358, 272, 2748, 63, 875, 275, 295, 14, 954, 8, 82, 24726, 77, 9, 12773, 83, 32639, 2795, 11918, 3260, 2748, 63, 875, 9, 272, 340, 2306, 63, 1652, 1137, 2748, 63, 875, 26, 267, 23454, 63, 3200, 63, 1246, 14, 9728, 8, 288, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 12, 288, 3762, 6270, 1985, 26, 1652, 63, 3118, 63, 548, 63, 19491, 63, 808, 24615, 937, 267, 776, 272, 372, 2748, 63, 875, 421, 199, 533, 3161, 3989, 8, 4317, 17412, 3989, 12, 603, 23564, 4311, 3989, 304, 272, 347, 636, 826, 721, 277, 12, 2748, 1617, 12, 2518, 63, 344, 12, 2518, 63, 694, 12, 326, 1125, 63, 8877, 12, 326, 2248, 63, 705, 63, 3112, 29, 549, 12, 1347, 63, 1972, 63, 344, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 437, 1021, 626, 10022, 8697, 687, 2748, 14, 221, 12078, 2005, 333, 324, 1540, 370, 4868, 626, 267, 1006, 4008, 1172, 3747, 5340, 85, 458, 14, 398, 2748, 1617, 26, 314, 4692, 14389, 370, 3877, 314, 6511, 4621, 315, 267, 408, 267, 291, 14, 9703, 275, 10018, 8, 442, 9, 221, 327, 4637, 1035, 1967, 402, 892, 1166, 63, 1247, 367, 626, 4637, 267, 291, 14, 2972, 63, 1247, 275, 10018, 8, 409, 9, 221, 327, 4637, 1035, 663, 402, 1202, 1166, 63, 1247, 398, 327, 12934, 314, 2518, 63, 344, 465, 3032, 315, 367, 2945, 3659, 7830, 2419, 267, 327, 9445, 370, 295, 13307, 314, 5981, 15, 1972, 15, 633, 63, 354, 267, 291, 14, 1972, 63, 344, 275, 2518, 63, 344, 267, 291, 14, 912, 63, 705, 63, 3112, 275, 2248, 63, 705, 63, 3112, 267, 291, 14, 10012, 275, 2748, 1617, 398, 347, 2112, 63, 1652, 8, 1652, 304, 288, 408, 32488, 376, 2748, 1059, 12, 436, 2529, 282, 15398, 2737, 687, 288, 626, 2748, 14, 288, 408, 953, 347, 1852, 63, 354, 63, 3235, 8, 1652, 63, 576, 304, 355, 408, 355, 4155, 3238, 626, 314, 1166, 63, 354, 402, 2748, 63, 576, 365, 3747, 14, 221, 982, 282, 10889, 6511, 355, 625, 4579, 5872, 410, 16721, 642, 1819, 1159, 1166, 63, 354, 12, 1218, 282, 892, 1373, 14, 2234, 23169, 283, 5464, 7, 2225, 340, 3451, 12, 436, 9584, 503, 1806, 16334, 314, 283, 633, 63, 354, 7, 2225, 14, 355, 408, 355, 327, 21685, 59, 5819, 1055, 18146, 642, 734, 5403, 2518, 8603, 365, 4224, 334, 529, 17396, 10137, 314, 15439, 31820, 1104, 9, 2234, 327, 3762, 626, 7710, 1929, 3747, 1561, 306, 29002, 3877, 334, 269, 1077, 3877, 9, 1174, 14, 355, 1929, 63, 22484, 63, 1247, 275, 661, 6462, 297, 283, 16211, 297, 283, 3722, 297, 283, 1972, 297, 283, 11316, 297, 3521, 283, 3722, 4041, 297, 283, 6843, 63, 4790, 297, 283, 7870, 358, 2234, 1921, 275, 2748, 63, 576, 14, 6640, 355, 1947, 275, 2748, 63, 576, 14, 1450, 355, 1305, 275, 2400, 671, 26, 671, 355, 327, 3868, 780, 370, 862, 370, 664, 282, 536, 12, 315, 1865, 221, 334, 498, 12, 29579, 805, 12, 2813, 790, 2410, 7664, 17076, 355, 16807, 275, 4274, 633, 63, 354, 297, 1305, 12, 756, 395, 2574, 661, 5464, 297, 1305, 12, 715, 395, 2574, 661, 354, 297, 12625, 14, 3118, 12, 756, 395, 2574, 661, 2918, 63, 354, 297, 12625, 14, 3118, 12, 756, 1874, 2234, 1166, 63, 354, 275, 488, 355, 367, 790, 12, 3633, 12, 2813, 315, 16807, 26, 490, 340, 790, 315, 1921, 26, 717, 1166, 63, 354, 275, 3633, 8, 962, 59, 498, 566, 717, 340, 2813, 26, 1169, 2150, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MeirKriheli/Open-Knesset
notify/management/commands/notify.py
5
13040
from __future__ import absolute_import from django.core.management.base import NoArgsCommand from django.contrib.auth.models import User, Group from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.utils.translation import ugettext as _ from django.utils import translation from django.template.loader import render_to_string from django.template import TemplateDoesNotExist from django.conf import settings from django.core.cache import cache import datetime from optparse import make_option import logging logger = logging.getLogger("open-knesset.notify") from actstream.models import Follow, Action from mailer import send_html_mail from mks.models import Member from laws.models import Bill, get_debated_bills from agendas.models import Agenda from notify.models import LastSent from user.models import UserProfile from committees.models import Topic class Command(NoArgsCommand): help = "Send e-mail notification to users that requested it." requires_model_validation = False update_models = [Member, Bill, Agenda, Topic, None] from_email = getattr(settings, 'DEFAULT_FROM_EMAIL', 'email@example.com') days_back = getattr(settings, 'DEFAULT_NOTIFICATION_DAYS_BACK', 10) lang = getattr(settings, 'LANGUAGE_CODE', 'he') @property def domain(self): if not hasattr(self, '_domain'): self._domain = Site.objects.get_current().domain return self._domain option_list = NoArgsCommand.option_list + ( make_option('--daily', action='store_true', dest='daily', help="send notifications to users that requested a daily update"), make_option('--weekly', action='store_true', dest='weekly', help="send notifications to users that requested a weekly update")) def agenda_update(self, agenda): ''' generate the general update email for this agenda. this will be called, and its output added to the email, if and only if there has been some update in it's data. ''' mks = agenda.selected_instances(Member) template_name = 'notify/agenda_update' update_txt = render_to_string(template_name + '.txt', {'mks': mks, 'domain': self.domain}) update_html = render_to_string(template_name + '.html', {'mks': mks, 'domain': self.domain}) return (update_txt, update_html) @classmethod def get_model_headers(cls, model): ''' for a given model this function returns a tuple with (model, text_header, html_header) ''' try: template_name = 'notify/%s_section' % model.__name__.lower() return (model, render_to_string(template_name + '.txt'), render_to_string(template_name + '.html')) except TemplateDoesNotExist: return (model, model._meta.verbose_name_plural, '<h2>%s</h2>' % model._meta.verbose_name_plural.format()) except AttributeError: return (model, _('Other Updates'), '<h2>%s</h2>' % _('Other Updates')) def get_email_for_user(self, user): ''' return the body text and html for a user's email ''' updates = dict(zip(self.update_models, ([] for x in self.update_models))) # will contain the updates to be sent updates_html = dict(zip(self.update_models, ([] for x in self.update_models))) follows = Follow.objects.filter(user=user) # everything this user is following # sometime a user follows something several times. we want to filter that out: follows = set([f.actor for f in follows]) for f in follows: if not f: logger.warning('Follow object with None actor. ignoring') continue model_class = f.__class__ model_template = f.__class__.__name__.lower() try: model_name = f.__class__._meta.verbose_name except AttributeError: logger.warning('follows %d has no __class__?' % f.id) model_name = "" content_type = ContentType.objects.get_for_model(f) if model_class in updates: key = model_class else: key = None # put all updates for 'other' classes at the 'None' group try: # get actions that happened since last update last_sent = LastSent.objects.get(user=user, content_type=content_type, object_pk=f.id) last_sent_time = last_sent.time stream = Action.objects.filter(actor_content_type=content_type, actor_object_id=f.id, timestamp__gt=last_sent_time, ).order_by('-timestamp') if stream: # if there are updates to be sent, last_sent.save() # update timestamp of last sent except LastSent.DoesNotExist: # never updated about this actor, send some updates stream = Action.objects.filter(actor_content_type=content_type, actor_object_id=f.id, timestamp__gt=datetime.datetime.now() - datetime.timedelta( self.days_back), ).order_by('-timestamp') last_sent = LastSent.objects.create(user=user, content_type=content_type, object_pk=f.id) if stream: # this actor has some updates try: # genereate the appropriate header for this actor class header = render_to_string(('notify/%(model)s_header.txt' % {'model': model_template}), {'model': model_name, 'object': f}) except TemplateDoesNotExist: header = render_to_string(('notify/model_header.txt'), {'model': model_name, 'object': f}) try: header_html = render_to_string(('notify/%(model)s_header.html' % {'model': model_template}), {'model': model_name, 'object': f, 'domain': self.domain}) except TemplateDoesNotExist: header_html = render_to_string(('notify/model_header.html'), {'model': model_name, 'object': f, 'domain': self.domain}) updates[key].append(header) updates_html[key].append(header_html) for action_instance in stream: # now generate the updates themselves try: action_output = render_to_string( ('activity/%(verb)s/action_email.txt' % {'verb': action_instance.verb.replace(' ', '_')}), {'action': action_instance}, None) except TemplateDoesNotExist: # fallback to the generic template action_output = render_to_string(('activity/action_email.txt'), {'action': action_instance}, None) try: action_output_html = render_to_string( ('activity/%(verb)s/action_email.html' % {'verb': action_instance.verb.replace(' ', '_')}), {'action': action_instance, 'domain': self.domain}, None) except TemplateDoesNotExist: # fallback to the generic template action_output_html = render_to_string(('activity/action_email.html'), {'action': action_instance, 'domain': self.domain}, None) updates[key].append(action_output) updates_html[key].append(action_output_html) if model_class == Agenda: txt, html = self.agenda_update(f) updates[key].append(txt) updates_html[key].append(html) email_body = [] email_body_html = [] # Add the updates for followed models for (model_class, title, title_html) in map(self.get_model_headers, self.update_models): if updates[model_class]: # this model has some updates, add it to the email email_body.append(title.format()) email_body.append('\n'.join(updates[model_class])) email_body_html.append(title_html.format()) email_body_html.append(''.join(updates_html[model_class])) if email_body or email_body_html: # Generate party membership section if needed up = UserProfile.objects.filter(user=user).select_related('party') if up: up = up[0] party = up.party if party: num_members = cache.get('party_num_members_%d' % party.id, None) if not num_members: num_members = party.userprofile_set.count() cache.set('party_num_members_%d' % party.id, num_members, settings.LONG_CACHE_TIME) else: num_members = None debated_bills = get_debated_bills() or [] template_name = 'notify/party_membership' party_membership_txt = render_to_string(template_name + '.txt', {'user': user, 'userprofile': up, 'num_members': num_members, 'bills': debated_bills, 'domain': self.domain}) party_membership_html = render_to_string(template_name + '.html', {'user': user, 'userprofile': up, 'num_members': num_members, 'bills': debated_bills, 'domain': self.domain}) else: logger.warning('Can\'t find user profile') if email_body: email_body.insert(0, party_membership_txt) if email_body_html: email_body_html.insert(0, party_membership_html) return (email_body, email_body_html) def handle_noargs(self, **options): daily = options.get('daily', False) weekly = options.get('weekly', False) if not daily and not weekly: print "use --daily or --weekly" return translation.activate(self.lang) email_notification = [] if daily: email_notification.append('D') if weekly: email_notification.append('W') queued = 0 g = Group.objects.get(name='Valid Email') for user in User.objects.filter(groups=g, profiles__isnull=False) \ .exclude(email=''): try: user_profile = user.profiles.get() except UserProfile.DoesNotExist: logger.warn('can\'t access user %d userprofile' % user.id) continue if (user_profile.email_notification in email_notification): # if this user has requested emails in the frequency we are # handling now email_body, email_body_html = self.get_email_for_user(user) if email_body: # there are some updates. generate email header = render_to_string(('notify/header.txt'), {'user': user}) footer = render_to_string(('notify/footer.txt'), {'user': user, 'domain': self.domain}) header_html = render_to_string(('notify/header.html'), {'user': user}) footer_html = render_to_string(('notify/footer.html'), {'user': user, 'domain': self.domain}) send_html_mail(_('Open Knesset Updates'), "%s\n%s\n%s" % (header, '\n'.join(email_body), footer), "%s\n%s\n%s" % (header_html, ''.join(email_body_html), footer_html), self.from_email, [user.email], ) queued += 1 logger.info("%d email notifications queued for sending" % queued) translation.deactivate()
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 504, 1639, 14, 1160, 492, 27193, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 646, 2197, 199, 504, 8691, 492, 1852, 63, 1422, 199, 646, 2050, 199, 199, 2921, 275, 2050, 14, 5572, 480, 1490, 13, 75, 17775, 409, 14, 6814, 531, 199, 199, 504, 2454, 1745, 14, 992, 492, 21876, 12, 10033, 199, 504, 610, 3566, 492, 3222, 63, 1360, 63, 1198, 199, 504, 333, 6080, 14, 992, 492, 14409, 199, 504, 1127, 3569, 14, 992, 492, 699, 778, 12, 664, 63, 16762, 972, 63, 66, 15350, 199, 504, 1839, 500, 305, 14, 992, 492, 21582, 29162, 199, 504, 11705, 14, 992, 492, 15237, 17367, 199, 504, 922, 14, 992, 492, 19037, 199, 504, 5532, 266, 397, 14, 992, 492, 32166, 421, 199, 533, 5817, 8, 27099, 3110, 304, 272, 1720, 275, 298, 6795, 325, 13, 1198, 6955, 370, 4390, 626, 5839, 652, 2122, 339, 5074, 63, 1238, 63, 6136, 275, 756, 339, 1678, 63, 992, 275, 359, 7021, 12, 699, 778, 12, 21582, 29162, 12, 32166, 12, 488, 61, 272, 687, 63, 2123, 275, 2519, 8, 1751, 12, 283, 3472, 63, 12491, 63, 10089, 297, 283, 2123, 32, 2694, 14, 957, 358, 272, 7609, 63, 894, 275, 2519, 8, 1751, 12, 283, 3472, 63, 22839, 2594, 63, 25683, 63, 7111, 297, 1616, 9, 272, 6339, 275, 2519, 8, 1751, 12, 283, 13947, 63, 6012, 297, 283, 426, 358, 339, 768, 1829, 272, 347, 2881, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 2261, 735, 288, 291, 423, 2261, 275, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 267, 372, 291, 423, 2261, 339, 945, 63, 513, 275, 3091, 6213, 3110, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 4517, 18621, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 18621, 297, 490, 1720, 628, 2254, 13116, 370, 4390, 626, 5839, 282, 26122, 1678, 1288, 267, 1852, 63, 1422, 4517, 6419, 590, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 6419, 590, 297, 490, 1720, 628, 2254, 13116, 370, 4390, 626, 5839, 282, 8620, 590, 1678, 2237, 339, 347, 1839, 29162, 63, 873, 8, 277, 12, 1839, 29162, 304, 267, 1449, 3550, 314, 8605, 1678, 3031, 367, 642, 1839, 29162, 14, 288, 642, 911, 506, 2797, 12, 436, 2399, 1072, 3483, 370, 314, 3031, 12, 288, 340, 436, 1454, 340, 2337, 965, 2757, 2005, 1678, 315, 652, 1159, 666, 14, 267, 1449, 267, 333, 6080, 275, 1839, 29162, 14, 5511, 63, 5990, 8, 7021, 9, 267, 1978, 63, 354, 275, 283, 6814, 15, 643, 29162, 63, 873, 7, 267, 1678, 63, 2424, 275, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 2424, 297, 4228, 791, 16335, 356, 333, 6080, 12, 4318, 283, 2261, 356, 291, 14, 2261, 1552, 267, 1678, 63, 1360, 275, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 1360, 297, 4318, 791, 16335, 356, 333, 6080, 12, 3147, 283, 2261, 356, 291, 14, 2261, 1552, 267, 372, 334, 873, 63, 2424, 12, 1678, 63, 1360, 9, 339, 768, 3744, 272, 347, 664, 63, 1238, 63, 2139, 8, 1886, 12, 1402, 304, 267, 1449, 367, 282, 1627, 1402, 642, 805, 2529, 282, 2008, 543, 288, 334, 1238, 12, 1318, 63, 1291, 12, 3517, 63, 1291, 9, 267, 1449, 267, 862, 26, 288, 1978, 63, 354, 275, 283, 6814, 3149, 83, 63, 2792, 7, 450, 1402, 855, 354, 4343, 2325, 342, 288, 372, 334, 1238, 12, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 2424, 659, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 1360, 1333, 267, 871, 27193, 26, 288, 372, 334, 1238, 12, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 12, 2650, 72, 18, 6598, 83, 1108, 72, 18, 3524, 450, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 14, 908, 1012, 267, 871, 4281, 26, 288, 372, 334, 1238, 12, 4018, 8632, 24663, 659, 2650, 72, 18, 6598, 83, 1108, 72, 18, 3524, 450, 4018, 8632, 24663, 1333, 339, 347, 664, 63, 2123, 63, 509, 63, 751, 8, 277, 12, 922, 304, 267, 1449, 372, 314, 2396, 1318, 436, 3517, 367, 282, 922, 1159, 3031, 1449, 267, 7029, 275, 1211, 8, 3065, 8, 277, 14, 873, 63, 992, 12, 7287, 61, 367, 671, 315, 291, 14, 873, 63, 992, 1724, 221, 327, 911, 1395, 314, 7029, 370, 506, 4847, 267, 7029, 63, 1360, 275, 1211, 8, 3065, 8, 277, 14, 873, 63, 992, 12, 7287, 61, 367, 671, 315, 291, 14, 873, 63, 992, 1724, 267, 11924, 275, 21876, 14, 1462, 14, 1541, 8, 751, 29, 751, 9, 221, 327, 8137, 642, 922, 365, 2569, 267, 327, 2005, 521, 282, 922, 11924, 6020, 9978, 5431, 14, 781, 2934, 370, 2457, 626, 734, 26, 267, 11924, 275, 663, 779, 70, 14, 5021, 367, 289, 315, 11924, 566, 267, 367, 289, 315, 11924, 26, 288, 340, 440, 289, 26, 355, 2512, 14, 3764, 360, 18696, 909, 543, 488, 20318, 14, 17289, 358, 355, 1980, 288, 1402, 63, 533, 275, 289, 855, 533, 363, 288, 1402, 63, 1160, 275, 289, 855, 533, 4914, 354, 4343, 2325, 342, 288, 862, 26, 355, 1402, 63, 354, 275, 289, 855, 533, 363, 423, 2024, 14, 3832, 63, 354, 288, 871, 4281, 26, 355, 2512, 14, 3764, 360, 7207, 83, 450, 68, 965, 949, 636, 533, 363, 14069, 450, 289, 14, 344, 9, 355, 1402, 63, 354, 275, 3087, 288, 1564, 63, 466, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 70, 9, 288, 340, 1402, 63, 533, 315, 7029, 26, 355, 790, 275 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 504, 1639, 14, 1160, 492, 27193, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 646, 2197, 199, 504, 8691, 492, 1852, 63, 1422, 199, 646, 2050, 199, 199, 2921, 275, 2050, 14, 5572, 480, 1490, 13, 75, 17775, 409, 14, 6814, 531, 199, 199, 504, 2454, 1745, 14, 992, 492, 21876, 12, 10033, 199, 504, 610, 3566, 492, 3222, 63, 1360, 63, 1198, 199, 504, 333, 6080, 14, 992, 492, 14409, 199, 504, 1127, 3569, 14, 992, 492, 699, 778, 12, 664, 63, 16762, 972, 63, 66, 15350, 199, 504, 1839, 500, 305, 14, 992, 492, 21582, 29162, 199, 504, 11705, 14, 992, 492, 15237, 17367, 199, 504, 922, 14, 992, 492, 19037, 199, 504, 5532, 266, 397, 14, 992, 492, 32166, 421, 199, 533, 5817, 8, 27099, 3110, 304, 272, 1720, 275, 298, 6795, 325, 13, 1198, 6955, 370, 4390, 626, 5839, 652, 2122, 339, 5074, 63, 1238, 63, 6136, 275, 756, 339, 1678, 63, 992, 275, 359, 7021, 12, 699, 778, 12, 21582, 29162, 12, 32166, 12, 488, 61, 272, 687, 63, 2123, 275, 2519, 8, 1751, 12, 283, 3472, 63, 12491, 63, 10089, 297, 283, 2123, 32, 2694, 14, 957, 358, 272, 7609, 63, 894, 275, 2519, 8, 1751, 12, 283, 3472, 63, 22839, 2594, 63, 25683, 63, 7111, 297, 1616, 9, 272, 6339, 275, 2519, 8, 1751, 12, 283, 13947, 63, 6012, 297, 283, 426, 358, 339, 768, 1829, 272, 347, 2881, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 2261, 735, 288, 291, 423, 2261, 275, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 267, 372, 291, 423, 2261, 339, 945, 63, 513, 275, 3091, 6213, 3110, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 4517, 18621, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 18621, 297, 490, 1720, 628, 2254, 13116, 370, 4390, 626, 5839, 282, 26122, 1678, 1288, 267, 1852, 63, 1422, 4517, 6419, 590, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 6419, 590, 297, 490, 1720, 628, 2254, 13116, 370, 4390, 626, 5839, 282, 8620, 590, 1678, 2237, 339, 347, 1839, 29162, 63, 873, 8, 277, 12, 1839, 29162, 304, 267, 1449, 3550, 314, 8605, 1678, 3031, 367, 642, 1839, 29162, 14, 288, 642, 911, 506, 2797, 12, 436, 2399, 1072, 3483, 370, 314, 3031, 12, 288, 340, 436, 1454, 340, 2337, 965, 2757, 2005, 1678, 315, 652, 1159, 666, 14, 267, 1449, 267, 333, 6080, 275, 1839, 29162, 14, 5511, 63, 5990, 8, 7021, 9, 267, 1978, 63, 354, 275, 283, 6814, 15, 643, 29162, 63, 873, 7, 267, 1678, 63, 2424, 275, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 2424, 297, 4228, 791, 16335, 356, 333, 6080, 12, 4318, 283, 2261, 356, 291, 14, 2261, 1552, 267, 1678, 63, 1360, 275, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 1360, 297, 4318, 791, 16335, 356, 333, 6080, 12, 3147, 283, 2261, 356, 291, 14, 2261, 1552, 267, 372, 334, 873, 63, 2424, 12, 1678, 63, 1360, 9, 339, 768, 3744, 272, 347, 664, 63, 1238, 63, 2139, 8, 1886, 12, 1402, 304, 267, 1449, 367, 282, 1627, 1402, 642, 805, 2529, 282, 2008, 543, 288, 334, 1238, 12, 1318, 63, 1291, 12, 3517, 63, 1291, 9, 267, 1449, 267, 862, 26, 288, 1978, 63, 354, 275, 283, 6814, 3149, 83, 63, 2792, 7, 450, 1402, 855, 354, 4343, 2325, 342, 288, 372, 334, 1238, 12, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 2424, 659, 3795, 63, 475, 63, 875, 8, 1160, 63, 354, 435, 1987, 1360, 1333, 267, 871, 27193, 26, 288, 372, 334, 1238, 12, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 12, 2650, 72, 18, 6598, 83, 1108, 72, 18, 3524, 450, 1402, 423, 2024, 14, 3832, 63, 354, 63, 10019, 14, 908, 1012, 267, 871, 4281, 26, 288, 372, 334, 1238, 12, 4018, 8632, 24663, 659, 2650, 72, 18, 6598, 83, 1108, 72, 18, 3524, 450, 4018, 8632, 24663, 1333, 339, 347, 664, 63, 2123, 63, 509, 63, 751, 8, 277, 12, 922, 304, 267, 1449, 372, 314, 2396, 1318, 436, 3517, 367, 282, 922, 1159, 3031, 1449, 267, 7029, 275, 1211, 8, 3065, 8, 277, 14, 873, 63, 992, 12, 7287, 61, 367, 671, 315, 291, 14, 873, 63, 992, 1724, 221, 327, 911, 1395, 314, 7029, 370, 506, 4847, 267, 7029, 63, 1360, 275, 1211, 8, 3065, 8, 277, 14, 873, 63, 992, 12, 7287, 61, 367, 671, 315, 291, 14, 873, 63, 992, 1724, 267, 11924, 275, 21876, 14, 1462, 14, 1541, 8, 751, 29, 751, 9, 221, 327, 8137, 642, 922, 365, 2569, 267, 327, 2005, 521, 282, 922, 11924, 6020, 9978, 5431, 14, 781, 2934, 370, 2457, 626, 734, 26, 267, 11924, 275, 663, 779, 70, 14, 5021, 367, 289, 315, 11924, 566, 267, 367, 289, 315, 11924, 26, 288, 340, 440, 289, 26, 355, 2512, 14, 3764, 360, 18696, 909, 543, 488, 20318, 14, 17289, 358, 355, 1980, 288, 1402, 63, 533, 275, 289, 855, 533, 363, 288, 1402, 63, 1160, 275, 289, 855, 533, 4914, 354, 4343, 2325, 342, 288, 862, 26, 355, 1402, 63, 354, 275, 289, 855, 533, 363, 423, 2024, 14, 3832, 63, 354, 288, 871, 4281, 26, 355, 2512, 14, 3764, 360, 7207, 83, 450, 68, 965, 949, 636, 533, 363, 14069, 450, 289, 14, 344, 9, 355, 1402, 63, 354, 275, 3087, 288, 1564, 63, 466, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 70, 9, 288, 340, 1402, 63, 533, 315, 7029, 26, 355, 790, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mihailignatenko/erp
addons/account_asset/account_asset_invoice.py
193
3070
# -*- encoding: 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 class account_invoice(osv.osv): _inherit = 'account.invoice' def action_number(self, cr, uid, ids, *args): result = super(account_invoice, self).action_number(cr, uid, ids, *args) for inv in self.browse(cr, uid, ids): self.pool.get('account.invoice.line').asset_create(cr, uid, inv.invoice_line) return result def line_get_convert(self, cr, uid, x, part, date, context=None): res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context=context) res['asset_id'] = x.get('asset_id', False) return res class account_invoice_line(osv.osv): _inherit = 'account.invoice.line' _columns = { 'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'), } def asset_create(self, cr, uid, lines, context=None): context = context or {} asset_obj = self.pool.get('account.asset.asset') for line in lines: if line.asset_category_id: vals = { 'name': line.name, 'code': line.invoice_id.number or False, 'category_id': line.asset_category_id.id, 'purchase_value': line.price_subtotal, 'period_id': line.invoice_id.period_id.id, 'partner_id': line.invoice_id.partner_id.id, 'company_id': line.invoice_id.company_id.id, 'currency_id': line.invoice_id.currency_id.id, 'purchase_date' : line.invoice_id.date_invoice, } changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context) vals.update(changed_vals['value']) asset_id = asset_obj.create(cr, uid, vals, context=context) if line.asset_category_id.open_asset: asset_obj.validate(cr, uid, [asset_id], context=context) return True # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 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, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 5404, 7, 272, 347, 1595, 63, 1955, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 627, 589, 304, 267, 754, 275, 1613, 8, 2048, 63, 5404, 12, 291, 680, 1287, 63, 1955, 8, 1556, 12, 1747, 12, 2762, 12, 627, 589, 9, 267, 367, 4572, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 304, 288, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 14, 604, 1959, 6562, 63, 981, 8, 1556, 12, 1747, 12, 4572, 14, 5404, 63, 604, 9, 267, 372, 754, 339, 347, 1004, 63, 362, 63, 3916, 8, 277, 12, 2467, 12, 1747, 12, 671, 12, 1777, 12, 1434, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 2048, 63, 5404, 12, 291, 680, 604, 63, 362, 63, 3916, 8, 1556, 12, 1747, 12, 671, 12, 1777, 12, 1434, 12, 1067, 29, 1100, 9, 267, 522, 459, 6562, 63, 344, 418, 275, 671, 14, 362, 360, 6562, 63, 344, 297, 756, 9, 267, 372, 522, 421, 199, 533, 2933, 63, 5404, 63, 604, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 5404, 14, 604, 7, 272, 485, 3406, 275, 469, 267, 283, 6562, 63, 3710, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 6562, 14, 3710, 297, 283, 19979, 13573, 659, 272, 789, 272, 347, 8977, 63, 981, 8, 277, 12, 2467, 12, 1747, 12, 2385, 12, 1067, 29, 403, 304, 267, 1067, 275, 1067, 503, 1052, 267, 8977, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 6562, 14, 6562, 358, 267, 367, 1004, 315, 2385, 26, 288, 340, 1004, 14, 6562, 63, 3710, 63, 344, 26, 355, 5322, 275, 469, 490, 283, 354, 356, 1004, 14, 354, 12, 490, 283, 600, 356, 1004, 14, 5404, 63, 344, 14, 1955, 503, 756, 12, 490, 283, 3710, 63, 344, 356, 1004, 14, 6562, 63, 3710, 63, 344, 14, 344, 12, 490, 283, 9533, 63, 585, 356, 1004, 14, 4777, 63, 954, 2923, 12, 490, 283, 5191, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 5191, 63, 344, 14, 344, 12, 490, 283, 3899, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 3899, 63, 344, 14, 344, 12, 490, 283, 4627, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 4627, 63, 344, 14, 344, 12, 490, 283, 4968, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 4968, 63, 344, 14, 344, 12, 490, 283, 9533, 63, 602, 7, 520, 1004, 14, 5404, 63, 344, 14, 602, 63, 5404, 12, 355, 789, 355, 2896, 63, 3643, 275, 8977, 63, 1113, 14, 18128, 63, 3710, 63, 344, 8, 1556, 12, 1747, 12, 990, 5322, 459, 3710, 63, 344, 995, 1067, 29, 1100, 9, 355, 5322, 14, 873, 8, 2489, 63, 3643, 459, 585, 1105, 355, 8977, 63, 344, 275, 8977, 63, 1113, 14, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 355, 340, 1004, 14, 6562, 63, 3710, 63, 344, 14, 1490, 63, 6562, 26, 490, 8977, 63, 1113, 14, 3502, 8, 1556, 12, 1747, 12, 359, 6562, 63, 344, 467, 1067, 29, 1100, 9, 267, 372, 715, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 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, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 5404, 7, 272, 347, 1595, 63, 1955, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 627, 589, 304, 267, 754, 275, 1613, 8, 2048, 63, 5404, 12, 291, 680, 1287, 63, 1955, 8, 1556, 12, 1747, 12, 2762, 12, 627, 589, 9, 267, 367, 4572, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 304, 288, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 14, 604, 1959, 6562, 63, 981, 8, 1556, 12, 1747, 12, 4572, 14, 5404, 63, 604, 9, 267, 372, 754, 339, 347, 1004, 63, 362, 63, 3916, 8, 277, 12, 2467, 12, 1747, 12, 671, 12, 1777, 12, 1434, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 2048, 63, 5404, 12, 291, 680, 604, 63, 362, 63, 3916, 8, 1556, 12, 1747, 12, 671, 12, 1777, 12, 1434, 12, 1067, 29, 1100, 9, 267, 522, 459, 6562, 63, 344, 418, 275, 671, 14, 362, 360, 6562, 63, 344, 297, 756, 9, 267, 372, 522, 421, 199, 533, 2933, 63, 5404, 63, 604, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 5404, 14, 604, 7, 272, 485, 3406, 275, 469, 267, 283, 6562, 63, 3710, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 6562, 14, 3710, 297, 283, 19979, 13573, 659, 272, 789, 272, 347, 8977, 63, 981, 8, 277, 12, 2467, 12, 1747, 12, 2385, 12, 1067, 29, 403, 304, 267, 1067, 275, 1067, 503, 1052, 267, 8977, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 6562, 14, 6562, 358, 267, 367, 1004, 315, 2385, 26, 288, 340, 1004, 14, 6562, 63, 3710, 63, 344, 26, 355, 5322, 275, 469, 490, 283, 354, 356, 1004, 14, 354, 12, 490, 283, 600, 356, 1004, 14, 5404, 63, 344, 14, 1955, 503, 756, 12, 490, 283, 3710, 63, 344, 356, 1004, 14, 6562, 63, 3710, 63, 344, 14, 344, 12, 490, 283, 9533, 63, 585, 356, 1004, 14, 4777, 63, 954, 2923, 12, 490, 283, 5191, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 5191, 63, 344, 14, 344, 12, 490, 283, 3899, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 3899, 63, 344, 14, 344, 12, 490, 283, 4627, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 4627, 63, 344, 14, 344, 12, 490, 283, 4968, 63, 344, 356, 1004, 14, 5404, 63, 344, 14, 4968, 63, 344, 14, 344, 12, 490, 283, 9533, 63, 602, 7, 520, 1004, 14, 5404, 63, 344, 14, 602, 63, 5404, 12, 355, 789, 355, 2896, 63, 3643, 275, 8977, 63, 1113, 14, 18128, 63, 3710, 63, 344, 8, 1556, 12, 1747, 12, 990, 5322, 459, 3710, 63, 344, 995, 1067, 29, 1100, 9, 355, 5322, 14, 873, 8, 2489, 63, 3643, 459, 585, 1105, 355, 8977, 63, 344, 275, 8977, 63, 1113, 14, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 355, 340, 1004, 14, 6562, 63, 3710, 63, 344, 14, 1490, 63, 6562, 26, 490, 8977, 63, 1113, 14, 3502, 8, 1556, 12, 1747, 12, 359, 6562, 63, 344, 467, 1067, 29, 1100, 9, 267, 372, 715, 421, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gauribhoite/personfinder
env/google_appengine/lib/django-1.4/django/contrib/localflavor/nl/forms.py
87
2859
""" NL-specific Form helpers """ from __future__ import absolute_import import re from django.contrib.localflavor.nl.nl_provinces import PROVINCE_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError from django.forms.fields import Field, Select from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ pc_re = re.compile('^\d{4}[A-Z]{2}$') sofi_re = re.compile('^\d{9}$') numeric_re = re.compile('^\d+$') class NLZipCodeField(Field): """ A Dutch postal code field. """ default_error_messages = { 'invalid': _('Enter a valid postal code'), } def clean(self, value): super(NLZipCodeField, self).clean(value) if value in EMPTY_VALUES: return u'' value = value.strip().upper().replace(' ', '') if not pc_re.search(value): raise ValidationError(self.error_messages['invalid']) if int(value[:4]) < 1000: raise ValidationError(self.error_messages['invalid']) return u'%s %s' % (value[:4], value[4:]) class NLProvinceSelect(Select): """ A Select widget that uses a list of provinces of the Netherlands as its choices. """ def __init__(self, attrs=None): super(NLProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) class NLPhoneNumberField(Field): """ A Dutch telephone number field. """ default_error_messages = { 'invalid': _('Enter a valid phone number'), } def clean(self, value): super(NLPhoneNumberField, self).clean(value) if value in EMPTY_VALUES: return u'' phone_nr = re.sub('[\-\s\(\)]', '', smart_unicode(value)) if len(phone_nr) == 10 and numeric_re.search(phone_nr): return value if phone_nr[:3] == '+31' and len(phone_nr) == 12 and \ numeric_re.search(phone_nr[3:]): return value raise ValidationError(self.error_messages['invalid']) class NLSoFiNumberField(Field): """ A Dutch social security number (SoFi/BSN) field. http://nl.wikipedia.org/wiki/Sofinummer """ default_error_messages = { 'invalid': _('Enter a valid SoFi number'), } def clean(self, value): super(NLSoFiNumberField, self).clean(value) if value in EMPTY_VALUES: return u'' if not sofi_re.search(value): raise ValidationError(self.error_messages['invalid']) if int(value) == 0: raise ValidationError(self.error_messages['invalid']) checksum = 0 for i in range(9, 1, -1): checksum += int(value[9-i]) * i checksum -= int(value[-1]) if checksum % 11 != 0: raise ValidationError(self.error_messages['invalid']) return value
apache-2.0
[ 624, 199, 14176, 13, 6100, 8204, 10897, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 295, 199, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 7530, 14, 7530, 63, 496, 11908, 823, 492, 3611, 54, 568, 2089, 63, 16236, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 9496, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 421, 199, 2352, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 91, 20, 22857, 33, 13, 58, 8194, 18, 93, 9988, 199, 1152, 329, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 91, 25, 93, 9988, 199, 6677, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 11, 9988, 199, 199, 533, 24719, 8674, 3034, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 2963, 279, 1233, 901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2963, 279, 1233, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 8674, 3034, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 574, 275, 574, 14, 1913, 1252, 4142, 1252, 1814, 360, 1656, 4074, 267, 340, 440, 13171, 63, 264, 14, 1733, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 340, 1109, 8, 585, 1491, 20, 566, 665, 5198, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 372, 399, 5956, 83, 450, 83, 7, 450, 334, 585, 1491, 20, 467, 574, 59, 20, 5728, 199, 199, 533, 24719, 919, 86, 2855, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 557, 11908, 823, 402, 314, 5612, 728, 31813, 465, 2399, 272, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 1613, 8, 14176, 919, 86, 2855, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 2514, 54, 568, 2089, 63, 16236, 9, 199, 199, 533, 24719, 25640, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 14001, 9339, 1329, 901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 14617, 1329, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 25640, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 14617, 63, 7865, 275, 295, 14, 954, 360, 7023, 2696, 83, 29323, 1874, 297, 3260, 11179, 63, 2975, 8, 585, 430, 398, 340, 822, 8, 9339, 63, 7865, 9, 508, 1616, 436, 8950, 63, 264, 14, 1733, 8, 9339, 63, 7865, 304, 288, 372, 574, 398, 340, 14617, 63, 7865, 1491, 19, 61, 508, 6681, 2192, 7, 436, 822, 8, 9339, 63, 7865, 9, 508, 3144, 436, 971, 1779, 8950, 63, 264, 14, 1733, 8, 9339, 63, 7865, 59, 19, 28847, 288, 372, 574, 398, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 199, 199, 533, 24719, 5158, 9047, 3259, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 20295, 6391, 1329, 334, 5158, 9047, 15, 34, 8199, 9, 901, 14, 339, 1455, 921, 7530, 14, 13961, 14, 1308, 15, 6797, 15, 51, 1618, 262, 453, 2626, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2002, 9047, 1329, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 5158, 9047, 3259, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 340, 440, 880, 329, 63, 264, 14, 1733, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 340, 1109, 8, 585, 9, 508, 378, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 9040, 275, 378, 267, 367, 284, 315, 1425, 8, 25, 12, 413, 12, 446, 17, 304, 288, 9040, 847, 1109, 8, 585, 59, 25, 13, 73, 566, 627, 284, 267, 9040, 4862, 1109, 8, 585, 1988, 17, 566, 398, 340, 9040, 450, 4119, 1137, 378, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 372, 574, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 14176, 13, 6100, 8204, 10897, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 295, 199, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 7530, 14, 7530, 63, 496, 11908, 823, 492, 3611, 54, 568, 2089, 63, 16236, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 9496, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 421, 199, 2352, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 91, 20, 22857, 33, 13, 58, 8194, 18, 93, 9988, 199, 1152, 329, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 91, 25, 93, 9988, 199, 6677, 63, 264, 275, 295, 14, 2014, 9097, 60, 68, 11, 9988, 199, 199, 533, 24719, 8674, 3034, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 2963, 279, 1233, 901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2963, 279, 1233, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 8674, 3034, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 574, 275, 574, 14, 1913, 1252, 4142, 1252, 1814, 360, 1656, 4074, 267, 340, 440, 13171, 63, 264, 14, 1733, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 340, 1109, 8, 585, 1491, 20, 566, 665, 5198, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 372, 399, 5956, 83, 450, 83, 7, 450, 334, 585, 1491, 20, 467, 574, 59, 20, 5728, 199, 199, 533, 24719, 919, 86, 2855, 5446, 8, 5446, 304, 272, 408, 272, 437, 9496, 3938, 626, 4440, 282, 769, 402, 557, 11908, 823, 402, 314, 5612, 728, 31813, 465, 2399, 272, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 1613, 8, 14176, 919, 86, 2855, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 2514, 54, 568, 2089, 63, 16236, 9, 199, 199, 533, 24719, 25640, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 14001, 9339, 1329, 901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 14617, 1329, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 25640, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 14617, 63, 7865, 275, 295, 14, 954, 360, 7023, 2696, 83, 29323, 1874, 297, 3260, 11179, 63, 2975, 8, 585, 430, 398, 340, 822, 8, 9339, 63, 7865, 9, 508, 1616, 436, 8950, 63, 264, 14, 1733, 8, 9339, 63, 7865, 304, 288, 372, 574, 398, 340, 14617, 63, 7865, 1491, 19, 61, 508, 6681, 2192, 7, 436, 822, 8, 9339, 63, 7865, 9, 508, 3144, 436, 971, 1779, 8950, 63, 264, 14, 1733, 8, 9339, 63, 7865, 59, 19, 28847, 288, 372, 574, 398, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 199, 199, 533, 24719, 5158, 9047, 3259, 792, 8, 792, 304, 272, 408, 272, 437, 577, 337, 335, 20295, 6391, 1329, 334, 5158, 9047, 15, 34, 8199, 9, 901, 14, 339, 1455, 921, 7530, 14, 13961, 14, 1308, 15, 6797, 15, 51, 1618, 262, 453, 2626, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 2002, 9047, 1329, 659, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 1613, 8, 14176, 5158, 9047, 3259, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 398, 340, 440, 880, 329, 63, 264, 14, 1733, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 340, 1109, 8, 585, 9, 508, 378, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 9040, 275, 378, 267, 367, 284, 315, 1425, 8, 25, 12, 413, 12, 446, 17, 304, 288, 9040, 847, 1109, 8, 585, 59, 25, 13, 73, 566, 627, 284, 267, 9040, 4862, 1109, 8, 585, 1988, 17, 566, 398, 340, 9040, 450, 4119, 1137, 378, 26, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 372, 574, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
eddiep1101/django-oscar
src/oscar/apps/catalogue/reviews/migrations/0001_initial.py
51
3324
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import django.db.models.deletion import oscar.core.validators from django.conf import settings class Migration(migrations.Migration): dependencies = [ ('catalogue', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='ProductReview', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('score', models.SmallIntegerField(verbose_name='Score', choices=[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)])), ('title', models.CharField(max_length=255, verbose_name='Title', validators=[oscar.core.validators.non_whitespace])), ('body', models.TextField(verbose_name='Body')), ('name', models.CharField(max_length=255, verbose_name='Name', blank=True)), ('email', models.EmailField(max_length=75, verbose_name='Email', blank=True)), ('homepage', models.URLField(verbose_name='URL', blank=True)), ('status', models.SmallIntegerField(default=1, verbose_name='Status', choices=[(0, 'Requires moderation'), (1, 'Approved'), (2, 'Rejected')])), ('total_votes', models.IntegerField(default=0, verbose_name='Total Votes')), ('delta_votes', models.IntegerField(default=0, db_index=True, verbose_name='Delta Votes')), ('date_created', models.DateTimeField(auto_now_add=True)), ('product', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, related_name='reviews', to='catalogue.Product', null=True)), ('user', models.ForeignKey(null=True, related_name='reviews', to=settings.AUTH_USER_MODEL, blank=True)), ], options={ 'ordering': ['-delta_votes', 'id'], 'verbose_name_plural': 'Product reviews', 'verbose_name': 'Product review', 'abstract': False, }, bases=(models.Model,), ), migrations.CreateModel( name='Vote', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('delta', models.SmallIntegerField(verbose_name='Delta', choices=[(1, 'Up'), (-1, 'Down')])), ('date_created', models.DateTimeField(auto_now_add=True)), ('review', models.ForeignKey(related_name='votes', to='reviews.ProductReview')), ('user', models.ForeignKey(related_name='review_votes', to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['-date_created'], 'verbose_name_plural': 'Votes', 'verbose_name': 'Vote', 'abstract': False, }, bases=(models.Model,), ), migrations.AlterUniqueTogether( name='vote', unique_together=set([('user', 'review')]), ), migrations.AlterUniqueTogether( name='productreview', unique_together=set([('product', 'user')]), ), ]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 312, 22707, 14, 1018, 14, 11346, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 22330, 297, 283, 4183, 63, 2747, 659, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 5884, 21000, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3397, 297, 1709, 14, 14640, 8, 3832, 63, 354, 534, 12642, 297, 3415, 17497, 16, 12, 378, 395, 334, 17, 12, 413, 395, 334, 18, 12, 499, 395, 334, 19, 12, 650, 395, 334, 20, 12, 841, 395, 334, 21, 12, 959, 3948, 395, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 6888, 297, 14370, 1524, 79, 22707, 14, 1018, 14, 11346, 14, 2865, 63, 8506, 12884, 355, 661, 2030, 297, 1709, 14, 6254, 8, 3832, 63, 354, 534, 8173, 3855, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 985, 297, 4596, 29, 549, 1826, 355, 661, 2123, 297, 1709, 14, 16577, 8, 988, 63, 1267, 29, 2194, 12, 3376, 63, 354, 534, 7035, 297, 4596, 29, 549, 1826, 355, 661, 25539, 297, 1709, 14, 17363, 8, 3832, 63, 354, 534, 2632, 297, 4596, 29, 549, 1826, 355, 661, 1205, 297, 1709, 14, 14640, 8, 885, 29, 17, 12, 3376, 63, 354, 534, 3694, 297, 3415, 17497, 16, 12, 283, 18153, 818, 1754, 659, 334, 17, 12, 283, 25923, 1354, 659, 334, 18, 12, 283, 497, 8553, 2023, 395, 355, 661, 2923, 63, 16660, 297, 1709, 14, 3901, 8, 885, 29, 16, 12, 3376, 63, 354, 534, 7316, 812, 6510, 3855, 355, 661, 3136, 63, 16660, 297, 1709, 14, 3901, 8, 885, 29, 16, 12, 1592, 63, 1080, 29, 549, 12, 3376, 63, 354, 534, 13411, 812, 6510, 3855, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 2558, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 3597, 63, 8084, 12, 4048, 63, 354, 534, 24169, 297, 370, 534, 22330, 14, 5884, 297, 2973, 29, 549, 1826, 355, 661, 751, 297, 1709, 14, 3190, 8, 2307, 29, 549, 12, 4048, 63, 354, 534, 24169, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 4596, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 11573, 3136, 63, 16660, 297, 283, 344, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 5884, 295, 4196, 297, 355, 283, 3832, 63, 354, 356, 283, 5884, 11248, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 54, 1583, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3136, 297, 1709, 14, 14640, 8, 3832, 63, 354, 534, 13411, 297, 3415, 17497, 17, 12, 283, 1721, 659, 5868, 17, 12, 283, 3514, 2023, 395, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 8578, 297, 1709, 14, 3190, 8, 2407, 63, 354, 534, 16660, 297, 370, 534, 24169, 14, 5884, 21000, 3855, 355, 661, 751, 297, 1709, 14, 3190, 8, 2407, 63, 354, 534, 8578, 63, 16660, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 11573, 602, 63, 3966, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 54, 6510, 297, 355, 283, 3832, 63, 354, 356, 283, 54, 1583, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14364, 11427, 1378, 4920, 8, 288, 536, 534, 14317, 297, 288, 3747, 63, 6314, 29, 409, 8318, 751, 297, 283, 8578, 22864, 267, 2318, 267, 6180, 14, 14364, 11427, 1378, 4920, 8, 288, 536, 534, 2558, 8578, 297, 288, 3747, 63, 6314, 29, 409, 8318, 2558, 297, 283, 751, 22864, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 312, 22707, 14, 1018, 14, 11346, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 22330, 297, 283, 4183, 63, 2747, 659, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 5884, 21000, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3397, 297, 1709, 14, 14640, 8, 3832, 63, 354, 534, 12642, 297, 3415, 17497, 16, 12, 378, 395, 334, 17, 12, 413, 395, 334, 18, 12, 499, 395, 334, 19, 12, 650, 395, 334, 20, 12, 841, 395, 334, 21, 12, 959, 3948, 395, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 6888, 297, 14370, 1524, 79, 22707, 14, 1018, 14, 11346, 14, 2865, 63, 8506, 12884, 355, 661, 2030, 297, 1709, 14, 6254, 8, 3832, 63, 354, 534, 8173, 3855, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 985, 297, 4596, 29, 549, 1826, 355, 661, 2123, 297, 1709, 14, 16577, 8, 988, 63, 1267, 29, 2194, 12, 3376, 63, 354, 534, 7035, 297, 4596, 29, 549, 1826, 355, 661, 25539, 297, 1709, 14, 17363, 8, 3832, 63, 354, 534, 2632, 297, 4596, 29, 549, 1826, 355, 661, 1205, 297, 1709, 14, 14640, 8, 885, 29, 17, 12, 3376, 63, 354, 534, 3694, 297, 3415, 17497, 16, 12, 283, 18153, 818, 1754, 659, 334, 17, 12, 283, 25923, 1354, 659, 334, 18, 12, 283, 497, 8553, 2023, 395, 355, 661, 2923, 63, 16660, 297, 1709, 14, 3901, 8, 885, 29, 16, 12, 3376, 63, 354, 534, 7316, 812, 6510, 3855, 355, 661, 3136, 63, 16660, 297, 1709, 14, 3901, 8, 885, 29, 16, 12, 1592, 63, 1080, 29, 549, 12, 3376, 63, 354, 534, 13411, 812, 6510, 3855, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 2558, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 3597, 63, 8084, 12, 4048, 63, 354, 534, 24169, 297, 370, 534, 22330, 14, 5884, 297, 2973, 29, 549, 1826, 355, 661, 751, 297, 1709, 14, 3190, 8, 2307, 29, 549, 12, 4048, 63, 354, 534, 24169, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 4596, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 11573, 3136, 63, 16660, 297, 283, 344, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 5884, 295, 4196, 297, 355, 283, 3832, 63, 354, 356, 283, 5884, 11248, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 54, 1583, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3136, 297, 1709, 14, 14640, 8, 3832, 63, 354, 534, 13411, 297, 3415, 17497, 17, 12, 283, 1721, 659, 5868, 17, 12, 283, 3514, 2023, 395, 355, 661, 602, 63, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 661, 8578, 297, 1709, 14, 3190, 8, 2407, 63, 354, 534, 16660, 297, 370, 534, 24169, 14, 5884, 21000, 3855, 355, 661, 751, 297, 1709, 14, 3190, 8, 2407, 63, 354, 534, 8578, 63, 16660, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 11573, 602, 63, 3966, 995, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 54, 6510, 297, 355, 283, 3832, 63, 354, 356, 283, 54, 1583, 297, 355, 283, 6198, 356, 756, 12, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14364, 11427, 1378, 4920, 8, 288, 536, 534, 14317, 297, 288, 3747, 63, 6314, 29, 409, 8318, 751, 297, 283, 8578, 22864, 267, 2318, 267, 6180, 14, 14364, 11427, 1378, 4920, 8, 288, 536, 534, 2558, 8578, 297, 288, 3747, 63, 6314, 29, 409, 8318, 2558, 297, 283, 751, 22864, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Ca1ne/EnochPrima
Documentation/target/tcm_mod_builder.py
3119
42754
#!/usr/bin/python # The TCM v4 multi-protocol fabric module generation script for drivers/target/$NEW_MOD # # Copyright (c) 2010 Rising Tide Systems # Copyright (c) 2010 Linux-iSCSI.org # # Author: nab@kernel.org # import os, sys import subprocess as sub import string import re import optparse tcm_dir = "" fabric_ops = [] fabric_mod_dir = "" fabric_mod_port = "" fabric_mod_init_port = "" def tcm_mod_err(msg): print msg sys.exit(1) def tcm_mod_create_module_subdir(fabric_mod_dir_var): if os.path.isdir(fabric_mod_dir_var) == True: return 1 print "Creating fabric_mod_dir: " + fabric_mod_dir_var ret = os.mkdir(fabric_mod_dir_var) if ret: tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var) return def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n" buf += " u64 nport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n" buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* FC lport target portal group tag for TCM */\n" buf += " u16 lport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n" buf += " struct " + fabric_mod_name + "_lport *lport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_lport {\n" buf += " /* SCSI protocol the lport is providing */\n" buf += " u8 lport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n" buf += " u64 lport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Target Lport */\n" buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n" buf += " struct se_wwn lport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "lport" fabric_mod_init_port = "nport" return def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n" buf += " u64 iport_wwpn;\n" buf += " /* ASCII formatted WWPN for Sas Initiator port */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* SAS port target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for SAS Target port */\n" buf += " u64 tport_wwpn;\n" buf += " /* ASCII formatted WWPN for SAS Target port */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* ASCII formatted InitiatorName */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* iSCSI target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* ASCII formatted TargetName for IQN */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_base_includes(proto_ident, fabric_mod_dir_val, fabric_mod_name): if proto_ident == "FC": tcm_mod_build_FC_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "SAS": tcm_mod_build_SAS_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "iSCSI": tcm_mod_build_iSCSI_include(fabric_mod_dir_val, fabric_mod_name) else: print "Unsupported proto_ident: " + proto_ident sys.exit(1) return def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_configfs.c" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#include <linux/module.h>\n" buf += "#include <linux/moduleparam.h>\n" buf += "#include <linux/version.h>\n" buf += "#include <generated/utsrelease.h>\n" buf += "#include <linux/utsname.h>\n" buf += "#include <linux/init.h>\n" buf += "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/configfs.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_configfs.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/configfs_macros.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "/* Local pointer to allocated TCM configfs fabric module */\n" buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n" buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n" buf += " u32 nexus_depth;\n\n" buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n" buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" buf += " if (!(se_nacl_new))\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" buf += " nexus_depth = 1;\n" buf += " /*\n" buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n" buf += " * when converting a NodeACL from demo mode -> explict\n" buf += " */\n" buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n" buf += " name, nexus_depth);\n" buf += " if (IS_ERR(se_nacl)) {\n" buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n" buf += " return se_nacl;\n" buf += " }\n" buf += " /*\n" buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n" buf += " */\n" buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" buf += " return se_nacl;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n" buf += " kfree(nacl);\n" buf += "}\n\n" buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n" buf += " struct se_wwn *wwn,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + "*" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n\n" buf += " struct " + fabric_mod_name + "_tpg *tpg;\n" buf += " unsigned long tpgt;\n" buf += " int ret;\n\n" buf += " if (strstr(name, \"tpgt_\") != name)\n" buf += " return ERR_PTR(-EINVAL);\n" buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" buf += " return ERR_PTR(-EINVAL);\n\n" buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" buf += " if (!(tpg)) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n" buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n" buf += " ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n" buf += " &tpg->se_tpg, (void *)tpg,\n" buf += " TRANSPORT_TPG_TYPE_NORMAL);\n" buf += " if (ret < 0) {\n" buf += " kfree(tpg);\n" buf += " return NULL;\n" buf += " }\n" buf += " return &tpg->se_tpg;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_tpg(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n" buf += " core_tpg_deregister(se_tpg);\n" buf += " kfree(tpg);\n" buf += "}\n\n" buf += "static struct se_wwn *" + fabric_mod_name + "_make_" + fabric_mod_port + "(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n\n" buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n\n" buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" buf += " if (!(" + fabric_mod_port + ")) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n" buf += " kfree(" + fabric_mod_port + ");\n" buf += "}\n\n" buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " char *page)\n" buf += "{\n" buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += "}\n\n" buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n" buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n" buf += " &" + fabric_mod_name + "_wwn_version.attr,\n" buf += " NULL,\n" buf += "};\n\n" buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n" buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n" buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n" buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n" buf += " .tpg_get_default_depth = " + fabric_mod_name + "_get_default_depth,\n" buf += " .tpg_get_pr_transport_id = " + fabric_mod_name + "_get_pr_transport_id,\n" buf += " .tpg_get_pr_transport_id_len = " + fabric_mod_name + "_get_pr_transport_id_len,\n" buf += " .tpg_parse_pr_out_transport_id = " + fabric_mod_name + "_parse_pr_out_transport_id,\n" buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n" buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n" buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" buf += " .release_cmd_to_pool = " + fabric_mod_name + "_release_cmd,\n" buf += " .release_cmd_direct = " + fabric_mod_name + "_release_cmd,\n" buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" buf += " .close_session = " + fabric_mod_name + "_close_session,\n" buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n" buf += " .fall_back_to_erl0 = " + fabric_mod_name + "_reset_nexus,\n" buf += " .sess_logged_in = " + fabric_mod_name + "_sess_logged_in,\n" buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n" buf += " .sess_get_initiator_sid = NULL,\n" buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n" buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n" buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n" buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n" buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n" buf += " .new_cmd_failure = " + fabric_mod_name + "_new_cmd_failure,\n" buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n" buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n" buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n" buf += " .get_fabric_sense_len = " + fabric_mod_name + "_get_fabric_sense_len,\n" buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n" buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n" buf += " .pack_lun = " + fabric_mod_name + "_pack_lun,\n" buf += " /*\n" buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n" buf += " */\n" buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n" buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" buf += " .fabric_post_link = NULL,\n" buf += " .fabric_pre_unlink = NULL,\n" buf += " .fabric_make_np = NULL,\n" buf += " .fabric_drop_np = NULL,\n" buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n" buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n" buf += "};\n\n" buf += "static int " + fabric_mod_name + "_register_configfs(void)\n" buf += "{\n" buf += " struct target_fabric_configfs *fabric;\n" buf += " int ret;\n\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += " /*\n" buf += " * Register the top level struct config_item_type with TCM core\n" buf += " */\n" buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" buf += " if (!(fabric)) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" buf += " return -ENOMEM;\n" buf += " }\n" buf += " /*\n" buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" buf += " */\n" buf += " fabric->tf_ops = " + fabric_mod_name + "_ops;\n" buf += " /*\n" buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n" buf += " */\n" buf += " TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" buf += " /*\n" buf += " * Register the fabric for use within TCM\n" buf += " */\n" buf += " ret = target_fabric_configfs_register(fabric);\n" buf += " if (ret < 0) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n" buf += " \" for " + fabric_mod_name.upper() + "\\n\");\n" buf += " return ret;\n" buf += " }\n" buf += " /*\n" buf += " * Setup our local pointer to *fabric\n" buf += " */\n" buf += " " + fabric_mod_name + "_fabric_configfs = fabric;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n" buf += "{\n" buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n" buf += " return;\n\n" buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += "};\n\n" buf += "static int __init " + fabric_mod_name + "_init(void)\n" buf += "{\n" buf += " int ret;\n\n" buf += " ret = " + fabric_mod_name + "_register_configfs();\n" buf += " if (ret < 0)\n" buf += " return ret;\n\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_exit(void)\n" buf += "{\n" buf += " " + fabric_mod_name + "_deregister_configfs();\n" buf += "};\n\n" buf += "#ifdef MODULE\n" buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" buf += "MODULE_LICENSE(\"GPL\");\n" buf += "module_init(" + fabric_mod_name + "_init);\n" buf += "module_exit(" + fabric_mod_name + "_exit);\n" buf += "#endif\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_scan_fabric_ops(tcm_dir): fabric_ops_api = tcm_dir + "include/target/target_core_fabric_ops.h" print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api process_fo = 0; p = open(fabric_ops_api, 'r') line = p.readline() while line: if process_fo == 0 and re.search('struct target_core_fabric_ops {', line): line = p.readline() continue if process_fo == 0: process_fo = 1; line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) continue line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) p.close() return def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" bufi = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.c" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) fi = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.h" print "Writing file: " + fi pi = open(fi, 'w') if not pi: tcm_mod_err("Unable to open file: " + fi) buf = "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/list.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n" buf += "#include <scsi/scsi.h>\n" buf += "#include <scsi/scsi_host.h>\n" buf += "#include <scsi/scsi_device.h>\n" buf += "#include <scsi/scsi_cmnd.h>\n" buf += "#include <scsi/libfc.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "int " + fabric_mod_name + "_check_true(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_true(struct se_portal_group *);\n" buf += "int " + fabric_mod_name + "_check_false(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_false(struct se_portal_group *);\n" total_fabric_ops = len(fabric_ops) i = 0 while i < total_fabric_ops: fo = fabric_ops[i] i += 1 # print "fabric_ops: " + fo if re.search('get_fabric_name', fo): buf += "char *" + fabric_mod_name + "_get_fabric_name(void)\n" buf += "{\n" buf += " return \"" + fabric_mod_name[4:] + "\";\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_name(void);\n" continue if re.search('get_fabric_proto_ident', fo): buf += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " u8 proto_id;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " proto_id = fc_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " proto_id = sas_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " proto_id = iscsi_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" buf += " }\n\n" buf += " return proto_id;\n" buf += "}\n\n" bufi += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *);\n" if re.search('get_wwn', fo): buf += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_name[0];\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *);\n" if re.search('get_tag', fo): buf += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " return tpg->" + fabric_mod_port + "_tpgt;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *);\n" if re.search('get_default_depth', fo): buf += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *);\n" if re.search('get_pr_transport_id\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code,\n" buf += " unsigned char *buf)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *, unsigned char *);\n" if re.search('get_pr_transport_id_len\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *);\n" if re.search('parse_pr_out_transport_id\)\(', fo): buf += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " const char *buf,\n" buf += " u32 *out_tid_len,\n" buf += " char **port_nexus_ptr)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " char *tid = NULL;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " tid = fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " tid = iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" buf += " }\n\n" buf += " return tid;\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n" bufi += " const char *, u32 *, char **);\n" if re.search('alloc_fabric_acl\)\(', fo): buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" buf += " if (!(nacl)) {\n" buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n" buf += " return NULL;\n" buf += " }\n\n" buf += " return &nacl->se_node_acl;\n" buf += "}\n\n" bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n" if re.search('release_fabric_acl\)\(', fo): buf += "void " + fabric_mod_name + "_release_fabric_acl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " kfree(nacl);\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n" bufi += " struct se_node_acl *);\n" if re.search('tpg_get_inst_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n" if re.search('release_cmd_to_pool', fo): buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n" if re.search('shutdown_session\)\(', fo): buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n" if re.search('close_session\)\(', fo): buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_close_session(struct se_session *);\n" if re.search('stop_session\)\(', fo): buf += "void " + fabric_mod_name + "_stop_session(struct se_session *se_sess, int sess_sleep , int conn_sleep)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_stop_session(struct se_session *, int, int);\n" if re.search('fall_back_to_erl0\)\(', fo): buf += "void " + fabric_mod_name + "_reset_nexus(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_reset_nexus(struct se_session *);\n" if re.search('sess_logged_in\)\(', fo): buf += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *);\n" if re.search('sess_get_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *);\n" if re.search('write_pending\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending(struct se_cmd *);\n" if re.search('write_pending_status\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *);\n" if re.search('set_default_node_attributes\)\(', fo): buf += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *nacl)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *);\n" if re.search('get_task_tag\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *);\n" if re.search('get_cmd_state\)\(', fo): buf += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n" if re.search('new_cmd_failure\)\(', fo): buf += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *);\n" if re.search('queue_data_in\)\(', fo): buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *);\n" if re.search('queue_status\)\(', fo): buf += "int " + fabric_mod_name + "_queue_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_status(struct se_cmd *);\n" if re.search('queue_tm_rsp\)\(', fo): buf += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *);\n" if re.search('get_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void);\n" if re.search('set_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *, u32);\n" if re.search('is_state_remove\)\(', fo): buf += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n" if re.search('pack_lun\)\(', fo): buf += "u64 " + fabric_mod_name + "_pack_lun(unsigned int lun)\n" buf += "{\n" buf += " WARN_ON(lun >= 256);\n" buf += " /* Caller wants this byte-swapped */\n" buf += " return cpu_to_le64((lun & 0xff) << 8);\n" buf += "}\n\n" bufi += "u64 " + fabric_mod_name + "_pack_lun(unsigned int);\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() ret = pi.write(bufi) if ret: tcm_mod_err("Unable to write fi: " + fi) pi.close() return def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Makefile" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf += fabric_mod_name + "-objs := " + fabric_mod_name + "_fabric.o \\\n" buf += " " + fabric_mod_name + "_configfs.o\n" buf += "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name + ".o\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Kconfig" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf = "config " + fabric_mod_name.upper() + "\n" buf += " tristate \"" + fabric_mod_name.upper() + " fabric module\"\n" buf += " depends on TARGET_CORE && CONFIGFS_FS\n" buf += " default n\n" buf += " ---help---\n" buf += " Say Y here to enable the " + fabric_mod_name.upper() + " fabric module\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_add_kbuild(tcm_dir, fabric_mod_name): buf = "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name.lower() + "/\n" kbuild = tcm_dir + "/drivers/target/Makefile" f = open(kbuild, 'a') f.write(buf) f.close() return def tcm_mod_add_kconfig(tcm_dir, fabric_mod_name): buf = "source \"drivers/target/" + fabric_mod_name.lower() + "/Kconfig\"\n" kconfig = tcm_dir + "/drivers/target/Kconfig" f = open(kconfig, 'a') f.write(buf) f.close() return def main(modname, proto_ident): # proto_ident = "FC" # proto_ident = "SAS" # proto_ident = "iSCSI" tcm_dir = os.getcwd(); tcm_dir += "/../../" print "tcm_dir: " + tcm_dir fabric_mod_name = modname fabric_mod_dir = tcm_dir + "drivers/target/" + fabric_mod_name print "Set fabric_mod_name: " + fabric_mod_name print "Set fabric_mod_dir: " + fabric_mod_dir print "Using proto_ident: " + proto_ident if proto_ident != "FC" and proto_ident != "SAS" and proto_ident != "iSCSI": print "Unsupported proto_ident: " + proto_ident sys.exit(1) ret = tcm_mod_create_module_subdir(fabric_mod_dir) if ret: print "tcm_mod_create_module_subdir() failed because module already exists!" sys.exit(1) tcm_mod_build_base_includes(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_scan_fabric_ops(tcm_dir) tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_configfs(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name) tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Makefile..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kbuild(tcm_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Kconfig..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kconfig(tcm_dir, fabric_mod_name) return parser = optparse.OptionParser() parser.add_option('-m', '--modulename', help='Module name', dest='modname', action='store', nargs=1, type='string') parser.add_option('-p', '--protoident', help='Protocol Ident', dest='protoident', action='store', nargs=1, type='string') (opts, args) = parser.parse_args() mandatories = ['modname', 'protoident'] for m in mandatories: if not opts.__dict__[m]: print "mandatory option is missing\n" parser.print_help() exit(-1) if __name__ == "__main__": main(str(opts.modname), opts.protoident)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
matpalm/malmomo
viz_advantage_surface.py
1
3160
#!/usr/bin/env python # hacktasic viz of the quadratic surface of advantage around the max output # for a couple of clear block on right / left / center cases import agents import argparse import base_network import Image import numpy as np import models import sys import tensorflow as tf import replay_memory import util from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt from matplotlib import cm np.set_printoptions(precision=5, threshold=10000, suppress=True, linewidth=10000) parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--width', type=int, default=160, help="render width") parser.add_argument('--height', type=int, default=120, help="render height") agents.add_opts(parser) models.add_opts(parser) replay_memory.add_opts(parser) util.add_opts(parser) opts = parser.parse_args() #opts.ckpt_dir = "runs/14/d/ckpts" # last known good print >>sys.stderr, "OPTS", opts # init our rl_agent agent_cstr = eval("agents.NafAgent") agent = agent_cstr(opts) an = agent.network # prepare three plots; one for each of block on left, in center, or on right fig = plt.figure(figsize=plt.figaspect(0.3)) plt.title(opts.ckpt_dir) R = np.arange(-1, 1.25, 0.25) X, Y = np.meshgrid(R, R) for plot_idx, (img_file, desc) in enumerate([("runs/14/d/imgs/ep_00007/e0000.png", "on left"), ("runs/14/d/imgs/ep_00007/e0019.png", "center"), ("runs/14/d/imgs/ep_00007/e0034.png", "on right")]): print "calculating for", desc, "..." # slurp in bitmap img = Image.open(img_file) img = np.array(img)[:,:,:3] # collect q-value for all x, y values in one hit all_x_y_pairs = np.stack(zip(np.ravel(X), np.ravel(Y))) img_repeated = [img] * all_x_y_pairs.shape[0] q_values = agent.sess.run(an.q_value, feed_dict={an.input_state: img_repeated, an.input_action: all_x_y_pairs, base_network.FLIP_HORIZONTALLY: False}) Z = q_values.reshape(X.shape) # plot as surface ax = fig.add_subplot(1,3,plot_idx+1, projection='3d') ax.plot_surface(X, Y, Z, rstride=1, cstride=1, color='b', cmap=cm.coolwarm, linewidth=1) ax.set_title(desc) ax.set_xlabel("turn") ax.set_ylabel("move") ax.set_zlabel("q") # include single vertical line where q was maximised (according to output_action) output = agent.sess.run(an.output_action, feed_dict={an.input_state: [img], base_network.FLIP_HORIZONTALLY: False}) turn, move = np.squeeze(output) q_value = agent.sess.run(an.q_value, feed_dict={an.input_state: [img], an.input_action: [[turn, move]], base_network.FLIP_HORIZONTALLY: False}) print "turn", turn, "move", move, "=> q", np.squeeze(q_value), "Zmin=", np.min(Z), "Zmax=", np.max(Z) ax.plot([turn, turn], [move, move], [np.min(Z), np.max(Z)], linewidth=5) # render plt.savefig("/tmp/test.png") plt.show()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 11176, 84, 2484, 373, 565, 402, 314, 16744, 19826, 13195, 402, 30268, 6818, 314, 1390, 1072, 199, 3, 367, 282, 17535, 402, 5436, 1853, 641, 2451, 1182, 3602, 1182, 8126, 5560, 199, 199, 646, 22867, 199, 646, 7534, 199, 646, 1300, 63, 1200, 199, 646, 6047, 199, 646, 2680, 465, 980, 199, 646, 1709, 199, 646, 984, 199, 646, 3228, 465, 2833, 199, 646, 24331, 63, 4844, 199, 646, 4884, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 7824, 19, 68, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 492, 6904, 199, 199, 1590, 14, 409, 63, 1361, 1419, 8, 6833, 29, 21, 12, 8765, 29, 9943, 12, 15678, 29, 549, 12, 21213, 29, 9943, 9, 199, 199, 2087, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 2087, 14, 525, 63, 2094, 4517, 2063, 297, 730, 29, 442, 12, 849, 29, 8488, 12, 1720, 628, 3352, 3462, 531, 199, 2087, 14, 525, 63, 2094, 4517, 3333, 297, 730, 29, 442, 12, 849, 29, 6708, 12, 1720, 628, 3352, 4569, 531, 199, 14250, 14, 525, 63, 3291, 8, 2087, 9, 199, 992, 14, 525, 63, 3291, 8, 2087, 9, 199, 19540, 63, 4844, 14, 525, 63, 3291, 8, 2087, 9, 199, 1974, 14, 525, 63, 3291, 8, 2087, 9, 199, 3291, 275, 1798, 14, 1122, 63, 589, 342, 199, 3, 3291, 14, 24462, 63, 694, 275, 298, 10802, 15, 1079, 15, 68, 15, 346, 8382, 2, 221, 327, 2061, 6040, 6954, 199, 1361, 4331, 1274, 14, 3083, 12, 298, 25636, 401, 3999, 199, 199, 3, 4205, 4154, 25717, 63, 4054, 199, 4054, 63, 67, 495, 275, 3468, 480, 14250, 14, 46, 2756, 7788, 531, 199, 4054, 275, 6631, 63, 67, 495, 8, 3291, 9, 199, 290, 275, 6631, 14, 1200, 199, 199, 3, 9275, 7795, 19695, 27, 1373, 367, 1924, 402, 1853, 641, 3602, 12, 315, 8126, 12, 503, 641, 2451, 199, 592, 275, 4488, 14, 8941, 8, 23899, 29, 6003, 14, 592, 18658, 8, 16, 14, 19, 430, 199, 6003, 14, 1213, 8, 3291, 14, 24462, 63, 694, 9, 199, 50, 275, 980, 14, 5605, 2801, 17, 12, 413, 14, 821, 12, 378, 14, 821, 9, 199, 56, 12, 1488, 275, 980, 14, 6480, 3825, 8, 50, 12, 820, 9, 199, 509, 5137, 63, 2996, 12, 334, 4060, 63, 493, 12, 4328, 9, 315, 3874, 27187, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 993, 14, 4524, 401, 298, 265, 3602, 1288, 6163, 1689, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 25018, 14, 4524, 401, 298, 4218, 1288, 6163, 1689, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 383, 1082, 14, 4524, 401, 298, 265, 2451, 531, 4682, 523, 870, 298, 13494, 1958, 367, 401, 4328, 12, 298, 11500, 819, 327, 5340, 300, 80, 315, 20810, 523, 6050, 275, 6047, 14, 1490, 8, 4060, 63, 493, 9, 523, 6050, 275, 980, 14, 1144, 8, 4060, 24517, 11941, 26, 19, 61, 819, 327, 8775, 1894, 13, 585, 367, 1006, 671, 12, 612, 1338, 315, 1373, 9793, 523, 1006, 63, 88, 63, 89, 63, 7322, 275, 980, 14, 2340, 8, 3065, 8, 1590, 14, 11186, 8, 56, 395, 980, 14, 11186, 8, 57, 1724, 523, 6050, 63, 7593, 275, 359, 4060, 61, 627, 1006, 63, 88, 63, 89, 63, 7322, 14, 1392, 59, 16, 61, 523, 1894, 63, 1459, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 81, 63, 585, 12, 1169, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 6050, 63, 7593, 12, 4318, 376, 14, 1210, 63, 1287, 26, 1006, 63, 88, 63, 89, 63, 7322, 12, 4318, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 3107, 275, 1894, 63, 1459, 14, 5217, 8, 56, 14, 1392, 9, 819, 327, 5137, 465, 13195, 523, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 19, 12, 2798, 63, 2996, 11, 17, 12, 14777, 534, 19, 68, 358, 523, 2185, 14, 2798, 63, 10992, 8, 56, 12, 1488, 12, 3107, 12, 519, 12318, 29, 17, 12, 286, 12318, 29, 17, 12, 3164, 534, 66, 297, 14920, 29, 4400, 14, 18499, 10669, 12, 21213, 29, 17, 9, 523, 2185, 14, 409, 63, 1213, 8, 3257, 9, 523, 2185, 14, 409, 63, 14168, 480, 353, 531, 523, 2185, 14, 409, 63, 13849, 480, 1185, 531, 523, 2185, 14, 409, 63, 90, 1302, 480, 81, 531, 819, 327, 2387, 2849, 13763, 1004, 2382, 1894, 1990, 1390, 1017, 9096, 334, 645, 5422, 370, 1072, 63, 1287, 9, 523, 1072, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 1199, 63, 1287, 12, 2079, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 359, 4060, 467, 3660, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 7485, 12, 4057, 275, 980, 14, 16597, 8, 1199, 9, 523, 1894, 63, 585, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 81, 63, 585, 12, 2574, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 359, 4060, 467, 4228, 376, 14, 1210, 63, 1287, 26, 3474, 353, 12, 4057, 2365, 4228, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 870, 298, 353, 401, 7485, 12, 298, 1185, 401, 4057, 12, 298, 28266, 1894, 401, 980, 14, 16597, 8, 81, 63, 585, 395, 298, 58, 827, 11107, 980, 14, 827, 8, 58, 395, 298, 58, 988, 11107, 980, 14, 988, 8, 58, 9, 523, 2185, 14, 2798, 779, 353, 12, 7485, 467, 359, 1185, 12, 4057, 467, 359, 1590, 14, 827, 8, 58, 395, 980, 14, 988, 8, 58, 4360, 21213, 29, 21, 9, 421, 199, 3, 3795, 199, 6003, 14, 19556, 4769, 2791, 15, 396, 14, 4524, 531, 199, 6003, 14, 2384, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 11176, 84, 2484, 373, 565, 402, 314, 16744, 19826, 13195, 402, 30268, 6818, 314, 1390, 1072, 199, 3, 367, 282, 17535, 402, 5436, 1853, 641, 2451, 1182, 3602, 1182, 8126, 5560, 199, 199, 646, 22867, 199, 646, 7534, 199, 646, 1300, 63, 1200, 199, 646, 6047, 199, 646, 2680, 465, 980, 199, 646, 1709, 199, 646, 984, 199, 646, 3228, 465, 2833, 199, 646, 24331, 63, 4844, 199, 646, 4884, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 7824, 19, 68, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 8027, 492, 6904, 199, 199, 1590, 14, 409, 63, 1361, 1419, 8, 6833, 29, 21, 12, 8765, 29, 9943, 12, 15678, 29, 549, 12, 21213, 29, 9943, 9, 199, 199, 2087, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 199, 2087, 14, 525, 63, 2094, 4517, 2063, 297, 730, 29, 442, 12, 849, 29, 8488, 12, 1720, 628, 3352, 3462, 531, 199, 2087, 14, 525, 63, 2094, 4517, 3333, 297, 730, 29, 442, 12, 849, 29, 6708, 12, 1720, 628, 3352, 4569, 531, 199, 14250, 14, 525, 63, 3291, 8, 2087, 9, 199, 992, 14, 525, 63, 3291, 8, 2087, 9, 199, 19540, 63, 4844, 14, 525, 63, 3291, 8, 2087, 9, 199, 1974, 14, 525, 63, 3291, 8, 2087, 9, 199, 3291, 275, 1798, 14, 1122, 63, 589, 342, 199, 3, 3291, 14, 24462, 63, 694, 275, 298, 10802, 15, 1079, 15, 68, 15, 346, 8382, 2, 221, 327, 2061, 6040, 6954, 199, 1361, 4331, 1274, 14, 3083, 12, 298, 25636, 401, 3999, 199, 199, 3, 4205, 4154, 25717, 63, 4054, 199, 4054, 63, 67, 495, 275, 3468, 480, 14250, 14, 46, 2756, 7788, 531, 199, 4054, 275, 6631, 63, 67, 495, 8, 3291, 9, 199, 290, 275, 6631, 14, 1200, 199, 199, 3, 9275, 7795, 19695, 27, 1373, 367, 1924, 402, 1853, 641, 3602, 12, 315, 8126, 12, 503, 641, 2451, 199, 592, 275, 4488, 14, 8941, 8, 23899, 29, 6003, 14, 592, 18658, 8, 16, 14, 19, 430, 199, 6003, 14, 1213, 8, 3291, 14, 24462, 63, 694, 9, 199, 50, 275, 980, 14, 5605, 2801, 17, 12, 413, 14, 821, 12, 378, 14, 821, 9, 199, 56, 12, 1488, 275, 980, 14, 6480, 3825, 8, 50, 12, 820, 9, 199, 509, 5137, 63, 2996, 12, 334, 4060, 63, 493, 12, 4328, 9, 315, 3874, 27187, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 993, 14, 4524, 401, 298, 265, 3602, 1288, 6163, 1689, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 25018, 14, 4524, 401, 298, 4218, 1288, 6163, 1689, 10802, 15, 1079, 15, 68, 15, 1017, 458, 15, 1545, 63, 993, 23, 15, 69, 383, 1082, 14, 4524, 401, 298, 265, 2451, 531, 4682, 523, 870, 298, 13494, 1958, 367, 401, 4328, 12, 298, 11500, 819, 327, 5340, 300, 80, 315, 20810, 523, 6050, 275, 6047, 14, 1490, 8, 4060, 63, 493, 9, 523, 6050, 275, 980, 14, 1144, 8, 4060, 24517, 11941, 26, 19, 61, 819, 327, 8775, 1894, 13, 585, 367, 1006, 671, 12, 612, 1338, 315, 1373, 9793, 523, 1006, 63, 88, 63, 89, 63, 7322, 275, 980, 14, 2340, 8, 3065, 8, 1590, 14, 11186, 8, 56, 395, 980, 14, 11186, 8, 57, 1724, 523, 6050, 63, 7593, 275, 359, 4060, 61, 627, 1006, 63, 88, 63, 89, 63, 7322, 14, 1392, 59, 16, 61, 523, 1894, 63, 1459, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 81, 63, 585, 12, 1169, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 6050, 63, 7593, 12, 4318, 376, 14, 1210, 63, 1287, 26, 1006, 63, 88, 63, 89, 63, 7322, 12, 4318, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 3107, 275, 1894, 63, 1459, 14, 5217, 8, 56, 14, 1392, 9, 819, 327, 5137, 465, 13195, 523, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 19, 12, 2798, 63, 2996, 11, 17, 12, 14777, 534, 19, 68, 358, 523, 2185, 14, 2798, 63, 10992, 8, 56, 12, 1488, 12, 3107, 12, 519, 12318, 29, 17, 12, 286, 12318, 29, 17, 12, 3164, 534, 66, 297, 14920, 29, 4400, 14, 18499, 10669, 12, 21213, 29, 17, 9, 523, 2185, 14, 409, 63, 1213, 8, 3257, 9, 523, 2185, 14, 409, 63, 14168, 480, 353, 531, 523, 2185, 14, 409, 63, 13849, 480, 1185, 531, 523, 2185, 14, 409, 63, 90, 1302, 480, 81, 531, 819, 327, 2387, 2849, 13763, 1004, 2382, 1894, 1990, 1390, 1017, 9096, 334, 645, 5422, 370, 1072, 63, 1287, 9, 523, 1072, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 1199, 63, 1287, 12, 2079, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 359, 4060, 467, 3660, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 7485, 12, 4057, 275, 980, 14, 16597, 8, 1199, 9, 523, 1894, 63, 585, 275, 6631, 14, 5480, 14, 1065, 8, 290, 14, 81, 63, 585, 12, 2574, 4733, 63, 807, 3126, 290, 14, 1210, 63, 929, 26, 359, 4060, 467, 4228, 376, 14, 1210, 63, 1287, 26, 3474, 353, 12, 4057, 2365, 4228, 1300, 63, 1200, 14, 3143, 1772, 63, 40, 7947, 28292, 26, 756, 1552, 523, 870, 298, 353, 401, 7485, 12, 298, 1185, 401, 4057, 12, 298, 28266, 1894, 401, 980, 14, 16597, 8, 81, 63, 585, 395, 298, 58, 827, 11107, 980, 14, 827, 8, 58, 395, 298, 58, 988, 11107, 980, 14, 988, 8, 58, 9, 523, 2185, 14, 2798, 779, 353, 12, 7485, 467, 359, 1185, 12, 4057, 467, 359, 1590, 14, 827, 8, 58, 395, 980, 14, 988, 8, 58, 4360, 21213, 29, 21, 9, 421, 199, 3, 3795, 199, 6003, 14, 19556, 4769, 2791, 15, 396, 14, 4524, 531, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32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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 ]
jkarabas/py-snarkx
snarkx/io/graph6.py
1
3675
import networkx as nx from os.path import abspath, isfile, join, dirname, isdir, basename, splitext from tempfile import TemporaryFile from snarkx.io import ParseFileError __all__ = ['GraphReaderG6', 'GraphWriterG6'] class GraphReaderG6(object): def __init__(self, path: str): if path is None: raise TypeError('`None` not allowed.') self._filepath = abspath(path) if not isfile(self._filepath): raise FileNotFoundError def __iter__(self): self._stream = open(self._filepath, 'r', encoding='ascii') # graph file to be read self._line_no = 0 return self def __next__(self): if self._stream.closed: raise RuntimeError('Input file is closed.') while True: try: _rawline = self._stream.readline() except UnicodeDecodeError: raise ParseFileError("File '{0}' not likely in correct format.".format(self._filepath)) except: raise self._line_no += 1 if _rawline == '': self._stream.close() raise StopIteration try: graph = nx.parse_graph6(_rawline.strip()) return graph except (nx.NetworkXError, TypeError): raise ParseFileError("File '{0}' not likely in correct format.".format(self._filepath)) except: raise class GraphWriterG6(object): max_bound = None allow_comments = False default_extension = '.g6' def __init__(self, path): if path is None: raise TypeError('`None` not allowed for `path`.') _dirname = dirname(abspath(path)) if not (isdir(_dirname)): raise RuntimeError('Directory does not exist: {0}'.format(_dirname)) _filename = basename(abspath(path)) self._filename = join(_dirname, _filename) if isdir(join(_dirname, _filename)): raise RuntimeError('The directory: {0}'.format(self._filename)) # self._stream = open(self._filename, mode='w+t', encoding='ascii') self._tstream = TemporaryFile(mode='w+t') self._empty = True def __del__(self): self.close() def write(self, graph): if not self._tstream.closed: try: if self._empty: self._tstream.write('{0}\n'.format(nx.generate_graph6(graph))) self._empty = False else: self._tstream.write('{0}\n'.format(nx.generate_graph6(graph, header=False))) except nx.NetworkXError: pass # FIXME an exception should not be silently passed except: raise else: raise RuntimeError('Writing to a closed file: {0}'.format(self._filename)) def close(self): if not self._empty: _stream = open(self._filename, mode='w+t', encoding='ascii') self._tstream.seek(0) for _line in self._tstream: _stream.write('{0}\n'.format(_line.strip())) _stream.close() self._tstream = None _stream = None if __name__ == '__main__': ipath = '/Users/janci/_WORK_/_DEPRECATED_/snarkx-py/snarkx/resources/hog' ifilename = 'Generated_graphs.22.05.sn.cyc4.g6.bad' opath = '.' ofilename = 'file.g6' reader = GraphReaderG6(join(ipath, ifilename)) writer = GraphWriterG6(join(opath, ofilename)) gno = 0 for graph in reader: gno += 1 print('Graph no {0} with order {1}'.format(gno, len(graph))) writer.write(graph)
gpl-3.0
[ 646, 24313, 465, 8484, 199, 504, 747, 14, 515, 492, 19529, 12, 29214, 12, 4263, 12, 9017, 12, 26004, 12, 9593, 12, 2249, 7699, 199, 504, 5549, 492, 21791, 1173, 199, 199, 504, 6895, 1096, 88, 14, 2308, 492, 6077, 25212, 199, 199, 363, 452, 363, 275, 788, 4578, 5929, 39, 22, 297, 283, 4578, 6261, 39, 22, 418, 421, 199, 533, 11513, 5929, 39, 22, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 931, 26, 620, 304, 267, 340, 931, 365, 488, 26, 288, 746, 3146, 360, 64, 403, 64, 440, 4370, 2659, 398, 291, 423, 7218, 275, 19529, 8, 515, 9, 267, 340, 440, 29214, 8, 277, 423, 7218, 304, 288, 746, 3814, 10870, 339, 347, 636, 1661, 721, 277, 304, 267, 291, 423, 1745, 275, 1551, 8, 277, 423, 7218, 12, 283, 82, 297, 2644, 534, 4371, 358, 221, 327, 3343, 570, 370, 506, 1586, 267, 291, 423, 604, 63, 889, 275, 378, 267, 372, 291, 339, 347, 636, 2184, 721, 277, 304, 267, 340, 291, 423, 1745, 14, 5938, 26, 288, 746, 6064, 360, 3205, 570, 365, 6876, 2659, 267, 1830, 715, 26, 288, 862, 26, 355, 485, 1773, 604, 275, 291, 423, 1745, 14, 6407, 342, 288, 871, 18965, 26, 355, 746, 6077, 25212, 480, 1173, 5041, 16, 6834, 440, 12060, 315, 3211, 1475, 15848, 908, 8, 277, 423, 7218, 430, 288, 871, 26, 355, 746, 288, 291, 423, 604, 63, 889, 847, 413, 288, 340, 485, 1773, 604, 508, 8061, 355, 291, 423, 1745, 14, 1600, 342, 355, 746, 10852, 288, 862, 26, 355, 3343, 275, 8484, 14, 1122, 63, 2180, 22, 1547, 1773, 604, 14, 1913, 1012, 355, 372, 3343, 288, 871, 334, 7343, 14, 4491, 29356, 12, 3146, 304, 355, 746, 6077, 25212, 480, 1173, 5041, 16, 6834, 440, 12060, 315, 3211, 1475, 15848, 908, 8, 277, 423, 7218, 430, 288, 871, 26, 355, 746, 421, 199, 533, 11513, 6261, 39, 22, 8, 785, 304, 272, 1390, 63, 3556, 275, 488, 272, 2040, 63, 6223, 275, 756, 272, 849, 63, 3435, 275, 1987, 71, 22, 7, 339, 347, 636, 826, 721, 277, 12, 931, 304, 267, 340, 931, 365, 488, 26, 288, 746, 3146, 360, 64, 403, 64, 440, 4370, 367, 658, 515, 2313, 358, 398, 485, 3475, 275, 9017, 8, 4832, 8, 515, 430, 267, 340, 440, 334, 6027, 1547, 3475, 2298, 288, 746, 6064, 360, 6231, 1630, 440, 2187, 26, 469, 16, 5285, 908, 1547, 3475, 430, 267, 485, 1501, 275, 9593, 8, 4832, 8, 515, 430, 267, 291, 423, 1501, 275, 4263, 1547, 3475, 12, 485, 1501, 9, 267, 340, 26004, 8, 904, 1547, 3475, 12, 485, 1501, 2298, 288, 746, 6064, 360, 1918, 2082, 26, 469, 16, 5285, 908, 8, 277, 423, 1501, 430, 398, 327, 291, 423, 1745, 275, 1551, 8, 277, 423, 1501, 12, 818, 534, 87, 11, 84, 297, 2644, 534, 4371, 358, 267, 291, 423, 84, 1745, 275, 21791, 1173, 8, 632, 534, 87, 11, 84, 358, 267, 291, 423, 1667, 275, 715, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 1600, 342, 339, 347, 2218, 8, 277, 12, 3343, 304, 267, 340, 440, 291, 423, 84, 1745, 14, 5938, 26, 288, 862, 26, 355, 340, 291, 423, 1667, 26, 490, 291, 423, 84, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 8, 7343, 14, 4208, 63, 2180, 22, 8, 2180, 1724, 490, 291, 423, 1667, 275, 756, 355, 587, 26, 490, 291, 423, 84, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 8, 7343, 14, 4208, 63, 2180, 22, 8, 2180, 12, 1406, 29, 797, 1724, 288, 871, 8484, 14, 4491, 29356, 26, 355, 986, 221, 327, 7600, 376, 1919, 1077, 440, 506, 18030, 3032, 288, 871, 26, 355, 746, 267, 587, 26, 288, 746, 6064, 360, 16646, 370, 282, 6876, 570, 26, 469, 16, 5285, 908, 8, 277, 423, 1501, 430, 339, 347, 4002, 8, 277, 304, 267, 340, 440, 291, 423, 1667, 26, 288, 485, 1745, 275, 1551, 8, 277, 423, 1501, 12, 818, 534, 87, 11, 84, 297, 2644, 534, 4371, 358, 288, 291, 423, 84, 1745, 14, 5507, 8, 16, 9, 288, 367, 485, 604, 315, 291, 423, 84, 1745, 26, 355, 485, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 1547, 604, 14, 1913, 4059, 288, 485, 1745, 14, 1600, 342, 288, 291, 423, 84, 1745, 275, 488, 288, 485, 1745, 275, 488, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 284, 515, 275, 1994, 12117, 15, 24418, 559, 15607, 8406, 63, 15607, 25832, 63, 15, 5167, 1096, 88, 13, 647, 15, 5167, 1096, 88, 15, 4435, 15, 526, 71, 7, 272, 284, 1501, 275, 283, 12706, 63, 16670, 14, 1081, 14, 1717, 14, 5167, 14, 1480, 67, 20, 14, 71, 22, 14, 4087, 7, 272, 312, 515, 275, 7815, 272, 312, 1501, 275, 283, 493, 14, 71, 22, 7, 339, 7002, 275, 11513, 5929, 39, 22, 8, 904, 8, 73, 515, 12, 284, 1501, 430, 272, 7060, 275, 11513, 6261, 39, 22, 8, 904, 8, 79, 515, 12, 312, 1501, 430, 272, 486, 889, 275, 378, 272, 367, 3343, 315, 7002, 26, 267, 486, 889, 847, 413, 267, 870, 360, 4578, 949, 469, 16, 93, 543, 1865, 469, 17, 5285, 908, 8, 784, 79, 12, 822, 8, 2180, 1724, 267, 7060, 14, 952, 8, 2180, 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 ]
[ 24313, 465, 8484, 199, 504, 747, 14, 515, 492, 19529, 12, 29214, 12, 4263, 12, 9017, 12, 26004, 12, 9593, 12, 2249, 7699, 199, 504, 5549, 492, 21791, 1173, 199, 199, 504, 6895, 1096, 88, 14, 2308, 492, 6077, 25212, 199, 199, 363, 452, 363, 275, 788, 4578, 5929, 39, 22, 297, 283, 4578, 6261, 39, 22, 418, 421, 199, 533, 11513, 5929, 39, 22, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 931, 26, 620, 304, 267, 340, 931, 365, 488, 26, 288, 746, 3146, 360, 64, 403, 64, 440, 4370, 2659, 398, 291, 423, 7218, 275, 19529, 8, 515, 9, 267, 340, 440, 29214, 8, 277, 423, 7218, 304, 288, 746, 3814, 10870, 339, 347, 636, 1661, 721, 277, 304, 267, 291, 423, 1745, 275, 1551, 8, 277, 423, 7218, 12, 283, 82, 297, 2644, 534, 4371, 358, 221, 327, 3343, 570, 370, 506, 1586, 267, 291, 423, 604, 63, 889, 275, 378, 267, 372, 291, 339, 347, 636, 2184, 721, 277, 304, 267, 340, 291, 423, 1745, 14, 5938, 26, 288, 746, 6064, 360, 3205, 570, 365, 6876, 2659, 267, 1830, 715, 26, 288, 862, 26, 355, 485, 1773, 604, 275, 291, 423, 1745, 14, 6407, 342, 288, 871, 18965, 26, 355, 746, 6077, 25212, 480, 1173, 5041, 16, 6834, 440, 12060, 315, 3211, 1475, 15848, 908, 8, 277, 423, 7218, 430, 288, 871, 26, 355, 746, 288, 291, 423, 604, 63, 889, 847, 413, 288, 340, 485, 1773, 604, 508, 8061, 355, 291, 423, 1745, 14, 1600, 342, 355, 746, 10852, 288, 862, 26, 355, 3343, 275, 8484, 14, 1122, 63, 2180, 22, 1547, 1773, 604, 14, 1913, 1012, 355, 372, 3343, 288, 871, 334, 7343, 14, 4491, 29356, 12, 3146, 304, 355, 746, 6077, 25212, 480, 1173, 5041, 16, 6834, 440, 12060, 315, 3211, 1475, 15848, 908, 8, 277, 423, 7218, 430, 288, 871, 26, 355, 746, 421, 199, 533, 11513, 6261, 39, 22, 8, 785, 304, 272, 1390, 63, 3556, 275, 488, 272, 2040, 63, 6223, 275, 756, 272, 849, 63, 3435, 275, 1987, 71, 22, 7, 339, 347, 636, 826, 721, 277, 12, 931, 304, 267, 340, 931, 365, 488, 26, 288, 746, 3146, 360, 64, 403, 64, 440, 4370, 367, 658, 515, 2313, 358, 398, 485, 3475, 275, 9017, 8, 4832, 8, 515, 430, 267, 340, 440, 334, 6027, 1547, 3475, 2298, 288, 746, 6064, 360, 6231, 1630, 440, 2187, 26, 469, 16, 5285, 908, 1547, 3475, 430, 267, 485, 1501, 275, 9593, 8, 4832, 8, 515, 430, 267, 291, 423, 1501, 275, 4263, 1547, 3475, 12, 485, 1501, 9, 267, 340, 26004, 8, 904, 1547, 3475, 12, 485, 1501, 2298, 288, 746, 6064, 360, 1918, 2082, 26, 469, 16, 5285, 908, 8, 277, 423, 1501, 430, 398, 327, 291, 423, 1745, 275, 1551, 8, 277, 423, 1501, 12, 818, 534, 87, 11, 84, 297, 2644, 534, 4371, 358, 267, 291, 423, 84, 1745, 275, 21791, 1173, 8, 632, 534, 87, 11, 84, 358, 267, 291, 423, 1667, 275, 715, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 1600, 342, 339, 347, 2218, 8, 277, 12, 3343, 304, 267, 340, 440, 291, 423, 84, 1745, 14, 5938, 26, 288, 862, 26, 355, 340, 291, 423, 1667, 26, 490, 291, 423, 84, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 8, 7343, 14, 4208, 63, 2180, 22, 8, 2180, 1724, 490, 291, 423, 1667, 275, 756, 355, 587, 26, 490, 291, 423, 84, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 8, 7343, 14, 4208, 63, 2180, 22, 8, 2180, 12, 1406, 29, 797, 1724, 288, 871, 8484, 14, 4491, 29356, 26, 355, 986, 221, 327, 7600, 376, 1919, 1077, 440, 506, 18030, 3032, 288, 871, 26, 355, 746, 267, 587, 26, 288, 746, 6064, 360, 16646, 370, 282, 6876, 570, 26, 469, 16, 5285, 908, 8, 277, 423, 1501, 430, 339, 347, 4002, 8, 277, 304, 267, 340, 440, 291, 423, 1667, 26, 288, 485, 1745, 275, 1551, 8, 277, 423, 1501, 12, 818, 534, 87, 11, 84, 297, 2644, 534, 4371, 358, 288, 291, 423, 84, 1745, 14, 5507, 8, 16, 9, 288, 367, 485, 604, 315, 291, 423, 84, 1745, 26, 355, 485, 1745, 14, 952, 11117, 16, 4988, 78, 1370, 908, 1547, 604, 14, 1913, 4059, 288, 485, 1745, 14, 1600, 342, 288, 291, 423, 84, 1745, 275, 488, 288, 485, 1745, 275, 488, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 284, 515, 275, 1994, 12117, 15, 24418, 559, 15607, 8406, 63, 15607, 25832, 63, 15, 5167, 1096, 88, 13, 647, 15, 5167, 1096, 88, 15, 4435, 15, 526, 71, 7, 272, 284, 1501, 275, 283, 12706, 63, 16670, 14, 1081, 14, 1717, 14, 5167, 14, 1480, 67, 20, 14, 71, 22, 14, 4087, 7, 272, 312, 515, 275, 7815, 272, 312, 1501, 275, 283, 493, 14, 71, 22, 7, 339, 7002, 275, 11513, 5929, 39, 22, 8, 904, 8, 73, 515, 12, 284, 1501, 430, 272, 7060, 275, 11513, 6261, 39, 22, 8, 904, 8, 79, 515, 12, 312, 1501, 430, 272, 486, 889, 275, 378, 272, 367, 3343, 315, 7002, 26, 267, 486, 889, 847, 413, 267, 870, 360, 4578, 949, 469, 16, 93, 543, 1865, 469, 17, 5285, 908, 8, 784, 79, 12, 822, 8, 2180, 1724, 267, 7060, 14, 952, 8, 2180, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
me4488/NOPE_Kernel_V2
tools/perf/scripts/python/failed-syscalls-by-pid.py
11180
2058
# failed system call counts, by pid # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide failed system call totals, broken down by pid. # 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 * usage = "perf script -s syscall-counts-by-pid.py [comm|pid]\n"; for_comm = None for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: try: for_pid = int(sys.argv[1]) except: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_error_totals() def raw_syscalls__sys_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, ret): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return if ret < 0: try: syscalls[common_comm][common_pid][id][ret] += 1 except TypeError: syscalls[common_comm][common_pid][id][ret] = 1 def print_error_totals(): if for_comm is not None: print "\nsyscall errors for %s:\n\n" % (for_comm), else: print "\nsyscall errors:\n\n", print "%-30s %10s\n" % ("comm [pid]", "count"), print "%-30s %10s\n" % ("------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id in id_keys: print " syscall: %-16s\n" % syscall_name(id), ret_keys = syscalls[comm][pid][id].keys() for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): print " err = %-20s %10d\n" % (strerror(ret), val),
gpl-2.0
[ 3, 3405, 2656, 1240, 8242, 12, 701, 4422, 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, 3405, 2656, 1240, 23576, 12, 10529, 3224, 701, 4422, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 92, 3150, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 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, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 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, 705, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 2224, 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, 2203, 304, 199, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 421, 198, 692, 2203, 665, 378, 26, 507, 198, 893, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 847, 413, 507, 198, 2590, 3146, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 275, 413, 199, 199, 318, 870, 63, 705, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 2552, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 2552, 3427, 78, 60, 78, 401, 339, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 11472, 298, 835, 1288, 272, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 777, 10965, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 315, 1305, 63, 1612, 26, 24449, 870, 298, 221, 18901, 26, 19752, 975, 83, 60, 78, 2, 450, 18901, 63, 354, 8, 344, 395, 24449, 2203, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1527, 344, 1055, 1612, 342, 24449, 367, 2203, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1527, 344, 1055, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 1871, 259, 870, 298, 259, 2329, 275, 19752, 1165, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 20395, 8, 3292, 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 ]
[ 3405, 2656, 1240, 8242, 12, 701, 4422, 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, 3405, 2656, 1240, 23576, 12, 10529, 3224, 701, 4422, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 92, 3150, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 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, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 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, 705, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 2224, 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, 2203, 304, 199, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 421, 198, 692, 2203, 665, 378, 26, 507, 198, 893, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 847, 413, 507, 198, 2590, 3146, 26, 686, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 1527, 3292, 61, 275, 413, 199, 199, 318, 870, 63, 705, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 2552, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 2552, 3427, 78, 60, 78, 401, 339, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 11472, 298, 835, 1288, 272, 870, 18301, 1216, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 777, 10965, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 315, 1305, 63, 1612, 26, 24449, 870, 298, 221, 18901, 26, 19752, 975, 83, 60, 78, 2, 450, 18901, 63, 354, 8, 344, 395, 24449, 2203, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1527, 344, 1055, 1612, 342, 24449, 367, 2203, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1527, 344, 1055, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 1871, 259, 870, 298, 259, 2329, 275, 19752, 1165, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 20395, 8, 3292, 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, 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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 ]
DCSO/tie2misp
loader.py
2
8612
""" DCSO TIE2MISP Parser Copyright (c) 2017, DCSO GmbH """ import requests from requests import HTTPError, ConnectionError, ConnectTimeout from model import Config from model.events import C2Server, Malware, Actor, Family from datetime import datetime, timedelta import logging import sys class Loader: @staticmethod def start(conf, tags, type, startdate, file, noupload, searchfile, proxy_misp_addr, proxy_tie_addr): # Building Auth Header conf_authHeader = {'Authorization': 'Bearer ' + conf.tie_api_key} # Building URL date_since = startdate.strftime("%Y-%m-%d") dt = startdate + timedelta(days=1) date_until = dt.strftime("%Y-%m-%d") category = None finished = True event = None connection_error = False # Eventtype if type == 'c2server': event = C2Server(conf.org_name, conf.org_uuid, conf.event_base_thread_level, conf.event_published, conf.event_info_c2server, startdate) category = 'c2-server' elif type == 'malware': event = Malware(conf.org_name, conf.org_uuid, conf.event_base_thread_level, conf.event_published, conf.event_info_malware, startdate) category = 'malware' elif type == 'actor': event = Actor(conf.org_name, conf.org_uuid, conf.event_base_thread_level, conf.event_published, conf.event_info_actor, startdate) category = 'actor' elif type == 'family': event = Family(conf.org_name, conf.org_uuid, conf.event_base_thread_level, conf.event_published, conf.event_info_family, startdate) category = 'family' # Buildung parameters payload = dict() if category == 'c2-server' or category == 'malware': payload['category'] = category payload['created_since'] = date_since payload['created_until'] = date_until else: attr_list = '' count = 0 for l in searchfile: if count is 0: attr_list += l else: attr_list += ',' + l count += 1 attr_list = attr_list.replace('\n', '') if category is 'actor': payload['actor'] = attr_list else: payload['family'] = attr_list url = conf.tie_api_url + conf.url_iocs index = 0 connection_retrys = 1 while finished: try: myResponse = requests.get(url, params=payload, headers=conf_authHeader, proxies=proxy_tie_addr) # For successful API call, response code will be 200 (OK) if myResponse.ok: # print(myResponse.status_code) # Loading the response data into a dict variable # json.loads takes in only binary or string variables so using content to fetch binary content # Loads (Load String) takes a Json file and converts into python data structure # (dict or list, depending on JSON) try: jsonResponse = myResponse.json() # check is TIE Response is complete response_has_more = None response_iocs = None response_params = None if 'has_more' in jsonResponse and 'iocs' in jsonResponse and 'params' in jsonResponse: response_has_more = jsonResponse['has_more'] response_iocs = jsonResponse['iocs'] response_params = jsonResponse['params'] else: raise ValueError("Error: TIE answered with an invalid or empty JSON Response") # parsing received IOC's logging.info("Parsing... - Offset: " + str(index) + " to " + str(index + len(response_iocs))) index += len(response_iocs) if type == 'c2server': C2Server.parse(event, response_iocs, tags) elif type == 'malware': Malware.parse(event, response_iocs, tags) elif type == 'actor': Actor.parse(event, response_iocs, tags) elif type == 'family': Family.parse(event, response_iocs, tags) if response_has_more is not True: finished = False logging.info("There are no more attributes") logging.info("#### Finished #####") break else: if isinstance(myResponse.links, dict): res = myResponse.links["next"] url = res["url"] logging.info("#### Continue #####") except ValueError: logging.error("Error: Invalid or empty JSON Response") elif myResponse.status_code >= 500 and myResponse.status_code <= 550: logging.warning("It seems there are connection issues with TIE at the moment") logging.warning("Status-Code: " + str(myResponse.status_code) + " - Try: " + connection_retrys + " from 5") connection_retrys += 1 if connection_retrys < 6: continue else: logging.error("TIE seems not to be available at the moment or connection is interrupted") raise ConnectionError else: # If response code is not ok (200), print the resulting http error code with description logging.error("Error:") logging.error(myResponse.content) myResponse.raise_for_status() except (HTTPError, ConnectionError, ConnectTimeout) as e: logging.error("Error:") logging.error("TIE seems not to be available at the moment or connection is interrupted") connection_error = True finished = False # TIE is available? if not noupload and not connection_error and conf.misp_api_key is not None and conf.misp_api_url is not None: # Add Base Tags if isinstance(event, C2Server): if tags.c2tags_base is not None: for val in tags.c2tags_base: event.append_tags(tags.c2tags_base[val]) elif isinstance(event, Malware): if tags.malwaretags_base is not None: for val in tags.c2tags_base: event.append_tags(tags.c2tags_base[val]) # Load things up try: event.upload(conf, proxy_misp_addr) except Exception as e: logging.error("Error uploading event to MISP. Something went wrong...\n") else: if not noupload and not connection_error: logging.warning("Can not upload event. MISP API key or MISP API URL is missing") if file: # Serialize event as MISP Event json_output = event.serialize() outfile = type + "_" + str(event.uuid) + ".json" logging.info("Saved attributes as JSON-File: " + outfile) with open(outfile, "w") as text_file: text_file.write(json_output) @staticmethod def init_logger(logPath, fileName, logLvl, consoleLog, fileLog): logger = logging.getLogger() logger.setLevel(logLvl) formatter = logging.Formatter('%(asctime)s [%(levelname)-5.5s] %(message)s') consoleHandler = logging.StreamHandler(sys.stdout) consoleHandler.setFormatter(formatter) logger.addHandler(consoleHandler) if consoleLog is False: consoleHandler.setLevel(logLvl) else: consoleHandler.setLevel(100) if fileLog is False: fileHandler = logging.FileHandler("{0}/{1}.log".format(logPath, fileName)) fileHandler.setFormatter(formatter) fileHandler.setLevel(logLvl) logger.addHandler(fileHandler)
bsd-3-clause
[ 624, 199, 36, 3298, 47, 377, 4332, 18, 9674, 48, 10191, 199, 7384, 334, 67, 9, 9708, 12, 577, 3298, 47, 23428, 199, 624, 199, 646, 4145, 199, 504, 4145, 492, 15050, 12, 25417, 12, 15175, 6372, 199, 504, 1402, 492, 4094, 199, 504, 1402, 14, 4368, 492, 445, 18, 3120, 12, 29936, 1068, 12, 437, 630, 12, 481, 4632, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 2050, 199, 646, 984, 421, 199, 533, 22865, 26, 339, 768, 4639, 272, 347, 1343, 8, 2190, 12, 3762, 12, 730, 12, 1343, 602, 12, 570, 12, 949, 5064, 12, 2754, 493, 12, 4566, 63, 1292, 80, 63, 2697, 12, 4566, 63, 23958, 63, 2697, 304, 398, 327, 6516, 316, 3590, 10240, 267, 3743, 63, 1178, 2567, 275, 791, 11626, 356, 283, 3655, 21462, 283, 435, 3743, 14, 23958, 63, 1246, 63, 498, 93, 398, 327, 6516, 316, 2851, 267, 1434, 63, 8585, 275, 1343, 602, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 267, 4487, 275, 1343, 602, 435, 6871, 8, 4899, 29, 17, 9, 267, 1434, 63, 8111, 275, 4487, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 267, 4637, 275, 488, 267, 9158, 275, 715, 267, 1566, 275, 488, 267, 1950, 63, 705, 275, 756, 398, 327, 6763, 466, 267, 340, 730, 508, 283, 67, 18, 1000, 356, 288, 1566, 275, 445, 18, 3120, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2490, 3743, 14, 1430, 63, 815, 63, 67, 18, 1000, 12, 1343, 602, 9, 288, 4637, 275, 283, 67, 18, 13, 1000, 7, 267, 916, 730, 508, 283, 2174, 1068, 356, 288, 1566, 275, 29936, 1068, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 1169, 3743, 14, 1430, 63, 815, 63, 2174, 1068, 12, 1343, 602, 9, 288, 4637, 275, 283, 2174, 1068, 7, 398, 916, 730, 508, 283, 5021, 356, 288, 1566, 275, 437, 630, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2490, 3743, 14, 1430, 63, 815, 63, 5021, 12, 1343, 602, 9, 288, 4637, 275, 283, 5021, 7, 398, 916, 730, 508, 283, 6606, 356, 288, 1566, 275, 481, 4632, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2079, 3743, 14, 1430, 63, 815, 63, 6606, 12, 1343, 602, 9, 288, 4637, 275, 283, 6606, 7, 398, 327, 6516, 10335, 2633, 267, 4886, 275, 1211, 342, 267, 340, 4637, 508, 283, 67, 18, 13, 1000, 7, 503, 4637, 508, 283, 2174, 1068, 356, 288, 4886, 459, 3710, 418, 275, 4637, 288, 4886, 459, 3966, 63, 8585, 418, 275, 1434, 63, 8585, 288, 4886, 459, 3966, 63, 8111, 418, 275, 1434, 63, 8111, 398, 587, 26, 288, 1921, 63, 513, 275, 2125, 288, 2338, 275, 378, 288, 367, 634, 315, 2754, 493, 26, 355, 340, 2338, 365, 378, 26, 490, 1921, 63, 513, 847, 634, 355, 587, 26, 490, 1921, 63, 513, 847, 13647, 435, 634, 355, 2338, 847, 413, 288, 1921, 63, 513, 275, 1921, 63, 513, 14, 1814, 2258, 78, 297, 4074, 288, 340, 4637, 365, 283, 5021, 356, 355, 4886, 459, 5021, 418, 275, 1921, 63, 513, 288, 587, 26, 355, 4886, 459, 6606, 418, 275, 1921, 63, 513, 398, 1166, 275, 3743, 14, 23958, 63, 1246, 63, 633, 435, 3743, 14, 633, 63, 73, 14851, 267, 1478, 275, 378, 267, 1950, 63, 264, 454, 588, 275, 413, 267, 1830, 9158, 26, 288, 862, 26, 355, 3002, 2364, 275, 4145, 14, 362, 8, 633, 12, 1862, 29, 4749, 12, 2323, 29, 2190, 63, 1178, 2567, 12, 14942, 29, 3280, 63, 23958, 63, 2697, 9, 355, 327, 2104, 9512, 3261, 1240, 12, 1177, 1233, 911, 506, 1926, 334, 3593, 9, 355, 340, 3002, 2364, 14, 745, 26, 490, 327, 870, 8, 1662, 2364, 14, 1205, 63, 600, 9, 490, 327, 3835, 5384, 314, 1177, 666, 1901, 282, 1211, 1750, 490, 327, 2022, 14, 3640, 6181, 315, 1454, 3366, 503, 1059, 2860, 880, 1808, 1564, 370, 5267, 3366, 1564, 490, 327, 30367, 334, 6200, 2624, 9, 6181, 282, 14587, 570, 436, 15373, 1901, 2366, 666, 5523, 490, 327, 334, 807, 503, 769, 12, 10298, 641, 4840, 9, 4951, 862, 26, 717, 2022, 2364, 275, 3002, 2364, 14, 1001, 342, 9453, 327, 1104, 365, 377, 4332, 7232, 365, 4890, 717, 1177, 63, 1989, 63, 6878, 275, 488, 717, 1177, 63, 73, 14851, 275, 488, 717, 1177, 63, 1162, 275, 488, 717, 340, 283, 1989, 63, 6878, 7, 315, 2022, 2364, 436, 283, 73, 14851, 7, 315, 2022, 2364, 436, 283, 1162, 7, 315, 2022, 2364, 26, 1169, 1177, 63, 1989, 63, 6878, 275, 2022, 2364, 459, 1989, 63, 6878, 418, 1169, 1177, 63, 73, 14851, 275, 2022, 2364, 459, 73, 14851, 418, 1169, 1177, 63, 1162, 275, 2022, 2364, 459, 1162, 418, 717, 587, 26, 1169, 746, 1722, 480, 547, 26, 377, 4332, 4987, 21221, 543, 376, 3866, 503, 2701, 4840, 7232, 531, 9453, 327, 6057, 3086, 5004, 35, 1159, 717, 2050, 14, 815, 480, 17412, 1396, 446, 29432, 26, 298, 435, 620, 8, 1080, 9, 435, 298, 370, 298, 435, 620, 8, 1080, 435, 822, 8, 1310, 63, 73, 14851, 1724, 717, 1478, 847, 822, 8, 1310, 63, 73, 14851, 9, 9453, 340, 730, 508, 283, 67, 18, 1000, 356, 1169, 445, 18, 3120, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851, 12, 3762, 9, 717, 916, 730, 508, 283, 2174, 1068, 356, 1169, 29936, 1068, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851, 12, 3762, 9, 717, 916, 730, 508, 283, 5021, 356, 1169, 437, 630, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851, 12, 3762, 9, 717, 916, 730, 508, 283, 6606, 356, 1169, 481, 4632, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851 ]
[ 199, 36, 3298, 47, 377, 4332, 18, 9674, 48, 10191, 199, 7384, 334, 67, 9, 9708, 12, 577, 3298, 47, 23428, 199, 624, 199, 646, 4145, 199, 504, 4145, 492, 15050, 12, 25417, 12, 15175, 6372, 199, 504, 1402, 492, 4094, 199, 504, 1402, 14, 4368, 492, 445, 18, 3120, 12, 29936, 1068, 12, 437, 630, 12, 481, 4632, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 2050, 199, 646, 984, 421, 199, 533, 22865, 26, 339, 768, 4639, 272, 347, 1343, 8, 2190, 12, 3762, 12, 730, 12, 1343, 602, 12, 570, 12, 949, 5064, 12, 2754, 493, 12, 4566, 63, 1292, 80, 63, 2697, 12, 4566, 63, 23958, 63, 2697, 304, 398, 327, 6516, 316, 3590, 10240, 267, 3743, 63, 1178, 2567, 275, 791, 11626, 356, 283, 3655, 21462, 283, 435, 3743, 14, 23958, 63, 1246, 63, 498, 93, 398, 327, 6516, 316, 2851, 267, 1434, 63, 8585, 275, 1343, 602, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 267, 4487, 275, 1343, 602, 435, 6871, 8, 4899, 29, 17, 9, 267, 1434, 63, 8111, 275, 4487, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 531, 267, 4637, 275, 488, 267, 9158, 275, 715, 267, 1566, 275, 488, 267, 1950, 63, 705, 275, 756, 398, 327, 6763, 466, 267, 340, 730, 508, 283, 67, 18, 1000, 356, 288, 1566, 275, 445, 18, 3120, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2490, 3743, 14, 1430, 63, 815, 63, 67, 18, 1000, 12, 1343, 602, 9, 288, 4637, 275, 283, 67, 18, 13, 1000, 7, 267, 916, 730, 508, 283, 2174, 1068, 356, 288, 1566, 275, 29936, 1068, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 1169, 3743, 14, 1430, 63, 815, 63, 2174, 1068, 12, 1343, 602, 9, 288, 4637, 275, 283, 2174, 1068, 7, 398, 916, 730, 508, 283, 5021, 356, 288, 1566, 275, 437, 630, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2490, 3743, 14, 1430, 63, 815, 63, 5021, 12, 1343, 602, 9, 288, 4637, 275, 283, 5021, 7, 398, 916, 730, 508, 283, 6606, 356, 288, 1566, 275, 481, 4632, 8, 2190, 14, 1308, 63, 354, 12, 3743, 14, 1308, 63, 2580, 12, 3743, 14, 1430, 63, 1095, 63, 2671, 63, 1896, 12, 3743, 14, 1430, 63, 8987, 12, 2079, 3743, 14, 1430, 63, 815, 63, 6606, 12, 1343, 602, 9, 288, 4637, 275, 283, 6606, 7, 398, 327, 6516, 10335, 2633, 267, 4886, 275, 1211, 342, 267, 340, 4637, 508, 283, 67, 18, 13, 1000, 7, 503, 4637, 508, 283, 2174, 1068, 356, 288, 4886, 459, 3710, 418, 275, 4637, 288, 4886, 459, 3966, 63, 8585, 418, 275, 1434, 63, 8585, 288, 4886, 459, 3966, 63, 8111, 418, 275, 1434, 63, 8111, 398, 587, 26, 288, 1921, 63, 513, 275, 2125, 288, 2338, 275, 378, 288, 367, 634, 315, 2754, 493, 26, 355, 340, 2338, 365, 378, 26, 490, 1921, 63, 513, 847, 634, 355, 587, 26, 490, 1921, 63, 513, 847, 13647, 435, 634, 355, 2338, 847, 413, 288, 1921, 63, 513, 275, 1921, 63, 513, 14, 1814, 2258, 78, 297, 4074, 288, 340, 4637, 365, 283, 5021, 356, 355, 4886, 459, 5021, 418, 275, 1921, 63, 513, 288, 587, 26, 355, 4886, 459, 6606, 418, 275, 1921, 63, 513, 398, 1166, 275, 3743, 14, 23958, 63, 1246, 63, 633, 435, 3743, 14, 633, 63, 73, 14851, 267, 1478, 275, 378, 267, 1950, 63, 264, 454, 588, 275, 413, 267, 1830, 9158, 26, 288, 862, 26, 355, 3002, 2364, 275, 4145, 14, 362, 8, 633, 12, 1862, 29, 4749, 12, 2323, 29, 2190, 63, 1178, 2567, 12, 14942, 29, 3280, 63, 23958, 63, 2697, 9, 355, 327, 2104, 9512, 3261, 1240, 12, 1177, 1233, 911, 506, 1926, 334, 3593, 9, 355, 340, 3002, 2364, 14, 745, 26, 490, 327, 870, 8, 1662, 2364, 14, 1205, 63, 600, 9, 490, 327, 3835, 5384, 314, 1177, 666, 1901, 282, 1211, 1750, 490, 327, 2022, 14, 3640, 6181, 315, 1454, 3366, 503, 1059, 2860, 880, 1808, 1564, 370, 5267, 3366, 1564, 490, 327, 30367, 334, 6200, 2624, 9, 6181, 282, 14587, 570, 436, 15373, 1901, 2366, 666, 5523, 490, 327, 334, 807, 503, 769, 12, 10298, 641, 4840, 9, 4951, 862, 26, 717, 2022, 2364, 275, 3002, 2364, 14, 1001, 342, 9453, 327, 1104, 365, 377, 4332, 7232, 365, 4890, 717, 1177, 63, 1989, 63, 6878, 275, 488, 717, 1177, 63, 73, 14851, 275, 488, 717, 1177, 63, 1162, 275, 488, 717, 340, 283, 1989, 63, 6878, 7, 315, 2022, 2364, 436, 283, 73, 14851, 7, 315, 2022, 2364, 436, 283, 1162, 7, 315, 2022, 2364, 26, 1169, 1177, 63, 1989, 63, 6878, 275, 2022, 2364, 459, 1989, 63, 6878, 418, 1169, 1177, 63, 73, 14851, 275, 2022, 2364, 459, 73, 14851, 418, 1169, 1177, 63, 1162, 275, 2022, 2364, 459, 1162, 418, 717, 587, 26, 1169, 746, 1722, 480, 547, 26, 377, 4332, 4987, 21221, 543, 376, 3866, 503, 2701, 4840, 7232, 531, 9453, 327, 6057, 3086, 5004, 35, 1159, 717, 2050, 14, 815, 480, 17412, 1396, 446, 29432, 26, 298, 435, 620, 8, 1080, 9, 435, 298, 370, 298, 435, 620, 8, 1080, 435, 822, 8, 1310, 63, 73, 14851, 1724, 717, 1478, 847, 822, 8, 1310, 63, 73, 14851, 9, 9453, 340, 730, 508, 283, 67, 18, 1000, 356, 1169, 445, 18, 3120, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851, 12, 3762, 9, 717, 916, 730, 508, 283, 2174, 1068, 356, 1169, 29936, 1068, 14, 1122, 8, 1430, 12, 1177, 63, 73, 14851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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alxnov/ansible-modules-core
cloud/digital_ocean/digital_ocean_sshkey.py
23
5127
#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: digital_ocean_sshkey short_description: Create/delete an SSH key in DigitalOcean description: - Create/delete an SSH key. version_added: "1.6" author: "Michael Gregson (@mgregson)" options: state: description: - Indicate desired state of the target. default: present choices: ['present', 'absent'] client_id: description: - DigitalOcean manager id. api_key: description: - DigitalOcean api key. id: description: - Numeric, the SSH key id you want to operate on. name: description: - String, this is the name of an SSH key to create or destroy. ssh_pub_key: description: - The public SSH key you want to add to your account. notes: - Two environment variables can be used, DO_CLIENT_ID and DO_API_KEY. - Version 1 of DigitalOcean API is used. requirements: - "python >= 2.6" - dopy ''' EXAMPLES = ''' # Ensure a SSH key is present # If a key matches this name, will return the ssh key id and changed = False # If no existing key matches this name, a new key is created, the ssh key id is returned and changed = False - digital_ocean_sshkey: state: present name: my_ssh_key ssh_pub_key: 'ssh-rsa AAAA...' client_id: XXX api_key: XXX ''' import os import time try: from dopy.manager import DoError, DoManager HAS_DOPY = True except ImportError: HAS_DOPY = False class TimeoutError(DoError): def __init__(self, msg, id): super(TimeoutError, self).__init__(msg) self.id = id class JsonfyMixIn(object): def to_json(self): return self.__dict__ class SSH(JsonfyMixIn): manager = None def __init__(self, ssh_key_json): self.__dict__.update(ssh_key_json) update_attr = __init__ def destroy(self): self.manager.destroy_ssh_key(self.id) return True @classmethod def setup(cls, client_id, api_key): cls.manager = DoManager(client_id, api_key) @classmethod def find(cls, name): if not name: return False keys = cls.list_all() for key in keys: if key.name == name: return key return False @classmethod def list_all(cls): json = cls.manager.all_ssh_keys() return map(cls, json) @classmethod def add(cls, name, key_pub): json = cls.manager.new_ssh_key(name, key_pub) return cls(json) def core(module): def getkeyordie(k): v = module.params[k] if v is None: module.fail_json(msg='Unable to load %s' % k) return v try: # params['client_id'] will be None even if client_id is not passed in client_id = module.params['client_id'] or os.environ['DO_CLIENT_ID'] api_key = module.params['api_key'] or os.environ['DO_API_KEY'] except KeyError, e: module.fail_json(msg='Unable to load %s' % e.message) changed = True state = module.params['state'] SSH.setup(client_id, api_key) name = getkeyordie('name') if state in ('present'): key = SSH.find(name) if key: module.exit_json(changed=False, ssh_key=key.to_json()) key = SSH.add(name, getkeyordie('ssh_pub_key')) module.exit_json(changed=True, ssh_key=key.to_json()) elif state in ('absent'): key = SSH.find(name) if not key: module.exit_json(changed=False, msg='SSH key with the name of %s is not found.' % name) key.destroy() module.exit_json(changed=True) def main(): module = AnsibleModule( argument_spec = dict( state = dict(choices=['present', 'absent'], default='present'), client_id = dict(aliases=['CLIENT_ID'], no_log=True), api_key = dict(aliases=['API_KEY'], no_log=True), name = dict(type='str'), id = dict(aliases=['droplet_id'], type='int'), ssh_pub_key = dict(type='str'), ), required_one_of = ( ['id', 'name'], ), ) if not HAS_DOPY: module.fail_json(msg='dopy required for this module') try: core(module) except TimeoutError as e: module.fail_json(msg=str(e), id=e.id) except (DoError, Exception) as e: module.fail_json(msg=str(e)) # import module snippets from ansible.module_utils.basic import * 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, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20545, 63, 31737, 63, 5510, 498, 199, 3612, 63, 1802, 26, 2790, 15, 1807, 376, 12027, 790, 315, 29979, 47, 20867, 199, 1802, 26, 1362, 446, 2790, 15, 1807, 376, 12027, 790, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 2502, 26, 298, 45, 11781, 598, 23957, 265, 8593, 6649, 23957, 265, 2924, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 1362, 446, 1010, 10188, 6387, 1174, 402, 314, 1347, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 523, 1890, 63, 344, 26, 1362, 1369, 26, 1362, 446, 29979, 47, 20867, 5256, 1305, 14, 523, 2986, 63, 498, 26, 272, 1369, 26, 1362, 446, 29979, 47, 20867, 2986, 790, 14, 523, 1305, 26, 272, 1369, 26, 1362, 446, 19378, 12, 314, 12027, 790, 1305, 1265, 2934, 370, 19218, 641, 14, 523, 536, 26, 272, 1369, 26, 1362, 446, 2624, 12, 642, 365, 314, 536, 402, 376, 12027, 790, 370, 1218, 503, 11972, 14, 523, 8635, 63, 5645, 63, 498, 26, 272, 1369, 26, 1362, 446, 710, 4575, 12027, 790, 1265, 2934, 370, 1050, 370, 2195, 2933, 14, 199, 199, 5983, 26, 523, 446, 16853, 3734, 2860, 883, 506, 1202, 12, 3506, 63, 9901, 63, 998, 436, 3506, 63, 3735, 63, 3078, 14, 523, 446, 3394, 413, 402, 29979, 47, 20867, 3261, 365, 1202, 14, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 366, 927, 199, 2344, 421, 199, 8918, 275, 1449, 199, 3, 7523, 282, 12027, 790, 365, 3451, 199, 3, 982, 282, 790, 4450, 642, 536, 12, 911, 372, 314, 8635, 790, 1305, 436, 2896, 275, 756, 199, 3, 982, 949, 3411, 790, 4450, 642, 536, 12, 282, 892, 790, 365, 2737, 12, 314, 8635, 790, 1305, 365, 2138, 436, 2896, 275, 756, 199, 199, 13, 20545, 63, 31737, 63, 5510, 498, 26, 272, 1174, 26, 3451, 272, 536, 26, 3002, 63, 5510, 63, 498, 272, 8635, 63, 5645, 63, 498, 26, 283, 5510, 13, 13487, 437, 10985, 13698, 272, 1890, 63, 344, 26, 5787, 272, 2986, 63, 498, 26, 5787, 199, 199, 2344, 199, 199, 646, 747, 199, 646, 900, 199, 199, 893, 26, 272, 687, 366, 927, 14, 2609, 492, 4226, 547, 12, 4226, 2988, 272, 7509, 63, 1649, 4521, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 1649, 4521, 275, 756, 199, 199, 533, 31886, 8, 2585, 547, 304, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 1305, 304, 267, 1613, 8, 19382, 12, 291, 2843, 826, 721, 1328, 9, 267, 291, 14, 344, 275, 1305, 199, 199, 533, 14587, 1399, 26527, 8, 785, 304, 272, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 291, 855, 807, 363, 199, 199, 533, 12027, 8, 9653, 1399, 26527, 304, 272, 5256, 275, 488, 339, 347, 636, 826, 721, 277, 12, 8635, 63, 498, 63, 1001, 304, 267, 291, 855, 807, 4343, 873, 8, 5510, 63, 498, 63, 1001, 9, 272, 1678, 63, 962, 275, 636, 826, 363, 339, 347, 11972, 8, 277, 304, 267, 291, 14, 2609, 14, 7237, 63, 5510, 63, 498, 8, 277, 14, 344, 9, 267, 372, 715, 339, 768, 3744, 272, 347, 3272, 8, 1886, 12, 1890, 63, 344, 12, 2986, 63, 498, 304, 267, 843, 14, 2609, 275, 4226, 2988, 8, 1258, 63, 344, 12, 2986, 63, 498, 9, 339, 768, 3744, 272, 347, 2342, 8, 1886, 12, 536, 304, 267, 340, 440, 536, 26, 288, 372, 756, 267, 2883, 275, 843, 14, 513, 63, 452, 342, 267, 367, 790, 315, 2883, 26, 288, 340, 790, 14, 354, 508, 536, 26, 355, 372, 790, 267, 372, 756, 339, 768, 3744, 272, 347, 769, 63, 452, 8, 1886, 304, 267, 2022, 275, 843, 14, 2609, 14, 452, 63, 5510, 63, 1612, 342, 267, 372, 2341, 8, 1886, 12, 2022, 9, 339, 768, 3744, 272, 347, 1050, 8, 1886, 12, 536, 12, 790, 63, 5645, 304, 267, 2022, 275, 843, 14, 2609, 14, 1222, 63, 5510, 63, 498, 8, 354, 12, 790, 63, 5645, 9, 267, 372, 843, 8, 1001, 9, 199, 199, 318, 6170, 8, 578, 304, 272, 347, 664, 498, 269, 15130, 8, 75, 304, 267, 373, 275, 859, 14, 1162, 59, 75, 61, 267, 340, 373, 365, 488, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 534, 6005, 370, 2248, 450, 83, 7, 450, 1022, 9, 267, 372, 373, 339, 862, 26, 267, 327, 1862, 459, 1258, 63, 344, 418, 911, 506, 488, 2755, 340, 1890, 63, 344, 365, 440, 3032, 315, 267, 1890, 63, 344, 275, 859, 14, 1162, 459, 1258, 63, 344, 418, 503, 747, 14, 2314, 459, 1649, 63, 9901, 63, 998, 418, 267, 2986, 63, 498, 275, 859, 14, 1162, 459, 1246, 63, 498, 418, 503, 747, 14, 2314, 459, 1649, 63, 3735, 63, 3078, 418, 272, 871, 4067, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 6005, 370, 2248, 450, 83, 7, 450, 325, 14, 1188, 9, 339, 2896, 275, 715, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 12027, 14, 2758, 8 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 20545, 63, 31737, 63, 5510, 498, 199, 3612, 63, 1802, 26, 2790, 15, 1807, 376, 12027, 790, 315, 29979, 47, 20867, 199, 1802, 26, 1362, 446, 2790, 15, 1807, 376, 12027, 790, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 2502, 26, 298, 45, 11781, 598, 23957, 265, 8593, 6649, 23957, 265, 2924, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 1362, 446, 1010, 10188, 6387, 1174, 402, 314, 1347, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 523, 1890, 63, 344, 26, 1362, 1369, 26, 1362, 446, 29979, 47, 20867, 5256, 1305, 14, 523, 2986, 63, 498, 26, 272, 1369, 26, 1362, 446, 29979, 47, 20867, 2986, 790, 14, 523, 1305, 26, 272, 1369, 26, 1362, 446, 19378, 12, 314, 12027, 790, 1305, 1265, 2934, 370, 19218, 641, 14, 523, 536, 26, 272, 1369, 26, 1362, 446, 2624, 12, 642, 365, 314, 536, 402, 376, 12027, 790, 370, 1218, 503, 11972, 14, 523, 8635, 63, 5645, 63, 498, 26, 272, 1369, 26, 1362, 446, 710, 4575, 12027, 790, 1265, 2934, 370, 1050, 370, 2195, 2933, 14, 199, 199, 5983, 26, 523, 446, 16853, 3734, 2860, 883, 506, 1202, 12, 3506, 63, 9901, 63, 998, 436, 3506, 63, 3735, 63, 3078, 14, 523, 446, 3394, 413, 402, 29979, 47, 20867, 3261, 365, 1202, 14, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 366, 927, 199, 2344, 421, 199, 8918, 275, 1449, 199, 3, 7523, 282, 12027, 790, 365, 3451, 199, 3, 982, 282, 790, 4450, 642, 536, 12, 911, 372, 314, 8635, 790, 1305, 436, 2896, 275, 756, 199, 3, 982, 949, 3411, 790, 4450, 642, 536, 12, 282, 892, 790, 365, 2737, 12, 314, 8635, 790, 1305, 365, 2138, 436, 2896, 275, 756, 199, 199, 13, 20545, 63, 31737, 63, 5510, 498, 26, 272, 1174, 26, 3451, 272, 536, 26, 3002, 63, 5510, 63, 498, 272, 8635, 63, 5645, 63, 498, 26, 283, 5510, 13, 13487, 437, 10985, 13698, 272, 1890, 63, 344, 26, 5787, 272, 2986, 63, 498, 26, 5787, 199, 199, 2344, 199, 199, 646, 747, 199, 646, 900, 199, 199, 893, 26, 272, 687, 366, 927, 14, 2609, 492, 4226, 547, 12, 4226, 2988, 272, 7509, 63, 1649, 4521, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 1649, 4521, 275, 756, 199, 199, 533, 31886, 8, 2585, 547, 304, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 1305, 304, 267, 1613, 8, 19382, 12, 291, 2843, 826, 721, 1328, 9, 267, 291, 14, 344, 275, 1305, 199, 199, 533, 14587, 1399, 26527, 8, 785, 304, 272, 347, 370, 63, 1001, 8, 277, 304, 267, 372, 291, 855, 807, 363, 199, 199, 533, 12027, 8, 9653, 1399, 26527, 304, 272, 5256, 275, 488, 339, 347, 636, 826, 721, 277, 12, 8635, 63, 498, 63, 1001, 304, 267, 291, 855, 807, 4343, 873, 8, 5510, 63, 498, 63, 1001, 9, 272, 1678, 63, 962, 275, 636, 826, 363, 339, 347, 11972, 8, 277, 304, 267, 291, 14, 2609, 14, 7237, 63, 5510, 63, 498, 8, 277, 14, 344, 9, 267, 372, 715, 339, 768, 3744, 272, 347, 3272, 8, 1886, 12, 1890, 63, 344, 12, 2986, 63, 498, 304, 267, 843, 14, 2609, 275, 4226, 2988, 8, 1258, 63, 344, 12, 2986, 63, 498, 9, 339, 768, 3744, 272, 347, 2342, 8, 1886, 12, 536, 304, 267, 340, 440, 536, 26, 288, 372, 756, 267, 2883, 275, 843, 14, 513, 63, 452, 342, 267, 367, 790, 315, 2883, 26, 288, 340, 790, 14, 354, 508, 536, 26, 355, 372, 790, 267, 372, 756, 339, 768, 3744, 272, 347, 769, 63, 452, 8, 1886, 304, 267, 2022, 275, 843, 14, 2609, 14, 452, 63, 5510, 63, 1612, 342, 267, 372, 2341, 8, 1886, 12, 2022, 9, 339, 768, 3744, 272, 347, 1050, 8, 1886, 12, 536, 12, 790, 63, 5645, 304, 267, 2022, 275, 843, 14, 2609, 14, 1222, 63, 5510, 63, 498, 8, 354, 12, 790, 63, 5645, 9, 267, 372, 843, 8, 1001, 9, 199, 199, 318, 6170, 8, 578, 304, 272, 347, 664, 498, 269, 15130, 8, 75, 304, 267, 373, 275, 859, 14, 1162, 59, 75, 61, 267, 340, 373, 365, 488, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 534, 6005, 370, 2248, 450, 83, 7, 450, 1022, 9, 267, 372, 373, 339, 862, 26, 267, 327, 1862, 459, 1258, 63, 344, 418, 911, 506, 488, 2755, 340, 1890, 63, 344, 365, 440, 3032, 315, 267, 1890, 63, 344, 275, 859, 14, 1162, 459, 1258, 63, 344, 418, 503, 747, 14, 2314, 459, 1649, 63, 9901, 63, 998, 418, 267, 2986, 63, 498, 275, 859, 14, 1162, 459, 1246, 63, 498, 418, 503, 747, 14, 2314, 459, 1649, 63, 3735, 63, 3078, 418, 272, 871, 4067, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 6005, 370, 2248, 450, 83, 7, 450, 325, 14, 1188, 9, 339, 2896, 275, 715, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 12027, 14, 2758, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Minizinger/discordKuubioBot
bot/file_config.py
1
1384
import json import os import re from emoji import UNICODE_EMOJI import codecs import random class Config: def __init__(self): with codecs.open('../config/reactions.json', 'r', 'utf-8') as f: self.reactions = json.load(f) self.reaction_chance = self.reactions.pop('chance', 100) / 100 with codecs.open('../config/responses.json', 'r', 'utf-8') as f: self.responses = json.load(f) self.response_chance = self.responses.pop('chance', 100) / 100 def determine_reactions(self, message): if random.random() < self.reaction_chance: return [reaction for reaction in self.reactions if any(re.search(r, message) if r in UNICODE_EMOJI else re.search(r'\b' + r + r'\b', message) for r in self.reactions[reaction])] return [] # only returning one responce here to prevent def determine_response(self, message): if random.random() < self.response_chance: start = [response for response in self.responses['start'] if any(re.search(r'\A' + r + r'\b', message) for r in self.responses['start'][response])] if start: return start[0] other = [response for response in self.responses['any'] if any(r in message for r in self.responses['any'][response])] if other: return other[0] return None
mit
[ 646, 2022, 199, 646, 747, 199, 646, 295, 199, 504, 325, 20452, 492, 6778, 948, 9125, 63, 37, 2679, 32126, 199, 646, 6010, 199, 646, 2196, 199, 199, 533, 4094, 26, 272, 347, 636, 826, 721, 277, 304, 267, 543, 6010, 14, 1490, 24592, 888, 15, 264, 3723, 14, 1001, 297, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 288, 291, 14, 264, 3723, 275, 2022, 14, 912, 8, 70, 9, 288, 291, 14, 29834, 63, 335, 554, 275, 291, 14, 264, 3723, 14, 1935, 360, 335, 554, 297, 2948, 9, 1182, 2948, 267, 543, 6010, 14, 1490, 24592, 888, 15, 10360, 14, 1001, 297, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 288, 291, 14, 10360, 275, 2022, 14, 912, 8, 70, 9, 288, 291, 14, 1310, 63, 335, 554, 275, 291, 14, 10360, 14, 1935, 360, 335, 554, 297, 2948, 9, 1182, 2948, 2286, 347, 6705, 63, 264, 3723, 8, 277, 12, 1245, 304, 267, 340, 2196, 14, 2355, 342, 665, 291, 14, 29834, 63, 335, 554, 26, 288, 372, 359, 29834, 367, 26909, 315, 291, 14, 264, 3723, 340, 1263, 8, 264, 14, 1733, 8, 82, 12, 1245, 9, 340, 519, 315, 6778, 948, 9125, 63, 37, 2679, 32126, 587, 295, 14, 1733, 8, 82, 1154, 66, 7, 435, 519, 435, 519, 1154, 66, 297, 1245, 9, 367, 519, 315, 291, 14, 264, 3723, 59, 29834, 12457, 267, 372, 942, 339, 327, 1454, 8152, 1373, 9163, 301, 2348, 370, 7981, 5591, 347, 6705, 63, 1310, 8, 277, 12, 1245, 304, 267, 340, 2196, 14, 2355, 342, 665, 291, 14, 1310, 63, 335, 554, 26, 288, 1343, 275, 359, 1310, 367, 1177, 315, 291, 14, 10360, 459, 928, 418, 340, 1263, 8, 264, 14, 1733, 8, 82, 1154, 33, 7, 435, 519, 435, 519, 1154, 66, 297, 1245, 9, 367, 519, 315, 291, 14, 10360, 459, 928, 3488, 1310, 12457, 288, 340, 1343, 26, 355, 372, 1343, 59, 16, 61, 288, 1163, 275, 359, 1310, 367, 1177, 315, 291, 14, 10360, 459, 1629, 418, 340, 1263, 8, 82, 315, 1245, 367, 519, 315, 291, 14, 10360, 459, 1629, 3488, 1310, 12457, 288, 340, 1163, 26, 355, 372, 1163, 59, 16, 61, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2022, 199, 646, 747, 199, 646, 295, 199, 504, 325, 20452, 492, 6778, 948, 9125, 63, 37, 2679, 32126, 199, 646, 6010, 199, 646, 2196, 199, 199, 533, 4094, 26, 272, 347, 636, 826, 721, 277, 304, 267, 543, 6010, 14, 1490, 24592, 888, 15, 264, 3723, 14, 1001, 297, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 288, 291, 14, 264, 3723, 275, 2022, 14, 912, 8, 70, 9, 288, 291, 14, 29834, 63, 335, 554, 275, 291, 14, 264, 3723, 14, 1935, 360, 335, 554, 297, 2948, 9, 1182, 2948, 267, 543, 6010, 14, 1490, 24592, 888, 15, 10360, 14, 1001, 297, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 288, 291, 14, 10360, 275, 2022, 14, 912, 8, 70, 9, 288, 291, 14, 1310, 63, 335, 554, 275, 291, 14, 10360, 14, 1935, 360, 335, 554, 297, 2948, 9, 1182, 2948, 2286, 347, 6705, 63, 264, 3723, 8, 277, 12, 1245, 304, 267, 340, 2196, 14, 2355, 342, 665, 291, 14, 29834, 63, 335, 554, 26, 288, 372, 359, 29834, 367, 26909, 315, 291, 14, 264, 3723, 340, 1263, 8, 264, 14, 1733, 8, 82, 12, 1245, 9, 340, 519, 315, 6778, 948, 9125, 63, 37, 2679, 32126, 587, 295, 14, 1733, 8, 82, 1154, 66, 7, 435, 519, 435, 519, 1154, 66, 297, 1245, 9, 367, 519, 315, 291, 14, 264, 3723, 59, 29834, 12457, 267, 372, 942, 339, 327, 1454, 8152, 1373, 9163, 301, 2348, 370, 7981, 5591, 347, 6705, 63, 1310, 8, 277, 12, 1245, 304, 267, 340, 2196, 14, 2355, 342, 665, 291, 14, 1310, 63, 335, 554, 26, 288, 1343, 275, 359, 1310, 367, 1177, 315, 291, 14, 10360, 459, 928, 418, 340, 1263, 8, 264, 14, 1733, 8, 82, 1154, 33, 7, 435, 519, 435, 519, 1154, 66, 297, 1245, 9, 367, 519, 315, 291, 14, 10360, 459, 928, 3488, 1310, 12457, 288, 340, 1343, 26, 355, 372, 1343, 59, 16, 61, 288, 1163, 275, 359, 1310, 367, 1177, 315, 291, 14, 10360, 459, 1629, 418, 340, 1263, 8, 82, 315, 1245, 367, 519, 315, 291, 14, 10360, 459, 1629, 3488, 1310, 12457, 288, 340, 1163, 26, 355, 372, 1163, 59, 16, 61, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Permutatrix/servo
tests/wpt/web-platform-tests/tools/html5lib/html5lib/treewalkers/lxmletree.py
618
6033
from __future__ import absolute_import, division, unicode_literals from six import text_type from lxml import etree from ..treebuilders.etree import tag_regexp from gettext import gettext _ = gettext from . import _base from .. import ihatexml def ensure_str(s): if s is None: return None elif isinstance(s, text_type): return s else: return s.decode("utf-8", "strict") class Root(object): def __init__(self, et): self.elementtree = et self.children = [] if et.docinfo.internalDTD: self.children.append(Doctype(self, ensure_str(et.docinfo.root_name), ensure_str(et.docinfo.public_id), ensure_str(et.docinfo.system_url))) root = et.getroot() node = root while node.getprevious() is not None: node = node.getprevious() while node is not None: self.children.append(node) node = node.getnext() self.text = None self.tail = None def __getitem__(self, key): return self.children[key] def getnext(self): return None def __len__(self): return 1 class Doctype(object): def __init__(self, root_node, name, public_id, system_id): self.root_node = root_node self.name = name self.public_id = public_id self.system_id = system_id self.text = None self.tail = None def getnext(self): return self.root_node.children[1] class FragmentRoot(Root): def __init__(self, children): self.children = [FragmentWrapper(self, child) for child in children] self.text = self.tail = None def getnext(self): return None class FragmentWrapper(object): def __init__(self, fragment_root, obj): self.root_node = fragment_root self.obj = obj if hasattr(self.obj, 'text'): self.text = ensure_str(self.obj.text) else: self.text = None if hasattr(self.obj, 'tail'): self.tail = ensure_str(self.obj.tail) else: self.tail = None def __getattr__(self, name): return getattr(self.obj, name) def getnext(self): siblings = self.root_node.children idx = siblings.index(self) if idx < len(siblings) - 1: return siblings[idx + 1] else: return None def __getitem__(self, key): return self.obj[key] def __bool__(self): return bool(self.obj) def getparent(self): return None def __str__(self): return str(self.obj) def __unicode__(self): return str(self.obj) def __len__(self): return len(self.obj) class TreeWalker(_base.NonRecursiveTreeWalker): def __init__(self, tree): if hasattr(tree, "getroot"): tree = Root(tree) elif isinstance(tree, list): tree = FragmentRoot(tree) _base.NonRecursiveTreeWalker.__init__(self, tree) self.filter = ihatexml.InfosetFilter() def getNodeDetails(self, node): if isinstance(node, tuple): # Text node node, key = node assert key in ("text", "tail"), _("Text nodes are text or tail, found %s") % key return _base.TEXT, ensure_str(getattr(node, key)) elif isinstance(node, Root): return (_base.DOCUMENT,) elif isinstance(node, Doctype): return _base.DOCTYPE, node.name, node.public_id, node.system_id elif isinstance(node, FragmentWrapper) and not hasattr(node, "tag"): return _base.TEXT, node.obj elif node.tag == etree.Comment: return _base.COMMENT, ensure_str(node.text) elif node.tag == etree.Entity: return _base.ENTITY, ensure_str(node.text)[1:-1] # strip &; else: # This is assumed to be an ordinary element match = tag_regexp.match(ensure_str(node.tag)) if match: namespace, tag = match.groups() else: namespace = None tag = ensure_str(node.tag) attrs = {} for name, value in list(node.attrib.items()): name = ensure_str(name) value = ensure_str(value) match = tag_regexp.match(name) if match: attrs[(match.group(1), match.group(2))] = value else: attrs[(None, name)] = value return (_base.ELEMENT, namespace, self.filter.fromXmlName(tag), attrs, len(node) > 0 or node.text) def getFirstChild(self, node): assert not isinstance(node, tuple), _("Text nodes have no children") assert len(node) or node.text, "Node has no children" if node.text: return (node, "text") else: return node[0] def getNextSibling(self, node): if isinstance(node, tuple): # Text node node, key = node assert key in ("text", "tail"), _("Text nodes are text or tail, found %s") % key if key == "text": # XXX: we cannot use a "bool(node) and node[0] or None" construct here # because node[0] might evaluate to False if it has no child element if len(node): return node[0] else: return None else: # tail return node.getnext() return (node, "tail") if node.tail else node.getnext() def getParentNode(self, node): if isinstance(node, tuple): # Text node node, key = node assert key in ("text", "tail"), _("Text nodes are text or tail, found %s") % key if key == "text": return node # else: fallback to "normal" processing return node.getparent()
mpl-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 504, 14490, 492, 7559, 199, 504, 2508, 2350, 20968, 14, 9464, 492, 1947, 63, 11191, 199, 199, 504, 9796, 492, 9796, 199, 63, 275, 9796, 199, 199, 504, 1275, 492, 485, 1095, 199, 199, 504, 2508, 492, 284, 72, 323, 1652, 421, 199, 318, 4868, 63, 495, 8, 83, 304, 272, 340, 308, 365, 488, 26, 267, 372, 488, 272, 916, 1228, 8, 83, 12, 1318, 63, 466, 304, 267, 372, 308, 272, 587, 26, 267, 372, 308, 14, 2708, 480, 1624, 13, 24, 401, 298, 4768, 531, 421, 199, 533, 12826, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10844, 304, 267, 291, 14, 2108, 2350, 275, 10844, 267, 291, 14, 3223, 275, 942, 267, 340, 10844, 14, 32139, 14, 4672, 21156, 26, 288, 291, 14, 3223, 14, 740, 8, 21629, 8, 277, 12, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 1231, 63, 354, 395, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 3455, 63, 344, 395, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 2253, 63, 633, 1724, 267, 1738, 275, 10844, 14, 24544, 342, 267, 1031, 275, 1738, 398, 1830, 1031, 14, 362, 6352, 342, 365, 440, 488, 26, 288, 1031, 275, 1031, 14, 362, 6352, 342, 267, 1830, 1031, 365, 440, 488, 26, 288, 291, 14, 3223, 14, 740, 8, 932, 9, 288, 1031, 275, 1031, 14, 362, 2184, 342, 398, 291, 14, 505, 275, 488, 267, 291, 14, 1521, 275, 488, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 3223, 59, 498, 61, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 488, 339, 347, 636, 552, 721, 277, 304, 267, 372, 413, 421, 199, 533, 4226, 3667, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1738, 63, 932, 12, 536, 12, 4575, 63, 344, 12, 2656, 63, 344, 304, 267, 291, 14, 1231, 63, 932, 275, 1738, 63, 932, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3455, 63, 344, 275, 4575, 63, 344, 267, 291, 14, 2253, 63, 344, 275, 2656, 63, 344, 398, 291, 14, 505, 275, 488, 267, 291, 14, 1521, 275, 488, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 291, 14, 1231, 63, 932, 14, 3223, 59, 17, 61, 421, 199, 533, 481, 4338, 6405, 8, 6405, 304, 272, 347, 636, 826, 721, 277, 12, 4978, 304, 267, 291, 14, 3223, 275, 359, 11080, 4590, 8, 277, 12, 1982, 9, 367, 1982, 315, 4978, 61, 267, 291, 14, 505, 275, 291, 14, 1521, 275, 488, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 488, 421, 199, 533, 481, 4338, 4590, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 7956, 63, 1231, 12, 1559, 304, 267, 291, 14, 1231, 63, 932, 275, 7956, 63, 1231, 267, 291, 14, 1113, 275, 1559, 267, 340, 2688, 8, 277, 14, 1113, 12, 283, 505, 735, 288, 291, 14, 505, 275, 4868, 63, 495, 8, 277, 14, 1113, 14, 505, 9, 267, 587, 26, 288, 291, 14, 505, 275, 488, 267, 340, 2688, 8, 277, 14, 1113, 12, 283, 1521, 735, 288, 291, 14, 1521, 275, 4868, 63, 495, 8, 277, 14, 1113, 14, 1521, 9, 267, 587, 26, 288, 291, 14, 1521, 275, 488, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 14, 1113, 12, 536, 9, 339, 347, 664, 2184, 8, 277, 304, 267, 31871, 275, 291, 14, 1231, 63, 932, 14, 3223, 267, 4280, 275, 31871, 14, 1080, 8, 277, 9, 267, 340, 4280, 665, 822, 8, 338, 3345, 780, 9, 446, 413, 26, 288, 372, 31871, 59, 2996, 435, 413, 61, 267, 587, 26, 288, 372, 488, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 1113, 59, 498, 61, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 2155, 8, 277, 14, 1113, 9, 339, 347, 664, 1708, 8, 277, 304, 267, 372, 488, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1113, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1113, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 1113, 9, 421, 199, 533, 12178, 26020, 1547, 1095, 14, 6932, 25122, 3987, 26020, 304, 272, 347, 636, 826, 721, 277, 12, 3123, 304, 267, 340, 2688, 8, 2350, 12, 298, 24544, 2349, 288, 3123, 275, 12826, 8, 2350, 9, 267, 916, 1228, 8, 2350, 12, 769, 304, 288, 3123, 275, 481, 4338, 6405, 8, 2350, 9, 267, 485, 1095, 14, 6932, 25122, 3987, 26020, 855, 826, 721, 277, 12, 3123, 9, 267, 291, 14, 1541, 275, 284, 72, 323, 1652, 14, 2354, 409, 4131, 342, 339, 347, 664, 1716, 11347, 8, 277, 12, 1031, 304, 267, 340, 1228, 8, 932, 12, 2008, 304, 221, 327, 4516, 1031, 288, 1031, 12, 790, 275, 1031, 288, 702, 790, 315, 1689, 505, 401, 298, 1521, 1288, 3824, 1872, 3380, 787, 1318, 503, 9483, 12, 1911, 450, 83, 531, 450, 790, 288, 372, 485, 1095, 14, 3876, 12, 4868, 63, 495, 8, 5675, 8, 932, 12, 790, 430, 398, 916, 1228, 8, 932, 12, 12826, 304, 288, 372, 6110, 1095, 14, 7884, 4258, 398, 916, 1228, 8, 932, 12, 4226, 3667, 304, 288, 372, 485, 1095, 14, 16556, 12, 1031, 14, 354, 12, 1031, 14, 3455, 63, 344, 12, 1031, 14, 2253, 63, 344, 398, 916, 1228, 8, 932, 12, 481, 4338, 4590, 9, 436, 440, 2688, 8, 932, 12, 298, 1450, 2349, 288, 372, 485, 1095, 14, 3876, 12, 1031, 14, 1113, 398, 916, 1031, 14, 1450, 508, 7559, 14, 7488, 26, 288, 372, 485, 1095, 14, 10973, 12, 4868, 63, 495, 8, 932, 14, 505, 9, 398, 916, 1031, 14, 1450, 508, 7559, 14, 7302, 26, 288, 372, 485, 1095, 14, 13630, 12, 4868, 63, 495, 8, 932, 14, 505, 2788, 17, 6809, 17, 61, 221, 327, 6202, 1253, 27, 398, 587, 26, 288, 327, 961, 365, 10826, 370, 506, 376, 24801, 1819, 288, 1336, 275 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 504, 14490, 492, 7559, 199, 504, 2508, 2350, 20968, 14, 9464, 492, 1947, 63, 11191, 199, 199, 504, 9796, 492, 9796, 199, 63, 275, 9796, 199, 199, 504, 1275, 492, 485, 1095, 199, 199, 504, 2508, 492, 284, 72, 323, 1652, 421, 199, 318, 4868, 63, 495, 8, 83, 304, 272, 340, 308, 365, 488, 26, 267, 372, 488, 272, 916, 1228, 8, 83, 12, 1318, 63, 466, 304, 267, 372, 308, 272, 587, 26, 267, 372, 308, 14, 2708, 480, 1624, 13, 24, 401, 298, 4768, 531, 421, 199, 533, 12826, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10844, 304, 267, 291, 14, 2108, 2350, 275, 10844, 267, 291, 14, 3223, 275, 942, 267, 340, 10844, 14, 32139, 14, 4672, 21156, 26, 288, 291, 14, 3223, 14, 740, 8, 21629, 8, 277, 12, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 1231, 63, 354, 395, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 3455, 63, 344, 395, 1460, 4868, 63, 495, 8, 386, 14, 32139, 14, 2253, 63, 633, 1724, 267, 1738, 275, 10844, 14, 24544, 342, 267, 1031, 275, 1738, 398, 1830, 1031, 14, 362, 6352, 342, 365, 440, 488, 26, 288, 1031, 275, 1031, 14, 362, 6352, 342, 267, 1830, 1031, 365, 440, 488, 26, 288, 291, 14, 3223, 14, 740, 8, 932, 9, 288, 1031, 275, 1031, 14, 362, 2184, 342, 398, 291, 14, 505, 275, 488, 267, 291, 14, 1521, 275, 488, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 3223, 59, 498, 61, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 488, 339, 347, 636, 552, 721, 277, 304, 267, 372, 413, 421, 199, 533, 4226, 3667, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1738, 63, 932, 12, 536, 12, 4575, 63, 344, 12, 2656, 63, 344, 304, 267, 291, 14, 1231, 63, 932, 275, 1738, 63, 932, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3455, 63, 344, 275, 4575, 63, 344, 267, 291, 14, 2253, 63, 344, 275, 2656, 63, 344, 398, 291, 14, 505, 275, 488, 267, 291, 14, 1521, 275, 488, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 291, 14, 1231, 63, 932, 14, 3223, 59, 17, 61, 421, 199, 533, 481, 4338, 6405, 8, 6405, 304, 272, 347, 636, 826, 721, 277, 12, 4978, 304, 267, 291, 14, 3223, 275, 359, 11080, 4590, 8, 277, 12, 1982, 9, 367, 1982, 315, 4978, 61, 267, 291, 14, 505, 275, 291, 14, 1521, 275, 488, 339, 347, 664, 2184, 8, 277, 304, 267, 372, 488, 421, 199, 533, 481, 4338, 4590, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 7956, 63, 1231, 12, 1559, 304, 267, 291, 14, 1231, 63, 932, 275, 7956, 63, 1231, 267, 291, 14, 1113, 275, 1559, 267, 340, 2688, 8, 277, 14, 1113, 12, 283, 505, 735, 288, 291, 14, 505, 275, 4868, 63, 495, 8, 277, 14, 1113, 14, 505, 9, 267, 587, 26, 288, 291, 14, 505, 275, 488, 267, 340, 2688, 8, 277, 14, 1113, 12, 283, 1521, 735, 288, 291, 14, 1521, 275, 4868, 63, 495, 8, 277, 14, 1113, 14, 1521, 9, 267, 587, 26, 288, 291, 14, 1521, 275, 488, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 14, 1113, 12, 536, 9, 339, 347, 664, 2184, 8, 277, 304, 267, 31871, 275, 291, 14, 1231, 63, 932, 14, 3223, 267, 4280, 275, 31871, 14, 1080, 8, 277, 9, 267, 340, 4280, 665, 822, 8, 338, 3345, 780, 9, 446, 413, 26, 288, 372, 31871, 59, 2996, 435, 413, 61, 267, 587, 26, 288, 372, 488, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 14, 1113, 59, 498, 61, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 2155, 8, 277, 14, 1113, 9, 339, 347, 664, 1708, 8, 277, 304, 267, 372, 488, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1113, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 1113, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 14, 1113, 9, 421, 199, 533, 12178, 26020, 1547, 1095, 14, 6932, 25122, 3987, 26020, 304, 272, 347, 636, 826, 721, 277, 12, 3123, 304, 267, 340, 2688, 8, 2350, 12, 298, 24544, 2349, 288, 3123, 275, 12826, 8, 2350, 9, 267, 916, 1228, 8, 2350, 12, 769, 304, 288, 3123, 275, 481, 4338, 6405, 8, 2350, 9, 267, 485, 1095, 14, 6932, 25122, 3987, 26020, 855, 826, 721, 277, 12, 3123, 9, 267, 291, 14, 1541, 275, 284, 72, 323, 1652, 14, 2354, 409, 4131, 342, 339, 347, 664, 1716, 11347, 8, 277, 12, 1031, 304, 267, 340, 1228, 8, 932, 12, 2008, 304, 221, 327, 4516, 1031, 288, 1031, 12, 790, 275, 1031, 288, 702, 790, 315, 1689, 505, 401, 298, 1521, 1288, 3824, 1872, 3380, 787, 1318, 503, 9483, 12, 1911, 450, 83, 531, 450, 790, 288, 372, 485, 1095, 14, 3876, 12, 4868, 63, 495, 8, 5675, 8, 932, 12, 790, 430, 398, 916, 1228, 8, 932, 12, 12826, 304, 288, 372, 6110, 1095, 14, 7884, 4258, 398, 916, 1228, 8, 932, 12, 4226, 3667, 304, 288, 372, 485, 1095, 14, 16556, 12, 1031, 14, 354, 12, 1031, 14, 3455, 63, 344, 12, 1031, 14, 2253, 63, 344, 398, 916, 1228, 8, 932, 12, 481, 4338, 4590, 9, 436, 440, 2688, 8, 932, 12, 298, 1450, 2349, 288, 372, 485, 1095, 14, 3876, 12, 1031, 14, 1113, 398, 916, 1031, 14, 1450, 508, 7559, 14, 7488, 26, 288, 372, 485, 1095, 14, 10973, 12, 4868, 63, 495, 8, 932, 14, 505, 9, 398, 916, 1031, 14, 1450, 508, 7559, 14, 7302, 26, 288, 372, 485, 1095, 14, 13630, 12, 4868, 63, 495, 8, 932, 14, 505, 2788, 17, 6809, 17, 61, 221, 327, 6202, 1253, 27, 398, 587, 26, 288, 327, 961, 365, 10826, 370, 506, 376, 24801, 1819, 288, 1336, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MahdiZareie/event-recorder
event_recorder/settings.py
1
3735
""" Django settings for event_recorder project. Generated by 'django-admin startproject' using Django 1.9.4. For more information on this file, see https://docs.djangoproject.com/en/1.9/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.9/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'zby*6_dfe__%s_qq*^r7aj_!!rdj14lh24bhzfkjg0ifa4x-=^' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', 'event', 'user', 'sms_ir', ] MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'event_recorder.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates') ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'event_recorder.wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] LOGIN_REDIRECT_URL = "/event/panel" # Internationalization # https://docs.djangoproject.com/en/1.9/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Tehran' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") STATICFILES_DIRS = [ os.path.join(BASE_DIR, "staticfiles") ] # Celery Configurations BROKER_URL = 'redis://localhost:6379/0' from datetime import timedelta CELERYBEAT_SCHEDULE = { 'check_new_messages': { 'task': 'event.tasks.load_occurrences', 'schedule': timedelta(seconds=10) }, } CELERY_TIMEZONE = 'UTC'
mit
[ 624, 199, 9323, 2202, 367, 1566, 63, 27733, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 25, 14, 20, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 646, 747, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 421, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 283, 90, 991, 10, 22, 63, 68, 771, 363, 5, 83, 63, 16672, 10, 62, 82, 23, 9091, 63, 3480, 6883, 74, 1079, 25514, 1194, 66, 19552, 9010, 74, 71, 16, 73, 667, 20, 88, 13, 29, 62, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 942, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 359, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 339, 283, 11146, 19, 297, 339, 283, 1430, 297, 272, 283, 751, 297, 272, 283, 18751, 63, 723, 297, 199, 199, 61, 199, 199, 19987, 63, 13748, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 61, 199, 199, 5441, 63, 18125, 275, 283, 1430, 63, 27733, 14, 3603, 7, 199, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 288, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 5876, 358, 267, 2156, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 288, 2156, 267, 1660, 272, 1660, 199, 61, 199, 199, 16828, 63, 24051, 275, 283, 1430, 63, 27733, 14, 6508, 14, 3578, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 12645, 17439, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 10659, 19, 659, 272, 789, 199, 93, 421, 199, 3, 13635, 6411, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 12645, 1178, 13, 2060, 13, 11346, 199, 199, 5580, 63, 9032, 63, 5600, 19033, 275, 359, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 1899, 1646, 7467, 13093, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 12092, 4625, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 14687, 6139, 8640, 297, 272, 1660, 199, 61, 199, 199, 17208, 63, 19747, 63, 2632, 275, 3286, 1430, 15, 7885, 2, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 4961, 63, 15353, 275, 283, 13878, 15, 6301, 72, 1312, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 10449, 63, 5441, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 298, 1986, 531, 199, 10449, 9472, 63, 14455, 275, 359, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 298, 18373, 531, 199, 61, 199, 199, 3, 445, 19028, 4094, 6556, 199, 199, 21111, 19972, 63, 2632, 275, 283, 15369, 921, 5967, 26, 22, 12015, 15, 16, 7, 199, 504, 2197, 492, 6871, 199 ]
[ 199, 9323, 2202, 367, 1566, 63, 27733, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 25, 14, 20, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 11299, 15, 1751, 15, 199, 199, 1858, 314, 2615, 769, 402, 2202, 436, 3932, 1338, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 646, 747, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 421, 199, 3, 27534, 13, 928, 16367, 2202, 446, 625, 83, 10020, 367, 9920, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 3, 24143, 32712, 14750, 26, 4215, 314, 7565, 790, 1202, 315, 9920, 7565, 1, 199, 12961, 63, 3078, 275, 283, 90, 991, 10, 22, 63, 68, 771, 363, 5, 83, 63, 16672, 10, 62, 82, 23, 9091, 63, 3480, 6883, 74, 1079, 25514, 1194, 66, 19552, 9010, 74, 71, 16, 73, 667, 20, 88, 13, 29, 62, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 942, 421, 199, 3, 13515, 5492, 199, 199, 15942, 63, 14219, 275, 359, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 339, 283, 11146, 19, 297, 339, 283, 1430, 297, 272, 283, 751, 297, 272, 283, 18751, 63, 723, 297, 199, 199, 61, 199, 199, 19987, 63, 13748, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 4434, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 61, 199, 199, 5441, 63, 18125, 275, 283, 1430, 63, 27733, 14, 3603, 7, 199, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 288, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 5876, 358, 267, 2156, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 288, 2156, 267, 1660, 272, 1660, 199, 61, 199, 199, 16828, 63, 24051, 275, 283, 1430, 63, 27733, 14, 6508, 14, 3578, 7, 421, 199, 3, 8692, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 12645, 17439, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 697, 14, 10659, 19, 659, 272, 789, 199, 93, 421, 199, 3, 13635, 6411, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 1121, 15, 1751, 12645, 1178, 13, 2060, 13, 11346, 199, 199, 5580, 63, 9032, 63, 5600, 19033, 275, 359, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 1899, 1646, 7467, 13093, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 12092, 4625, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 7844, 6139, 8640, 297, 272, 1660, 272, 469, 267, 283, 2339, 356, 283, 1176, 14, 2828, 14, 1178, 14, 2060, 63, 6136, 14, 14687, 6139, 8640, 297, 272, 1660, 199, 61, 199, 199, 17208, 63, 19747, 63, 2632, 275, 3286, 1430, 15, 7885, 2, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 11299, 15, 73, 1085, 78, 15, 199, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 4961, 63, 15353, 275, 283, 13878, 15, 6301, 72, 1312, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 25, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 10449, 63, 5441, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 298, 1986, 531, 199, 10449, 9472, 63, 14455, 275, 359, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 298, 18373, 531, 199, 61, 199, 199, 3, 445, 19028, 4094, 6556, 199, 199, 21111, 19972, 63, 2632, 275, 283, 15369, 921, 5967,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gohin/django
tests/template_loader/tests.py
289
6920
from django.template import TemplateDoesNotExist from django.template.loader import ( get_template, render_to_string, select_template, ) from django.test import SimpleTestCase, override_settings from django.test.client import RequestFactory @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.dummy.TemplateStrings', 'APP_DIRS': True, }, { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.request', ], }, }]) class TemplateLoaderTests(SimpleTestCase): def test_get_template_first_engine(self): template = get_template("template_loader/hello.html") self.assertEqual(template.render(), "Hello! (template strings)\n") def test_get_template_second_engine(self): template = get_template("template_loader/goodbye.html") self.assertEqual(template.render(), "Goodbye! (Django templates)\n") def test_get_template_using_engine(self): template = get_template("template_loader/hello.html", using="django") self.assertEqual(template.render(), "Hello! (Django templates)\n") def test_get_template_not_found(self): with self.assertRaises(TemplateDoesNotExist) as e: get_template("template_loader/unknown.html") self.assertEqual( e.exception.chain[-1].tried[0][0].template_name, 'template_loader/unknown.html', ) self.assertEqual(e.exception.chain[-1].backend.name, 'django') def test_select_template_first_engine(self): template = select_template(["template_loader/unknown.html", "template_loader/hello.html"]) self.assertEqual(template.render(), "Hello! (template strings)\n") def test_select_template_second_engine(self): template = select_template(["template_loader/unknown.html", "template_loader/goodbye.html"]) self.assertEqual(template.render(), "Goodbye! (Django templates)\n") def test_select_template_using_engine(self): template = select_template(["template_loader/unknown.html", "template_loader/hello.html"], using="django") self.assertEqual(template.render(), "Hello! (Django templates)\n") def test_select_template_empty(self): with self.assertRaises(TemplateDoesNotExist): select_template([]) def test_select_template_not_found(self): with self.assertRaises(TemplateDoesNotExist) as e: select_template(["template_loader/unknown.html", "template_loader/missing.html"]) self.assertEqual( e.exception.chain[0].tried[0][0].template_name, 'template_loader/unknown.html', ) self.assertEqual(e.exception.chain[0].backend.name, 'dummy') self.assertEqual( e.exception.chain[-1].tried[0][0].template_name, 'template_loader/missing.html', ) self.assertEqual(e.exception.chain[-1].backend.name, 'django') def test_select_template_tries_all_engines_before_names(self): template = select_template(["template_loader/goodbye.html", "template_loader/hello.html"]) self.assertEqual(template.render(), "Goodbye! (Django templates)\n") def test_render_to_string_first_engine(self): content = render_to_string("template_loader/hello.html") self.assertEqual(content, "Hello! (template strings)\n") def test_render_to_string_second_engine(self): content = render_to_string("template_loader/goodbye.html") self.assertEqual(content, "Goodbye! (Django templates)\n") def test_render_to_string_with_request(self): request = RequestFactory().get('/foobar/') content = render_to_string("template_loader/request.html", request=request) self.assertEqual(content, "/foobar/\n") def test_render_to_string_using_engine(self): content = render_to_string("template_loader/hello.html", using="django") self.assertEqual(content, "Hello! (Django templates)\n") def test_render_to_string_not_found(self): with self.assertRaises(TemplateDoesNotExist) as e: render_to_string("template_loader/unknown.html") self.assertEqual( e.exception.chain[-1].tried[0][0].template_name, 'template_loader/unknown.html', ) self.assertEqual(e.exception.chain[-1].backend.name, 'django') def test_render_to_string_with_list_first_engine(self): content = render_to_string(["template_loader/unknown.html", "template_loader/hello.html"]) self.assertEqual(content, "Hello! (template strings)\n") def test_render_to_string_with_list_second_engine(self): content = render_to_string(["template_loader/unknown.html", "template_loader/goodbye.html"]) self.assertEqual(content, "Goodbye! (Django templates)\n") def test_render_to_string_with_list_using_engine(self): content = render_to_string(["template_loader/unknown.html", "template_loader/hello.html"], using="django") self.assertEqual(content, "Hello! (Django templates)\n") def test_render_to_string_with_list_empty(self): with self.assertRaises(TemplateDoesNotExist): render_to_string([]) def test_render_to_string_with_list_not_found(self): with self.assertRaises(TemplateDoesNotExist) as e: render_to_string(["template_loader/unknown.html", "template_loader/missing.html"]) self.assertEqual( e.exception.chain[0].tried[0][0].template_name, 'template_loader/unknown.html', ) self.assertEqual(e.exception.chain[0].backend.name, 'dummy') self.assertEqual( e.exception.chain[1].tried[0][0].template_name, 'template_loader/unknown.html', ) self.assertEqual(e.exception.chain[1].backend.name, 'django') self.assertEqual( e.exception.chain[2].tried[0][0].template_name, 'template_loader/missing.html', ) self.assertEqual(e.exception.chain[2].backend.name, 'dummy') self.assertEqual( e.exception.chain[3].tried[0][0].template_name, 'template_loader/missing.html', ) self.assertEqual(e.exception.chain[3].backend.name, 'django') def test_render_to_string_with_list_tries_all_engines_before_names(self): content = render_to_string(["template_loader/goodbye.html", "template_loader/hello.html"]) self.assertEqual(content, "Goodbye! (Django templates)\n")
bsd-3-clause
[ 504, 1639, 14, 1160, 492, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 492, 334, 272, 664, 63, 1160, 12, 3795, 63, 475, 63, 875, 12, 3504, 63, 1160, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 421, 199, 32, 4415, 63, 1751, 8, 25437, 1524, 91, 272, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 5869, 14, 4231, 12672, 297, 272, 283, 7121, 63, 14455, 356, 715, 12, 199, 1386, 469, 272, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 272, 283, 7121, 63, 14455, 356, 715, 12, 272, 283, 8808, 356, 469, 267, 283, 1100, 63, 10547, 356, 359, 288, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 267, 2156, 272, 1660, 199, 29810, 199, 533, 5458, 5455, 2925, 8, 17968, 304, 339, 347, 511, 63, 362, 63, 1160, 63, 2246, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 4375, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 4941, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 401, 1808, 628, 1176, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 1397, 63, 4214, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 9, 465, 325, 26, 288, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5187, 14, 1360, 531, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 1988, 17, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 5187, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 1988, 17, 1055, 4620, 14, 354, 12, 283, 1176, 358, 339, 347, 511, 63, 2416, 63, 1160, 63, 2246, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 4375, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 4941, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 2255, 1808, 628, 1176, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 1667, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 304, 288, 3504, 63, 1160, 4157, 339, 347, 511, 63, 2416, 63, 1160, 63, 1397, 63, 4214, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 9, 465, 325, 26, 288, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2490, 298, 1160, 63, 3422, 15, 4752, 14, 1360, 3135, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 59, 16, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 5187, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 59, 16, 1055, 4620, 14, 354, 12, 283, 5869, 358, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 1988, 17, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 4752, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 1988, 17, 1055, 4620, 14, 354, 12, 283, 1176, 358, 339, 347, 511, 63, 2416, 63, 1160, 63, 6264, 63, 452, 63, 30378, 63, 5182, 63, 1247, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 2246, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 531, 267, 291, 14, 629, 8, 1317, 12, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 4375, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 531, 267, 291, 14, 629, 8, 1317, 12, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 1045, 63, 1069, 8, 277, 304, 267, 1056, 275, 18638, 1252, 362, 2336, 9664, 6217, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 1069, 14, 1360, 401, 1056, 29, 1069, 9, 267, 291, 14, 629, 8, 1317, 12, 3286, 9664, 6307, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 4941, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 401, 1808, 628, 1176, 531, 267, 291, 14, 629 ]
[ 1639, 14, 1160, 492, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 492, 334, 272, 664, 63, 1160, 12, 3795, 63, 475, 63, 875, 12, 3504, 63, 1160, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 421, 199, 32, 4415, 63, 1751, 8, 25437, 1524, 91, 272, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 5869, 14, 4231, 12672, 297, 272, 283, 7121, 63, 14455, 356, 715, 12, 199, 1386, 469, 272, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 272, 283, 7121, 63, 14455, 356, 715, 12, 272, 283, 8808, 356, 469, 267, 283, 1100, 63, 10547, 356, 359, 288, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 267, 2156, 272, 1660, 199, 29810, 199, 533, 5458, 5455, 2925, 8, 17968, 304, 339, 347, 511, 63, 362, 63, 1160, 63, 2246, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 4375, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 4941, 63, 3908, 8, 277, 304, 267, 1978, 275, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 401, 1808, 628, 1176, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 362, 63, 1160, 63, 1397, 63, 4214, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 9, 465, 325, 26, 288, 664, 63, 1160, 480, 1160, 63, 3422, 15, 5187, 14, 1360, 531, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 1988, 17, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 5187, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 1988, 17, 1055, 4620, 14, 354, 12, 283, 1176, 358, 339, 347, 511, 63, 2416, 63, 1160, 63, 2246, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 4375, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 4941, 63, 3908, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 2255, 1808, 628, 1176, 531, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 6257, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 2416, 63, 1160, 63, 1667, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 304, 288, 3504, 63, 1160, 4157, 339, 347, 511, 63, 2416, 63, 1160, 63, 1397, 63, 4214, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4231, 7400, 9, 465, 325, 26, 288, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 5187, 14, 1360, 401, 2490, 298, 1160, 63, 3422, 15, 4752, 14, 1360, 3135, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 59, 16, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 5187, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 59, 16, 1055, 4620, 14, 354, 12, 283, 5869, 358, 267, 291, 14, 629, 8, 288, 325, 14, 1971, 14, 4429, 1988, 17, 1055, 599, 379, 59, 16, 1527, 16, 1055, 1160, 63, 354, 12, 288, 283, 1160, 63, 3422, 15, 4752, 14, 1360, 297, 267, 776, 267, 291, 14, 629, 8, 69, 14, 1971, 14, 4429, 1988, 17, 1055, 4620, 14, 354, 12, 283, 1176, 358, 339, 347, 511, 63, 2416, 63, 1160, 63, 6264, 63, 452, 63, 30378, 63, 5182, 63, 1247, 8, 277, 304, 267, 1978, 275, 3504, 63, 1160, 5234, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 401, 2511, 298, 1160, 63, 3422, 15, 5006, 14, 1360, 3135, 267, 291, 14, 629, 8, 1160, 14, 3352, 1062, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 2246, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 531, 267, 291, 14, 629, 8, 1317, 12, 298, 6257, 1, 334, 1160, 3326, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 4375, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 8302, 16481, 14, 1360, 531, 267, 291, 14, 629, 8, 1317, 12, 298, 20652, 16481, 1, 334, 9323, 7009, 2862, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 1045, 63, 1069, 8, 277, 304, 267, 1056, 275, 18638, 1252, 362, 2336, 9664, 6217, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 1069, 14, 1360, 401, 1056, 29, 1069, 9, 267, 291, 14, 629, 8, 1317, 12, 3286, 9664, 6307, 78, 531, 339, 347, 511, 63, 3352, 63, 475, 63, 875, 63, 4941, 63, 3908, 8, 277, 304, 267, 1564, 275, 3795, 63, 475, 63, 875, 480, 1160, 63, 3422, 15, 5006, 14, 1360, 401, 1808, 628, 1176, 531, 267, 291, 14, 629, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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rates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". Replace these with more appropriate tests for your application. """ from django.test import TestCase, Client from issues.models import * urls = "/admin/issues/issue/ /issues/create-issue/ /issues/add-issues/ /issues/reports/ /issues/create-report/".split() class Issues(TestCase): def setUp(self): User.objects.create_superuser(username="ak", password='k', email="a@a.com") self.c = Client(enforce_csrf_checks=False) self.c.login(username="ak", password='k') Project.obj.create(project="proj1") Type.obj.create(type="type1") Status.obj.create(status="open") Priority.obj.create(priority=1, label='') Tag.obj.create(tag="tag1") def test_urls(self): for url in urls: resp = self.c.get(url) self.assertIn(resp.status_code, (200, )) def post(self, url, **kwargs): return self.c.post(url, kwargs, HTTP_ORIGIN="localhost") def test_create_issue(self): resp = self.post("/issues/create-issue/", owner=1, title="iss1", project=1, priority_code=1, difficulty=3, type=1, progress = 0, project__0 = 1, project__1 = '', tags__1 = '1', tags__2 = '', tags__3 = '', tags__4 = '', tags__5 = '', tags__6 = '', ) iss = Issue.obj.get(pk=1) resp = self.c.get("/issues/issue/1/") self.assertEqual(resp.status_code, 200) self.assertIn("iss1", resp.content) def test_create_report(self): columns = """ title status""" filters = """ priority_code__priority__gt = 0 """ group_by = """ priority_code project """ resp = self.post("/issues/create-report/", name="rep1", columns=columns, filters=filters, group_by=group_by) rep = Report.obj.get(pk=1) resp = self.c.get("/issues/report/1/") self.assertEqual(resp.status_code, 200) self.assertIn("priority", resp.content) self.assertIn("project", resp.content)
mit
[ 624, 199, 2765, 570, 23789, 31216, 2877, 3365, 15725, 402, 2295, 334, 368, 8868, 436, 1373, 199, 2796, 680, 5723, 911, 3865, 986, 1380, 1265, 1255, 298, 9053, 14, 647, 511, 1674, 199, 199, 11328, 3520, 543, 1655, 5827, 2295, 367, 2195, 4223, 14, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 12, 6810, 199, 504, 10876, 14, 992, 492, 627, 199, 199, 3603, 275, 3286, 2113, 15, 10115, 15, 5237, 15, 1182, 10115, 15, 981, 13, 5237, 15, 1182, 10115, 15, 525, 13, 10115, 15, 1182, 10115, 15, 15629, 15, 1182, 10115, 15, 981, 13, 3070, 15, 1674, 1294, 342, 199, 199, 533, 13383, 83, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 2876, 14, 1462, 14, 981, 63, 11434, 8, 2473, 628, 1151, 401, 2505, 534, 75, 297, 3031, 628, 65, 32, 65, 14, 957, 531, 267, 291, 14, 67, 275, 6810, 8, 19817, 63, 10088, 63, 8625, 29, 797, 9, 267, 291, 14, 67, 14, 2886, 8, 2473, 628, 1151, 401, 2505, 534, 75, 358, 398, 7290, 14, 1113, 14, 981, 8, 1715, 628, 5468, 17, 531, 267, 2434, 14, 1113, 14, 981, 8, 466, 628, 466, 17, 531, 267, 9795, 14, 1113, 14, 981, 8, 1205, 628, 1490, 531, 267, 8538, 3822, 14, 1113, 14, 981, 8, 6693, 29, 17, 12, 1768, 13275, 267, 8053, 14, 1113, 14, 981, 8, 1450, 628, 1450, 17, 531, 339, 347, 511, 63, 3603, 8, 277, 304, 267, 367, 1166, 315, 8187, 26, 288, 3085, 275, 291, 14, 67, 14, 362, 8, 633, 9, 288, 291, 14, 4080, 8, 4518, 14, 1205, 63, 600, 12, 334, 1840, 12, 5082, 339, 347, 2963, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 372, 291, 14, 67, 14, 1932, 8, 633, 12, 2074, 12, 3101, 63, 24832, 628, 5967, 531, 339, 347, 511, 63, 981, 63, 5237, 8, 277, 304, 267, 3085, 275, 291, 14, 1932, 4769, 10115, 15, 981, 13, 5237, 10665, 5771, 29, 17, 12, 2538, 628, 19857, 17, 401, 2199, 29, 17, 12, 7464, 63, 600, 29, 17, 12, 23976, 17323, 29, 19, 12, 730, 29, 17, 12, 586, 6696, 257, 275, 378, 12, 586, 2199, 363, 16, 275, 413, 12, 586, 2199, 363, 17, 275, 3260, 586, 3762, 363, 17, 259, 275, 283, 17, 297, 586, 3762, 363, 18, 259, 275, 3260, 586, 3762, 363, 19, 259, 275, 3260, 586, 3762, 363, 20, 259, 275, 3260, 586, 3762, 363, 21, 259, 275, 3260, 586, 3762, 363, 22, 259, 275, 3260, 586, 776, 267, 365, 83, 275, 13383, 14, 1113, 14, 362, 8, 2051, 29, 17, 9, 267, 3085, 275, 291, 14, 67, 14, 362, 4769, 10115, 15, 5237, 15, 17, 13589, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 480, 19857, 17, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 981, 63, 3070, 8, 277, 304, 267, 4362, 275, 408, 267, 2538, 267, 2004, 624, 267, 4766, 275, 408, 267, 7464, 63, 600, 363, 6693, 363, 3308, 275, 378, 267, 408, 267, 1572, 63, 991, 275, 408, 267, 7464, 63, 600, 267, 2199, 267, 408, 267, 3085, 275, 291, 14, 1932, 4769, 10115, 15, 981, 13, 3070, 10665, 536, 628, 1155, 17, 401, 4362, 29, 3406, 12, 4766, 29, 4273, 12, 1572, 63, 991, 29, 923, 63, 991, 9, 267, 1833, 275, 11774, 14, 1113, 14, 362, 8, 2051, 29, 17, 9, 267, 3085, 275, 291, 14, 67, 14, 362, 4769, 10115, 15, 3070, 15, 17, 13589, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 480, 6693, 401, 3085, 14, 1317, 9, 267, 291, 14, 4080, 480, 1715, 401, 3085, 14, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2765, 570, 23789, 31216, 2877, 3365, 15725, 402, 2295, 334, 368, 8868, 436, 1373, 199, 2796, 680, 5723, 911, 3865, 986, 1380, 1265, 1255, 298, 9053, 14, 647, 511, 1674, 199, 199, 11328, 3520, 543, 1655, 5827, 2295, 367, 2195, 4223, 14, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 12, 6810, 199, 504, 10876, 14, 992, 492, 627, 199, 199, 3603, 275, 3286, 2113, 15, 10115, 15, 5237, 15, 1182, 10115, 15, 981, 13, 5237, 15, 1182, 10115, 15, 525, 13, 10115, 15, 1182, 10115, 15, 15629, 15, 1182, 10115, 15, 981, 13, 3070, 15, 1674, 1294, 342, 199, 199, 533, 13383, 83, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 2876, 14, 1462, 14, 981, 63, 11434, 8, 2473, 628, 1151, 401, 2505, 534, 75, 297, 3031, 628, 65, 32, 65, 14, 957, 531, 267, 291, 14, 67, 275, 6810, 8, 19817, 63, 10088, 63, 8625, 29, 797, 9, 267, 291, 14, 67, 14, 2886, 8, 2473, 628, 1151, 401, 2505, 534, 75, 358, 398, 7290, 14, 1113, 14, 981, 8, 1715, 628, 5468, 17, 531, 267, 2434, 14, 1113, 14, 981, 8, 466, 628, 466, 17, 531, 267, 9795, 14, 1113, 14, 981, 8, 1205, 628, 1490, 531, 267, 8538, 3822, 14, 1113, 14, 981, 8, 6693, 29, 17, 12, 1768, 13275, 267, 8053, 14, 1113, 14, 981, 8, 1450, 628, 1450, 17, 531, 339, 347, 511, 63, 3603, 8, 277, 304, 267, 367, 1166, 315, 8187, 26, 288, 3085, 275, 291, 14, 67, 14, 362, 8, 633, 9, 288, 291, 14, 4080, 8, 4518, 14, 1205, 63, 600, 12, 334, 1840, 12, 5082, 339, 347, 2963, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 372, 291, 14, 67, 14, 1932, 8, 633, 12, 2074, 12, 3101, 63, 24832, 628, 5967, 531, 339, 347, 511, 63, 981, 63, 5237, 8, 277, 304, 267, 3085, 275, 291, 14, 1932, 4769, 10115, 15, 981, 13, 5237, 10665, 5771, 29, 17, 12, 2538, 628, 19857, 17, 401, 2199, 29, 17, 12, 7464, 63, 600, 29, 17, 12, 23976, 17323, 29, 19, 12, 730, 29, 17, 12, 586, 6696, 257, 275, 378, 12, 586, 2199, 363, 16, 275, 413, 12, 586, 2199, 363, 17, 275, 3260, 586, 3762, 363, 17, 259, 275, 283, 17, 297, 586, 3762, 363, 18, 259, 275, 3260, 586, 3762, 363, 19, 259, 275, 3260, 586, 3762, 363, 20, 259, 275, 3260, 586, 3762, 363, 21, 259, 275, 3260, 586, 3762, 363, 22, 259, 275, 3260, 586, 776, 267, 365, 83, 275, 13383, 14, 1113, 14, 362, 8, 2051, 29, 17, 9, 267, 3085, 275, 291, 14, 67, 14, 362, 4769, 10115, 15, 5237, 15, 17, 13589, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 480, 19857, 17, 401, 3085, 14, 1317, 9, 339, 347, 511, 63, 981, 63, 3070, 8, 277, 304, 267, 4362, 275, 408, 267, 2538, 267, 2004, 624, 267, 4766, 275, 408, 267, 7464, 63, 600, 363, 6693, 363, 3308, 275, 378, 267, 408, 267, 1572, 63, 991, 275, 408, 267, 7464, 63, 600, 267, 2199, 267, 408, 267, 3085, 275, 291, 14, 1932, 4769, 10115, 15, 981, 13, 3070, 10665, 536, 628, 1155, 17, 401, 4362, 29, 3406, 12, 4766, 29, 4273, 12, 1572, 63, 991, 29, 923, 63, 991, 9, 267, 1833, 275, 11774, 14, 1113, 14, 362, 8, 2051, 29, 17, 9, 267, 3085, 275, 291, 14, 67, 14, 362, 4769, 10115, 15, 3070, 15, 17, 13589, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 4080, 480, 6693, 401, 3085, 14, 1317, 9, 267, 291, 14, 4080, 480, 1715, 401, 3085, 14, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: terraform short_description: Manages a Terraform deployment (and plans) description: - Provides support for deploying resources with Terraform and pulling resource information back into Ansible. version_added: "2.5" options: state: choices: ['planned', 'present', 'absent'] description: - Goal state of given stage/project required: false default: present binary_path: description: - The path of a terraform binary to use, relative to the 'service_path' unless you supply an absolute path. required: false project_path: description: - The path to the root of the Terraform directory with the vars.tf/main.tf/etc to use. required: true workspace: description: - The terraform workspace to work with. required: false default: default version_added: 2.7 purge_workspace: description: - Only works with state = absent - If true, the workspace will be deleted after the "terraform destroy" action. - The 'default' workspace will not be deleted. required: false default: false type: bool version_added: 2.7 plan_file: description: - The path to an existing Terraform plan file to apply. If this is not specified, Ansible will build a new TF plan and execute it. Note that this option is required if 'state' has the 'planned' value. required: false state_file: description: - The path to an existing Terraform state file to use when building plan. If this is not specified, the default `terraform.tfstate` will be used. - This option is ignored when plan is specified. required: false variables_file: description: - The path to a variables file for Terraform to fill into the TF configurations. required: false variables: description: - A group of key-values to override template variables or those in variables files. required: false targets: description: - A list of specific resources to target in this plan/application. The resources selected here will also auto-include any dependencies. required: false lock: description: - Enable statefile locking, if you use a service that accepts locks (such as S3+DynamoDB) to store your statefile. required: false type: bool lock_timeout: description: - How long to maintain the lock on the statefile, if you use a service that accepts locks (such as S3+DynamoDB). required: false force_init: description: - To avoid duplicating infra, if a state file can't be found this will force a `terraform init`. Generally, this should be turned off unless you intend to provision an entirely new Terraform deployment. default: false required: false type: bool backend_config: description: - A group of key-values to provide at init stage to the -backend-config parameter. required: false version_added: 2.7 notes: - To just run a `terraform plan`, use check mode. requirements: [ "terraform" ] author: "Ryan Scott Brown (@ryansb)" ''' EXAMPLES = """ # Basic deploy of a service - terraform: project_path: '{{ project_dir }}' state: present # Define the backend configuration at init - terraform: project_path: 'project/' state: "{{ state }}" force_init: true backend_config: region: "eu-west-1" bucket: "some-bucket" key: "random.tfstate" """ RETURN = """ outputs: type: complex description: A dictionary of all the TF outputs by their assigned name. Use `.outputs.MyOutputName.value` to access the value. returned: on success sample: '{"bukkit_arn": {"sensitive": false, "type": "string", "value": "arn:aws:s3:::tf-test-bukkit"}' contains: sensitive: type: bool returned: always description: Whether Terraform has marked this value as sensitive type: type: string returned: always description: The type of the value (string, int, etc) value: returned: always description: The value of the output as interpolated by Terraform stdout: type: string description: Full `terraform` command stdout, in case you want to display it or examine the event log returned: always sample: '' command: type: string description: Full `terraform` command built by this module, in case you want to re-run the command outside the module or debug a problem. returned: always sample: terraform apply ... """ import os import json import tempfile import traceback from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils.basic import AnsibleModule DESTROY_ARGS = ('destroy', '-no-color', '-force') APPLY_ARGS = ('apply', '-no-color', '-input=false', '-auto-approve=true') module = None def preflight_validation(bin_path, project_path, variables_args=None, plan_file=None): if project_path in [None, ''] or '/' not in project_path: module.fail_json(msg="Path for Terraform project can not be None or ''.") if not os.path.exists(bin_path): module.fail_json(msg="Path for Terraform binary '{0}' doesn't exist on this host - check the path and try again please.".format(bin_path)) if not os.path.isdir(project_path): module.fail_json(msg="Path for Terraform project '{0}' doesn't exist on this host - check the path and try again please.".format(project_path)) rc, out, err = module.run_command([bin_path, 'validate'] + variables_args, cwd=project_path, use_unsafe_shell=True) if rc != 0: module.fail_json(msg="Failed to validate Terraform configuration files:\r\n{0}".format(err)) def _state_args(state_file): if state_file and os.path.exists(state_file): return ['-state', state_file] if state_file and not os.path.exists(state_file): module.fail_json(msg='Could not find state_file "{0}", check the path and try again.'.format(state_file)) return [] def init_plugins(bin_path, project_path, backend_config): command = [bin_path, 'init', '-input=false'] if backend_config: for key, val in backend_config.items(): command.extend([ '-backend-config', shlex_quote('{0}={1}'.format(key, val)) ]) rc, out, err = module.run_command(command, cwd=project_path) if rc != 0: module.fail_json(msg="Failed to initialize Terraform modules:\r\n{0}".format(err)) def get_workspace_context(bin_path, project_path): workspace_ctx = {"current": "default", "all": []} command = [bin_path, 'workspace', 'list', '-no-color'] rc, out, err = module.run_command(command, cwd=project_path) if rc != 0: module.fail_json(msg="Failed to list Terraform workspaces:\r\n{0}".format(err)) for item in out.split('\n'): stripped_item = item.strip() if not stripped_item: continue elif stripped_item.startswith('* '): workspace_ctx["current"] = stripped_item.replace('* ', '') else: workspace_ctx["all"].append(stripped_item) return workspace_ctx def _workspace_cmd(bin_path, project_path, action, workspace): command = [bin_path, 'workspace', action, workspace, '-no-color'] rc, out, err = module.run_command(command, cwd=project_path) if rc != 0: module.fail_json(msg="Failed to {0} workspace:\r\n{1}".format(action, err)) return rc, out, err def create_workspace(bin_path, project_path, workspace): _workspace_cmd(bin_path, project_path, 'new', workspace) def select_workspace(bin_path, project_path, workspace): _workspace_cmd(bin_path, project_path, 'select', workspace) def remove_workspace(bin_path, project_path, workspace): _workspace_cmd(bin_path, project_path, 'delete', workspace) def build_plan(bin_path, project_path, variables_args, state_file, targets, plan_path=None): if plan_path is None: f, plan_path = tempfile.mkstemp(suffix='.tfplan') command = [bin_path, 'plan', '-input=false', '-no-color', '-detailed-exitcode', '-out', plan_path] for t in (targets or []): command.extend(['-target', t]) command.extend(_state_args(state_file)) rc, out, err = module.run_command(command + variables_args, cwd=project_path, use_unsafe_shell=True) if rc == 0: # no changes return plan_path, False elif rc == 1: # failure to plan module.fail_json(msg='Terraform plan could not be created\r\nSTDOUT: {0}\r\n\r\nSTDERR: {1}'.format(out, err)) elif rc == 2: # changes, but successful return plan_path, True module.fail_json(msg='Terraform plan failed with unexpected exit code {0}. \r\nSTDOUT: {1}\r\n\r\nSTDERR: {2}'.format(rc, out, err)) def main(): global module module = AnsibleModule( argument_spec=dict( project_path=dict(required=True, type='path'), binary_path=dict(type='path'), workspace=dict(required=False, type='str', default='default'), purge_workspace=dict(type='bool', default=False), state=dict(default='present', choices=['present', 'absent', 'planned']), variables=dict(type='dict'), variables_file=dict(type='path'), plan_file=dict(type='path'), state_file=dict(type='path'), targets=dict(type='list', default=[]), lock=dict(type='bool', default=True), lock_timeout=dict(type='int',), force_init=dict(type='bool', default=False), backend_config=dict(type='dict', default=None), ), required_if=[('state', 'planned', ['plan_file'])], supports_check_mode=True, ) project_path = module.params.get('project_path') bin_path = module.params.get('binary_path') workspace = module.params.get('workspace') purge_workspace = module.params.get('purge_workspace') state = module.params.get('state') variables = module.params.get('variables') or {} variables_file = module.params.get('variables_file') plan_file = module.params.get('plan_file') state_file = module.params.get('state_file') force_init = module.params.get('force_init') backend_config = module.params.get('backend_config') if bin_path is not None: command = [bin_path] else: command = [module.get_bin_path('terraform', required=True)] if force_init: init_plugins(command[0], project_path, backend_config) workspace_ctx = get_workspace_context(command[0], project_path) if workspace_ctx["current"] != workspace: if workspace not in workspace_ctx["all"]: create_workspace(command[0], project_path, workspace) else: select_workspace(command[0], project_path, workspace) variables_args = [] for k, v in variables.items(): variables_args.extend([ '-var', '{0}={1}'.format(k, v) ]) if variables_file: variables_args.extend(['-var-file', variables_file]) preflight_validation(command[0], project_path, variables_args) if state == 'present': command.extend(APPLY_ARGS) elif state == 'absent': command.extend(DESTROY_ARGS) if module.params.get('lock') is not None: if module.params.get('lock'): command.append('-lock=true') else: command.append('-lock=true') if module.params.get('lock_timeout') is not None: command.append('-lock-timeout=%ds' % module.params.get('lock_timeout')) for t in (module.params.get('targets') or []): command.extend(['-target', t]) # we aren't sure if this plan will result in changes, so assume yes needs_application, changed = True, True if state == 'planned': plan_file, needs_application = build_plan(command[0], project_path, variables_args, state_file, module.params.get('targets'), plan_file) if state == 'absent': # deleting cannot use a statefile needs_application = True # add variables settings to destroy command command.extend(variables_args) elif plan_file and os.path.exists(plan_file): command.append(plan_file) elif plan_file and not os.path.exists(plan_file): module.fail_json(msg='Could not find plan_file "{0}", check the path and try again.'.format(plan_file)) else: plan_file, needs_application = build_plan(command[0], project_path, variables_args, state_file, module.params.get('targets'), plan_file) command.append(plan_file) if needs_application and not module.check_mode and not state == 'planned': rc, out, err = module.run_command(command, cwd=project_path) if state == 'absent' and 'Resources: 0' in out: changed = False if rc != 0: module.fail_json( msg="Failure when executing Terraform command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(rc, out, err), command=' '.join(command) ) else: changed = False out, err = '', '' outputs_command = [command[0], 'output', '-no-color', '-json'] + _state_args(state_file) rc, outputs_text, outputs_err = module.run_command(outputs_command, cwd=project_path) if rc == 1: module.warn("Could not get Terraform outputs. This usually means none have been defined.\nstdout: {0}\nstderr: {1}".format(outputs_text, outputs_err)) outputs = {} elif rc != 0: module.fail_json( msg="Failure when getting Terraform outputs. " "Exited {0}.\nstdout: {1}\nstderr: {2}".format(rc, outputs_text, outputs_err), command=' '.join(outputs_command)) else: outputs = json.loads(outputs_text) # Restore the Terraform workspace found when running the module if workspace_ctx["current"] != workspace: select_workspace(command[0], project_path, workspace_ctx["current"]) if state == 'absent' and workspace != 'default' and purge_workspace is True: remove_workspace(command[0], project_path, workspace) module.exit_json(changed=changed, state=state, workspace=workspace, outputs=outputs, stdout=out, stderr=err, command=' '.join(command)) 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, 9708, 12, 820, 89, 290, 428, 331, 6215, 699, 18406, 665, 651, 796, 66, 32, 17164, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 2044, 345, 964, 199, 3612, 63, 1802, 26, 21612, 282, 13861, 345, 964, 14295, 334, 460, 1620, 796, 9, 199, 1802, 26, 1362, 446, 21552, 2291, 367, 12287, 316, 5944, 543, 13861, 345, 964, 436, 10299, 316, 2126, 2073, 2556, 1771, 1901, 2622, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 1419, 26, 523, 1174, 26, 272, 3415, 26, 788, 20235, 297, 283, 1881, 297, 283, 5575, 418, 272, 1369, 26, 489, 446, 3971, 279, 1174, 402, 1627, 9546, 15, 1715, 272, 1415, 26, 3055, 272, 849, 26, 3451, 523, 3366, 63, 515, 26, 272, 1369, 26, 489, 446, 710, 931, 402, 282, 2044, 345, 964, 3366, 370, 675, 12, 3847, 370, 314, 283, 1364, 63, 515, 7, 267, 7444, 1265, 17169, 376, 3679, 931, 14, 272, 1415, 26, 3055, 523, 2199, 63, 515, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 314, 1738, 402, 314, 13861, 345, 964, 2082, 543, 314, 267, 6802, 14, 3249, 15, 973, 14, 3249, 15, 6839, 370, 675, 14, 272, 1415, 26, 2549, 523, 14466, 26, 272, 1369, 26, 489, 446, 710, 2044, 345, 964, 14466, 370, 1736, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 849, 272, 1015, 63, 3270, 26, 499, 14, 23, 523, 18503, 63, 13249, 26, 272, 1369, 26, 489, 446, 5972, 5419, 543, 1174, 275, 9552, 489, 446, 982, 2549, 12, 314, 14466, 911, 506, 5463, 2410, 314, 298, 351, 345, 964, 11972, 2, 1595, 14, 489, 446, 710, 283, 885, 7, 14466, 911, 440, 506, 5463, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 730, 26, 2155, 272, 1015, 63, 3270, 26, 499, 14, 23, 523, 8683, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 376, 3411, 13861, 345, 964, 8683, 570, 370, 4838, 14, 982, 642, 365, 440, 267, 2013, 12, 2622, 911, 1900, 282, 892, 21721, 8683, 436, 5341, 652, 14, 267, 3390, 626, 642, 945, 365, 1415, 340, 283, 929, 7, 965, 314, 283, 20235, 7, 574, 14, 272, 1415, 26, 3055, 523, 1174, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 376, 3411, 13861, 345, 964, 1174, 570, 370, 675, 1380, 10015, 8683, 14, 267, 982, 642, 365, 440, 2013, 12, 314, 849, 658, 351, 345, 964, 14, 3249, 929, 64, 911, 506, 1202, 14, 489, 446, 961, 945, 365, 5525, 1380, 8683, 365, 2013, 14, 272, 1415, 26, 3055, 523, 2860, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 2860, 570, 367, 13861, 345, 964, 370, 5554, 1901, 314, 21721, 267, 13422, 14, 272, 1415, 26, 3055, 523, 2860, 26, 272, 1369, 26, 489, 446, 437, 1572, 402, 790, 13, 1459, 370, 4278, 1978, 2860, 503, 5204, 315, 267, 2860, 1584, 14, 272, 1415, 26, 3055, 523, 4545, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2488, 5944, 370, 1347, 315, 642, 8683, 15, 3578, 14, 710, 267, 5944, 4895, 2348, 911, 2597, 2599, 13, 2613, 1263, 5124, 14, 272, 1415, 26, 3055, 523, 4650, 26, 272, 1369, 26, 489, 446, 12030, 1174, 493, 27267, 12, 340, 1265, 675, 282, 2435, 626, 11479, 23340, 334, 10180, 267, 465, 428, 19, 11, 36, 27784, 9, 370, 3877, 2195, 1174, 493, 14, 272, 1415, 26, 3055, 272, 730, 26, 2155, 523, 4650, 63, 2593, 26, 272, 1369, 26, 489, 446, 7494, 1846, 370, 11075, 314, 4650, 641, 314, 1174, 493, 12, 340, 1265, 675, 282, 2435, 267, 626, 11479, 23340, 334, 10180, 465, 428, 19, 11, 36, 27784, 680, 272, 1415, 26, 3055, 523, 3542, 63, 826, 26, 272, 1369, 26, 489, 446, 4005, 5126, 366, 4230, 1958, 28890, 12, 340, 282, 1174, 570, 883, 1133, 506, 1911, 642, 911, 267, 3542, 282, 658, 351, 345, 964, 4205, 2313, 1464, 1183, 12, 642, 1077, 506, 19136, 2331, 7444, 267, 1265, 315, 7169, 370, 15408, 376, 21926, 892, 13861, 345, 964, 14295, 14, 272, 849, 26, 3055, 272, 1415, 26, 3055, 272, 730, 26, 2155, 523, 4865, 63, 888, 26, 272, 1369, 26, 489, 446, 437, 1572, 402, 790, 13, 1459, 370, 5647, 737, 4205, 9546, 370, 314, 446, 4620, 13, 888, 2725, 14, 272, 1415, 26, 3055, 272, 1015, 63, 3270, 26, 499, 14, 23, 199, 5983, 26, 2043, 446, 4005, 2951, 1255, 282, 658, 351, 345, 964, 8683, 3559, 675, 1104, 818, 14, 199, 7538, 26, 359, 298, 351, 345, 964, 2, 1622, 199, 2502, 26, 298, 50, 89, 290, 428, 331, 6215, 699, 18406, 8593, 651, 796, 66, 2924, 199, 2344, 199, 199, 8918, 275, 408, 199, 3, 10082, 12287, 402, 282, 2435, 199, 13, 2044, 345, 964, 26, 272, 2199, 63, 515, 26, 11400, 2199, 63, 694, 16339, 272, 1174, 26, 3451, 199, 199, 3, 13930, 314, 4865, 2897, 737, 4205, 199, 13, 2044, 345, 964, 26, 272, 2199, 63, 515, 26, 283, 1715, 4805, 272, 1174, 26, 7370, 1174, 7820, 272, 3542, 63, 826, 26, 2549, 272, 4865, 63, 888, 26, 489, 4897, 26, 298, 16913, 13, 19082, 13, 17, 2, 489, 5315, 26, 298, 3972, 13, 4623, 2, 489, 790, 26, 298, 2355, 14, 3249, 929, 2, 199, 624, 199, 199, 9677, 275, 408, 199, 4467, 26, 523, 730, 26, 6114, 523, 1369, 26, 437, 2600, 402, 1006, 314, 21721, 4704, 701, 3932, 7943, 536, 14, 3645, 19853, 4467, 14, 5713, 2959, 985, 14, 585, 64, 370, 2879 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 9708, 12, 820, 89, 290, 428, 331, 6215, 699, 18406, 665, 651, 796, 66, 32, 17164, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 2044, 345, 964, 199, 3612, 63, 1802, 26, 21612, 282, 13861, 345, 964, 14295, 334, 460, 1620, 796, 9, 199, 1802, 26, 1362, 446, 21552, 2291, 367, 12287, 316, 5944, 543, 13861, 345, 964, 436, 10299, 316, 2126, 2073, 2556, 1771, 1901, 2622, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 1419, 26, 523, 1174, 26, 272, 3415, 26, 788, 20235, 297, 283, 1881, 297, 283, 5575, 418, 272, 1369, 26, 489, 446, 3971, 279, 1174, 402, 1627, 9546, 15, 1715, 272, 1415, 26, 3055, 272, 849, 26, 3451, 523, 3366, 63, 515, 26, 272, 1369, 26, 489, 446, 710, 931, 402, 282, 2044, 345, 964, 3366, 370, 675, 12, 3847, 370, 314, 283, 1364, 63, 515, 7, 267, 7444, 1265, 17169, 376, 3679, 931, 14, 272, 1415, 26, 3055, 523, 2199, 63, 515, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 314, 1738, 402, 314, 13861, 345, 964, 2082, 543, 314, 267, 6802, 14, 3249, 15, 973, 14, 3249, 15, 6839, 370, 675, 14, 272, 1415, 26, 2549, 523, 14466, 26, 272, 1369, 26, 489, 446, 710, 2044, 345, 964, 14466, 370, 1736, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 849, 272, 1015, 63, 3270, 26, 499, 14, 23, 523, 18503, 63, 13249, 26, 272, 1369, 26, 489, 446, 5972, 5419, 543, 1174, 275, 9552, 489, 446, 982, 2549, 12, 314, 14466, 911, 506, 5463, 2410, 314, 298, 351, 345, 964, 11972, 2, 1595, 14, 489, 446, 710, 283, 885, 7, 14466, 911, 440, 506, 5463, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 730, 26, 2155, 272, 1015, 63, 3270, 26, 499, 14, 23, 523, 8683, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 376, 3411, 13861, 345, 964, 8683, 570, 370, 4838, 14, 982, 642, 365, 440, 267, 2013, 12, 2622, 911, 1900, 282, 892, 21721, 8683, 436, 5341, 652, 14, 267, 3390, 626, 642, 945, 365, 1415, 340, 283, 929, 7, 965, 314, 283, 20235, 7, 574, 14, 272, 1415, 26, 3055, 523, 1174, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 376, 3411, 13861, 345, 964, 1174, 570, 370, 675, 1380, 10015, 8683, 14, 267, 982, 642, 365, 440, 2013, 12, 314, 849, 658, 351, 345, 964, 14, 3249, 929, 64, 911, 506, 1202, 14, 489, 446, 961, 945, 365, 5525, 1380, 8683, 365, 2013, 14, 272, 1415, 26, 3055, 523, 2860, 63, 493, 26, 272, 1369, 26, 489, 446, 710, 931, 370, 282, 2860, 570, 367, 13861, 345, 964, 370, 5554, 1901, 314, 21721, 267, 13422, 14, 272, 1415, 26, 3055, 523, 2860, 26, 272, 1369, 26, 489, 446, 437, 1572, 402, 790, 13, 1459, 370, 4278, 1978, 2860, 503, 5204, 315, 267, 2860, 1584, 14, 272, 1415, 26, 3055, 523, 4545, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2488, 5944, 370, 1347, 315, 642, 8683, 15, 3578, 14, 710, 267, 5944, 4895, 2348, 911, 2597, 2599, 13, 2613, 1263, 5124, 14, 272, 1415, 26, 3055, 523, 4650, 26, 272, 1369, 26, 489, 446, 12030, 1174, 493, 27267, 12, 340, 1265, 675, 282, 2435, 626, 11479, 23340, 334, 10180, 267, 465, 428, 19, 11, 36, 27784, 9, 370, 3877, 2195, 1174, 493, 14, 272, 1415, 26, 3055, 272, 730, 26, 2155, 523, 4650, 63, 2593, 26, 272, 1369, 26, 489, 446, 7494, 1846, 370, 11075, 314, 4650, 641, 314, 1174, 493, 12, 340, 1265, 675, 282, 2435, 267, 626, 11479, 23340, 334, 10180, 465, 428, 19, 11, 36, 27784, 680, 272, 1415, 26, 3055, 523, 3542, 63, 826, 26, 272, 1369, 26, 489, 446, 4005, 5126, 366, 4230, 1958, 28890, 12, 340, 282, 1174, 570, 883, 1133, 506, 1911, 642, 911, 267, 3542, 282, 658, 351, 345, 964, 4205, 2313, 1464, 1183, 12, 642, 1077, 506, 19136, 2331, 7444, 267, 1265, 315, 7169, 370, 15408, 376, 21926, 892, 13861, 345, 964, 14295, 14, 272, 849, 26, 3055, 272, 1415, 26, 3055, 272, 730, 26, 2155, 523, 4865, 63, 888, 26, 272, 1369, 26, 489, 446, 437, 1572, 402, 790, 13, 1459, 370, 5647, 737, 4205, 9546, 370, 314, 446, 4620, 13, 888, 2725, 14, 272, 1415, 26, 3055, 272, 1015, 63, 3270, 26, 499, 14, 23, 199, 5983, 26, 2043, 446, 4005, 2951, 1255, 282, 658, 351, 345, 964, 8683, 3559, 675, 1104, 818, 14, 199, 7538, 26, 359, 298, 351, 345, 964, 2, 1622, 199, 2502, 26, 298, 50, 89, 290, 428, 331, 6215, 699, 18406, 8593, 651, 796, 66, 2924, 199, 2344, 199, 199, 8918, 275, 408, 199, 3, 10082, 12287, 402, 282, 2435, 199, 13, 2044, 345, 964, 26, 272, 2199, 63, 515, 26, 11400, 2199, 63, 694, 16339, 272, 1174, 26, 3451, 199, 199, 3, 13930, 314, 4865, 2897, 737, 4205, 199, 13, 2044, 345, 964, 26, 272, 2199, 63, 515, 26, 283, 1715, 4805, 272, 1174, 26, 7370, 1174, 7820, 272, 3542, 63, 826, 26, 2549, 272, 4865, 63, 888, 26, 489, 4897, 26, 298, 16913, 13, 19082, 13, 17, 2, 489, 5315, 26, 298, 3972, 13, 4623, 2, 489, 790, 26, 298, 2355, 14, 3249, 929, 2, 199, 624, 199, 199, 9677, 275, 408, 199, 4467, 26, 523, 730, 26, 6114, 523, 1369, 26, 437, 2600, 402, 1006, 314, 21721, 4704, 701, 3932, 7943, 536, 14, 3645, 19853, 4467, 14, 5713, 2959, 985, 14, 585, 64, 370, 2879, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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